Good morning,
Is it possible to color only certain lines in a ComboBox?
I know this is not possible with SetGadgetItemColor() but is there a routine someone wrote to do this?
I would like, in my ComboBox, to put the words that are in uppercase with a different color...
thank you
ComboBoxGadget and color
Re: ComboBoxGadget and color
Use this module:
viewtopic.php?t=74163
viewtopic.php?t=74163
Re: ComboBoxGadget and color
Hello Caronte3D,
1) I added the line at the beginning of my program:
2) I put this line (once the Combobox is powered):
and the first line is not in blue color...
Did I use the instruction incorrectly?
1) I added the line at the beginning of my program:
Code: Select all
IncludeFile "D:\Purebasic\MY MUSIC\ComboBoxEx\ComboBoxEx\ComboBoxExModule.pbi"
Code: Select all
ComboBoxEx::SetItemColor(#ComboDisplayDirectories,1,#Blue)
Did I use the instruction incorrectly?
Re: ComboBoxGadget and color
Load the .pbi in a new tab and execute to see an example.
Take a look at the end of the .pbi to know what to do.
Take a look at the end of the .pbi to know what to do.
Re: ComboBoxGadget and color
Hello Caronte3D,
I did it but it's not explained the different parameters when creating a ComboBox, that's why I posted this message.
I did it but it's not explained the different parameters when creating a ComboBox, that's why I posted this message.
Re: ComboBoxGadget and color
You have the whole source code, you can take a look.
Example, you can see that in the begining:
And you can take a look at ComboBoxEx::Gadget() the get an idea of the parameters:
Example, you can see that in the begining:
Code: Select all
;{ _____ ComboBoxEx - Commands _____
; ComboBoxEx::AddItem() - similar to 'AddGadgetItem()'
; ComboBoxEx::AttachPopupMenu() - attach a popup menu to the list
; ComboBoxEx::Copy() - copy selection to clipboard
; ComboBoxEx::Cut() - cut selection to clipboard
; ComboBoxEx::Delete() - delete selection
; ComboBoxEx::ClearItems() - similar to 'ClearGadgetItems()'
; ComboBoxEx::CountItems() - similar to 'CountGadgetItems()'
; ComboBoxEx::Disable() - similar to 'DisableGadget()'
; ComboBoxEx::GetData() - similar to 'GetGadgetData()'
; ComboBoxEx::GetID() - similar to 'GetGadgetData()', but string instead of quad
; ComboBoxEx::GetColor() - similar to 'GetGadgetColor()'
; ComboBoxEx::GetItemData() - similar to 'GetGadgetItemData()'
; ComboBoxEx::GetItemLabel() - similar to 'GetGadgetItemData()', but string instead of quad
; ComboBoxEx::GetItemText() - similar to 'GetGadgetItemText()'
; ComboBoxEx::GetLabelText() - similar to 'GetGadgetItemText()', but label instead of row
; ComboBoxEx::GetState() - similar to 'GetGadgetState()'
; ComboBoxEx::GetText() - similar to 'GetGadgetText()'
; ComboBoxEx::Gadget() - similar to 'ComboBoxGadget()'
; ComboBoxEx::Hide() - similar to 'HideGadget()'
; ComboBoxEx::Paste() - paste clipboard
; ComboBoxEx::RemoveItem() - similar to 'RemoveGadgetItem()'
; ComboBoxEx::SetAttribute() - similar to 'SetGadgetAttribute()'
; ComboBoxEx::SetAutoResizeFlags() - [#MoveX|#MoveY|#Width|#Height]
; ComboBoxEx::SetColor() - similar to 'SetGadgetColor()'
; ComboBoxEx::SetData() - similar to 'SetGadgetData()'
; ComboBoxEx::SetFont() - similar to 'SetGadgetFont()'
; ComboBoxEx::SetID() - similar to 'SetGadgetData()', but string instead of quad
; ComboBoxEx::SetImage() - replace the arrow with an image
; ComboBoxEx::SetItemColor() - similar to 'SetGadgetItemColor()'
; ComboBoxEx::SetItemData() - similar to 'SetGadgetItemData()'
; ComboBoxEx::SetItemImage() - similar to 'SetGadgetItemImage()'
; ComboBoxEx::SetItemText() - similar to 'SetGadgetItemText()'
; ComboBoxEx::SetLabelText() - similar to 'SetGadgetItemText()', but label instead of row
; ComboBoxEx::SetState() - similar to 'SetGadgetState()'
; ComboBoxEx::SetText() - similar to 'SetGadgetText()'
Code: Select all
Procedure Gadget(GNum.i, X.i, Y.i, Width.i, Height.i, maxListHeight.i, Content.s="", Flags.i=#False, WindowNum.i=#PB_Default)
Define.i Result, txtNum
CompilerIf Defined(ModuleEx, #PB_Module)
If ModuleEx::#Version < #ModuleEx : Debug "Please update ModuleEx.pbi" : EndIf
CompilerEndIf
If Flags & #UseExistingCanvas ;{ Use an existing CanvasGadget
If IsGadget(GNum)
Result = #True
Else
ProcedureReturn #False
EndIf
;}
Else
Result = CanvasGadget(GNum, X, Y, Width, 20, #PB_Canvas_Keyboard)
EndIf
If Result
If GNum = #PB_Any : GNum = Result : EndIf
If AddMapElement(ComboEx(), Str(GNum))
ComboEx()\CanvasNum = GNum
ComboEx()\Text = Content
ComboEx()\Flags = Flags
If WindowNum = #PB_Default
ComboEx()\Window\Num = GetGadgetWindow()
Else
ComboEx()\Window\Num = WindowNum
EndIf
CompilerSelect #PB_Compiler_OS ;{ Font
CompilerCase #PB_OS_Windows
ComboEx()\FontID = GetGadgetFont(#PB_Default)
CompilerCase #PB_OS_MacOS
txtNum = TextGadget(#PB_Any, 0, 0, 0, 0, " ")
If txtNum
ComboEx()\FontID = GetGadgetFont(txtNum)
FreeGadget(txtNum)
EndIf
CompilerCase #PB_OS_Linux
ComboEx()\FontID = GetGadgetFont(#PB_Default)
CompilerEndSelect ;}
ComboEx()\Padding = 4
ComboEx()\Button\Image\Num = #PB_Default
ComboEx()\Size\X = X
ComboEx()\Size\Y = Y
ComboEx()\Size\Width = Width
ComboEx()\Size\Height = Height
ComboEx()\ListView\Height = maxListHeight
InitList_()
ComboEx()\ListView\State = #PB_Default
ComboEx()\CanvasCursor = #PB_Cursor_Default
ComboEx()\Cursor\Pause = #True
ComboEx()\Cursor\State = #True
ComboEx()\Color\Front = $000000
ComboEx()\Color\Back = $FFFFFF
ComboEx()\Color\FocusText = $FFFFFF
ComboEx()\Color\FocusBack = $D77800
ComboEx()\Color\Border = $A0A0A0
ComboEx()\Color\Gadget = $EDEDED
ComboEx()\Color\DisableFront = $72727D
ComboEx()\Color\DisableBack = $CCCCCA
ComboEx()\Color\Cursor = $800000
ComboEx()\Color\Button = $E3E3E3
ComboEx()\Color\Highlight = $D77800
ComboEx()\Color\HighlightText = $FFFFFF
ComboEx()\Color\WordColor = $CC6600
CompilerSelect #PB_Compiler_OS ;{ Color
CompilerCase #PB_OS_Windows
ComboEx()\Color\Front = GetSysColor_(#COLOR_WINDOWTEXT)
ComboEx()\Color\Back = GetSysColor_(#COLOR_WINDOW)
ComboEx()\Color\FocusText = GetSysColor_(#COLOR_HIGHLIGHTTEXT)
ComboEx()\Color\FocusBack = GetSysColor_(#COLOR_HIGHLIGHT)
ComboEx()\Color\Gadget = GetSysColor_(#COLOR_MENU)
ComboEx()\Color\Button = GetSysColor_(#COLOR_3DLIGHT)
ComboEx()\Color\Border = GetSysColor_(#COLOR_ACTIVEBORDER)
ComboEx()\Color\WordColor = GetSysColor_(#COLOR_HOTLIGHT)
ComboEx()\Color\Highlight = GetSysColor_(#COLOR_HIGHLIGHT)
ComboEx()\Color\HighlightText = GetSysColor_(#COLOR_HIGHLIGHTTEXT)
CompilerCase #PB_OS_MacOS
ComboEx()\Color\Front = OSX_NSColorToRGB(CocoaMessage(0, 0, "NSColor textColor"))
ComboEx()\Color\FocusBack = BlendColor_(OSX_NSColorToRGB(CocoaMessage(0, 0, "NSColor textBackgroundColor")), $FFFFFF, 80)
ComboEx()\Color\FocusBack = OSX_NSColorToRGB(CocoaMessage(0, 0, "NSColor keyboardFocusIndicatorColor"))
ComboEx()\Color\Gadget = OSX_NSColorToRGB(CocoaMessage(0, 0, "NSColor windowBackgroundColor"))
ComboEx()\Color\Button = OSX_NSColorToRGB(CocoaMessage(0, 0, "NSColor controlBackgroundColor"))
ComboEx()\Color\Border = OSX_NSColorToRGB(CocoaMessage(0, 0, "NSColor grayColor"))
ComboEx()\Color\Highlight = OSX_NSColorToRGB(CocoaMessage(0, 0, "NSColor selectedTextBackgroundColor"))
ComboEx()\Color\HighlightText = OSX_NSColorToRGB(CocoaMessage(0, 0, "NSColor selectedTextColor"))
CompilerCase #PB_OS_Linux
CompilerEndSelect ;}
BindGadgetEvent(GNum, @_FocusHandler(), #PB_EventType_Focus)
BindGadgetEvent(GNum, @_LostFocusHandler(), #PB_EventType_LostFocus)
BindGadgetEvent(GNum, @_LeftButtonDownHandler(), #PB_EventType_LeftButtonDown)
BindGadgetEvent(GNum, @_LeftButtonUpHandler(), #PB_EventType_LeftButtonUp)
BindGadgetEvent(GNum, @_InputHandler(), #PB_EventType_Input)
BindGadgetEvent(GNum, @_KeyDownHandler(), #PB_EventType_KeyDown)
BindGadgetEvent(GNum, @_MouseMoveHandler(), #PB_EventType_MouseMove)
BindGadgetEvent(GNum, @_MouseLeaveHandler(), #PB_EventType_MouseLeave)
BindGadgetEvent(GNum, @_MouseEnterHandler(), #PB_EventType_MouseEnter)
BindGadgetEvent(GNum, @_RightClickHandler(), #PB_EventType_RightClick)
BindGadgetEvent(GNum, @_LeftDoubleClickHandler(), #PB_EventType_LeftDoubleClick)
BindGadgetEvent(GNum, @_CursorDrawing(), #PB_EventType_Change)
BindGadgetEvent(GNum, @_ResizeHandler(), #PB_EventType_Resize)
If IsWindow(WindowNum) : BindEvent(#PB_Event_MoveWindow, @_MoveWindowHandler(), WindowNum) : EndIf
If Flags & #AutoResize
If IsWindow(WindowNum)
ComboEx()\Window\Width = WindowWidth(WindowNum)
ComboEx()\Window\Height = WindowHeight(WindowNum)
BindEvent(#PB_Event_SizeWindow, @_ResizeWindowHandler(), WindowNum)
EndIf
EndIf
AddWindowTimer(ComboEx()\Window\Num, #CursorTimer, #CursorFrequency)
BindEvent(#PB_Event_Timer, @_CursorDrawing(), ComboEx()\Window\Num)
CompilerIf Defined(ModuleEx, #PB_Module)
BindEvent(#Event_Theme, @_ThemeHandler())
CompilerEndIf
BindEvent(#PB_Event_CloseWindow, @_CloseWindowHandler(), ComboEx()\Window\Num)
Draw_()
EndIf
EndIf
ProcedureReturn GNum
EndProcedure
Re: ComboBoxGadget and color
Thank you Caronte3D,
I had looked (I am French and do not always understand very well even if I use Google Translate).
I don't understand what the parameters are for.
1) Content.s=""
2) maxListHeight.i (if this is to set the number of items in the ComBoBox, I don't know in advance).
3) Flags.i=#False (I guess it's for indicated on the ComboBox is editable or not, if it has a border or by...)
4) WindowNum.i=#PB_Default (I assume this is the window that contains the ComboGadget)
Anyway, thank you for your information.
I had looked (I am French and do not always understand very well even if I use Google Translate).
I don't understand what the parameters are for.
1) Content.s=""
2) maxListHeight.i (if this is to set the number of items in the ComBoBox, I don't know in advance).
3) Flags.i=#False (I guess it's for indicated on the ComboBox is editable or not, if it has a border or by...)
4) WindowNum.i=#PB_Default (I assume this is the window that contains the ComboGadget)
Anyway, thank you for your information.
Re: ComboBoxGadget and color
Hello,
I got this information from Thorsten1867 (thanks to him)
maxListHeight: Maximum height of the selection list before using a scrollbar.
Content: The text that displays before something is selected.
Flags: #Borderless / #Editable / #UpperCase / #LowerCase / #Image / #AutoResize / #Left / #Right / #Center / #MultiSelect / #Style_RoundThumb / #Style_Win11
WindowNum: Top window number or ID
I got this information from Thorsten1867 (thanks to him)
maxListHeight: Maximum height of the selection list before using a scrollbar.
Content: The text that displays before something is selected.
Flags: #Borderless / #Editable / #UpperCase / #LowerCase / #Image / #AutoResize / #Left / #Right / #Center / #MultiSelect / #Style_RoundThumb / #Style_Win11
WindowNum: Top window number or ID