It is currently Tue Oct 22, 2019 5:07 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Gadgets Height on each OS
PostPosted: Wed May 29, 2019 4:14 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Mar 10, 2013 3:01 pm
Posts: 650
Location: Portugal
Hello!

Since depending on the OS the height of the gadgets change, I created this little snippet that will show the height size.

Just select a font and run it on your target OSes.

Code:
    Enumeration
      #WINDOW_MAIN
      #BUTTON
      #TEXT
      #STRING
      #COMBOBOX
      #CHECKBOX
      #RADIOBUTTON
      #SPIN
    EndEnumeration

   
   
    Procedure GadgetFit(gadget)
 
      x=GadgetX(gadget)
      y=GadgetY(gadget)
      w=GadgetWidth(gadget)
      h=GadgetHeight(gadget)
      w_new=GadgetWidth(gadget,#PB_Gadget_RequiredSize)
      h_new=GadgetHeight(gadget,#PB_Gadget_RequiredSize)
 
      If w<>w_new Or h<>h_new
        ResizeGadget(gadget,x,y,w_new,h_new)     
      EndIf
 
    EndProcedure
   
   
   
    ; Open a Window
    If OpenWindow(#WINDOW_MAIN,0,0,1024,600,"Gadgets Height on each OS",#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)=#False : MessageRequester("Error", "Can't open a window.", #PB_MessageRequester_Error) : EndIf
   
   
    t=LoadFont(1,"Arial",10,#PB_Font_HighQuality) ;Load Arial Font, Size 10
    If t=#False : MessageRequester("Error", "Can't load Arial font.",#PB_MessageRequester_Error) : EndIf   
    SetGadgetFont(#PB_Default,FontID(1))   
   
   
    x=10
    y=10
   
   
    ; Button Gadget
    ButtonGadget(#BUTTON,x,y,200,200,"ZXp")
    GadgetFit(#BUTTON)
    Debug "Button Gadget:"+Str(GadgetHeight(#BUTTON))
   
    x+100
   
    ; Text Gadget
    TextGadget(#TEXT,x,y,200,200,"ZXp")
    GadgetFit(#TEXT)
    Debug "Text Gadget:"+Str(GadgetHeight(#TEXT))
   
   
    x+100
   
   
    ; String Gadget
    StringGadget(#STRING,x,y,200,200,"ZXp")
    GadgetFit(#STRING)
    Debug "String Gadget:"+Str(GadgetHeight(#STRING))
   
   
    x+100
   
    ; Combobox Gadget
    ComboBoxGadget(#COMBOBOX,x,y,200,200)
    AddGadgetItem(#COMBOBOX,-1,"ZXp")
    GadgetFit(#COMBOBOX)
    Debug "Combobox Gadget:"+Str(GadgetHeight(#COMBOBOX))
     
   
    x+100
   
    ; CheckBox Gadget
    CheckBoxGadget(#CHECKBOX,x,y,200,200,"ZXp")
    GadgetFit(#CHECKBOX)
    Debug "CheckBox Gadget:"+Str(GadgetHeight(#CHECKBOX))   
     
   
    x+100
   
    ; RadioButton Gadget
    OptionGadget(#RADIOBUTTON,x,y,200,200,"ZXp")
    GadgetFit(#RADIOBUTTON)
    Debug "RadioButton Gadget:"+Str(GadgetHeight(#RADIOBUTTON))
   
   
   
    x+100
   
    ; Spin Gadget
    OptionGadget(#SPIN,x,y,200,200,"ZXp")
    GadgetFit(#SPIN)
    Debug "Spin Gadget:"+Str(GadgetHeight(#SPIN))


Top
 Profile  
Reply with quote  
 Post subject: Re: Gadgets Height on each OS
PostPosted: Thu Aug 22, 2019 8:32 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Mar 10, 2013 3:01 pm
Posts: 650
Location: Portugal
Hello!

I had forgotten the ProgressBar Gadget:

Code:
    Enumeration
      #WINDOW_MAIN
      #BUTTON
      #TEXT
      #STRING
      #COMBOBOX
      #CHECKBOX
      #RADIOBUTTON
      #SPIN
      #PROGRESSBAR
    EndEnumeration

   
   
    Procedure GadgetFit(gadget)
 
      x=GadgetX(gadget)
      y=GadgetY(gadget)
      w=GadgetWidth(gadget)
      h=GadgetHeight(gadget)
      w_new=GadgetWidth(gadget,#PB_Gadget_RequiredSize)
      h_new=GadgetHeight(gadget,#PB_Gadget_RequiredSize)
 
      If w<>w_new Or h<>h_new
        ResizeGadget(gadget,x,y,w_new,h_new)     
      EndIf
 
    EndProcedure
   
   
   
    ; Open a Window
    If OpenWindow(#WINDOW_MAIN,0,0,1024,600,"Gadgets Height on each OS",#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)=#False : MessageRequester("Error", "Can't open a window.", #PB_MessageRequester_Error) : EndIf
   
   
    t=LoadFont(1,"Arial",10,#PB_Font_HighQuality) ;Load Arial Font, Size 10
    If t=#False : MessageRequester("Error", "Can't load Arial font.",#PB_MessageRequester_Error) : EndIf   
    SetGadgetFont(#PB_Default,FontID(1))   
   
   
    x=10
    y=10
   
   
    ; Button Gadget
    ButtonGadget(#BUTTON,x,y,200,200,"ZXpy")
    GadgetFit(#BUTTON)
    Debug "Button Gadget:"+Str(GadgetHeight(#BUTTON))
   
    x+100
   
    ; Text Gadget
    TextGadget(#TEXT,x,y,200,200,"ZXpy")
    GadgetFit(#TEXT)
    Debug "Text Gadget:"+Str(GadgetHeight(#TEXT))
   
   
    x+100
   
   
    ; String Gadget
    StringGadget(#STRING,x,y,200,200,"ZXpy")
    GadgetFit(#STRING)
    Debug "String Gadget:"+Str(GadgetHeight(#STRING))
   
   
    x+100
   
    ; Combobox Gadget
    ComboBoxGadget(#COMBOBOX,x,y,200,200)
    AddGadgetItem(#COMBOBOX,-1,"ZXpy")
    GadgetFit(#COMBOBOX)
    Debug "Combobox Gadget:"+Str(GadgetHeight(#COMBOBOX))
     
   
    x+100
   
    ; CheckBox Gadget
    CheckBoxGadget(#CHECKBOX,x,y,200,200,"ZXpy")
    GadgetFit(#CHECKBOX)
    Debug "CheckBox Gadget:"+Str(GadgetHeight(#CHECKBOX))   
     
   
    x+100
   
    ; RadioButton Gadget
    OptionGadget(#RADIOBUTTON,x,y,200,200,"ZXpy")
    GadgetFit(#RADIOBUTTON)
    Debug "RadioButton Gadget:"+Str(GadgetHeight(#RADIOBUTTON))
   
   
   
    x+100
   
    ; Spin Gadget
    SpinGadget(#SPIN,x,y,1,1,0,50)
    SetGadgetText(#SPIN,"9990")
    GadgetFit(#SPIN)
    Debug "Spin Gadget:"+Str(GadgetHeight(#SPIN))
   
   
   
    x+100
   
    ; ProgressBar Gadget
    ProgressBarGadget(#PROGRESSBAR,x,y,1000,1000,0,100)
    GadgetFit(#PROGRESSBAR)
    Debug "ProgressBar Gadget (width):"+Str(GadgetWidth(#PROGRESSBAR))
    Debug "ProgressBar Gadget (height):"+Str(GadgetHeight(#PROGRESSBAR))
   
   


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: Opcode and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye