summaryrefslogtreecommitdiff
path: root/iup/src/mot/iupmot_list.c
diff options
context:
space:
mode:
Diffstat (limited to 'iup/src/mot/iupmot_list.c')
-rwxr-xr-xiup/src/mot/iupmot_list.c105
1 files changed, 64 insertions, 41 deletions
diff --git a/iup/src/mot/iupmot_list.c b/iup/src/mot/iupmot_list.c
index f8e73ed..800e6e9 100755
--- a/iup/src/mot/iupmot_list.c
+++ b/iup/src/mot/iupmot_list.c
@@ -143,15 +143,36 @@ void iupdrvListInsertItem(Ihandle* ih, int pos, const char* value)
motListAddSortedItem(ih, value);
else
motListAddItem(ih, pos, value);
+
+ iupListUpdateOldValue(ih, pos, 0);
}
void iupdrvListRemoveItem(Ihandle* ih, int pos)
{
/* The utility functions use 0=last 1=first */
if (ih->data->is_dropdown || ih->data->has_editbox)
+ {
+ if (ih->data->is_dropdown && !ih->data->has_editbox)
+ {
+ /* must check if removing the current item */
+ int curpos;
+ XtVaGetValues(ih->handle, XmNselectedPosition, &curpos, NULL);
+ if (pos == curpos && iupdrvListGetCount(ih)>1)
+ {
+ if (curpos > 0) curpos--;
+ else curpos++;
+
+ XtRemoveCallback(ih->handle, XmNselectionCallback, (XtCallbackProc)motListComboBoxSelectionCallback, (XtPointer)ih);
+ XtVaSetValues(ih->handle, XmNselectedPosition, curpos, NULL);
+ XtAddCallback(ih->handle, XmNselectionCallback, (XtCallbackProc)motListComboBoxSelectionCallback, (XtPointer)ih);
+ }
+ }
XmComboBoxDeletePos(ih->handle, pos+1);
+ }
else
XmListDeletePos(ih->handle, pos+1);
+
+ iupListUpdateOldValue(ih, pos, 1);
}
void iupdrvListRemoveAllItems(Ihandle* ih)
@@ -174,7 +195,7 @@ void iupdrvListRemoveAllItems(Ihandle* ih)
static char* motListGetIdValueAttrib(Ihandle* ih, const char* name_id)
{
int pos = iupListGetPos(ih, name_id);
- if (pos != -1)
+ if (pos >= 0)
{
XmString* items;
XtVaGetValues(ih->handle, XmNitems, &items, NULL);
@@ -852,8 +873,10 @@ static int motListSetNCAttrib(Ihandle* ih, const char* value)
Widget cbedit;
XtVaGetValues(ih->handle, XmNtextField, &cbedit, NULL);
XtVaSetValues(cbedit, XmNmaxLength, ih->data->nc, NULL);
+ return 0;
}
- return 0;
+ else
+ return 1; /* store until not mapped, when mapped will be set again */
}
static int motListSetClipboardAttrib(Ihandle *ih, const char *value)
@@ -1181,32 +1204,32 @@ static int motListMapMethod(Ihandle* ih)
if (ih->data->is_dropdown || ih->data->has_editbox)
{
/* could not set XmNmappedWhenManaged to False because the list and the edit box where not displayed */
- /* iupmotSetArg(args, num_args, XmNmappedWhenManaged, False); */
- iupmotSetArg(args, num_args, XmNx, 0); /* x-position */
- iupmotSetArg(args, num_args, XmNy, 0); /* y-position */
- iupmotSetArg(args, num_args, XmNwidth, 10); /* default width to avoid 0 */
- iupmotSetArg(args, num_args, XmNheight, 10); /* default height to avoid 0 */
- iupmotSetArg(args, num_args, XmNmarginHeight, 0);
- iupmotSetArg(args, num_args, XmNmarginWidth, 0);
+ /* iupMOT_SETARG(args, num_args, XmNmappedWhenManaged, False); */
+ iupMOT_SETARG(args, num_args, XmNx, 0); /* x-position */
+ iupMOT_SETARG(args, num_args, XmNy, 0); /* y-position */
+ iupMOT_SETARG(args, num_args, XmNwidth, 10); /* default width to avoid 0 */
+ iupMOT_SETARG(args, num_args, XmNheight, 10); /* default height to avoid 0 */
+ iupMOT_SETARG(args, num_args, XmNmarginHeight, 0);
+ iupMOT_SETARG(args, num_args, XmNmarginWidth, 0);
if (iupAttribGetBoolean(ih, "CANFOCUS"))
- iupmotSetArg(args, num_args, XmNtraversalOn, True);
+ iupMOT_SETARG(args, num_args, XmNtraversalOn, True);
else
- iupmotSetArg(args, num_args, XmNtraversalOn, False);
+ iupMOT_SETARG(args, num_args, XmNtraversalOn, False);
- iupmotSetArg(args, num_args, XmNnavigationType, XmTAB_GROUP);
- iupmotSetArg(args, num_args, XmNhighlightThickness, 2);
- iupmotSetArg(args, num_args, XmNshadowThickness, 2);
+ iupMOT_SETARG(args, num_args, XmNnavigationType, XmTAB_GROUP);
+ iupMOT_SETARG(args, num_args, XmNhighlightThickness, 2);
+ iupMOT_SETARG(args, num_args, XmNshadowThickness, 2);
if (ih->data->has_editbox)
{
if (ih->data->is_dropdown)
- iupmotSetArg(args, num_args, XmNcomboBoxType, XmDROP_DOWN_COMBO_BOX); /* hidden-list+edit */
+ iupMOT_SETARG(args, num_args, XmNcomboBoxType, XmDROP_DOWN_COMBO_BOX); /* hidden-list+edit */
else
- iupmotSetArg(args, num_args, XmNcomboBoxType, XmCOMBO_BOX); /* visible-list+edit */
+ iupMOT_SETARG(args, num_args, XmNcomboBoxType, XmCOMBO_BOX); /* visible-list+edit */
}
else
- iupmotSetArg(args, num_args, XmNcomboBoxType, XmDROP_DOWN_LIST); /* hidden-list */
+ iupMOT_SETARG(args, num_args, XmNcomboBoxType, XmDROP_DOWN_LIST); /* hidden-list */
ih->handle = XtCreateManagedWidget(
child_id, /* child identifier */
@@ -1220,13 +1243,13 @@ static int motListMapMethod(Ihandle* ih)
/* Create the scrolled window */
- iupmotSetArg(args, num_args, XmNmappedWhenManaged, False); /* not visible when managed */
- iupmotSetArg(args, num_args, XmNscrollingPolicy, XmAPPLICATION_DEFINED);
- iupmotSetArg(args, num_args, XmNvisualPolicy, XmVARIABLE);
- iupmotSetArg(args, num_args, XmNscrollBarDisplayPolicy, XmSTATIC); /* can NOT be XmAS_NEEDED because XmAPPLICATION_DEFINED */
- iupmotSetArg(args, num_args, XmNspacing, 0); /* no space between scrollbars and text */
- iupmotSetArg(args, num_args, XmNborderWidth, 0);
- iupmotSetArg(args, num_args, XmNshadowThickness, 0);
+ iupMOT_SETARG(args, num_args, XmNmappedWhenManaged, False); /* not visible when managed */
+ iupMOT_SETARG(args, num_args, XmNscrollingPolicy, XmAPPLICATION_DEFINED);
+ iupMOT_SETARG(args, num_args, XmNvisualPolicy, XmVARIABLE);
+ iupMOT_SETARG(args, num_args, XmNscrollBarDisplayPolicy, XmSTATIC); /* can NOT be XmAS_NEEDED because XmAPPLICATION_DEFINED */
+ iupMOT_SETARG(args, num_args, XmNspacing, 0); /* no space between scrollbars and text */
+ iupMOT_SETARG(args, num_args, XmNborderWidth, 0);
+ iupMOT_SETARG(args, num_args, XmNshadowThickness, 0);
sb_win = XtCreateManagedWidget(
child_id, /* child identifier */
@@ -1243,34 +1266,34 @@ static int motListMapMethod(Ihandle* ih)
/* Create the list */
num_args = 0;
- iupmotSetArg(args, num_args, XmNx, 0); /* x-position */
- iupmotSetArg(args, num_args, XmNy, 0); /* y-position */
- iupmotSetArg(args, num_args, XmNwidth, 10); /* default width to avoid 0 */
- iupmotSetArg(args, num_args, XmNheight, 10); /* default height to avoid 0 */
+ iupMOT_SETARG(args, num_args, XmNx, 0); /* x-position */
+ iupMOT_SETARG(args, num_args, XmNy, 0); /* y-position */
+ iupMOT_SETARG(args, num_args, XmNwidth, 10); /* default width to avoid 0 */
+ iupMOT_SETARG(args, num_args, XmNheight, 10); /* default height to avoid 0 */
if (iupAttribGetBoolean(ih, "CANFOCUS"))
- iupmotSetArg(args, num_args, XmNtraversalOn, True);
+ iupMOT_SETARG(args, num_args, XmNtraversalOn, True);
else
- iupmotSetArg(args, num_args, XmNtraversalOn, False);
+ iupMOT_SETARG(args, num_args, XmNtraversalOn, False);
- iupmotSetArg(args, num_args, XmNnavigationType, XmTAB_GROUP);
- iupmotSetArg(args, num_args, XmNhighlightThickness, 2);
- iupmotSetArg(args, num_args, XmNshadowThickness, 2);
+ iupMOT_SETARG(args, num_args, XmNnavigationType, XmTAB_GROUP);
+ iupMOT_SETARG(args, num_args, XmNhighlightThickness, 2);
+ iupMOT_SETARG(args, num_args, XmNshadowThickness, 2);
- iupmotSetArg(args, num_args, XmNlistMarginHeight, 0); /* default padding */
- iupmotSetArg(args, num_args, XmNlistMarginWidth, 0);
- iupmotSetArg(args, num_args, XmNlistSpacing, 0);
- iupmotSetArg(args, num_args, XmNlistSizePolicy, XmCONSTANT); /* don't grow to fit, add scrollbar */
+ iupMOT_SETARG(args, num_args, XmNlistMarginHeight, 0); /* default padding */
+ iupMOT_SETARG(args, num_args, XmNlistMarginWidth, 0);
+ iupMOT_SETARG(args, num_args, XmNlistSpacing, 0);
+ iupMOT_SETARG(args, num_args, XmNlistSizePolicy, XmCONSTANT); /* don't grow to fit, add scrollbar */
if (ih->data->is_multiple)
- iupmotSetArg(args, num_args, XmNselectionPolicy, XmEXTENDED_SELECT);
+ iupMOT_SETARG(args, num_args, XmNselectionPolicy, XmEXTENDED_SELECT);
else
- iupmotSetArg(args, num_args, XmNselectionPolicy, XmBROWSE_SELECT);
+ iupMOT_SETARG(args, num_args, XmNselectionPolicy, XmBROWSE_SELECT);
if (iupAttribGetBoolean(ih, "AUTOHIDE"))
- iupmotSetArg(args, num_args, XmNscrollBarDisplayPolicy, XmAS_NEEDED);
+ iupMOT_SETARG(args, num_args, XmNscrollBarDisplayPolicy, XmAS_NEEDED);
else
- iupmotSetArg(args, num_args, XmNscrollBarDisplayPolicy, XmSTATIC);
+ iupMOT_SETARG(args, num_args, XmNscrollBarDisplayPolicy, XmSTATIC);
ih->handle = XtCreateManagedWidget(
child_id, /* child identifier */