It is currently Wed Aug 22, 2018 6:43 am

All times are UTC + 1 hour




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

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10427
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.

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

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))
    StopDrawing()
    End 
  EndIf
 
EndProcedure


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)
 
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf

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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


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