Page 1 of 1

Canvas gadget client area!

Posted: Wed Oct 26, 2011 6:26 pm
by srod
Lots of requests for the new canvas gadget it seems! :) A measure of just how useful this gadget is going to be I reckon.

Think I'll add another request though...

Any chance of an extension to GetGadgetAttribute(), say, in order to return the width (or height) of the client area of this control? I think this could be quite useful.

The reason I ask is that I would like to draw right up to the edge of the client area and the dimensions are of course affected by whether the control has a border or not. GadgetWidth(), on Windows at least, returns the entire width of the control regardless of whether there is a border or not! I would rather avoid hard-coding for the width of the border as I am not sure that this would carry from Windows to Linux etc. and the beauty of the canvas gadget is that it offers real cross-platform scope for the creation of new controls etc.

Thanks.

Re: Canvas gadget client area!

Posted: Wed Oct 26, 2011 6:48 pm
by STARGĂ…TE
you can use OutputWidth() and OutputHeight()

Code: Select all

Enumeration
	#Window
	#Gadget
EndEnumeration

OpenWindow(#Window, 0, 0, 800, 600, "WindowTitle", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
	CanvasGadget(#Gadget, 10, 10, 200, 200, #PB_Canvas_Border)

StartDrawing(CanvasOutput(#Gadget))
  Debug OutputWidth()
  Debug OutputHeight()
StopDrawing()

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

Re: Canvas gadget client area!

Posted: Wed Oct 26, 2011 8:14 pm
by srod
Well, fan my brow; I never knew about those 2 commands!

Probably 'cause I usually do all my drawing/painting with gdi and gdi+ etc. :)

Thanks Stargate.