1. getting a DC with wx

I've got wxWidgets going with EUPHORIA 4.0. I want to know, how do I get a 'DC' out of an object using WxEuphoria? I don't see the constructor analog anywhere.

Shawn Pringle

new topic     » topic index » view message » categorize

2. Re: getting a DC with wx

Are Controls and Frames special case DCs? How do I copy them? How do I let wx know that I want it to update the Window?

new topic     » goto parent     » topic index » view message » categorize

3. Re: getting a DC with wx

SDPringle said...

Are Controls and Frames special case DCs? How do I copy them? How do I let wx know that I want it to update the Window?

What exactly are you trying to do? And when? Within an onPaint event, you simply create a wxPaintDC. There are also wxMemoryDCs for manipulating images.

Matt

new topic     » goto parent     » topic index » view message » categorize

4. Re: getting a DC with wx

I am trying to create an example line-break conversion program to better understand wxWidgets. I want to update a status bar. So, I use wx_puts for that. I want to print in red for errors and green for regular messages. If I have two DCs for the same control can I set one to red and the other to green and then use one for error and one for info?

Without specifying DCs I call wx_puts() on the Window but nothing appears until I obscure the window and raise it again.

procedure output_wx( sequence fmt, sequence s, integer dc ) 
    if clearStatusFlag then 
	statusText = sprintf( fmt, s ) 
    else 
        statusText &= sprintf( fmt, s ) 
    end if 
    gui:begin_drawing( statusBar ) 
    ifdef DC then 
        gui:wx_puts( {statusBar,4,4,dc}, statusText ) 
    elsedef 
        gui:wx_puts( {statusBar,4,4}, statusText ) 
    end ifdef 
    gui:end_drawing( statusBar ) 
    clearStatusFlag = statusText[$] = '\n' 
end procedure 

The event that calls everything is the drag and drop event.

Shawn Pringle

new topic     » goto parent     » topic index » view message » categorize

5. Re: getting a DC with wx

wx_puts() is graphics-based, which means your text will be erased on the next wxEVT_PAINT event. You would have to store the text somewhere and repaint it again during that event. Why not just use set_status_text() instead?

-Greg

new topic     » goto parent     » topic index » view message » categorize

6. Re: getting a DC with wx

Thanks Greg. That solves the problem. Is there away to artificially trigger a PAINT event so that the Window will update itself?

new topic     » goto parent     » topic index » view message » categorize

7. Re: getting a DC with wx

SDPringle said...

Thanks Greg. That solves the problem. Is there away to artificially trigger a PAINT event so that the Window will update itself?

If you want to draw outside of a wxPAINT event, you can use a wxClientDC. It appears to be undocumented in wxEuphoria for some reason (I see documentation markup for it in the source, but it's not in the published docs), but it's there, and you can use it just like a wxPaintDC.

Matt

new topic     » goto parent     » topic index » view message » categorize

8. Re: getting a DC with wx

mattlewis said...

If you want to draw outside of a wxPAINT event, you can use a wxClientDC. It appears to be undocumented in wxEuphoria for some reason (I see documentation markup for it in the source, but it's not in the published docs), but it's there, and you can use it just like a wxPaintDC.

You can also call refresh_window() to trigger a manual repaint. My suggestion would be to create a wxMemoryDC from a wxBitmap, draw to that, then blit() it to the window when needed (either manually or during a paint). This sort of cached double-buffering is probably the most efficient method.

-Greg

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu