Library to manipulate groups Gadgets

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
holzhacker
Enthusiast
Enthusiast
Posts: 125
Joined: Mon Mar 08, 2010 9:14 pm
Location: "Mens sana in corpore sano"
Contact:

Library to manipulate groups Gadgets

Post by holzhacker »

What do you think of creating commands to control groups Gadgets.

type:

Code: Select all


...

Enumeration 
   #GROUP_Login
EndEnumeration

...

TextGadget(#PB_Login, 0, 20, 100, 25, "Login", #PB_Text_Right, #GROUP_Login)
TextGadget(#PB_Password, 0, 45, 100, 25, "Password", #PB_Text_Right, #GROUP_Login)

...
So we ...

Code: Select all

SetGroupColor(#GROUP_Login, #PB_Group_FrontColor, #FF0000)
And all the gadgets linked to the group have applied the same property. COLORS, ALIGNMENTS, POSITION, etc.

It is a suggestion ...
Greetings and thanks!

Romerio Medeiros
romerio@gmail.com
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Library to manipulate groups Gadgets

Post by IdeasVacuum »

+1

It is a bit of a pain to have to specify font, colour etc for every individual gadget.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
hichem
User
User
Posts: 26
Joined: Sun Sep 04, 2005 4:18 pm

Re: Library to manipulate groups Gadgets

Post by hichem »

+1
will simplify coding.
User avatar
holzhacker
Enthusiast
Enthusiast
Posts: 125
Joined: Mon Mar 08, 2010 9:14 pm
Location: "Mens sana in corpore sano"
Contact:

Re: Library to manipulate groups Gadgets

Post by holzhacker »

Well I do not know if this request will be granted, I did it this way:

Code: Select all

Declare.l InitGroups()
Declare.l SetGadgetGroup(GadgetID.l, GroupID.l)
Declare.l SetGroupText(GroupID, Text.s)
Declare.l SetGroupColor(GroupID, ColorType, Color)
Declare.l GetGroupColor(GroupID, ColorType)
Declare.l HideGroup(GroupID, State)
Declare.l DisableGroup(GroupID, State)
Declare.l GetGroupState(GroupID)
Declare.l SetGadgetGroup(GadgetID.l, GroupID.l)
Declare.l SetGroupResize(GroupID)

Procedure.l InitGroups()
  
  Structure Group
    id.l
    gadget.l
    state.l
    frontcolor.l
    backcolor.l
  EndStructure
        
  Global Dim Group.Group(100)
      
  Global CounterGroups.l = 0
  
EndProcedure

Procedure.l SetGadgetGroup(GadgetID.l, GroupID.l)
  
  Group(CounterGroups.l)\id.l      =  GroupID.l
  Group(CounterGroups.l)\gadget.l  =  GadgetID.l
    
  CounterGroups.l = CounterGroups.l + 1

EndProcedure 

Procedure.l SetGroupText(GroupID, Text.s)
  
  For ii.l=0 To (CounterGroups.l - 1)
    
    If  Group(ii.l)\id = GroupID
      SetGadgetText(Group(ii.l)\gadget.l, Text.s)
    EndIf 
    
  Next 
  
EndProcedure 

Procedure.l SetGroupColor(GroupID, ColorType, Color)
  
  For ii.l=0 To (CounterGroups.l - 1)
    
    If  Group(ii.l)\id = GroupID
      
      SetGadgetColor(Group(ii.l)\gadget.l, ColorType, Color)
      
      Select ColorType
        Case #PB_Gadget_FrontColor
          SetGadgetColor(Group(ii.l)\frontcolor.l, #PB_Gadget_FrontColor, Color)
        Case #PB_Gadget_BackColor
          SetGadgetColor(Group(ii.l)\backcolor.l, #PB_Gadget_BackColor, Color)
      EndSelect 
                     
    EndIf 
    
  Next 
  
EndProcedure 

Procedure.l GetGroupColor(GroupID, ColorType)
  
  For ii.l=0 To (CounterGroups.l - 1)
    
    If  Group(ii.l)\id = GroupID
      
      Select ColorType
        Case #PB_Gadget_FrontColor
          ProcedureReturn Group(ii.l)\frontcolor.l
        Case #PB_Gadget_BackColor
          ProcedureReturn Group(ii.l)\backcolor.l    
      EndSelect 
                         
    EndIf 
    
  Next 
  
EndProcedure 

Procedure.l HideGroup(GroupID, State)
  
  For ii.l=0 To (CounterGroups.l - 1)
    
    If  Group(ii.l)\id = GroupID
      HideGadget(Group(ii.l)\gadget.l, State)
    EndIf 
    
  Next 
  
EndProcedure 

Procedure.l DisableGroup(GroupID, State)
  
  For ii.l=0 To (CounterGroups.l - 1)
    
    If  Group(ii.l)\id = GroupID
      DisableGadget(Group(ii.l)\gadget.l, State)
    EndIf 
    
  Next 
  
EndProcedure 

Procedure.l SetGroupState(GroupID)
  
  For ii.l=0 To (CounterGroups.l - 1)
    
    If  Group(ii.l)\id = GroupID
      ProcedureReturn Group(ii.l)\State.l                     
    EndIf 
    
  Next 
  
EndProcedure 

Procedure.l GetGroupState(GroupID)
  
  For ii.l=0 To (CounterGroups.l - 1)
    
    If  Group(ii.l)\id = GroupID
      ProcedureReturn Group(ii.l)\State.l                     
    EndIf 
    
  Next 
  
EndProcedure 

Procedure.l SetGroupResize(GroupID)
  
  For ii.l=0 To (CounterGroups.l - 1)
    
    If  Group(ii.l)\id = GroupID
;      PureRESIZE_SetGadgetResize(Group(ii.l)\gadget.l, #True, #True, #False, #False)
;      PureRESIZE_SetGadgetProportionalResize(Group(ii.l)\gadget.l, #True, #True, #False, #False)
    EndIf 
    
  Next 
  
EndProcedure 

Greetings and thanks!

Romerio Medeiros
romerio@gmail.com
User avatar
em_uk
Enthusiast
Enthusiast
Posts: 366
Joined: Sun Aug 08, 2010 3:32 pm
Location: Manchester UK

Re: Library to manipulate groups Gadgets

Post by em_uk »

+1

Good technique there.
----

R Tape loading error, 0:1
Post Reply