It is currently Thu Oct 18, 2018 9:14 pm

All times are UTC + 1 hour

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: [Done] Canvas gadget / #PB_EventType_Resize
PostPosted: Thu Aug 09, 2018 6:51 pm 
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10440
Location: Beyond the pale...
Purebasic 5.70 Beta 1x64. Ubuntu 18.04.

qt subsystem.

The following shows that when using a #PB_EventType_Resize bound event with a canvas gadget, the underlying bitmap has not been resized prior to the event procedure firing. GadgetWidth() and GadgetHeight() seem correct. We had a similar problem under Windows before PB 5.70 beta 1.

This problem can hide itself within the StartDrawing() bug reported previously since if we are drawing within the resize event procedure, the StartDrawing() can fail if the bitmap still has 0 width, for example, because of this resizing issue; and the StartDrawing() bug then kicks in. Two bugs for the price of one!

Run the code and resize the window.

Procedure winSize()
  ResizeGadget(0, #PB_Ignore, #PB_Ignore, 100, WindowHeight(0)-20)

Procedure ResizeOne()
  If StartDrawing (CanvasOutput(0))
    Debug "Drawing output width = " + Str(OutputWidth()) + ", SHOULD BE 100!"
    Debug "Canvas gadget width = " + Str(GadgetWidth(0))
    Debug "Canvas gadget height = " + Str(GadgetHeight(0))

If OpenWindow(0, 0, 0, 220, 220, "Canvas example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget)
  CanvasGadget(0, 10, 10, 50, 200)
  BindEvent(#PB_Event_SizeWindow, @winSize(), 0)
  BindGadgetEvent(0, @ResizeOne(), #PB_EventType_Resize)
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow

I may look like a mule, but I'm not a complete ass.

Reply with quote  
 Post subject: Re: Canvas gadget / #PB_EventType_Resize
PostPosted: Sun Sep 16, 2018 8:40 pm 

Joined: Fri May 17, 2002 4:39 pm
Posts: 13386
Location: France

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye