1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-03-31 11:33:34 +02:00

many bug fixes, finished some delegate code, updated menu file bug from EXEC

to SHEXEC, updated french translations
This commit is contained in:
kojima
1999-05-29 21:41:25 +00:00
parent a43f369ec3
commit 5e4625dafe
74 changed files with 767 additions and 569 deletions

View File

@@ -14,12 +14,21 @@ changes since wmaker 0.53.0:
The notifications will still work, but using the delegate is preferable
How to convert old code to delegate callbacks:
Create a variable (static or dynamic) of the type of the delegate for
the widget type. Replace the notification observers with the
equivalent delegate callbacks. Put pointers to the callbacks
in the delegate variable.
1 - create a variable (static or dynamic) of the type of the
delegate for the widget type.
2 - Replace the notification observers with the equivalent
delegate callbacks.
3 - Put pointers to the callbacks in the delegate variable.
Take a look in wfilepanel.c to see how it is used there.
- changed W_ViewProcedureTable to delegates
This will only affect user created widgets. If you have a custom
widget, you will need to update the callbacks and the declaration
of the W_ViewProcedureTable variable to be a W_ViewDelegate,
which is declared in WINGsP.h To setup the delegate, assign
the delegate variable to view->delegate.
- WMTextField
Removed all the didChange notifications that were sent when the text
was changed programmatically. Only changes made by user interaction

View File

@@ -8,7 +8,7 @@
#include "WINGs.h"
#if WINGS_H_VERSION < 990222
#if WINGS_H_VERSION < 990516
#error There_is_an_old_WINGs.h_file_somewhere_in_your_system._Please_remove_it.
#endif
@@ -92,6 +92,7 @@ typedef struct W_FocusInfo {
struct W_FocusInfo *next;
} W_FocusInfo;
typedef struct W_Screen {
Display *display;
int screen;
@@ -234,12 +235,29 @@ typedef struct W_Screen {
typedef struct W_ViewDelegate {
void *data;
void (*didMove)(struct W_ViewDelegate*, WMView*);
void (*didResize)(struct W_ViewDelegate*, WMView*);
void (*willMove)(struct W_ViewDelegate*, WMView*, int*, int*);
void (*willResize)(struct W_ViewDelegate*, WMView*,
unsigned int*, unsigned int*);
} W_ViewDelegate;
typedef struct W_View {
struct W_Screen *screen;
WMWidget *self; /* must point to the widget the
* view belongs to */
W_ViewDelegate *delegate;
Window window;
WMSize size;
@@ -309,13 +327,6 @@ typedef struct W_EventHandler {
typedef struct W_ViewProcedureTable {
void (*setBackgroundColor)(WMWidget*, WMColor *color);
void (*resize)(WMWidget*, unsigned int, unsigned int);
void (*move)(WMWidget*, int, int);
} W_ViewProcedureTable;
typedef struct _WINGsConfiguration {
char *systemFont;
@@ -418,7 +429,7 @@ void W_InitApplication(WMScreen *scr);
void W_InitNotificationCenter(void);
W_Class W_RegisterUserWidget(W_ViewProcedureTable *procTable);
W_Class W_RegisterUserWidget(void);
void W_RedisplayView(WMView *view);

View File

@@ -44,6 +44,16 @@
#else /* !NDEBUG */
#ifdef DEBUG
#include <assert.h>
#define wassertr(expr) assert(expr)
#define wassertrv(expr, val) assert(expr)
#else /* !DEBUG */
#define wassertr(expr) \
if (!(expr)) { \
wwarning("%s line %i (%s): assertion %s failed",\
@@ -57,6 +67,7 @@
__FILE__, __LINE__, __ASSERT_FUNCTION, #expr);\
return (val);\
}
#endif /* !DEBUG */
#endif /* !NDEBUG */

View File

@@ -50,12 +50,13 @@ static void handleActionEvents(XEvent *event, void *data);
/*
* Some procedures you might want to override. Don't forget to call
* the equivalent view procedure after (or before) doing your stuff.
* Delegates
* See the source for the other widgets to see how to use.
* You won't need to use this most of the time.
*/
static W_ViewProcedureTable _MyWidgetViewProcedures = {
static W_ViewDelegate _MyWidgetDelegate = {
NULL,
NULL,
NULL,
NULL,
NULL
@@ -75,7 +76,7 @@ InitMyWidget(WMScreen *scr)
{
/* register our widget with WINGs and get our widget class ID */
if (!myWidgetClass) {
myWidgetClass = W_RegisterUserWidget(&_MyWidgetViewProcedures);
myWidgetClass = W_RegisterUserWidget();
}
return myWidgetClass;
@@ -97,7 +98,7 @@ CreateMyWidget(WMWidget *parent)
/* set the class ID */
mPtr->widgetClass = myWidgetClass;
/*
* Create the view for our widget.
* Note: the Window for the view is only created after the view is
@@ -113,6 +114,9 @@ CreateMyWidget(WMWidget *parent)
/* always do this */
mPtr->view->self = mPtr;
/* setup the delegates for the view */
mPtr->view->delegate = &_MyWidgetDelegate;
/*
* Intercept some events for our widget, so that we can handle them.
*/

View File

@@ -95,9 +95,16 @@ writeSelection(Display *dpy, Window requestor, Atom property, Atom type,
*/
gotError = False;
if (!XChangeProperty(dpy, requestor, property, type, format,
PropModeReplace, value, length))
return False;
#ifndef __sgi
if (!XChangeProperty(dpy, requestor, property, type, format,
PropModeReplace, value, length))
return False;
#else
/* in sgi seems this seems to return void */
XChangeProperty(dpy, requestor, property, type, format,
PropModeReplace, value, length);
#endif
XFlush(dpy);
return !gotError;

View File

@@ -87,12 +87,15 @@ static void removeColumn(WMBrowser *bPtr, int column);
static char*
createTruncatedString(WMFont *font, char *text, int *textLen, int width);
static void resizeBrowser(WMWidget*, unsigned int, unsigned int);
static void willResizeBrowser(W_ViewDelegate*, WMView*,
unsigned int*, unsigned int*);
W_ViewProcedureTable _BrowserViewProcedures = {
W_ViewDelegate _BrowserViewDelegate = {
NULL,
resizeBrowser,
NULL
NULL,
NULL,
NULL,
willResizeBrowser
};
@@ -117,6 +120,8 @@ WMCreateBrowser(WMWidget *parent)
}
bPtr->view->self = bPtr;
bPtr->view->delegate = &_BrowserViewDelegate;
WMCreateEventHandler(bPtr->view, ExposureMask|StructureNotifyMask
|ClientMessageMask, handleEvents, bPtr);
@@ -127,7 +132,7 @@ WMCreateBrowser(WMWidget *parent)
bPtr->flags.isTitled = DEFAULT_IS_TITLED;
bPtr->maxVisibleColumns = DEFAULT_MAX_VISIBLE_COLUMNS;
resizeBrowser(bPtr, DEFAULT_WIDTH, DEFAULT_HEIGHT);
WMResizeWidget(bPtr, DEFAULT_WIDTH, DEFAULT_HEIGHT);
bPtr->pathSeparator = wstrdup(DEFAULT_SEPARATOR);
@@ -201,7 +206,7 @@ WMSetBrowserMaxVisibleColumns(WMBrowser *bPtr, int columns)
removeColumn(bPtr, newFirstVisibleColumn + columns);
}
}
resizeBrowser(bPtr, bPtr->view->size.width, bPtr->view->size.height);
WMResizeWidget(bPtr, bPtr->view->size.width, bPtr->view->size.height);
if (bPtr->flags.loaded) {
XClearArea(bPtr->view->screen->display, bPtr->view->window, 0, 0,
bPtr->view->size.width, bPtr->titleHeight, False);
@@ -463,18 +468,19 @@ WMInsertBrowserItem(WMBrowser *bPtr, int column, int row, char *text,
static void
resizeBrowser(WMWidget *w, unsigned int width, unsigned int height)
willResizeBrowser(W_ViewDelegate *self, WMView *view,
unsigned int *width, unsigned int *height)
{
WMBrowser *bPtr = (WMBrowser*)w;
WMBrowser *bPtr = (WMBrowser*)view->self;
int cols = bPtr->maxVisibleColumns;
int colX, colY;
int i;
assert(width > 0);
assert(height > 0);
assert(*width > 0);
assert(*height > 0);
bPtr->columnSize.width = (width-(cols-1)*COLUMN_SPACING) / cols;
bPtr->columnSize.height = height;
bPtr->columnSize.width = (*width-(cols-1)*COLUMN_SPACING) / cols;
bPtr->columnSize.height = *height;
if (bPtr->flags.isTitled) {
colY = TITLE_SPACING + bPtr->titleHeight;
@@ -487,8 +493,8 @@ resizeBrowser(WMWidget *w, unsigned int width, unsigned int height)
bPtr->columnSize.height -= SCROLLER_WIDTH + 4;
if (bPtr->scroller) {
WMResizeWidget(bPtr->scroller, width-2, 1);
WMMoveWidget(bPtr->scroller, 1, height-SCROLLER_WIDTH-1);
WMResizeWidget(bPtr->scroller, *width-2, 1);
WMMoveWidget(bPtr->scroller, 1, *height-SCROLLER_WIDTH-1);
}
}
@@ -503,8 +509,6 @@ resizeBrowser(WMWidget *w, unsigned int width, unsigned int height)
colX += bPtr->columnSize.width+COLUMN_SPACING;
}
}
W_ResizeView(bPtr->view, width, height);
}

View File

@@ -99,13 +99,6 @@ static void handleEvents(XEvent *event, void *data);
static void handleActionEvents(XEvent *event, void *data);
W_ViewProcedureTable _ButtonViewProcedures = {
NULL,
NULL,
NULL
};
static char *WMPushedRadioNotification="WMPushedRadioNotification";

View File

@@ -40,14 +40,16 @@ static void handleDragEvents(XEvent *event, void *data);
static void handleActionEvents(XEvent *event, void *data);
static void resizeColorWell();
static void willResizeColorWell();
W_ViewProcedureTable _ColorWellViewProcedures = {
W_ViewDelegate _ColorWellViewDelegate = {
NULL,
resizeColorWell,
NULL
NULL,
NULL,
NULL,
willResizeColorWell
};
@@ -131,6 +133,8 @@ WMCreateColorWell(WMWidget *parent)
return NULL;
}
cPtr->view->self = cPtr;
cPtr->view->delegate = &_ColorWellViewDelegate;
cPtr->colorView = W_CreateView(cPtr->view);
if (!cPtr->colorView) {
@@ -155,7 +159,7 @@ WMCreateColorWell(WMWidget *parent)
cPtr->flags.bordered = 1;
resizeColorWell(cPtr, DEFAULT_WIDTH, DEFAULT_HEIGHT);
W_ResizeView(cPtr->view, DEFAULT_WIDTH, DEFAULT_HEIGHT);
WMAddNotificationObserver(activatedObserver, cPtr,
_ColorWellActivatedNotification, NULL);
@@ -194,7 +198,7 @@ WSetColorWellBordered(WMColorWell *cPtr, Bool flag)
{
if (cPtr->flags.bordered != flag) {
cPtr->flags.bordered = flag;
resizeColorWell(cPtr, cPtr->view->size.width, cPtr->view->size.height);
W_ResizeView(cPtr->view, cPtr->view->size.width, cPtr->view->size.height);
}
}
@@ -202,29 +206,27 @@ WSetColorWellBordered(WMColorWell *cPtr, Bool flag)
#define MIN(a,b) ((a) > (b) ? (b) : (a))
static void
resizeColorWell(WMColorWell *cPtr, unsigned int width, unsigned int height)
willResizeColorWell(W_ViewDelegate *self, WMView *view,
unsigned int *width, unsigned int *height)
{
WMColorWell *cPtr = (WMColorWell*)view->self;
int bw;
if (cPtr->flags.bordered) {
if (width < MIN_WIDTH)
width = MIN_WIDTH;
if (height < MIN_HEIGHT)
height = MIN_HEIGHT;
if (*width < MIN_WIDTH)
*width = MIN_WIDTH;
if (*height < MIN_HEIGHT)
*height = MIN_HEIGHT;
bw = (int)((float)MIN(width, height)*0.24);
W_ResizeView(cPtr->view, width, height);
W_ResizeView(cPtr->colorView, width-2*bw, height-2*bw);
bw = (int)((float)MIN(*width, *height)*0.24);
W_ResizeView(cPtr->colorView, *width-2*bw, *height-2*bw);
if (cPtr->colorView->pos.x!=bw || cPtr->colorView->pos.y!=bw)
W_MoveView(cPtr->colorView, bw, bw);
} else {
W_ResizeView(cPtr->view, width, height);
W_ResizeView(cPtr->colorView, width, height);
} else {
W_ResizeView(cPtr->colorView, *width, *height);
W_MoveView(cPtr->colorView, 0, 0);
}

View File

@@ -75,6 +75,12 @@ WMCreateFontInDefaultEncoding(WMScreen *scrPtr, char *fontName)
WMFont *font;
Display *display = scrPtr->display;
font = WMHashGet(scrPtr->fontCache, fontName);
if (font) {
WMRetainFont(font);
return font;
}
font = malloc(sizeof(WMFont));
if (!font)
return NULL;
@@ -95,6 +101,8 @@ WMCreateFontInDefaultEncoding(WMScreen *scrPtr, char *fontName)
font->refCount = 1;
assert(WMHashInsert(scrPtr->fontCache, font->name, font)==NULL);
return font;
}
@@ -143,7 +151,6 @@ WMFontHeight(WMFont *font)
WMFont*
WMSystemFontOfSize(WMScreen *scrPtr, int size)
{
@@ -153,7 +160,7 @@ WMSystemFontOfSize(WMScreen *scrPtr, int size)
fontSpec = makeFontSetOfSize(WINGsConfiguration.systemFont, size);
font = WMCreateFont(scrPtr, fontSpec);
if (!font) {
wwarning("could not load font set %s. Trying fixed.", fontSpec);
font = WMCreateFont(scrPtr, "fixed");

View File

@@ -16,14 +16,6 @@ typedef struct W_Frame {
} Frame;
struct W_ViewProcedureTable _FrameViewProcedures = {
NULL,
NULL,
NULL
};
#define DEFAULT_RELIEF WRGroove
#define DEFAULT_TITLE_POSITION WTPAtTop
#define DEFAULT_WIDTH 40

View File

@@ -309,55 +309,12 @@ static unsigned char STIPPLE_BITS[] = {
extern void W_ReadConfigurations(void);
extern W_ViewProcedureTable _WindowViewProcedures;
extern W_ViewProcedureTable _FrameViewProcedures;
extern W_ViewProcedureTable _LabelViewProcedures;
extern W_ViewProcedureTable _ButtonViewProcedures;
extern W_ViewProcedureTable _TextFieldViewProcedures;
extern W_ViewProcedureTable _ScrollerViewProcedures;
extern W_ViewProcedureTable _ScrollViewProcedures;
extern W_ViewProcedureTable _ListViewProcedures;
extern W_ViewProcedureTable _BrowserViewProcedures;
extern W_ViewProcedureTable _PopUpButtonViewProcedures;
extern W_ViewProcedureTable _ColorWellViewProcedures;
extern W_ViewProcedureTable _ScrollViewViewProcedures;
extern W_ViewProcedureTable _SliderViewProcedures;
extern W_ViewProcedureTable _SplitViewViewProcedures;
extern W_ViewProcedureTable _TabViewViewProcedures;
/*
* All widget classes defined must have an entry here.
*/
static W_ViewProcedureTable *procedureTables[16];
static W_ViewProcedureTable **userProcedureTable = NULL;
static int userWidgetCount=0;
/***** end data ******/
static void
initProcedureTable()
{
procedureTables[WC_Window] = &_WindowViewProcedures;
procedureTables[WC_Frame] = &_FrameViewProcedures;
procedureTables[WC_Label] = &_LabelViewProcedures;
procedureTables[WC_Button] = &_ButtonViewProcedures;
procedureTables[WC_TextField] = &_TextFieldViewProcedures;
procedureTables[WC_Scroller] = &_ScrollerViewProcedures;
procedureTables[WC_List] = &_ListViewProcedures;
procedureTables[WC_Browser] = &_BrowserViewProcedures;
procedureTables[WC_PopUpButton] = &_PopUpButtonViewProcedures;
procedureTables[WC_ColorWell] = &_ColorWellViewProcedures;
procedureTables[WC_ScrollView] = &_ScrollViewViewProcedures;
procedureTables[WC_Slider] = &_SliderViewProcedures;
procedureTables[WC_SplitView] = &_SplitViewViewProcedures;
procedureTables[WC_TabView] = &_TabViewViewProcedures;
}
static void
renderPixmap(W_Screen *screen, Pixmap d, Pixmap mask, char **data,
int width, int height)
@@ -562,8 +519,6 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
if (!initialized) {
initialized = 1;
initProcedureTable();
W_ReadConfigurations();
@@ -866,76 +821,29 @@ WMUnmapWidget(WMWidget *w)
void
WMSetWidgetBackgroundColor(WMWidget *w, WMColor *color)
{
if (W_CLASS(w) < WC_UserWidget
&& procedureTables[W_CLASS(w)]->setBackgroundColor) {
(*procedureTables[W_CLASS(w)]->setBackgroundColor)(w, color);
} else if (W_CLASS(w) >= WC_UserWidget
&& userProcedureTable[W_CLASS(w)-WC_UserWidget]->setBackgroundColor) {
(*userProcedureTable[W_CLASS(w)-WC_UserWidget]->setBackgroundColor)(w, color);
} else {
W_SetViewBackgroundColor(W_VIEW(w), color);
}
W_SetViewBackgroundColor(W_VIEW(w), color);
}
void
WMMoveWidget(WMWidget *w, int x, int y)
{
if (W_CLASS(w) < WC_UserWidget
&& procedureTables[W_CLASS(w)]->move) {
(*procedureTables[W_CLASS(w)]->move)(w, x, y);
} else if (W_CLASS(w) >= WC_UserWidget
&& userProcedureTable[W_CLASS(w)-WC_UserWidget]->move) {
(*userProcedureTable[W_CLASS(w)-WC_UserWidget]->move)(w, x, y);
} else {
W_MoveView(W_VIEW(w), x, y);
}
W_MoveView(W_VIEW(w), x, y);
}
void
WMResizeWidget(WMWidget *w, unsigned int width, unsigned int height)
{
if (W_CLASS(w) < WC_UserWidget
&& procedureTables[W_CLASS(w)]->resize) {
(*procedureTables[W_CLASS(w)]->resize)(w, width, height);
} else if (W_CLASS(w) >= WC_UserWidget
&& userProcedureTable[W_CLASS(w)-WC_UserWidget]->resize) {
(*userProcedureTable[W_CLASS(w)-WC_UserWidget]->resize)(w, width, height);
} else {
W_ResizeView(W_VIEW(w), width, height);
}
W_ResizeView(W_VIEW(w), width, height);
}
W_Class
W_RegisterUserWidget(W_ViewProcedureTable *procTable)
W_RegisterUserWidget(void)
{
W_ViewProcedureTable **newTable;
userWidgetCount++;
newTable = wmalloc(sizeof(W_ViewProcedureTable*)*userWidgetCount);
memcpy(newTable, userProcedureTable,
sizeof(W_ViewProcedureTable*)*(userWidgetCount-1));
newTable[userWidgetCount-1] = procTable;
free(userProcedureTable);
userProcedureTable = newTable;
return userWidgetCount + WC_UserWidget - 1;
}

View File

@@ -29,14 +29,6 @@ typedef struct W_Label {
} Label;
W_ViewProcedureTable _LabelViewProcedures = {
NULL,
NULL,
NULL
};
#define DEFAULT_WIDTH 60
#define DEFAULT_HEIGHT 14
#define DEFAULT_ALIGNMENT WALeft

View File

@@ -66,12 +66,14 @@ static void updateScroller(List *lPtr);
static void vScrollCallBack(WMWidget *scroller, void *self);
static void updateGeometry(WMList *lPtr);
static void resizeList();
static void didResizeList();
W_ViewProcedureTable _ListViewProcedures = {
W_ViewDelegate _ListViewDelegate = {
NULL,
resizeList,
NULL,
didResizeList,
NULL,
NULL
};
@@ -95,6 +97,8 @@ WMCreateList(WMWidget *parent)
}
lPtr->view->self = lPtr;
lPtr->view->delegate = &_ListViewDelegate;
WMCreateEventHandler(lPtr->view, ExposureMask|StructureNotifyMask
|ClientMessageMask, handleEvents, lPtr);
@@ -114,7 +118,7 @@ WMCreateList(WMWidget *parent)
/* make the scroller map itself when it's realized */
WMMapWidget(lPtr->vScroller);
resizeList(lPtr, DEFAULT_WIDTH, DEFAULT_HEIGHT);
W_ResizeView(lPtr->view, DEFAULT_WIDTH, DEFAULT_HEIGHT);
lPtr->selectedItem = -1;
@@ -829,11 +833,11 @@ updateGeometry(WMList *lPtr)
static void
resizeList(WMList *lPtr, unsigned int width, unsigned int height)
{
W_ResizeView(lPtr->view, width, height);
WMResizeWidget(lPtr->vScroller, 1, height-2);
didResizeList(W_ViewDelegate *self, WMView *view)
{
WMList *lPtr = (WMList*)view->self;
WMResizeWidget(lPtr->vScroller, 1, view->size.height-2);
updateGeometry(lPtr);
}

View File

@@ -55,13 +55,6 @@ typedef struct W_PopUpButton {
#define SCROLL_DELAY 10
W_ViewProcedureTable _PopUpButtonViewProcedures = {
NULL,
NULL,
NULL
};
#define DEFAULT_WIDTH 60
#define DEFAULT_HEIGHT 20
#define DEFAULT_CAPTION ""

View File

@@ -67,17 +67,19 @@ typedef struct W_Scroller {
static void destroyScroller(Scroller *sPtr);
static void paintScroller(Scroller *sPtr);
static void resizeScroller();
static void willResizeScroller();
static void handleEvents(XEvent *event, void *data);
static void handleActionEvents(XEvent *event, void *data);
static void handleMotion(Scroller *sPtr, int mouseX, int mouseY);
W_ViewProcedureTable _ScrollerViewProcedures = {
W_ViewDelegate _ScrollerViewDelegate = {
NULL,
resizeScroller,
NULL
NULL,
NULL,
NULL,
willResizeScroller
};
@@ -99,13 +101,15 @@ WMCreateScroller(WMWidget *parent)
return NULL;
}
sPtr->view->self = sPtr;
sPtr->view->delegate = &_ScrollerViewDelegate;
sPtr->flags.documentFullyVisible = 1;
WMCreateEventHandler(sPtr->view, ExposureMask|StructureNotifyMask
|ClientMessageMask, handleEvents, sPtr);
resizeScroller(sPtr, DEFAULT_WIDTH, DEFAULT_WIDTH);
W_ResizeView(sPtr->view, DEFAULT_WIDTH, DEFAULT_WIDTH);
sPtr->flags.arrowsPosition = DEFAULT_ARROWS_POSITION;
WMCreateEventHandler(sPtr->view, ButtonPressMask|ButtonReleaseMask
@@ -130,17 +134,17 @@ WMSetScrollerArrowsPosition(WMScroller *sPtr, WMScrollArrowPosition position)
static void
resizeScroller(WMScroller *sPtr, unsigned int width, unsigned int height)
willResizeScroller(W_ViewDelegate *self, WMView *view,
unsigned int *width, unsigned int *height)
{
if (width > height) {
WMScroller *sPtr = (WMScroller*)view->self;
if (*width > *height) {
sPtr->flags.horizontal = 1;
W_ResizeView(sPtr->view, width, SCROLLER_WIDTH);
*height = SCROLLER_WIDTH;
} else {
sPtr->flags.horizontal = 0;
W_ResizeView(sPtr->view, SCROLLER_WIDTH, height);
}
if (sPtr->view->flags.realized) {
paintScroller(sPtr);
*width = SCROLLER_WIDTH;
}
}

View File

@@ -38,9 +38,11 @@ static void handleViewportEvents(XEvent *event, void *data);
static void resizeScrollView();
W_ViewProcedureTable _ScrollViewViewProcedures = {
W_ViewDelegate _ScrollViewViewDelegate = {
NULL,
NULL,
resizeScrollView,
NULL,
NULL
};
@@ -67,7 +69,10 @@ WMCreateScrollView(WMWidget *parent)
free(sPtr);
return NULL;
}
sPtr->view->self = sPtr;
sPtr->view->delegate = &_ScrollViewViewDelegate;
sPtr->viewport->flags.mapWhenRealized = 1;
WMCreateEventHandler(sPtr->view, StructureNotifyMask|ExposureMask,
@@ -171,11 +176,9 @@ reorganizeInterior(WMScrollView *sPtr)
static void
resizeScrollView(WMScrollView *sPtr, unsigned int width, unsigned int height)
resizeScrollView(W_ViewDelegate *self, WMView *view)
{
W_ResizeView(sPtr->view, width, height);
reorganizeInterior(sPtr);
reorganizeInterior(view->self);
}

View File

@@ -37,12 +37,14 @@ typedef struct W_Slider {
static void resizeSlider();
static void didResizeSlider();
W_ViewProcedureTable _SliderViewProcedures = {
W_ViewDelegate _SliderViewDelegate = {
NULL,
resizeSlider,
NULL,
didResizeSlider,
NULL,
NULL
};
@@ -82,6 +84,8 @@ WMCreateSlider(WMWidget *parent)
}
sPtr->view->self = sPtr;
sPtr->view->delegate = &_SliderViewDelegate;
WMCreateEventHandler(sPtr->view, ExposureMask|StructureNotifyMask,
handleEvents, sPtr);
@@ -300,13 +304,15 @@ realizeSlider(Slider *sPtr)
static void
resizeSlider(Slider *sPtr, unsigned int width, unsigned int height)
didResizeSlider(W_ViewDelegate *self, WMView *view)
{
Slider *sPtr = (Slider*)view->self;
int width = sPtr->view->size.width;
int height = sPtr->view->size.height;
assert(width > 0);
assert(height > 0);
W_ResizeView(sPtr->view, width, height);
if (width > height) {
if (sPtr->flags.vertical) {
sPtr->flags.vertical = 0;

View File

@@ -33,14 +33,6 @@ static void handleEvents(XEvent *event, void *data);
static void handleActionEvents(XEvent *event, void *data);
W_ViewProcedureTable _SplitViewViewProcedures = {
NULL,
NULL,
NULL
};
static int
subviewCount(SplitView *sPtr)
{

View File

@@ -34,13 +34,6 @@ typedef struct W_TabView {
struct W_ViewProcedureTable _TabViewViewProcedures = {
NULL,
NULL,
NULL
};
#define DEFAULT_WIDTH 40
#define DEFAULT_HEIGHT 40

View File

@@ -486,11 +486,13 @@ int main(int argc, char **argv)
* Put the testSomething() function you want to test here.
*/
testTextField(scr);
testColorWell(scr);
#if 0
testTabView(scr);
#if 0
testTextField(scr);
testGradientButtons(scr);
testOpenFilePanel(scr);
@@ -499,7 +501,6 @@ int main(int argc, char **argv)
testGradientButtons(scr);
testScrollView(scr);
testColorWell(scr);
testSlider(scr);
testPullDown(scr);

View File

@@ -106,11 +106,13 @@ static void paintTextField(TextField *tPtr);
static void handleEvents(XEvent *event, void *data);
static void handleTextFieldActionEvents(XEvent *event, void *data);
static void resizeTextField();
static void didResizeTextField();
struct W_ViewProcedureTable _TextFieldViewProcedures = {
struct W_ViewDelegate _TextFieldViewDelegate = {
NULL,
resizeTextField,
NULL,
didResizeTextField,
NULL,
NULL
};
@@ -260,7 +262,9 @@ WMCreateTextField(WMWidget *parent)
return NULL;
}
tPtr->view->self = tPtr;
tPtr->view->delegate = &_TextFieldViewDelegate;
tPtr->view->attribFlags |= CWCursor;
tPtr->view->attribs.cursor = tPtr->view->screen->textCursor;
@@ -276,8 +280,6 @@ WMCreateTextField(WMWidget *parent)
WMCreateEventHandler(tPtr->view, ExposureMask|StructureNotifyMask
|FocusChangeMask, handleEvents, tPtr);
W_ResizeView(tPtr->view, DEFAULT_WIDTH, DEFAULT_HEIGHT);
tPtr->font = WMRetainFont(tPtr->view->screen->normalFont);
tPtr->flags.bordered = DEFAULT_BORDERED;
@@ -286,6 +288,8 @@ WMCreateTextField(WMWidget *parent)
tPtr->offsetWidth =
WMAX((tPtr->view->size.height - WMFontHeight(tPtr->font))/2, 1);
W_ResizeView(tPtr->view, DEFAULT_WIDTH, DEFAULT_HEIGHT);
WMCreateEventHandler(tPtr->view, EnterWindowMask|LeaveWindowMask
|ButtonReleaseMask|ButtonPressMask|KeyPressMask|Button1MotionMask,
handleTextFieldActionEvents, tPtr);
@@ -594,9 +598,9 @@ WMSetTextFieldPrevTextField(WMTextField *tPtr, WMTextField *prev)
static void
resizeTextField(WMTextField *tPtr, unsigned int width, unsigned int height)
didResizeTextField(W_ViewDelegate *self, WMView *view)
{
W_ResizeView(tPtr->view, width, height);
WMTextField *tPtr = (WMTextField*)view->self;
tPtr->offsetWidth =
WMAX((tPtr->view->size.height - WMFontHeight(tPtr->font))/2, 1);
@@ -612,6 +616,7 @@ makeHiddenString(int length)
memset(data, '*', length);
data[length] = '\0';
return data;
}

View File

@@ -439,14 +439,22 @@ W_MoveView(W_View *view, int x, int y)
{
assert(view->flags.root==0);
if (view->delegate && view->delegate->willMove) {
(*view->delegate->willMove)(view->delegate, view, &x, &y);
}
if (view->pos.x == x && view->pos.y == y)
return;
if (view->flags.realized) {
XMoveWindow(view->screen->display, view->window, x, y);
}
view->pos.x = x;
view->pos.y = y;
if (view->delegate && view->delegate->didMove) {
(*view->delegate->didMove)(view->delegate, view);
}
}
@@ -454,10 +462,14 @@ void
W_ResizeView(W_View *view, unsigned int width, unsigned int height)
{
int shrinked;
if (view->delegate && view->delegate->willResize) {
(*view->delegate->willResize)(view->delegate, view, &width, &height);
}
assert(width > 0);
assert(height > 0);
if (view->size.width == width && view->size.height == height)
return;
@@ -468,7 +480,11 @@ W_ResizeView(W_View *view, unsigned int width, unsigned int height)
}
view->size.width = width;
view->size.height = height;
if (view->delegate && view->delegate->didResize) {
(*view->delegate->didResize)(view->delegate, view);
}
if (view->flags.notifySizeChanged)
WMPostNotificationName(WMViewSizeDidChangeNotification, view, NULL);
}

View File

@@ -74,12 +74,14 @@ typedef struct {
static void resizeWindow(WMWidget *, unsigned, unsigned);
static void willResizeWindow(W_ViewDelegate *, WMView *, unsigned*, unsigned*);
struct W_ViewProcedureTable _WindowViewProcedures = {
struct W_ViewDelegate _WindowViewDelegate = {
NULL,
resizeWindow,
NULL
NULL,
NULL,
NULL,
willResizeWindow
};
@@ -165,6 +167,8 @@ WMCreateWindowWithStyle(WMScreen *screen, char *name, int style)
}
win->view->self = win;
win->view->delegate = &_WindowViewDelegate;
win->wname = wstrdup(name);
/* add to the window list of the screen (application) */
@@ -272,25 +276,24 @@ WMSetWindowCloseAction(WMWindow *win, WMAction *action, void *clientData)
static void
resizeWindow(WMWidget *w, unsigned width, unsigned height)
willResizeWindow(W_ViewDelegate *self, WMView *view,
unsigned *width, unsigned *height)
{
WMWindow *win = (WMWindow*)w;
WMWindow *win = (WMWindow*)view->self;
if (win->minSize.width > 0 && win->minSize.height > 0) {
if (width < win->minSize.width)
width = win->minSize.width;
if (height < win->minSize.height)
height = win->minSize.height;
if (*width < win->minSize.width)
*width = win->minSize.width;
if (*height < win->minSize.height)
*height = win->minSize.height;
}
if (win->maxSize.width > 0 && win->maxSize.height > 0) {
if (width > win->maxSize.width)
width = win->maxSize.width;
if (height > win->maxSize.height)
height = win->maxSize.height;
if (*width > win->maxSize.width)
*width = win->maxSize.width;
if (*height > win->maxSize.height)
*height = win->maxSize.height;
}
W_ResizeView(win->view, width, height);
}