mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 20:38:08 +01:00
various fixes, scrollview scrollers, text painting
This commit is contained in:
@@ -2,6 +2,7 @@ Changes since wmaker 0.64.0:
|
|||||||
............................
|
............................
|
||||||
|
|
||||||
- made programmatic scroller changes send notifications
|
- made programmatic scroller changes send notifications
|
||||||
|
- replaced WMSetBoxExpandsToParent with WMSetViewExpands...
|
||||||
|
|
||||||
changes since wmaker 0.63.1:
|
changes since wmaker 0.63.1:
|
||||||
............................
|
............................
|
||||||
|
|||||||
@@ -92,14 +92,14 @@ void WMSetTableColumnDelegate(WMTableColumn *column,
|
|||||||
void WMSetTableColumnConstraints(WMTableColumn *column,
|
void WMSetTableColumnConstraints(WMTableColumn *column,
|
||||||
unsigned minWidth, unsigned maxWidth)
|
unsigned minWidth, unsigned maxWidth)
|
||||||
{
|
{
|
||||||
wassertr(minWidth <= maxWidth);
|
wassertr(maxWidth == 0 || minWidth <= maxWidth);
|
||||||
|
|
||||||
column->minWidth = minWidth;
|
column->minWidth = minWidth;
|
||||||
column->maxWidth = maxWidth;
|
column->maxWidth = maxWidth;
|
||||||
|
|
||||||
if (column->width < column->minWidth)
|
if (column->width < column->minWidth)
|
||||||
WMSetTableColumnWidth(column, column->minWidth);
|
WMSetTableColumnWidth(column, column->minWidth);
|
||||||
else if (column->width > column->maxWidth || column->maxWidth == 0)
|
else if (column->width > column->maxWidth && column->maxWidth != 0)
|
||||||
WMSetTableColumnWidth(column, column->maxWidth);
|
WMSetTableColumnWidth(column, column->maxWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,17 +238,14 @@ static void splitterHandler(XEvent *event, void *data)
|
|||||||
switch (ev.type) {
|
switch (ev.type) {
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
ox = cx;
|
ox = cx;
|
||||||
|
|
||||||
if (column->width + ev.xmotion.x < column->minWidth)
|
if (column->width + ev.xmotion.x < column->minWidth)
|
||||||
cx = pos.x + column->minWidth;
|
cx = pos.x + column->minWidth;
|
||||||
|
else if (column->maxWidth > 0
|
||||||
|
&& column->width + ev.xmotion.x > column->maxWidth)
|
||||||
|
cx = pos.x + column->maxWidth;
|
||||||
else
|
else
|
||||||
cx = offsX + ev.xmotion.x;
|
cx = offsX + ev.xmotion.x;
|
||||||
|
|
||||||
if (column->maxWidth > 0) {
|
|
||||||
if (column->width + ev.xmotion.x > column->maxWidth)
|
|
||||||
cx = pos.x + column->maxWidth;
|
|
||||||
else
|
|
||||||
cx = offsX + ev.xmotion.x;
|
|
||||||
}
|
|
||||||
|
|
||||||
XDrawLine(dpy, w, gc, ox+20, 0, ox+20, h);
|
XDrawLine(dpy, w, gc, ox+20, 0, ox+20, h);
|
||||||
XDrawLine(dpy, w, gc, cx+20, 0, cx+20, h);
|
XDrawLine(dpy, w, gc, cx+20, 0, cx+20, h);
|
||||||
@@ -256,13 +253,13 @@ static void splitterHandler(XEvent *event, void *data)
|
|||||||
|
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
column->width = cx - pos.x;
|
column->width = cx - pos.x;
|
||||||
rearrangeHeader(table);
|
|
||||||
done = 1;
|
done = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XDrawLine(dpy, w, gc, cx+20, 0, cx+20, h);
|
XDrawLine(dpy, w, gc, cx+20, 0, cx+20, h);
|
||||||
|
rearrangeHeader(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ typedef struct W_TableViewDelegate {
|
|||||||
WMTableColumn *WMCreateTableColumn(char *title);
|
WMTableColumn *WMCreateTableColumn(char *title);
|
||||||
|
|
||||||
void WMSetTableColumnWidth(WMTableColumn *column, unsigned width);
|
void WMSetTableColumnWidth(WMTableColumn *column, unsigned width);
|
||||||
|
|
||||||
|
void WMSetTableColumnConstraints(WMTableColumn *column,
|
||||||
|
unsigned minWidth, unsigned maxWidth);
|
||||||
|
|
||||||
void WMSetTableColumnDelegate(WMTableColumn *column,
|
void WMSetTableColumnDelegate(WMTableColumn *column,
|
||||||
WMTableColumnDelegate *delegate);
|
WMTableColumnDelegate *delegate);
|
||||||
|
|||||||
@@ -1279,9 +1279,11 @@ main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
testDragAndDrop(scr);
|
||||||
|
#if 0
|
||||||
testScrollView(scr);
|
testScrollView(scr);
|
||||||
testTabView(scr);
|
testTabView(scr);
|
||||||
#if 0
|
|
||||||
testBox(scr);
|
testBox(scr);
|
||||||
testText(scr);
|
testText(scr);
|
||||||
testList(scr);
|
testList(scr);
|
||||||
@@ -1292,7 +1294,6 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
testTextField(scr);
|
testTextField(scr);
|
||||||
|
|
||||||
testDragAndDrop(scr);
|
|
||||||
testDragAndDrop(scr);
|
testDragAndDrop(scr);
|
||||||
testFontPanel(scr);
|
testFontPanel(scr);
|
||||||
|
|
||||||
|
|||||||
@@ -393,12 +393,31 @@ typedef struct WMAlertPanel {
|
|||||||
WMFrame *line; /* separator */
|
WMFrame *line; /* separator */
|
||||||
short result; /* button that was pushed */
|
short result; /* button that was pushed */
|
||||||
short done;
|
short done;
|
||||||
|
|
||||||
KeyCode retKey;
|
|
||||||
KeyCode escKey;
|
|
||||||
} WMAlertPanel;
|
} WMAlertPanel;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct WMGenericPanel {
|
||||||
|
WMWindow *win;
|
||||||
|
WMBox *vbox;
|
||||||
|
|
||||||
|
WMLabel *iLbl;
|
||||||
|
WMLabel *tLbl;
|
||||||
|
|
||||||
|
WMFrame *line;
|
||||||
|
|
||||||
|
WMFrame *content;
|
||||||
|
|
||||||
|
WMBox *buttonBox;
|
||||||
|
WMButton *defBtn;
|
||||||
|
WMButton *altBtn;
|
||||||
|
|
||||||
|
short result;
|
||||||
|
short done;
|
||||||
|
} WMGenericPanel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct WMInputPanel {
|
typedef struct WMInputPanel {
|
||||||
WMWindow *win; /* window */
|
WMWindow *win; /* window */
|
||||||
WMButton *defBtn; /* default button */
|
WMButton *defBtn; /* default button */
|
||||||
@@ -408,14 +427,9 @@ typedef struct WMInputPanel {
|
|||||||
WMTextField *text; /* text field */
|
WMTextField *text; /* text field */
|
||||||
short result; /* button that was pushed */
|
short result; /* button that was pushed */
|
||||||
short done;
|
short done;
|
||||||
|
|
||||||
KeyCode retKey;
|
|
||||||
KeyCode escKey;
|
|
||||||
} WMInputPanel;
|
} WMInputPanel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* WMRuler: */
|
/* WMRuler: */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
WMArray *tabs; /* a growable array of tabstops */
|
WMArray *tabs; /* a growable array of tabstops */
|
||||||
@@ -720,17 +734,17 @@ WMFont *WMBoldSystemFontOfSize(WMScreen *scrPtr, int size);
|
|||||||
|
|
||||||
XFontSet WMGetFontFontSet(WMFont *font);
|
XFontSet WMGetFontFontSet(WMFont *font);
|
||||||
|
|
||||||
WMFont * WMNormalizeFont(WMScreen *scr, WMFont *font);
|
WMFont *WMNormalizeFont(WMScreen *scr, WMFont *font);
|
||||||
|
|
||||||
WMFont * WMStrengthenFont(WMScreen *scr, WMFont *font);
|
WMFont *WMStrengthenFont(WMScreen *scr, WMFont *font);
|
||||||
|
|
||||||
WMFont * WMUnstrengthenFont(WMScreen *scr, WMFont *font);
|
WMFont *WMUnstrengthenFont(WMScreen *scr, WMFont *font);
|
||||||
|
|
||||||
WMFont * WMEmphasizeFont(WMScreen *scr, WMFont *font);
|
WMFont *WMEmphasizeFont(WMScreen *scr, WMFont *font);
|
||||||
|
|
||||||
WMFont * WMUnemphasizeFont(WMScreen *scr, WMFont *font);
|
WMFont *WMUnemphasizeFont(WMScreen *scr, WMFont *font);
|
||||||
|
|
||||||
WMFont * WMGetFontOfSize(WMScreen *scr, WMFont *font, int size);
|
WMFont *WMGetFontOfSize(WMScreen *scr, WMFont *font, int size);
|
||||||
|
|
||||||
/* ....................................................................... */
|
/* ....................................................................... */
|
||||||
|
|
||||||
@@ -864,6 +878,9 @@ void WMRedisplayWidget(WMWidget *w);
|
|||||||
|
|
||||||
void WMSetViewNotifySizeChanges(WMView *view, Bool flag);
|
void WMSetViewNotifySizeChanges(WMView *view, Bool flag);
|
||||||
|
|
||||||
|
void WMSetViewExpandsToParent(WMView *view, int topOffs, int leftOffs,
|
||||||
|
int rightOffs, int bottomOffs);
|
||||||
|
|
||||||
WMSize WMGetViewSize(WMView *view);
|
WMSize WMGetViewSize(WMView *view);
|
||||||
|
|
||||||
WMPoint WMGetViewPosition(WMView *view);
|
WMPoint WMGetViewPosition(WMView *view);
|
||||||
@@ -1709,9 +1726,6 @@ void WMRemoveBoxSubview(WMBox *bPtr, WMView *view);
|
|||||||
|
|
||||||
void WMSetBoxHorizontal(WMBox *box, Bool flag);
|
void WMSetBoxHorizontal(WMBox *box, Bool flag);
|
||||||
|
|
||||||
void WMSetBoxExpandsToParent(WMBox *box, int topOffs, int bottomOffs,
|
|
||||||
int leftOffs, int rightOffs);
|
|
||||||
|
|
||||||
/* ....................................................................... */
|
/* ....................................................................... */
|
||||||
|
|
||||||
int WMRunAlertPanel(WMScreen *app, WMWindow *owner, char *title, char *msg,
|
int WMRunAlertPanel(WMScreen *app, WMWindow *owner, char *title, char *msg,
|
||||||
@@ -1730,10 +1744,17 @@ WMInputPanel *WMCreateInputPanel(WMScreen *app, WMWindow *owner, char *title,
|
|||||||
char *msg, char *defaultText, char *okButton,
|
char *msg, char *defaultText, char *okButton,
|
||||||
char *cancelButton);
|
char *cancelButton);
|
||||||
|
|
||||||
|
|
||||||
|
WMGenericPanel *WMCreateGenericPanel(WMScreen *scrPtr, WMWindow *owner,
|
||||||
|
char *title, char *defaultButton,
|
||||||
|
char *alternateButton);
|
||||||
|
|
||||||
void WMDestroyAlertPanel(WMAlertPanel *panel);
|
void WMDestroyAlertPanel(WMAlertPanel *panel);
|
||||||
|
|
||||||
void WMDestroyInputPanel(WMInputPanel *panel);
|
void WMDestroyInputPanel(WMInputPanel *panel);
|
||||||
|
|
||||||
|
void WMDestroyGenericPanel(WMGenericPanel *panel);
|
||||||
|
|
||||||
/* ....................................................................... */
|
/* ....................................................................... */
|
||||||
|
|
||||||
/* only 1 instance per WMScreen */
|
/* only 1 instance per WMScreen */
|
||||||
|
|||||||
@@ -318,6 +318,11 @@ typedef struct W_View {
|
|||||||
Window window;
|
Window window;
|
||||||
|
|
||||||
WMSize size;
|
WMSize size;
|
||||||
|
|
||||||
|
short topOffs;
|
||||||
|
short leftOffs;
|
||||||
|
short bottomOffs;
|
||||||
|
short rightOffs;
|
||||||
|
|
||||||
WMPoint pos;
|
WMPoint pos;
|
||||||
|
|
||||||
|
|||||||
@@ -96,30 +96,36 @@ WMUnregisterViewDraggedTypes(WMView *view)
|
|||||||
|
|
||||||
static unsigned defDraggingEntered(WMView *self, WMDraggingInfo *info)
|
static unsigned defDraggingEntered(WMView *self, WMDraggingInfo *info)
|
||||||
{
|
{
|
||||||
|
printf("%x drag entered\n", W_VIEW_DRAWABLE(self));
|
||||||
return WDOperationNone;
|
return WDOperationNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned defDraggingUpdated(WMView *self, WMDraggingInfo *info)
|
static unsigned defDraggingUpdated(WMView *self, WMDraggingInfo *info)
|
||||||
{
|
{
|
||||||
|
printf("%x drag updat\n", W_VIEW_DRAWABLE(self));
|
||||||
return WDOperationNone;
|
return WDOperationNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void defDraggingExited(WMView *self, WMDraggingInfo *info)
|
static void defDraggingExited(WMView *self, WMDraggingInfo *info)
|
||||||
{
|
{
|
||||||
|
printf("%x drag exit\n", W_VIEW_DRAWABLE(self));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool defPrepareForDragOperation(WMView *self, WMDraggingInfo *info)
|
static Bool defPrepareForDragOperation(WMView *self, WMDraggingInfo *info)
|
||||||
{
|
{
|
||||||
|
printf("%x drag prep\n", W_VIEW_DRAWABLE(self));
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool defPerformDragOperation(WMView *self, WMDraggingInfo *info)
|
static Bool defPerformDragOperation(WMView *self, WMDraggingInfo *info)
|
||||||
{
|
{
|
||||||
|
printf("%x drag perf\n", W_VIEW_DRAWABLE(self));
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void defConcludeDragOperation(WMView *self, WMDraggingInfo *info)
|
static void defConcludeDragOperation(WMView *self, WMDraggingInfo *info)
|
||||||
{
|
{
|
||||||
|
printf("%x drag concl\n", W_VIEW_DRAWABLE(self));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
39
WINGs/wbox.c
39
WINGs/wbox.c
@@ -23,11 +23,6 @@ typedef struct W_Box {
|
|||||||
|
|
||||||
short borderWidth;
|
short borderWidth;
|
||||||
|
|
||||||
int topOffs;
|
|
||||||
int bottomOffs;
|
|
||||||
int leftOffs;
|
|
||||||
int rightOffs;
|
|
||||||
|
|
||||||
unsigned horizontal:1;
|
unsigned horizontal:1;
|
||||||
} Box;
|
} Box;
|
||||||
|
|
||||||
@@ -54,18 +49,6 @@ static W_ViewDelegate delegate = {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void resizedParent(void *self, WMNotification *notif)
|
|
||||||
{
|
|
||||||
WMView *view = (WMView*)WMGetNotificationObject(notif);
|
|
||||||
WMSize size = WMGetViewSize(view);
|
|
||||||
WMBox *box = (WMBox*)self;
|
|
||||||
|
|
||||||
WMMoveWidget(box, box->leftOffs, box->topOffs);
|
|
||||||
WMResizeWidget(box, size.width - (box->leftOffs + box->rightOffs),
|
|
||||||
size.height - (box->topOffs + box->bottomOffs));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WMBox*
|
WMBox*
|
||||||
WMCreateBox(WMWidget *parent)
|
WMCreateBox(WMWidget *parent)
|
||||||
{
|
{
|
||||||
@@ -249,28 +232,6 @@ WMSetBoxHorizontal(WMBox *box, Bool flag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
WMSetBoxExpandsToParent(WMBox *box, int topOffs, int bottomOffs,
|
|
||||||
int leftOffs, int rightOffs)
|
|
||||||
{
|
|
||||||
WMSize size = W_VIEW(box)->parent->size;
|
|
||||||
|
|
||||||
box->topOffs = topOffs;
|
|
||||||
box->bottomOffs = bottomOffs;
|
|
||||||
box->leftOffs = leftOffs;
|
|
||||||
box->rightOffs = rightOffs;
|
|
||||||
|
|
||||||
WMAddNotificationObserver(resizedParent, box,
|
|
||||||
WMViewSizeDidChangeNotification,
|
|
||||||
W_VIEW(box)->parent);
|
|
||||||
WMSetViewNotifySizeChanges(W_VIEW(box)->parent, True);
|
|
||||||
|
|
||||||
WMMoveWidget(box, leftOffs, topOffs);
|
|
||||||
WMResizeWidget(box, size.width - (leftOffs + rightOffs),
|
|
||||||
size.height - (topOffs + bottomOffs));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
destroyBox(Box *bPtr)
|
destroyBox(Box *bPtr)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -94,16 +94,23 @@ fitText(char *text, WMFont *font, int width, int wrap)
|
|||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
int w;
|
int w;
|
||||||
|
|
||||||
if (text[0]==0)
|
if (text[0]==0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
if (wrap) {
|
if (wrap) {
|
||||||
|
if (text[0]=='\n')
|
||||||
|
return 1;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
i++;
|
i++;
|
||||||
w = WMWidthOfString(font, text, i);
|
w = WMWidthOfString(font, text, i);
|
||||||
} while (w < width && text[i]!='\n' && text[i]!=0);
|
} while (w < width && text[i]!='\n' && text[i]!=0);
|
||||||
|
|
||||||
|
if (text[i]=='\n')
|
||||||
|
return i;
|
||||||
|
|
||||||
/* keep words complete */
|
/* keep words complete */
|
||||||
if (!isspace(text[i])) {
|
if (!isspace(text[i])) {
|
||||||
j = i;
|
j = i;
|
||||||
@@ -116,7 +123,6 @@ fitText(char *text, WMFont *font, int width, int wrap)
|
|||||||
while (text[i]!='\n' && text[i]!=0)
|
while (text[i]!='\n' && text[i]!=0)
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
175
WINGs/wpanel.c
175
WINGs/wpanel.c
@@ -26,11 +26,13 @@ static void
|
|||||||
handleKeyPress(XEvent *event, void *clientData)
|
handleKeyPress(XEvent *event, void *clientData)
|
||||||
{
|
{
|
||||||
WMAlertPanel *panel = (WMAlertPanel*)clientData;
|
WMAlertPanel *panel = (WMAlertPanel*)clientData;
|
||||||
|
KeySym ksym;
|
||||||
if (event->xkey.keycode == panel->retKey && panel->defBtn) {
|
|
||||||
|
XLookupString(&event->xkey, NULL, 0, &ksym, NULL);
|
||||||
|
|
||||||
|
if (ksym == XK_Return && panel->defBtn) {
|
||||||
WMPerformButtonClick(panel->defBtn);
|
WMPerformButtonClick(panel->defBtn);
|
||||||
}
|
} else if (ksym == XK_Escape) {
|
||||||
if (event->xkey.keycode == panel->escKey) {
|
|
||||||
if (panel->altBtn || panel->othBtn) {
|
if (panel->altBtn || panel->othBtn) {
|
||||||
WMPerformButtonClick(panel->othBtn ? panel->othBtn : panel->altBtn);
|
WMPerformButtonClick(panel->othBtn ? panel->othBtn : panel->altBtn);
|
||||||
} else {
|
} else {
|
||||||
@@ -106,10 +108,6 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
|
|||||||
panel = wmalloc(sizeof(WMAlertPanel));
|
panel = wmalloc(sizeof(WMAlertPanel));
|
||||||
memset(panel, 0, sizeof(WMAlertPanel));
|
memset(panel, 0, sizeof(WMAlertPanel));
|
||||||
|
|
||||||
|
|
||||||
panel->retKey = XKeysymToKeycode(scrPtr->display, XK_Return);
|
|
||||||
panel->escKey = XKeysymToKeycode(scrPtr->display, XK_Escape);
|
|
||||||
|
|
||||||
if (owner) {
|
if (owner) {
|
||||||
panel->win = WMCreatePanelWithStyleForWindow(owner, "alertPanel",
|
panel->win = WMCreatePanelWithStyleForWindow(owner, "alertPanel",
|
||||||
WMTitledWindowMask);
|
WMTitledWindowMask);
|
||||||
@@ -125,7 +123,7 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
|
|||||||
WMSetWindowTitle(panel->win, "");
|
WMSetWindowTitle(panel->win, "");
|
||||||
|
|
||||||
panel->vbox = WMCreateBox(panel->win);
|
panel->vbox = WMCreateBox(panel->win);
|
||||||
WMSetBoxExpandsToParent(panel->vbox, 0, 0, 0, 0);
|
WMSetViewExpandsToParent(WMWidgetView(panel->vbox), 0, 0, 0, 0);
|
||||||
WMSetBoxHorizontal(panel->vbox, False);
|
WMSetBoxHorizontal(panel->vbox, False);
|
||||||
WMMapWidget(panel->vbox);
|
WMMapWidget(panel->vbox);
|
||||||
|
|
||||||
@@ -277,11 +275,13 @@ static void
|
|||||||
handleKeyPress2(XEvent *event, void *clientData)
|
handleKeyPress2(XEvent *event, void *clientData)
|
||||||
{
|
{
|
||||||
WMInputPanel *panel = (WMInputPanel*)clientData;
|
WMInputPanel *panel = (WMInputPanel*)clientData;
|
||||||
|
KeySym ksym;
|
||||||
if (event->xkey.keycode == panel->retKey && panel->defBtn) {
|
|
||||||
|
XLookupString(&event->xkey, NULL, 0, &ksym, NULL);
|
||||||
|
|
||||||
|
if (ksym == XK_Return && panel->defBtn) {
|
||||||
WMPerformButtonClick(panel->defBtn);
|
WMPerformButtonClick(panel->defBtn);
|
||||||
}
|
} else if (ksym == XK_Escape) {
|
||||||
if (event->xkey.keycode == panel->escKey) {
|
|
||||||
if (panel->altBtn) {
|
if (panel->altBtn) {
|
||||||
WMPerformButtonClick(panel->altBtn);
|
WMPerformButtonClick(panel->altBtn);
|
||||||
} else {
|
} else {
|
||||||
@@ -386,9 +386,6 @@ WMCreateInputPanel(WMScreen *scrPtr, WMWindow *owner, char *title, char *msg,
|
|||||||
panel = wmalloc(sizeof(WMInputPanel));
|
panel = wmalloc(sizeof(WMInputPanel));
|
||||||
memset(panel, 0, sizeof(WMInputPanel));
|
memset(panel, 0, sizeof(WMInputPanel));
|
||||||
|
|
||||||
panel->retKey = XKeysymToKeycode(scrPtr->display, XK_Return);
|
|
||||||
panel->escKey = XKeysymToKeycode(scrPtr->display, XK_Escape);
|
|
||||||
|
|
||||||
if (owner)
|
if (owner)
|
||||||
panel->win = WMCreatePanelWithStyleForWindow(owner, "inputPanel",
|
panel->win = WMCreatePanelWithStyleForWindow(owner, "inputPanel",
|
||||||
WMTitledWindowMask);
|
WMTitledWindowMask);
|
||||||
@@ -485,3 +482,149 @@ WMCreateInputPanel(WMScreen *scrPtr, WMWindow *owner, char *title, char *msg,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WMDestroyGenericPanel(WMGenericPanel *panel)
|
||||||
|
{
|
||||||
|
WMUnmapWidget(panel->win);
|
||||||
|
WMDestroyWidget(panel->win);
|
||||||
|
wfree(panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WMGenericPanel*
|
||||||
|
WMCreateGenericPanel(WMScreen *scrPtr, WMWindow *owner,
|
||||||
|
char *title, char *defaultButton,
|
||||||
|
char *alternateButton)
|
||||||
|
{
|
||||||
|
WMGenericPanel *panel;
|
||||||
|
int dw=0, aw=0, w;
|
||||||
|
WMBox *hbox;
|
||||||
|
|
||||||
|
|
||||||
|
panel = wmalloc(sizeof(WMGenericPanel));
|
||||||
|
memset(panel, 0, sizeof(WMGenericPanel));
|
||||||
|
|
||||||
|
if (owner) {
|
||||||
|
panel->win = WMCreatePanelWithStyleForWindow(owner, "genericPanel",
|
||||||
|
WMTitledWindowMask);
|
||||||
|
} else {
|
||||||
|
panel->win = WMCreateWindowWithStyle(scrPtr, "genericPanel",
|
||||||
|
WMTitledWindowMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
WMSetWindowInitialPosition(panel->win,
|
||||||
|
(scrPtr->rootView->size.width - WMWidgetWidth(panel->win))/2,
|
||||||
|
(scrPtr->rootView->size.height - WMWidgetHeight(panel->win))/2);
|
||||||
|
|
||||||
|
WMSetWindowTitle(panel->win, "");
|
||||||
|
|
||||||
|
panel->vbox = WMCreateBox(panel->win);
|
||||||
|
WMSetViewExpandsToParent(WMWidgetView(panel->vbox), 0, 0, 0, 0);
|
||||||
|
WMSetBoxHorizontal(panel->vbox, False);
|
||||||
|
WMMapWidget(panel->vbox);
|
||||||
|
|
||||||
|
hbox = WMCreateBox(panel->vbox);
|
||||||
|
WMSetBoxBorderWidth(hbox, 5);
|
||||||
|
WMSetBoxHorizontal(hbox, True);
|
||||||
|
WMMapWidget(hbox);
|
||||||
|
WMAddBoxSubview(panel->vbox, WMWidgetView(hbox), False, True, 74, 0, 5);
|
||||||
|
|
||||||
|
panel->iLbl = WMCreateLabel(hbox);
|
||||||
|
WMSetLabelImagePosition(panel->iLbl, WIPImageOnly);
|
||||||
|
WMMapWidget(panel->iLbl);
|
||||||
|
WMAddBoxSubview(hbox, WMWidgetView(panel->iLbl), False, True, 64, 0, 10);
|
||||||
|
|
||||||
|
if (scrPtr->applicationIcon) {
|
||||||
|
WMSetLabelImage(panel->iLbl, scrPtr->applicationIcon);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (title) {
|
||||||
|
WMFont *largeFont;
|
||||||
|
|
||||||
|
largeFont = WMBoldSystemFontOfSize(scrPtr, 24);
|
||||||
|
|
||||||
|
panel->tLbl = WMCreateLabel(hbox);
|
||||||
|
WMMapWidget(panel->tLbl);
|
||||||
|
WMAddBoxSubview(hbox, WMWidgetView(panel->tLbl), True, True,
|
||||||
|
64, 0, 0);
|
||||||
|
WMSetLabelText(panel->tLbl, title);
|
||||||
|
WMSetLabelTextAlignment(panel->tLbl, WALeft);
|
||||||
|
WMSetLabelFont(panel->tLbl, largeFont);
|
||||||
|
|
||||||
|
WMReleaseFont(largeFont);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* create divider line */
|
||||||
|
|
||||||
|
panel->line = WMCreateFrame(panel->vbox);
|
||||||
|
WMMapWidget(panel->line);
|
||||||
|
WMAddBoxSubview(panel->vbox, WMWidgetView(panel->line), False, True,
|
||||||
|
2, 2, 5);
|
||||||
|
WMSetFrameRelief(panel->line, WRGroove);
|
||||||
|
|
||||||
|
|
||||||
|
panel->content = WMCreateFrame(panel->vbox);
|
||||||
|
WMMapWidget(panel->content);
|
||||||
|
WMAddBoxSubview(panel->vbox, WMWidgetView(panel->content), True, True,
|
||||||
|
50, 0, 5);
|
||||||
|
WMSetFrameRelief(panel->content, WRFlat);
|
||||||
|
|
||||||
|
hbox = WMCreateBox(panel->vbox);
|
||||||
|
WMSetBoxBorderWidth(hbox, 10);
|
||||||
|
WMSetBoxHorizontal(hbox, True);
|
||||||
|
WMMapWidget(hbox);
|
||||||
|
WMAddBoxSubview(panel->vbox, WMWidgetView(hbox), False, True, 44, 0, 0);
|
||||||
|
|
||||||
|
/* create buttons */
|
||||||
|
if (defaultButton)
|
||||||
|
dw = WMWidthOfString(scrPtr->normalFont, defaultButton,
|
||||||
|
strlen(defaultButton));
|
||||||
|
|
||||||
|
if (alternateButton)
|
||||||
|
aw = WMWidthOfString(scrPtr->normalFont, alternateButton,
|
||||||
|
strlen(alternateButton));
|
||||||
|
|
||||||
|
|
||||||
|
dw = dw + (scrPtr->buttonArrow ? scrPtr->buttonArrow->width : 0);
|
||||||
|
|
||||||
|
aw += 30;
|
||||||
|
dw += 30;
|
||||||
|
|
||||||
|
w = WMAX(dw, aw);
|
||||||
|
if ((w+10)*2 < 400) {
|
||||||
|
aw = w;
|
||||||
|
dw = w;
|
||||||
|
} else {
|
||||||
|
int t;
|
||||||
|
|
||||||
|
t = 400 - 40 - aw - dw;
|
||||||
|
aw += t/2;
|
||||||
|
dw += t/2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defaultButton) {
|
||||||
|
panel->defBtn = WMCreateCommandButton(hbox);
|
||||||
|
WMSetButtonAction(panel->defBtn, alertPanelOnClick, panel);
|
||||||
|
WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->defBtn),
|
||||||
|
False, True, dw, 0, 0);
|
||||||
|
WMSetButtonText(panel->defBtn, defaultButton);
|
||||||
|
WMSetButtonImage(panel->defBtn, scrPtr->buttonArrow);
|
||||||
|
WMSetButtonAltImage(panel->defBtn, scrPtr->pushedButtonArrow);
|
||||||
|
WMSetButtonImagePosition(panel->defBtn, WIPRight);
|
||||||
|
}
|
||||||
|
|
||||||
|
WMMapSubwidgets(hbox);
|
||||||
|
|
||||||
|
// WMCreateEventHandler(W_VIEW(panel->win), KeyPressMask,
|
||||||
|
// handleKeyPress3, panel);
|
||||||
|
|
||||||
|
WMRealizeWidget(panel->win);
|
||||||
|
WMMapSubwidgets(panel->win);
|
||||||
|
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -450,6 +450,10 @@ WMSetScrollViewHasHorizontalScroller(WMScrollView *sPtr, Bool flag)
|
|||||||
/* make it a horiz. scroller */
|
/* make it a horiz. scroller */
|
||||||
WMResizeWidget(sPtr->hScroller, 2, 1);
|
WMResizeWidget(sPtr->hScroller, 2, 1);
|
||||||
|
|
||||||
|
if (W_VIEW_REALIZED(sPtr->view)) {
|
||||||
|
WMRealizeWidget(sPtr->hScroller);
|
||||||
|
}
|
||||||
|
|
||||||
reorganizeInterior(sPtr);
|
reorganizeInterior(sPtr);
|
||||||
|
|
||||||
WMMapWidget(sPtr->hScroller);
|
WMMapWidget(sPtr->hScroller);
|
||||||
@@ -481,6 +485,10 @@ WMSetScrollViewHasVerticalScroller(WMScrollView *sPtr, Bool flag)
|
|||||||
/* make it a vert. scroller */
|
/* make it a vert. scroller */
|
||||||
WMResizeWidget(sPtr->vScroller, 1, 2);
|
WMResizeWidget(sPtr->vScroller, 1, 2);
|
||||||
|
|
||||||
|
if (W_VIEW_REALIZED(sPtr->view)) {
|
||||||
|
WMRealizeWidget(sPtr->vScroller);
|
||||||
|
}
|
||||||
|
|
||||||
reorganizeInterior(sPtr);
|
reorganizeInterior(sPtr);
|
||||||
|
|
||||||
WMMapWidget(sPtr->vScroller);
|
WMMapWidget(sPtr->vScroller);
|
||||||
|
|||||||
@@ -731,4 +731,37 @@ WMGetViewScreenPosition(WMView *view)
|
|||||||
return wmkpoint(x, y);
|
return wmkpoint(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void resizedParent(void *self, WMNotification *notif)
|
||||||
|
{
|
||||||
|
WMSize size = WMGetViewSize((WMView*)WMGetNotificationObject(notif));
|
||||||
|
WMView *view = (WMView*)self;
|
||||||
|
|
||||||
|
W_MoveView(view, view->leftOffs, view->topOffs);
|
||||||
|
W_ResizeView(view, size.width - (view->leftOffs + view->rightOffs),
|
||||||
|
size.height - (view->topOffs + view->bottomOffs));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WMSetViewExpandsToParent(WMView *view, int leftOffs, int topOffs,
|
||||||
|
int rightOffs, int bottomOffs)
|
||||||
|
{
|
||||||
|
WMSize size = view->parent->size;
|
||||||
|
|
||||||
|
view->topOffs = topOffs;
|
||||||
|
view->bottomOffs = bottomOffs;
|
||||||
|
view->leftOffs = leftOffs;
|
||||||
|
view->rightOffs = rightOffs;
|
||||||
|
|
||||||
|
WMAddNotificationObserver(resizedParent, view,
|
||||||
|
WMViewSizeDidChangeNotification,
|
||||||
|
view->parent);
|
||||||
|
WMSetViewNotifySizeChanges(view->parent, True);
|
||||||
|
|
||||||
|
W_MoveView(view, leftOffs, topOffs);
|
||||||
|
W_ResizeView(view, size.width - (leftOffs + rightOffs),
|
||||||
|
size.height - (topOffs + bottomOffs));
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user