Consolidation of GETting/SETting Gadget attributes

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Consolidation of GETting/SETting Gadget attributes

Post by USCode »

:idea: Are there any future plans to consolidate the Get/Set... Gadget functions using simple Get/Set functions? e.g. Expanding use and scope of the GetGadgetAttribute and SetGadgetAttribute functions?

This would allow us to get rid of a lot of gadget-specific functions and simplify and generalize things greatly. We wouldn't have to remember the large myriad of functions, just have handy a simple list of #PB_... constants.

These functions could be used to Get and Set ALL attributes (properties) for gadgets/windows/items, such as: XY coordinates, text, width, height, font, selected, checked, number of rows, alignment, hidden/shown, etc. etc.

A SMALL list of possibilities:

X = GetGadgetAttribute(#MyGadget, #PB_GadgetX)
RowSelected = GetGadgetAttribute(#MyListGadget, #PB_RowSelected)
Text = GetGadgetAttribute(#MyCheckbox, #PB_Text)
Visible = GetGadgetAttribute(#MyGadget, #PB_Visibility)
SetGadgetAttribute(#MyGadget, #PB_Text, "Gadget Text")
SetGadgetAttribute(#MyGadget, #PB_FontName, "Arial")
SetGadgetAttribute(#MyGadget, #PB_GadgetX, 123)
SetGadgetAttribute(#MyListGadget, #PB_Columns, 5)
SetGadgetAttribute(#MyGadget, #PB_Visibility, #TRUE)

Also, as new gadgets come along, just new gadget attribute constants would need to be added to support the new gadgets, not a set of specialized functions. Many PB functions are already generic across most gadgets, but many aren't and are specific to certain gadgets. We could get rid of functions like Set/GetGadgetState, Set/GetGadgetText, Set/GetGadgetFont, etc. etc.

Perhaps a total of 6 simple functions for Gadgets, Windows and "Items" and a consistent list of #PB_... constants would be all that is needed.

e.g.
SetWindowAttribute(#MyWindow, #PB_State, #PB_Minimized)
State = GetWindowAttribute(#MyWindow, #PB_State)

Thoughts?
Soulfire
User
User
Posts: 23
Joined: Mon Mar 08, 2004 7:17 am

Post by Soulfire »

I like the idea, but the constants would have to go along with PB's constant naming convention better. #PB_GadgetAttribute_FontName, for example.
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Post by USCode »

the constants would have to go along with PB's constant naming convention better
I agree 100%, I just don't like to type more than I have to - if Fred implements something like this (and I suspect he has something in mind for the future) can we come up with a shorter constant naming convention compromise? :wink:
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

4.0 ?

Post by USCode »

:?: Would you happen to have anything like this in mind for 4.0 Fred?
Post Reply