StringGadget text orientation

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
CSAUER
Enthusiast
Enthusiast
Posts: 188
Joined: Mon Oct 18, 2004 7:23 am
Location: Germany

StringGadget text orientation

Post by CSAUER »

I would like to see flags for left (=default), center and right orientation inside StringGadgets. This would be very useful especially if it would be available on all platforms.

BR, CSAUER
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PB4.1 - Win: MacBook black 2008 2,4 GHz, 4 GB RAM, MacOSX 10.5/VMWare/WinXP
PB4.1 - Mac: MacMini G4 1,4 GHz, 512 MB RAM, MacOSX 10.4
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Actually it's already in there for Windows, just name of the constant doesn't begin with "#PB_". Image

Code: Select all

OpenWindow(0,0,0,320,240,"void",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
StringGadget(0,5,5,200,20,"untitled1",#ES_LEFT)
StringGadget(1,5,30,200,20,"untitled2",#ES_CENTER)
StringGadget(2,5,55,200,20,"untitled3",#ES_RIGHT)

While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

Actually I just use the same flags for the text gadget and that works.

Code: Select all

StringGadget(#String_msrv, 456, 6, 138, 18, "SERVER ID", #PB_Text_Center)
I always thought it was an undocumented feature...
:D

Code: Select all


Enumeration
  #Window_0
EndEnumeration

Enumeration
  #Button_0
  #Text_3
  #String_INPUT
  #Text_2
  #Text_1
  #Text_0
  #String_2
  #String_1
  #String_0
EndEnumeration

Structure VisualDesignerGadgets
  Gadget.l
  EventFunction.l
EndStructure

Global NewList EventProcedures.VisualDesignerGadgets()

Procedure Button_0_Event(Window, Event, Gadget, Type)
  Debug "#Button_0"
  what$ = GetGadgetText(#String_INPUT)
    For x = #String_2 To #String_0
      SetGadgetText(x, what$)
    Next
    
EndProcedure

Procedure String_INPUT_Event(Window, Event, Gadget, Type)
  Debug "#String_INPUT"
EndProcedure

Procedure String_2_Event(Window, Event, Gadget, Type)
  Debug "#String_2"
EndProcedure

Procedure String_1_Event(Window, Event, Gadget, Type)
  Debug "#String_1"
EndProcedure

Procedure String_0_Event(Window, Event, Gadget, Type)
  Debug "#String_0"
EndProcedure

Procedure RegisterGadgetEvent(Gadget, *Function)
  
  If IsGadget(Gadget)
    AddElement(EventProcedures())
    EventProcedures()\Gadget        = Gadget
    EventProcedures()\EventFunction = *Function
  EndIf
  
EndProcedure

Procedure CallEventFunction(Window, Event, Gadget, Type)
  
  ForEach EventProcedures()
    If EventProcedures()\Gadget = Gadget
      CallFunctionFast(EventProcedures()\EventFunction, Window, Event, Gadget, Type)
      LastElement(EventProcedures())
    EndIf
  Next
  
EndProcedure

Procedure Open_Window_0()
  
  If OpenWindow(#Window_0, 5, 5, 404, 145, "TEXT STUFF",  #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_TitleBar )
    If CreateGadgetList(WindowID(#Window_0))
    
      StringGadget(#String_0, 5, 10, 120, 20, "left")
      RegisterGadgetEvent(#String_0, @String_0_Event())
      StringGadget(#String_1, 140, 10, 120, 20, "center", #PB_Text_Center)
      RegisterGadgetEvent(#String_1, @String_1_Event())
      StringGadget(#String_2, 275, 10, 120, 20, "right", #PB_Text_Right)
      RegisterGadgetEvent(#String_2, @String_2_Event())
      
      TextGadget(#Text_0, 5, 35, 120, 20, "LEFT")
      TextGadget(#Text_1, 140, 35, 120, 20, "CENTER", #PB_Text_Center)
      TextGadget(#Text_2, 275, 30, 120, 20, "RIGHT", #PB_Text_Right)
      
      StringGadget(#String_INPUT, 5, 60, 390, 20, "") ; input box
      RegisterGadgetEvent(#String_INPUT, @String_INPUT_Event())
      
      TextGadget(#Text_3, 5, 85, 390, 15, "TYPE A WORD AND HIT THE BUTTON", #PB_Text_Center)

      ButtonGadget(#Button_0, 5, 105, 390, 30, "ENTER THE TEXT")
      RegisterGadgetEvent(#Button_0, @Button_0_Event())
      
    EndIf
  EndIf
EndProcedure

Open_Window_0()

Repeat
  
  Event  = WaitWindowEvent()
  Gadget = EventGadget()
  Type   = EventType()
  Window = EventWindow()
  
  Select Event
    Case #PB_Event_Gadget
      CallEventFunction(Window, Event, Gadget, Type)
      
  EndSelect
  
Until Event = #PB_Event_CloseWindow

End
8)
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Rook Zimbabwe wrote:Actually I just use the same flags for the text gadget and that works.
It's because these flags are interpreted as API constants. Image

The enumeration is the same:

Code: Select all

#ES_CENTER = #PB_Text_Center
#ES_RIGHT = #PB_Text_Right
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
CONVERT
Enthusiast
Enthusiast
Posts: 130
Joined: Fri May 02, 2003 12:19 pm
Location: France

Re: StringGadget text orientation

Post by CONVERT »

As Rook Zimbabwe, I always thought it was an undocumented feature...

But, it would be great if PureBasic takes an official position: #ES_RIGHT and #ES_CENTER for Windows (and what for Linux?).
PureBasic 6.20 beta 2 (x64) | Windows 10 Pro x64 | Intel(R) Core(TM) i7-8700 CPU @ 3.20Ghz 16 GB RAM, SSD 500 GB, PC locally assembled.
Come back to 6.11 LTS 64 bits because of an issue with #PB_ComboBox_UpperCase in ComboBoxGadget() (Oct. 10, 2024).
User avatar
RSBasic
Moderator
Moderator
Posts: 1228
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: StringGadget text orientation

Post by RSBasic »

If you need api codes for Linux: http://www.chabba.de/Linux/StringGadget ... d_Align.pb (LinuxAPI-Lib by Omi)
Image
Image
User avatar
CONVERT
Enthusiast
Enthusiast
Posts: 130
Joined: Fri May 02, 2003 12:19 pm
Location: France

Re: StringGadget text orientation

Post by CONVERT »

Thanks, RSBasic.
PureBasic 6.20 beta 2 (x64) | Windows 10 Pro x64 | Intel(R) Core(TM) i7-8700 CPU @ 3.20Ghz 16 GB RAM, SSD 500 GB, PC locally assembled.
Come back to 6.11 LTS 64 bits because of an issue with #PB_ComboBox_UpperCase in ComboBoxGadget() (Oct. 10, 2024).
Post Reply