Need some help with wxEuphoria
- Posted by RStowasser Feb 25, 2009
- 853 views
Hello,
How could I improve this little bit of code derived from win32lib?
-- example11.exw -- -- Creates a Moire pattern with colored lines include wxeud.e constant Default = -1 , BrightRed = create( wxColour, {255,0,0}) , BrightGreen = create( wxColour, {0,255,0}) , BrightBlue = create( wxColour, {0,0,255}) constant WinFrame = create( wxFrame, {0,-1,"Colors", Default, Default, 150, 150} ) constant DrawWin = create( wxPanel, WinFrame ) -- pen colors constant RedPen = create( wxPen, {BrightRed, 1, wxSOLID} ) constant GreenPen = create( wxPen, {BrightGreen, 1, wxSOLID} ) constant BluePen = create( wxPen, {BrightBlue, 1, wxSOLID} ) procedure onPaint_DrawWin( atom this, atom id, atom event_type, atom event ) atom dc dc = create( wxClientDC, DrawWin ) begin_drawing(dc) for i = 1 to 150 by 3 do for j = 0 to 3 do -- pick a color if j < 1 then set_pen( dc, RedPen ) elsif j < 2 then set_pen( dc, GreenPen ) else set_pen( dc, BluePen ) end if -- draw the line draw_line( dc, {1, 1, i+j, 150} ) draw_line( dc, {1, 1, 150, i+j} ) end for end for end_drawing(dc) delete_instance(dc) end procedure -- tell Windows when to do the action set_event_handler( DrawWin, get_id(DrawWin), wxEVT_LEFT_DOWN, routine_id( "onPaint_DrawWin" )) wxMain( WinFrame)
If I click on the window the pattern will be drawn. If I use the wxEVT_PAINT event, then there will be an endless loop and I have to kill the example with the task-manager in Windows. The same problem occurs with bench_draw.exw of the demos.
Is there another event type which I could use to draw the pattern when the window opens? wxEVT_ACTIVATE or wxEVT_SHOW seem not to return the expected result.
Roland