1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-03-19 09:13:33 +01:00

WINGs: wpopupbutton add two functions to change the displayed item

This patch is adding WMSelectPopUpButtonPreviousItem and
WMSelectPopUpButtonNextItem functions to the widget.
The WINGs lib version is bumped.
This commit is contained in:
David Maciejak
2026-01-24 16:42:11 -05:00
committed by Carlos R. Mafra
parent c82e6dad5c
commit 156841f80e
3 changed files with 56 additions and 2 deletions

View File

@@ -1462,6 +1462,10 @@ void WMSetPopUpButtonEnabled(WMPopUpButton *bPtr, Bool flag);
Bool WMGetPopUpButtonEnabled(WMPopUpButton *bPtr); Bool WMGetPopUpButtonEnabled(WMPopUpButton *bPtr);
int WMSelectPopUpButtonPreviousItem(WMPopUpButton *bPtr);
int WMSelectPopUpButtonNextItem(WMPopUpButton *bPtr);
/* ---[ WINGs/wprogressindicator.c ]------------------------------------- */ /* ---[ WINGs/wprogressindicator.c ]------------------------------------- */
WMProgressIndicator* WMCreateProgressIndicator(WMWidget *parent); WMProgressIndicator* WMCreateProgressIndicator(WMWidget *parent);

View File

@@ -252,6 +252,56 @@ WMMenuItem *WMGetPopUpButtonMenuItem(WMPopUpButton * bPtr, int index)
return WMGetFromArray(bPtr->items, index); return WMGetFromArray(bPtr->items, index);
} }
int WMSelectPopUpButtonPreviousItem(WMPopUpButton * bPtr)
{
int testIndex;
CHECK_CLASS(bPtr, WC_PopUpButton);
if (bPtr->flags.pullsDown || bPtr->selectedItemIndex < 0)
return -1;
testIndex = bPtr->selectedItemIndex - 1;
while (testIndex >= 0 && !WMGetPopUpButtonItemEnabled(bPtr, testIndex))
testIndex--;
if (testIndex != -1) {
WMSetPopUpButtonSelectedItem(bPtr, testIndex);
if (bPtr->action)
(*bPtr->action) (bPtr, bPtr->clientData);
return testIndex;
}
return -1;
}
int WMSelectPopUpButtonNextItem(WMPopUpButton * bPtr)
{
int itemCount;
int testIndex;
CHECK_CLASS(bPtr, WC_PopUpButton);
if (bPtr->flags.pullsDown || bPtr->selectedItemIndex < 0)
return -1;
itemCount = WMGetArrayItemCount(bPtr->items);
testIndex = bPtr->selectedItemIndex + 1;
while (testIndex < itemCount && !WMGetPopUpButtonItemEnabled(bPtr, testIndex))
testIndex++;
if (testIndex != itemCount) {
WMSetPopUpButtonSelectedItem(bPtr, testIndex);
if (bPtr->action)
(*bPtr->action) (bPtr, bPtr->clientData);
return testIndex;
}
return -1;
}
static void paintPopUpButton(PopUpButton * bPtr) static void paintPopUpButton(PopUpButton * bPtr)
{ {
W_Screen *scr = bPtr->view->screen; W_Screen *scr = bPtr->view->screen;

View File

@@ -78,9 +78,9 @@ WRASTER_VERSION=$WRASTER_CURRENT:$WRASTER_REVISION:$WRASTER_AGE
AC_SUBST(WRASTER_VERSION) AC_SUBST(WRASTER_VERSION)
dnl dnl
dnl libWINGs dnl libWINGs
WINGS_CURRENT=5 WINGS_CURRENT=6
WINGS_REVISION=0 WINGS_REVISION=0
WINGS_AGE=2 WINGS_AGE=3
WINGS_VERSION=$WINGS_CURRENT:$WINGS_REVISION:$WINGS_AGE WINGS_VERSION=$WINGS_CURRENT:$WINGS_REVISION:$WINGS_AGE
AC_SUBST(WINGS_VERSION) AC_SUBST(WINGS_VERSION)
dnl dnl