Class: Fox::FXComboBox

Inherits:
FXPacker show all
Includes:
Enumerable
Defined in:
rdoc-sources/FXComboBox.rb,
lib/fox16/iterators.rb

Overview

An FXComboBox provides a way to select a string from a list of strings. Unless COMBOBOX_STATIC is passed, it also allows the user to enter a new string into the text field, for example if the desired entry is not in the list of strings. Passing COMBOBOX_REPLACE, COMBOBOX_INSERT_BEFORE, COMBOBOX_INSERT_AFTER, COMBOBOX_INSERT_FIRST, or COMBOBOX_INSERT_LAST causes a newly entered text to replace the current one in the list, or be added before or after the current entry, or to be added at the beginning or end of the list. FXComboBox is intended to enter text; if you need to enter a choice from a list of options, it is recommended that the FXListBox widget is used instead. When the text in the field is changed, a SEL_COMMAND will be send to the target. The FXComboBox can also receive ID_GETSTRINGVALUE and ID_SETSTRINGVALUE and so on, which will behave similar to FXTextField in that they will retrieve or update the value of the field.

Events

The following messages are sent by FXComboBox to its target:

SEL_CHANGED

sent when the text in the text field changes; the message data is a String containing the new text.

SEL_COMMAND

sent when a new item is selected from the list, or when a command message is sent from the text field; the message data is a String containing the new text.

ComboBox styles

COMBOBOX_NO_REPLACE

Leave the list the same

COMBOBOX_REPLACE

Replace current item with typed text

COMBOBOX_INSERT_BEFORE

Typed text inserted before current

COMBOBOX_INSERT_AFTER

Typed text inserted after current

COMBOBOX_INSERT_FIRST

Typed text inserted at begin of list

COMBOBOX_INSERT_LAST

Typed text inserted at end of list

COMBOBOX_STATIC

Unchangable text box

COMBOBOX_NORMAL

Default options for comboboxes

Message identifiers

ID_LIST

identifier associated with the embedded FXList instance

ID_TEXT

identifier associated with the embedded FXTextField instance

Instance Attribute Summary collapse

Attributes inherited from FXPacker

#baseColor, #borderColor, #borderWidth, #frameStyle, #hSpacing, #hiliteColor, #packingHints, #padBottom, #padLeft, #padRight, #padTop, #shadowColor, #vSpacing

Attributes inherited from FXWindow

#accelTable, #defaultCursor, #dragCursor, #focus, #key, #last, #layoutHints, #next, #numChildren, #owner, #parent, #prev, #root, #selector, #shell, #target, #x, #y

Attributes inherited from FXDrawable

#height, #visual, #width

Attributes inherited from FXId

#app, #userData, #xid

Instance Method Summary collapse

Methods inherited from FXComposite

#maxChildHeight, #maxChildWidth

Methods inherited from FXWindow

#acceptDrop, #acquireClipboard, #acquireSelection, #active?, #addHotKey, after?, #after?, before?, #before?, #beginDrag, #canFocus?, #changeFocus, #childAtIndex, #childOf?, #children, #clearDragRectangle, #clearShape, colorType, colorTypeName, commonAncestor, #composeContext, #composite?, #contains?, #containsChild?, #create, #createComposeContext, #cursorPosition, #default?, #defaultHeight, #defaultWidth, deleteType, deleteTypeName, #destroy, #destroyComposeContext, #detach, #didAccept, #disable, #doesSaveUnder?, #dragging?, #dropDisable, #dropEnable, #dropEnabled?, #dropFinished, #dropTarget?, #each_child, #each_child_recursive, #enable, #enabled?, #endDrag, #forceRefresh, #getChildAt, #getDNDData, #getHeightForWidth, #getWidthForHeight, #grab, #grabKeyboard, #grabbed?, #grabbedKeyboard?, #handleDrag, #hasClipboard?, #hasFocus?, #hasSelection?, #height, #height=, #hide, imageType, #inFocusChain?, #indexOfChild, #initial?, #inquireDNDAction, #inquireDNDTypes, #killFocus, #layout, #linkAfter, #linkBefore, #lower, #move, octetType, octetTypeName, #offeredDNDType?, #position, #raiseWindow, #recalc, #releaseClipboard, #releaseSelection, #remHotKey, #removeChild, #repaint, #reparent, #resize, #scroll, #setCursorPosition, #setDNDData, #setDefault, #setDragRectangle, #setFocus, #setInitial, #setShape, #shell?, #show, #shown?, stringType, textType, textTypeName, #tr, #translateCoordinatesFrom, #translateCoordinatesTo, #underCursor?, #ungrab, #ungrabKeyboard, #update, urilistType, urilistTypeName, utf16Type, utf16TypeName, utf8Type, utf8TypeName, #visible=, #width, #width=

Methods included from Responder2

#connect

Methods inherited from FXDrawable

#resize

Methods inherited from FXId

#create, #created?, #destroy, #detach, #runOnUiThread

Methods inherited from FXObject

#bind, #handle, #load, #save, subclasses

Constructor Details

#initialize(p, cols, target = nil, selector = 0, opts = COMBOBOX_NORMAL, x = 0, y = 0, width = 0, height = 0, padLeft = DEFAULT_PAD, padRight = DEFAULT_PAD, padTop = DEFAULT_PAD, padBottom = DEFAULT_PAD) ⇒ FXComboBox

Return an initialized FXComboBox instance, with room to display cols columns of text.

Parameters:

p

the parent widget for this combo-box Fox::FXComposite

cols

number of columns [Integer]

target

message target Fox::FXObject

selector

message identifier [Integer]

opts

the options [Integer]

x

initial x-position [Integer]

y

initial y-position [Integer]

width

initial width [Integer]

height

initial height [Integer]

padLeft

left-side padding, in pixels [Integer]

padRight

right-side padding, in pixels [Integer]

padTop

top-side padding, in pixels [Integer]

padBottom

bottom-side padding, in pixels [Integer]


106
107
# File 'rdoc-sources/FXComboBox.rb', line 106

def initialize(p, cols, target=nil, selector=0, opts=COMBOBOX_NORMAL, x=0, y=0, width=0, height=0, padLeft=DEFAULT_PAD, padRight=DEFAULT_PAD, padTop=DEFAULT_PAD, padBottom=DEFAULT_PAD) # :yields: theComboBox
end

Instance Attribute Details

#backColorObject

Window background color Fox::FXColor


70
71
72
# File 'rdoc-sources/FXComboBox.rb', line 70

def backColor
  @backColor
end

#comboStyleObject

Combo box style [Integer]


67
68
69
# File 'rdoc-sources/FXComboBox.rb', line 67

def comboStyle
  @comboStyle
end

#currentItemObject

Index of current item, or -1 if no current item [Integer]


61
62
63
# File 'rdoc-sources/FXComboBox.rb', line 61

def currentItem
  @currentItem
end

#editable=(value) ⇒ Object (writeonly)

Editable state [Boolean]


43
44
45
# File 'rdoc-sources/FXComboBox.rb', line 43

def editable=(value)
  @editable = value
end

#fontObject

Text font Fox::FXFont


64
65
66
# File 'rdoc-sources/FXComboBox.rb', line 64

def font
  @font
end

#helpTextObject

Status line help text [String]


82
83
84
# File 'rdoc-sources/FXComboBox.rb', line 82

def helpText
  @helpText
end

#justifyObject

Text justification mode; default is JUSTIFY_LEFT [Integer]


52
53
54
# File 'rdoc-sources/FXComboBox.rb', line 52

def justify
  @justify
end

#numColumnsObject

Number of columns [Integer]


49
50
51
# File 'rdoc-sources/FXComboBox.rb', line 49

def numColumns
  @numColumns
end

#numItemsObject (readonly)

Number of items in the list [Integer]


55
56
57
# File 'rdoc-sources/FXComboBox.rb', line 55

def numItems
  @numItems
end

#numVisibleObject

Number of visible items in the drop-down list [Integer]


58
59
60
# File 'rdoc-sources/FXComboBox.rb', line 58

def numVisible
  @numVisible
end

#selBackColorObject

Background color for selected items Fox::FXColor


76
77
78
# File 'rdoc-sources/FXComboBox.rb', line 76

def selBackColor
  @selBackColor
end

#selTextColorObject

Text color for selected items Fox::FXColor


79
80
81
# File 'rdoc-sources/FXComboBox.rb', line 79

def selTextColor
  @selTextColor
end

#textObject

Text [String]


46
47
48
# File 'rdoc-sources/FXComboBox.rb', line 46

def text
  @text
end

#textColorObject

Text color Fox::FXColor


73
74
75
# File 'rdoc-sources/FXComboBox.rb', line 73

def textColor
  @textColor
end

#tipTextObject

Tool tip message [String]


85
86
87
# File 'rdoc-sources/FXComboBox.rb', line 85

def tipText
  @tipText
end

Instance Method Details

#appendItem(text, data = nil) ⇒ Object

Append a new item to the list with the specified text and user data.


138
# File 'rdoc-sources/FXComboBox.rb', line 138

def appendItem(text, data=nil) ; end

#clearItemsObject

Remove all items from the list


154
# File 'rdoc-sources/FXComboBox.rb', line 154

def clearItems() ; end

#eachObject

Calls block once for each item in the list, passing the item's text and user data as parameters.


18
19
20
21
22
23
# File 'lib/fox16/iterators.rb', line 18

def each # :yields: itemText, itemData
  0.upto(numItems - 1) do |i|
    yield getItemText(i), getItemData(i)
  end
  self
end

#editable?Boolean

Return true if combobox is editable

Returns:

  • (Boolean)

113
# File 'rdoc-sources/FXComboBox.rb', line 113

def editable?() ; end

#fillItems(strings) ⇒ Object

Fill combo box by appending items from strings, where strings is an array of strings. Return the number of items added.


131
# File 'rdoc-sources/FXComboBox.rb', line 131

def fillItems(strings); end

#findItem(text, start = -1,, flags = SEARCH_FORWARD|SEARCH_WRAP) ⇒ Object

Search for items by name, beginning from the item with index start. If the start item is -1, the search will start at the first item in the list. The search flags may be SEARCH_FORWARD or SEARCH_BACKWARD, to control the search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP to control whether the search wraps at the start or end of the list. The option SEARCH_IGNORECASE causes a case-insensitive match. Finally, passing SEARCH_PREFIX causes searching for a prefix of the item name. Returns the index of the first matching item, or -1 if no matching item is found.


169
# File 'rdoc-sources/FXComboBox.rb', line 169

def findItem(text, start=-1, flags=SEARCH_FORWARD|SEARCH_WRAP); end

#findItemByData(data, start = -1,, flags = SEARCH_FORWARD|SEARCH_WRAP) ⇒ Object

Search for items by associated user data, beginning from the item with index start. If the start item is -1, the search will start at the first item in the list. The search flags may be SEARCH_FORWARD or SEARCH_BACKWARD, to control the search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP to control whether the search wraps at the start or end of the list. Returns the index of the first matching item, or -1 if no matching item is found.


183
# File 'rdoc-sources/FXComboBox.rb', line 183

def findItemByData(data, start=-1, flags=SEARCH_FORWARD|SEARCH_WRAP); end

#firstObject

Override Enumerable#first with FXWindow#first for backwards compatibility.


10
11
12
# File 'lib/fox16/iterators.rb', line 10

def first
  getFirst
end

#getItemData(index) ⇒ Object

Get data pointer for the item at index. Raises IndexError if index is out of bounds.


199
# File 'rdoc-sources/FXComboBox.rb', line 199

def getItemData(index) ; end

#getItemText(index) ⇒ Object

Get text for the item at index. Raises IndexError if index is out of bounds.


191
# File 'rdoc-sources/FXComboBox.rb', line 191

def getItemText(index) ; end

#insertItem(index, text, data = nil) ⇒ Object

Insert a new item at index, with the specified text and user data. Raises IndexError if index is out of bounds.


135
# File 'rdoc-sources/FXComboBox.rb', line 135

def insertItem(index, text, data=nil) ; end

#itemCurrent?(index) ⇒ Boolean

Return true if the item at index is the current item. Raises IndexError if index is out of bounds.

Returns:

  • (Boolean)

117
# File 'rdoc-sources/FXComboBox.rb', line 117

def itemCurrent?(index) ; end

#moveItem(newIndex, oldIndex) ⇒ Object

Move item from oldIndex to newIndex and return the new index of the item. Raises IndexError if either oldIndex or newIndex is out of bounds.


147
# File 'rdoc-sources/FXComboBox.rb', line 147

def moveItem(newIndex, oldIndex); end

#paneShown?Boolean

Return true if the pane is shown.

Returns:

  • (Boolean)

202
# File 'rdoc-sources/FXComboBox.rb', line 202

def paneShown?() ; end

#prependItem(text, data = nil) ⇒ Object

Prepend an item to the list with the specified text and user data


141
# File 'rdoc-sources/FXComboBox.rb', line 141

def prependItem(text, data=nil) ; end

#removeItem(index) ⇒ Object

Remove the item at index from the list. Raises IndexError if index is out of bounds.


151
# File 'rdoc-sources/FXComboBox.rb', line 151

def removeItem(index) ; end

#retrieveItem(index) ⇒ Object

Return the text of the item at the given index. Raises IndexError if index is out of bounds.


121
# File 'rdoc-sources/FXComboBox.rb', line 121

def retrieveItem(index) ; end

#setCurrentItem(index, notify = false) ⇒ Object

Set current item to index, where index is the zero-based index of the item. If notify is true, a SEL_COMMAND message is sent to the combo box's message target.


212
# File 'rdoc-sources/FXComboBox.rb', line 212

def setCurrentItem(index, notify=false); end

#setItem(index, text, data = nil) ⇒ Object

Replace the item at index with a new item with the specified text and user data. Raises IndexError if index is out of bounds.


125
# File 'rdoc-sources/FXComboBox.rb', line 125

def setItem(index, text, data=nil) ; end

#setItemData(index, data) ⇒ Object

Set user data for the item at index. Raises IndexError if index is out of bounds.


195
# File 'rdoc-sources/FXComboBox.rb', line 195

def setItemData(index, data) ; end

#setItemText(index, text) ⇒ Object

Set text for the item at index. Raises IndexError if index is out of bounds.


187
# File 'rdoc-sources/FXComboBox.rb', line 187

def setItemText(index, text) ; end

#sortItemsObject

Sort items using current sort function


205
# File 'rdoc-sources/FXComboBox.rb', line 205

def sortItems() ; end

#to_sObject

Return the combo box text


110
# File 'rdoc-sources/FXComboBox.rb', line 110

def to_s; end