Add method for inserting ComboBox item
void uiComboboxInsertAt(uiComboBox *c, int n, const char *text) * Unix: gtk_combo_box_insert * Windows: CB_INSERTSTRING * Darwin: NSArrayController.insert
This commit is contained in:
parent
d78dc94a48
commit
26fc1804e5
|
@ -81,6 +81,11 @@ void uiComboboxAppend(uiCombobox *c, const char *text)
|
||||||
[c->pbac addObject:uiprivToNSString(text)];
|
[c->pbac addObject:uiprivToNSString(text)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiComboboxInsertAt(uiCombobox *c, int n, const char *text)
|
||||||
|
{
|
||||||
|
[c->pbac insert:uiprivToNSString(text) atArrangedObjectIndex:n]
|
||||||
|
}
|
||||||
|
|
||||||
void uiComboboxDelete(uiCombobox *c, int n)
|
void uiComboboxDelete(uiCombobox *c, int n)
|
||||||
{
|
{
|
||||||
[c->pb removeItemAtIndex:n];
|
[c->pb removeItemAtIndex:n];
|
||||||
|
|
|
@ -39,6 +39,11 @@ static void appendCBRB(uiButton *b, void *data)
|
||||||
uiRadioButtonsAppend(rb, "New Item");
|
uiRadioButtonsAppend(rb, "New Item");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void insertCB(uiButton *b, void *data)
|
||||||
|
{
|
||||||
|
uiComboboxInsertAt(cbox, 0, "Inserted item");
|
||||||
|
}
|
||||||
|
|
||||||
static void deleteCB(uiButton *b, void *data)
|
static void deleteCB(uiButton *b, void *data)
|
||||||
{
|
{
|
||||||
uiComboboxDelete(cbox, 0);
|
uiComboboxDelete(cbox, 0);
|
||||||
|
@ -157,6 +162,9 @@ uiBox *makePage4(void)
|
||||||
b = uiNewButton("Append");
|
b = uiNewButton("Append");
|
||||||
uiButtonOnClicked(b, appendCBRB, NULL);
|
uiButtonOnClicked(b, appendCBRB, NULL);
|
||||||
uiBoxAppend(hbox, uiControl(b), 0);
|
uiBoxAppend(hbox, uiControl(b), 0);
|
||||||
|
b = uiNewButton("Insert");
|
||||||
|
uiButtonOnClicked(b, insertCB, NULL);
|
||||||
|
uiBoxAppend(hbox, uiControl(b), 0);
|
||||||
b = uiNewButton("Delete");
|
b = uiNewButton("Delete");
|
||||||
uiButtonOnClicked(b, deleteCB, NULL);
|
uiButtonOnClicked(b, deleteCB, NULL);
|
||||||
uiBoxAppend(hbox, uiControl(b), 0);
|
uiBoxAppend(hbox, uiControl(b), 0);
|
||||||
|
|
1
ui.h
1
ui.h
|
@ -226,6 +226,7 @@ _UI_EXTERN uiSeparator *uiNewVerticalSeparator(void);
|
||||||
typedef struct uiCombobox uiCombobox;
|
typedef struct uiCombobox uiCombobox;
|
||||||
#define uiCombobox(this) ((uiCombobox *) (this))
|
#define uiCombobox(this) ((uiCombobox *) (this))
|
||||||
_UI_EXTERN void uiComboboxAppend(uiCombobox *c, const char *text);
|
_UI_EXTERN void uiComboboxAppend(uiCombobox *c, const char *text);
|
||||||
|
_UI_EXTERN void uiComboboxInsertAt(uiCombobox *c, int n, const char *text);
|
||||||
_UI_EXTERN void uiComboboxDelete(uiCombobox *c, int n);
|
_UI_EXTERN void uiComboboxDelete(uiCombobox *c, int n);
|
||||||
_UI_EXTERN void uiComboboxClear(uiCombobox *c);
|
_UI_EXTERN void uiComboboxClear(uiCombobox *c);
|
||||||
_UI_EXTERN int uiComboboxSelected(uiCombobox *c);
|
_UI_EXTERN int uiComboboxSelected(uiCombobox *c);
|
||||||
|
|
|
@ -30,6 +30,11 @@ void uiComboboxAppend(uiCombobox *c, const char *text)
|
||||||
gtk_combo_box_text_append(c->comboboxText, NULL, text);
|
gtk_combo_box_text_append(c->comboboxText, NULL, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiComboboxInsertAt(uiCombobox *c, int n, const char *text)
|
||||||
|
{
|
||||||
|
gtk_combo_box_text_insert(c->comboboxText, n, NULL, text);
|
||||||
|
}
|
||||||
|
|
||||||
void uiComboboxDelete(uiCombobox *c, int n)
|
void uiComboboxDelete(uiCombobox *c, int n)
|
||||||
{
|
{
|
||||||
gtk_combo_box_text_remove(c->comboboxText, n);
|
gtk_combo_box_text_remove(c->comboboxText, n);
|
||||||
|
|
|
@ -69,6 +69,20 @@ void uiComboboxAppend(uiCombobox *c, const char *text)
|
||||||
uiprivFree(wtext);
|
uiprivFree(wtext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiComboboxInsertAt(uiCombobox *c, int n, const char *text)
|
||||||
|
{
|
||||||
|
WCHAR *wtext;
|
||||||
|
LRESULT res;
|
||||||
|
|
||||||
|
wtext = toUTF16(text);
|
||||||
|
res = SendMessageW(c->hwnd, CB_INSERTSTRING, (WPARAM)n, (LPARAM) wtext);
|
||||||
|
if (res == (LRESULT) CB_ERR)
|
||||||
|
logLastError(L"error inserting item to uiCombobox");
|
||||||
|
else if (res == (LRESULT) CB_ERRSPACE)
|
||||||
|
logLastError(L"memory exhausted inserting item to uiCombobox");
|
||||||
|
uiprivFree(wtext);
|
||||||
|
}
|
||||||
|
|
||||||
void uiComboboxDelete(uiCombobox *c, int n)
|
void uiComboboxDelete(uiCombobox *c, int n)
|
||||||
{
|
{
|
||||||
LRESULT res;
|
LRESULT res;
|
||||||
|
|
Loading…
Reference in New Issue