Canvas gadget client area!

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Canvas gadget client area!

Post 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.
I may look like a mule, but I'm not a complete ass.
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Canvas gadget client area!

Post 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
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Canvas gadget client area!

Post 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.
I may look like a mule, but I'm not a complete ass.
Post Reply