Draw rectangle on a Window DC

Anand anandpillai6 at yahoo.com
Tue Nov 5 04:03:49 EST 2002


Thanks Dennis. That technique worked.
But since I use a XOR operator the outline of the rectangle
does not have a unique color, but depends on the pixel color at (x,y).


Anand
Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote in message news:<d5r1pa.404.ln at ix.netcom.com>...
> Anand fed this fish to the penguins on Monday 21 October 2002 07:01 am:
> 
> > Hi
> > 
> >     I need to draw a rectangle when the user selects an area
> > over a wxPanel containing a wxStaticBitmap. The rectangle shoud change
> > in size according to the dragging of the mouse.
> >
>         I have no idea of the features of wx* but...
>  
> >  How do I write the event processing code so that I dont have many
> > rectangles overlapping each other, but just one that keeps changing
> > size ?
> >
>         The general technique for "rubber band" lines is to draw with an 
> exclusive-or operator. Then, before updating position, you redraw on 
> the old coordinates.
>  
> > The code I have right now,
> > 
> >  if event.Dragging():
> >                   
>         somewhere in here you need to redraw/erase the old box, THEN get the 
> new
> 
> >                     self.endpt = event.GetPosition()
> >                     w = (self.endpt.x - self.stpt.x) # stpt is stored
> >                     in earlier
> >                                                      # left mouse
> >                                                      # click.
> 
> --  
>  > ============================================================== <
>  >   wlfraed at ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
>  >      wulfraed at dm.net     |       Bestiaria Support Staff       <
>  > ============================================================== <
>  >        Bestiaria Home Page: http://www.beastie.dm.net/         <
>  >            Home Page: http://www.dm.net/~wulfraed/             <



More information about the Python-list mailing list