From aff89828594d895c826b5e600b5199eac74f71de Mon Sep 17 00:00:00 2001 From: kojima Date: Mon, 17 May 1999 03:55:35 +0000 Subject: [PATCH] added colorwell updating through colorpanel added delegate and new functions to tabview --- WINGs/ChangeLog | 1 + WINGs/WINGs.h | 23 +++++++++++++++++++++++ WINGs/wcolorpanel.c | 11 +++++++++-- WINGs/wcolorwell.c | 9 ++++----- WINGs/wtabview.c | 34 +++++++++++++++++++++++++++++++++- 5 files changed, 70 insertions(+), 8 deletions(-) diff --git a/WINGs/ChangeLog b/WINGs/ChangeLog index fbc47d81..6d1dad3e 100644 --- a/WINGs/ChangeLog +++ b/WINGs/ChangeLog @@ -27,6 +27,7 @@ changes since wmaker 0.53.0: manually when you change the text. - added WMTabView +- added WMGetColorPanelColor(WMColorPanel *panel) changes since wmaker 0.52.0: ............................ diff --git a/WINGs/WINGs.h b/WINGs/WINGs.h index 5d1fe86d..2b47c92d 100644 --- a/WINGs/WINGs.h +++ b/WINGs/WINGs.h @@ -453,6 +453,24 @@ typedef struct WMTextFieldDelegate { +typedef struct WMTabViewDelegate { + void *data; + + void (*didChangeNumberOfItems)(struct WMTabViewDelegate *self, + WMTabView *tabView); + + void (*didSelectItem)(struct WMTabViewDelegate *self, WMTabView *tabView, + WMTabViewItem *item); + + Bool (*shouldSelectItem)(struct WMTabViewDelegate *self, WMTabView *tabView, + WMTabViewItem *item); + + void (*willSelectItem)(struct WMTabViewDelegate *self, WMTabView *tabView, + WMTabViewItem *item); +} WMTabViewDelegate; + + + /* ....................................................................... */ @@ -1025,6 +1043,8 @@ void WMCloseColorPanel(WMColorPanel *panel); void WMSetColorPanelColor(WMColorPanel *panel, WMColor *color); +WMColor *WMGetColorPanelColor(WMColorPanel *panel); + void WMSetColorPanelPickerMode(WMColorPanel *panel, WMColorPanelMode mode); void WMSetColorPanelAction(WMColorPanel *panel, WMAction2 *action, void *data); @@ -1143,10 +1163,13 @@ void WMSelectTabViewItem(WMTabView *tPtr, WMTabViewItem *item); void WMSelectTabViewItemAtIndex(WMTabView *tPtr, int index); +void WMSetTabViewDelegate(WMTabView *tPtr, WMTabViewDelegate *delegate); WMTabViewItem *WMCreateTabViewItemWithIdentifier(int identifier); +int WMGetTabViewItemIdentifier(WMTabViewItem *item); + void WMSetTabViewItemLabel(WMTabViewItem *item, char *label); char *WMGetTabViewItemLabel(WMTabViewItem *item); diff --git a/WINGs/wcolorpanel.c b/WINGs/wcolorpanel.c index 661b618d..293a93d1 100644 --- a/WINGs/wcolorpanel.c +++ b/WINGs/wcolorpanel.c @@ -1288,11 +1288,18 @@ WMSetColorPanelPickerMode(WMColorPanel *panel, WMColorPanelMode mode) WMMapWidget(panel->colorListFrm); WMSetButtonSelected(panel->colorListBtn, True); } - - + panel->mode = mode; } + +WMColor* +WMGetColorPanelColor(WMColorPanel *panel) +{ + return WMGetColorWellColor(panel->colorWell); +} + + void WMSetColorPanelColor(WMColorPanel *panel, WMColor *color) { diff --git a/WINGs/wcolorwell.c b/WINGs/wcolorwell.c index 4a28407e..eab91038 100644 --- a/WINGs/wcolorwell.c +++ b/WINGs/wcolorwell.c @@ -69,7 +69,6 @@ static WMDragSourceProcs dragProcs = { static void colorChangedObserver(void *data, WMNotification *notification) { - /* WMColorPanel *panel = (WMColorPanel*)WMGetNotificationObject(notification); WMColorWell *cPtr = (WMColorWell*)data; WMColor *color; @@ -79,21 +78,21 @@ colorChangedObserver(void *data, WMNotification *notification) color = WMGetColorPanelColor(panel); - WMSetColorWellColor(cPtr, color);*/ - + WMSetColorWellColor(cPtr, color); + WMPostNotificationName(WMColorWellDidChangeNotification, cPtr, NULL); } static void updateColorCallback(void *self, void *data) { - /* WMColorPanel *panel = (WMColorPanel*)self; WMColorWell *cPtr = (ColorWell*)data; WMColor *color; color = WMGetColorPanelColor(panel); - WMSetColorWellColor(cPtr, color);*/ + WMSetColorWellColor(cPtr, color); + WMPostNotificationName(WMColorWellDidChangeNotification, cPtr, NULL); } diff --git a/WINGs/wtabview.c b/WINGs/wtabview.c index 8c382b5f..1fc75d69 100644 --- a/WINGs/wtabview.c +++ b/WINGs/wtabview.c @@ -17,6 +17,8 @@ typedef struct W_TabView { WMColor *lightGray; WMColor *tabColor; + WMTabViewDelegate *delegate; + short tabWidth; short tabHeight; @@ -127,6 +129,13 @@ WMCreateTabView(WMWidget *parent) } +void +WMSetTabViewDelegate(WMTabView *tPtr, WMTabViewDelegate *delegate) +{ + tPtr->delegate = delegate; +} + + void WMAddItemInTabView(WMTabView *tPtr, WMTabViewItem *item) { @@ -184,6 +193,8 @@ WMInsertItemInTabView(WMTabView *tPtr, int index, WMTabViewItem *item) if (index == 0) { W_MapTabViewItem(item); } + if (tPtr->delegate && tPtr->delegate->didChangeNumberOfItems) + (*tPtr->delegate->didChangeNumberOfItems)(tPtr->delegate, tPtr); } @@ -206,6 +217,8 @@ WMRemoveTabViewItem(WMTabView *tPtr, WMTabViewItem *item) break; } } + if (tPtr->delegate && tPtr->delegate->didChangeNumberOfItems) + (*tPtr->delegate->didChangeNumberOfItems)(tPtr->delegate, tPtr); } @@ -318,9 +331,17 @@ WMSelectTabViewItemAtIndex(WMTabView *tPtr, int index) else if (index >= tPtr->itemCount) index = tPtr->itemCount - 1; - item = tPtr->items[tPtr->selectedItem]; + if (tPtr->delegate && tPtr->delegate->shouldSelectItem) + if (!(*tPtr->delegate->shouldSelectItem)(tPtr->delegate, tPtr, + tPtr->items[index])) + return; + + if (tPtr->delegate && tPtr->delegate->willSelectItem) + (*tPtr->delegate->willSelectItem)(tPtr->delegate, tPtr, + tPtr->items[index]); + W_UnmapTabViewItem(item); @@ -329,6 +350,10 @@ WMSelectTabViewItemAtIndex(WMTabView *tPtr, int index) W_MapTabViewItem(item); tPtr->selectedItem = index; + + if (tPtr->delegate && tPtr->delegate->didSelectItem) + (*tPtr->delegate->didSelectItem)(tPtr->delegate, tPtr, + tPtr->items[index]); } @@ -601,6 +626,13 @@ WMCreateTabViewItemWithIdentifier(int identifier) } +int +WMGetTabViewItemIdentifier(WMTabViewItem *item) +{ + return item->identifier; +} + + void WMSetTabViewFont(WMTabView *tPtr, WMFont *font) {