mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +01:00
changed panel to use boxes
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
changes since wmaker 0.63.1:
|
||||||
|
............................
|
||||||
|
- added WMRunModalLoop() and WMBreakModalLoop()
|
||||||
|
- added WMSetBoxExpandsToParent()
|
||||||
|
|
||||||
changes since wmaker 0.62.1:
|
changes since wmaker 0.62.1:
|
||||||
............................
|
............................
|
||||||
- added WRuler widget
|
- added WRuler widget
|
||||||
@@ -58,6 +63,7 @@ changes since wmaker 0.62.1:
|
|||||||
the program name prepended to it. Similar to wwarning(), except that it
|
the program name prepended to it. Similar to wwarning(), except that it
|
||||||
doesn't add "warning:" in the output message.
|
doesn't add "warning:" in the output message.
|
||||||
- added WMBox widget
|
- added WMBox widget
|
||||||
|
- added WMAddTabViewItemWithView()
|
||||||
- added W_SetViewCursor()
|
- added W_SetViewCursor()
|
||||||
- made Extra widgets library
|
- made Extra widgets library
|
||||||
- added table widget in Extras library
|
- added table widget in Extras library
|
||||||
|
|||||||
@@ -772,6 +772,10 @@ void WMSelectTableViewRow(WMTableView *table, int row)
|
|||||||
{
|
{
|
||||||
if (table->clickedRow >= 0)
|
if (table->clickedRow >= 0)
|
||||||
setRowSelected(table, table->clickedRow, False);
|
setRowSelected(table, table->clickedRow, False);
|
||||||
|
|
||||||
|
if (row <= table->rows)
|
||||||
|
return;
|
||||||
|
|
||||||
setRowSelected(table, row, True);
|
setRowSelected(table, row, True);
|
||||||
table->clickedRow = row;
|
table->clickedRow = row;
|
||||||
|
|
||||||
@@ -788,6 +792,8 @@ void WMReloadTableView(WMTableView *table)
|
|||||||
|
|
||||||
repaintTable(table, 0, 0,
|
repaintTable(table, 0, 0,
|
||||||
W_VIEW_WIDTH(table->tableView), rect.size.height);
|
W_VIEW_WIDTH(table->tableView), rect.size.height);
|
||||||
|
|
||||||
|
table->clickedRow = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -363,6 +363,7 @@ typedef struct WMListItem {
|
|||||||
/* struct for message panel */
|
/* struct for message panel */
|
||||||
typedef struct WMAlertPanel {
|
typedef struct WMAlertPanel {
|
||||||
WMWindow *win; /* window */
|
WMWindow *win; /* window */
|
||||||
|
WMBox *vbox;
|
||||||
WMButton *defBtn; /* default button */
|
WMButton *defBtn; /* default button */
|
||||||
WMButton *altBtn; /* alternative button */
|
WMButton *altBtn; /* alternative button */
|
||||||
WMButton *othBtn; /* other button */
|
WMButton *othBtn; /* other button */
|
||||||
@@ -580,6 +581,9 @@ WMScreen *WMCreateSimpleApplicationScreen(Display *display);
|
|||||||
|
|
||||||
void WMScreenMainLoop(WMScreen *scr);
|
void WMScreenMainLoop(WMScreen *scr);
|
||||||
|
|
||||||
|
void WMBreakModalLoop(WMScreen *scr);
|
||||||
|
|
||||||
|
void WMRunModalLoop(WMScreen *scr, WMView *view);
|
||||||
|
|
||||||
RContext *WMScreenRContext(WMScreen *scr);
|
RContext *WMScreenRContext(WMScreen *scr);
|
||||||
|
|
||||||
@@ -1672,6 +1676,8 @@ void WMAddBoxSubviewAtEnd(WMBox *bPtr, WMView *view, Bool expand, Bool fill,
|
|||||||
|
|
||||||
void WMSetBoxHorizontal(WMBox *box, Bool flag);
|
void WMSetBoxHorizontal(WMBox *box, Bool flag);
|
||||||
|
|
||||||
|
void WMSetBoxExpandsToParent(WMBox *box);
|
||||||
|
|
||||||
/* ....................................................................... */
|
/* ....................................................................... */
|
||||||
|
|
||||||
int WMRunAlertPanel(WMScreen *app, WMWindow *owner, char *title, char *msg,
|
int WMRunAlertPanel(WMScreen *app, WMWindow *owner, char *title, char *msg,
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ typedef struct W_Screen {
|
|||||||
Window lastClickWindow; /* window of the last mousedown */
|
Window lastClickWindow; /* window of the last mousedown */
|
||||||
|
|
||||||
struct W_View *modalView;
|
struct W_View *modalView;
|
||||||
unsigned modal:1;
|
unsigned modalLoop:1;
|
||||||
unsigned ignoreNextDoubleClick:1;
|
unsigned ignoreNextDoubleClick:1;
|
||||||
} W_Screen;
|
} W_Screen;
|
||||||
|
|
||||||
|
|||||||
@@ -128,8 +128,9 @@ void
|
|||||||
WMSetViewDragDestinationProcs(WMView *view, WMDragDestinationProcs *procs)
|
WMSetViewDragDestinationProcs(WMView *view, WMDragDestinationProcs *procs)
|
||||||
{
|
{
|
||||||
if (view->dragDestinationProcs == NULL) {
|
if (view->dragDestinationProcs == NULL) {
|
||||||
wfree(view->dragDestinationProcs);
|
|
||||||
view->dragDestinationProcs = wmalloc(sizeof(WMDragDestinationProcs));
|
view->dragDestinationProcs = wmalloc(sizeof(WMDragDestinationProcs));
|
||||||
|
} else {
|
||||||
|
free(view->dragDestinationProcs);
|
||||||
}
|
}
|
||||||
*view->dragDestinationProcs = *procs;
|
*view->dragDestinationProcs = *procs;
|
||||||
|
|
||||||
|
|||||||
20
WINGs/wbox.c
20
WINGs/wbox.c
@@ -47,6 +47,16 @@ static W_ViewDelegate delegate = {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void resizedParent(void *self, WMNotification *notif)
|
||||||
|
{
|
||||||
|
WMView *view = (WMView*)WMGetNotificationObject(notif);
|
||||||
|
WMSize size = WMGetViewSize(view);
|
||||||
|
|
||||||
|
WMResizeWidget((WMWidget*)self, size.width, size.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
WMBox*
|
WMBox*
|
||||||
WMCreateBox(WMWidget *parent)
|
WMCreateBox(WMWidget *parent)
|
||||||
{
|
{
|
||||||
@@ -213,6 +223,16 @@ WMSetBoxHorizontal(WMBox *box, Bool flag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WMSetBoxExpandsToParent(WMBox *box)
|
||||||
|
{
|
||||||
|
WMAddNotificationObserver(resizedParent, box,
|
||||||
|
WMViewSizeDidChangeNotification,
|
||||||
|
W_VIEW(box)->parent);
|
||||||
|
WMSetViewNotifySizeChanges(W_VIEW(box)->parent, True);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
destroyBox(Box *bPtr)
|
destroyBox(Box *bPtr)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1038,6 +1038,29 @@ WMScreenMainLoop(WMScreen *scr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WMBreakModalLoop(WMScreen *scr)
|
||||||
|
{
|
||||||
|
scr->modalLoop = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WMRunModalLoop(WMScreen *scr, WMView *view)
|
||||||
|
{
|
||||||
|
WMScreen *scr = view->screen;
|
||||||
|
|
||||||
|
scr->modalView = view;
|
||||||
|
|
||||||
|
scr->modalLoop = 1;
|
||||||
|
while (scr->modalLoop) {
|
||||||
|
XEvent event;
|
||||||
|
|
||||||
|
WMNextEvent(scr->display, &event);
|
||||||
|
WMHandleEvent(&event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Display*
|
Display*
|
||||||
WMScreenDisplay(WMScreen *scr)
|
WMScreenDisplay(WMScreen *scr)
|
||||||
|
|||||||
100
WINGs/wpanel.c
100
WINGs/wpanel.c
@@ -11,7 +11,7 @@ alertPanelOnClick(WMWidget *self, void *clientData)
|
|||||||
{
|
{
|
||||||
WMAlertPanel *panel = clientData;
|
WMAlertPanel *panel = clientData;
|
||||||
|
|
||||||
panel->done = 1;
|
WMBreakModalLoop(WMWidgetScreen(panel->othBtn));
|
||||||
if (self == panel->defBtn) {
|
if (self == panel->defBtn) {
|
||||||
panel->result = WAPRDefault;
|
panel->result = WAPRDefault;
|
||||||
} else if (self == panel->othBtn) {
|
} else if (self == panel->othBtn) {
|
||||||
@@ -35,7 +35,7 @@ handleKeyPress(XEvent *event, void *clientData)
|
|||||||
WMPerformButtonClick(panel->othBtn ? panel->othBtn : panel->altBtn);
|
WMPerformButtonClick(panel->othBtn ? panel->othBtn : panel->altBtn);
|
||||||
} else {
|
} else {
|
||||||
panel->result = WAPRDefault;
|
panel->result = WAPRDefault;
|
||||||
panel->done=1;
|
WMBreakModalLoop(WMWidgetScreen(panel->othBtn));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,18 +72,9 @@ WMRunAlertPanel(WMScreen *scrPtr, WMWindow *owner,
|
|||||||
WMSetWindowInitialPosition(panel->win, px, py);
|
WMSetWindowInitialPosition(panel->win, px, py);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
scrPtr->modalView = W_VIEW(panel->win);
|
|
||||||
WMMapWidget(panel->win);
|
WMMapWidget(panel->win);
|
||||||
|
|
||||||
scrPtr->modal = 1;
|
WMRunModalLoop(scrPtr, W_VIEW(panel->win));
|
||||||
while (!panel->done || WMScreenPending(scrPtr)) {
|
|
||||||
XEvent event;
|
|
||||||
|
|
||||||
WMNextEvent(scrPtr->display, &event);
|
|
||||||
WMHandleEvent(&event);
|
|
||||||
}
|
|
||||||
scrPtr->modal = 0;
|
|
||||||
|
|
||||||
tmp = panel->result;
|
tmp = panel->result;
|
||||||
|
|
||||||
@@ -109,6 +100,7 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
|
|||||||
{
|
{
|
||||||
WMAlertPanel *panel;
|
WMAlertPanel *panel;
|
||||||
int x, dw=0, aw=0, ow=0, w;
|
int x, dw=0, aw=0, ow=0, w;
|
||||||
|
WMBox *hbox;
|
||||||
|
|
||||||
|
|
||||||
panel = wmalloc(sizeof(WMAlertPanel));
|
panel = wmalloc(sizeof(WMAlertPanel));
|
||||||
@@ -132,14 +124,23 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
|
|||||||
|
|
||||||
WMSetWindowTitle(panel->win, "");
|
WMSetWindowTitle(panel->win, "");
|
||||||
|
|
||||||
if (scrPtr->applicationIcon) {
|
panel->vbox = WMCreateBox(panel->win);
|
||||||
panel->iLbl = WMCreateLabel(panel->win);
|
WMSetBoxExpandsToParent(panel->vbox);
|
||||||
WMResizeWidget(panel->iLbl, scrPtr->applicationIcon->width,
|
WMSetBoxHorizontal(panel->vbox, False);
|
||||||
scrPtr->applicationIcon->height);
|
WMMapWidget(panel->vbox);
|
||||||
WMMoveWidget(panel->iLbl, 8 + (64 - scrPtr->applicationIcon->width)/2,
|
|
||||||
(75 - scrPtr->applicationIcon->height)/2);
|
hbox = WMCreateBox(panel->vbox);
|
||||||
WMSetLabelImage(panel->iLbl, scrPtr->applicationIcon);
|
WSetBoxHorizontal(hbox, True);
|
||||||
|
WMMapWidget(hbox);
|
||||||
|
WMAddBoxSubview(panel->vbox, WMWidgetView(hbox), False, True, 80, 0, 0, 5);
|
||||||
|
|
||||||
|
panel->iLbl = WMCreateLabel(hbox);
|
||||||
WMSetLabelImagePosition(panel->iLbl, WIPImageOnly);
|
WMSetLabelImagePosition(panel->iLbl, WIPImageOnly);
|
||||||
|
WMMapWidget(panel->iLbl);
|
||||||
|
WMAddBoxSubview(hbox, WMWidgetView(panel->iLbl), False, True, 64, 0, 0, 10);
|
||||||
|
|
||||||
|
if (scrPtr->applicationIcon) {
|
||||||
|
WMSetLabelImage(panel->iLbl, scrPtr->applicationIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (title) {
|
if (title) {
|
||||||
@@ -147,9 +148,10 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
|
|||||||
|
|
||||||
largeFont = WMBoldSystemFontOfSize(scrPtr, 24);
|
largeFont = WMBoldSystemFontOfSize(scrPtr, 24);
|
||||||
|
|
||||||
panel->tLbl = WMCreateLabel(panel->win);
|
panel->tLbl = WMCreateLabel(hbox);
|
||||||
WMMoveWidget(panel->tLbl, 80, (80 - WMFontHeight(largeFont))/2);
|
WMMapWidget(panel->tLbl);
|
||||||
WMResizeWidget(panel->tLbl, 400 - 70, WMFontHeight(largeFont)+4);
|
WMAddBoxSubview(hbox, WMWidgetView(panel->tLbl), True, True,
|
||||||
|
64, 0, 0, 0);
|
||||||
WMSetLabelText(panel->tLbl, title);
|
WMSetLabelText(panel->tLbl, title);
|
||||||
WMSetLabelTextAlignment(panel->tLbl, WALeft);
|
WMSetLabelTextAlignment(panel->tLbl, WALeft);
|
||||||
WMSetLabelFont(panel->tLbl, largeFont);
|
WMSetLabelFont(panel->tLbl, largeFont);
|
||||||
@@ -157,22 +159,28 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
|
|||||||
WMReleaseFont(largeFont);
|
WMReleaseFont(largeFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* create divider line */
|
||||||
|
|
||||||
|
panel->line = WMCreateFrame(panel->win);
|
||||||
|
WMMapWidget(panel->line);
|
||||||
|
WMAddBoxSubview(panel->vbox, WMWidgetView(panel->line), False, True,
|
||||||
|
2, 2, 5);
|
||||||
|
WMSetFrameRelief(panel->line, WRGroove);
|
||||||
|
|
||||||
|
|
||||||
if (msg) {
|
if (msg) {
|
||||||
panel->mLbl = WMCreateLabel(panel->win);
|
panel->mLbl = WMCreateLabel(panel->win);
|
||||||
WMMoveWidget(panel->mLbl, 10, 83);
|
WMMapWidget(panel->mLbl);
|
||||||
WMResizeWidget(panel->mLbl, 380, WMFontHeight(scrPtr->normalFont)*4);
|
WMAddBoxSubview(panel->vbox, WMWidgetView(panel->mLbl), True, True,
|
||||||
|
WMFontHeight(scrPtr->normalFont)*4, 0, 0, 5);
|
||||||
WMSetLabelText(panel->mLbl, msg);
|
WMSetLabelText(panel->mLbl, msg);
|
||||||
WMSetLabelTextAlignment(panel->mLbl, WACenter);
|
WMSetLabelTextAlignment(panel->mLbl, WACenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hbox = WMCreateBox(panel->vbox);
|
||||||
/* create divider line */
|
WMSetBoxHorizontal(hbox, True);
|
||||||
|
WMMapWidget(hbox);
|
||||||
panel->line = WMCreateFrame(panel->win);
|
WMAddBoxSubview(panel->vbox, hbox, False, True, 24, 0, 0, 0);
|
||||||
WMMoveWidget(panel->line, 0, 80);
|
|
||||||
WMResizeWidget(panel->line, 400, 2);
|
|
||||||
WMSetFrameRelief(panel->line, WRGroove);
|
|
||||||
|
|
||||||
/* create buttons */
|
/* create buttons */
|
||||||
if (otherButton)
|
if (otherButton)
|
||||||
@@ -214,8 +222,8 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
|
|||||||
|
|
||||||
panel->defBtn = WMCreateCommandButton(panel->win);
|
panel->defBtn = WMCreateCommandButton(panel->win);
|
||||||
WMSetButtonAction(panel->defBtn, alertPanelOnClick, panel);
|
WMSetButtonAction(panel->defBtn, alertPanelOnClick, panel);
|
||||||
WMMoveWidget(panel->defBtn, x, 144);
|
WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->defBtn),
|
||||||
WMResizeWidget(panel->defBtn, dw, 24);
|
False, True, dw, 0, 5);
|
||||||
WMSetButtonText(panel->defBtn, defaultButton);
|
WMSetButtonText(panel->defBtn, defaultButton);
|
||||||
WMSetButtonImage(panel->defBtn, scrPtr->buttonArrow);
|
WMSetButtonImage(panel->defBtn, scrPtr->buttonArrow);
|
||||||
WMSetButtonAltImage(panel->defBtn, scrPtr->pushedButtonArrow);
|
WMSetButtonAltImage(panel->defBtn, scrPtr->pushedButtonArrow);
|
||||||
@@ -225,8 +233,8 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
|
|||||||
x -= aw + 10;
|
x -= aw + 10;
|
||||||
|
|
||||||
panel->altBtn = WMCreateCommandButton(panel->win);
|
panel->altBtn = WMCreateCommandButton(panel->win);
|
||||||
WMMoveWidget(panel->altBtn, x, 144);
|
WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->altBtn),
|
||||||
WMResizeWidget(panel->altBtn, aw, 24);
|
False, True, aw, 0, 5);
|
||||||
WMSetButtonAction(panel->altBtn, alertPanelOnClick, panel);
|
WMSetButtonAction(panel->altBtn, alertPanelOnClick, panel);
|
||||||
WMSetButtonText(panel->altBtn, alternateButton);
|
WMSetButtonText(panel->altBtn, alternateButton);
|
||||||
}
|
}
|
||||||
@@ -235,12 +243,12 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
|
|||||||
|
|
||||||
panel->othBtn = WMCreateCommandButton(panel->win);
|
panel->othBtn = WMCreateCommandButton(panel->win);
|
||||||
WMSetButtonAction(panel->othBtn, alertPanelOnClick, panel);
|
WMSetButtonAction(panel->othBtn, alertPanelOnClick, panel);
|
||||||
WMMoveWidget(panel->othBtn, x, 144);
|
WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->othBtn),
|
||||||
WMResizeWidget(panel->othBtn, ow, 24);
|
False, True, ow, 0, 5);
|
||||||
WMSetButtonText(panel->othBtn, otherButton);
|
WMSetButtonText(panel->othBtn, otherButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
panel->done = 0;
|
WMMapSubwidgets(hbox);
|
||||||
|
|
||||||
WMCreateEventHandler(W_VIEW(panel->win), KeyPressMask,
|
WMCreateEventHandler(W_VIEW(panel->win), KeyPressMask,
|
||||||
handleKeyPress, panel);
|
handleKeyPress, panel);
|
||||||
@@ -260,7 +268,7 @@ inputBoxOnClick(WMWidget *self, void *clientData)
|
|||||||
{
|
{
|
||||||
WMInputPanel *panel = clientData;
|
WMInputPanel *panel = clientData;
|
||||||
|
|
||||||
panel->done = 1;
|
WMBreakModalLoop(WMWidgetScreen(self));
|
||||||
if (self == panel->defBtn) {
|
if (self == panel->defBtn) {
|
||||||
panel->result = WAPRDefault;
|
panel->result = WAPRDefault;
|
||||||
} else if (self == panel->altBtn) {
|
} else if (self == panel->altBtn) {
|
||||||
@@ -283,7 +291,7 @@ handleKeyPress2(XEvent *event, void *clientData)
|
|||||||
WMPerformButtonClick(panel->altBtn);
|
WMPerformButtonClick(panel->altBtn);
|
||||||
} else {
|
} else {
|
||||||
/* printf("got esc\n");*/
|
/* printf("got esc\n");*/
|
||||||
panel->done = 1;
|
WMBreakModalLoop(WMWidgetScreen(panel->altBtn));
|
||||||
panel->result = WAPRDefault;
|
panel->result = WAPRDefault;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -324,13 +332,7 @@ WMRunInputPanel(WMScreen *scrPtr, WMWindow *owner, char *title,
|
|||||||
|
|
||||||
WMMapWidget(panel->win);
|
WMMapWidget(panel->win);
|
||||||
|
|
||||||
while (!panel->done || WMScreenPending(scrPtr)) {
|
WMRunModalLoop(scrPtr, W_VIEW(panel->win));
|
||||||
XEvent event;
|
|
||||||
|
|
||||||
WMNextEvent(scrPtr->display, &event);
|
|
||||||
WMHandleEvent(&event);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (panel->result == WAPRDefault)
|
if (panel->result == WAPRDefault)
|
||||||
tmp = WMGetTextFieldText(panel->text);
|
tmp = WMGetTextFieldText(panel->text);
|
||||||
@@ -368,7 +370,7 @@ endedEditingObserver(void *observerData, WMNotification *notification)
|
|||||||
if (panel->altBtn)
|
if (panel->altBtn)
|
||||||
WMPerformButtonClick(panel->altBtn);
|
WMPerformButtonClick(panel->altBtn);
|
||||||
else {
|
else {
|
||||||
panel->done = 1;
|
WMBreakModalLoop(WMWidgetScreen(panel->defBtn));
|
||||||
panel->result = WAPRDefault;
|
panel->result = WAPRDefault;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -475,8 +477,6 @@ WMCreateInputPanel(WMScreen *scrPtr, WMWindow *owner, char *title, char *msg,
|
|||||||
WMSetButtonText(panel->altBtn, cancelButton);
|
WMSetButtonText(panel->altBtn, cancelButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
panel->done = 0;
|
|
||||||
|
|
||||||
WMCreateEventHandler(W_VIEW(panel->win), KeyPressMask,
|
WMCreateEventHandler(W_VIEW(panel->win), KeyPressMask,
|
||||||
handleKeyPress2, panel);
|
handleKeyPress2, panel);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user