Page 1 of 1

Library to manipulate groups Gadgets

Posted: Sat Aug 25, 2012 8:30 pm
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 ...

Re: Library to manipulate groups Gadgets

Posted: Sun Aug 26, 2012 2:47 am
by IdeasVacuum
+1

It is a bit of a pain to have to specify font, colour etc for every individual gadget.

Re: Library to manipulate groups Gadgets

Posted: Mon Aug 27, 2012 9:27 pm
by hichem
+1
will simplify coding.

Re: Library to manipulate groups Gadgets

Posted: Thu Jul 04, 2013 9:07 pm
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 


Re: Library to manipulate groups Gadgets

Posted: Wed Jul 10, 2013 1:06 am
by em_uk
+1

Good technique there.