Help wanted on SIMPLE task
Bengt Nilsson
bengt.nilsson11 at spray.se
Sun Mar 4 06:31:23 PST 2007
wxINVERT does not work for me, one draw operation clutters the window
as expected, two consecutive draw operation shows absolutely nothing
at all. (is my Mac too fast? I doubt it)
Does anyone have a code snippet to share for OnMouseEvent?
4 mar 2007 kl. 14.50 skrev Seth Manley:
>
> From some of my old wxWin 1.6x based code:
>
> wxClientDC dc(this);
> [...]
> dc.SetLogicalFunction(wxINVERT);
>
> -Seth
> http://www.xmlworkbench.com
>
>
>
>> From: Bengt Nilsson <bengt.nilsson11 at spray.se>
>> Reply-To: wx-users at lists.wxwidgets.org
>> To: wx-users at lists.wxwidgets.org
>> Subject: Re: Help wanted on SIMPLE task
>> Date: Sun, 4 Mar 2007 14:44:15 +0100
>>
>> Thanks for the extensive suggestions.
>> I will try the inverted line first.
>> However, I cannot find anything about "inverted" in the wx docs.
>> How do I set it?
>>
>> 4 mar 2007 kl. 14.34 skrev Stephan Rose:
>>
>>> On Sunday 04 March 2007 14:05, Bengt Nilsson wrote:
>>>> Hi!
>>>>
>>>> I am very new to wx programming and I need help on a simple task.
>>>>
>>>> How do I make a simple selection dragbox (using e.g. OnMouseEvent )
>>>> in a graphics window without destroying what's in it?
>>>>
>>>> I have the "Cross-Platform GUI Programming whith wxWidgets"
>>>> book, and
>>>> I think I have seen the source listing for the method there, but I
>>>> just can't seem to find int.
>>>> I have gone thru it several times and failed.
>>>>
>>>> I do not want to paint anything in the graphics window, I just want
>>>> to make a flickering frame over the content to select an area to
>>>> get
>>>> input to a zooming in function.
>>>>
>>>> Extremely standard, apparently too simple to be demonstrated in
>>>> wxWidgets samples, since I cannot find it there.
>>>
>>> There are multiple ways you can do this.
>>>
>>> First way is to draw all your stuff in your window to a
>>> backbuffer. Then when
>>> you go draw your selection box, first copy your backbuffer to
>>> your graphics
>>> window and then draw your selection box.
>>>
>>> This way you always have a copy of your original data without
>>> the selection
>>> box in it.
>>>
>>> That is the way I'd recommend it.
>>>
>>> The other way is to use inverted lines to draw your selection
>>> box. Using that
>>> method you do not need a backbuffer. An inverted line basically
>>> draws itself
>>> by inverting pixels instead of drawing itself in a set color.
>>>
>>> If you invert the pixel again, it goes back to its previous color.
>>>
>>> So basically it works like this:
>>>
>>> - Draw box with inverted line
>>> - Mouse move
>>> - Draw box *again* with inverted line on previous coordinates
>>> - Draw new box now with inverted lines on new coordinates
>>>
>>> You basically draw the box twice each mouse move. Once to erase
>>> the old box,
>>> then again to draw the new box.
>>>
>>> This was a very popular technique in the DOS and early windows
>>> days as it
>>> requires very little CPU resources to implement.
>>>
>>> Drawback though is that it is easy to screw up. If your
>>> coordinates get out of
>>> sync for any reason you will end up with pixels that stay
>>> inverted until you
>>> redraw your entire view.
>>>
>>> Another way, this is how I do it, is to use hardware accelerated
>>> drawing and
>>> simply draw the entire view every frame. That requires OpenGL
>>> though. I can
>>> draw over 20,000 objects in less than 10ms on this system here so
>>> I can
>>> afford to redraw the entire view every frame. =)
>>>
>>>
>>> --------------------------------------------------------------------
>>> -
>>> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
>>> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
>> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>>
>
> _________________________________________________________________
> Play Flexicon: the crossword game that feeds your brain. PLAY now
> for FREE. http://zone.msn.com/en/flexicon/default.htm?
> icid=flexicon_hmtagline
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>
More information about the wx-users
mailing list