1
0
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:
kojima
2001-01-09 16:45:14 +00:00
parent 35c5908565
commit 22eb14c9d5
8 changed files with 117 additions and 55 deletions

View File

@@ -1,3 +1,8 @@
changes since wmaker 0.63.1:
............................
- added WMRunModalLoop() and WMBreakModalLoop()
- added WMSetBoxExpandsToParent()
changes since wmaker 0.62.1:
............................
- 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
doesn't add "warning:" in the output message.
- added WMBox widget
- added WMAddTabViewItemWithView()
- added W_SetViewCursor()
- made Extra widgets library
- added table widget in Extras library

View File

@@ -772,6 +772,10 @@ void WMSelectTableViewRow(WMTableView *table, int row)
{
if (table->clickedRow >= 0)
setRowSelected(table, table->clickedRow, False);
if (row <= table->rows)
return;
setRowSelected(table, row, True);
table->clickedRow = row;
@@ -788,6 +792,8 @@ void WMReloadTableView(WMTableView *table)
repaintTable(table, 0, 0,
W_VIEW_WIDTH(table->tableView), rect.size.height);
table->clickedRow = -1;
}

View File

@@ -363,6 +363,7 @@ typedef struct WMListItem {
/* struct for message panel */
typedef struct WMAlertPanel {
WMWindow *win; /* window */
WMBox *vbox;
WMButton *defBtn; /* default button */
WMButton *altBtn; /* alternative button */
WMButton *othBtn; /* other button */
@@ -580,6 +581,9 @@ WMScreen *WMCreateSimpleApplicationScreen(Display *display);
void WMScreenMainLoop(WMScreen *scr);
void WMBreakModalLoop(WMScreen *scr);
void WMRunModalLoop(WMScreen *scr, WMView *view);
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 WMSetBoxExpandsToParent(WMBox *box);
/* ....................................................................... */
int WMRunAlertPanel(WMScreen *app, WMWindow *owner, char *title, char *msg,

View File

@@ -284,7 +284,7 @@ typedef struct W_Screen {
Window lastClickWindow; /* window of the last mousedown */
struct W_View *modalView;
unsigned modal:1;
unsigned modalLoop:1;
unsigned ignoreNextDoubleClick:1;
} W_Screen;

View File

@@ -128,8 +128,9 @@ void
WMSetViewDragDestinationProcs(WMView *view, WMDragDestinationProcs *procs)
{
if (view->dragDestinationProcs == NULL) {
wfree(view->dragDestinationProcs);
view->dragDestinationProcs = wmalloc(sizeof(WMDragDestinationProcs));
} else {
free(view->dragDestinationProcs);
}
*view->dragDestinationProcs = *procs;

View File

@@ -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*
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
destroyBox(Box *bPtr)
{

View File

@@ -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*
WMScreenDisplay(WMScreen *scr)

View File

@@ -11,7 +11,7 @@ alertPanelOnClick(WMWidget *self, void *clientData)
{
WMAlertPanel *panel = clientData;
panel->done = 1;
WMBreakModalLoop(WMWidgetScreen(panel->othBtn));
if (self == panel->defBtn) {
panel->result = WAPRDefault;
} else if (self == panel->othBtn) {
@@ -35,7 +35,7 @@ handleKeyPress(XEvent *event, void *clientData)
WMPerformButtonClick(panel->othBtn ? panel->othBtn : panel->altBtn);
} else {
panel->result = WAPRDefault;
panel->done=1;
WMBreakModalLoop(WMWidgetScreen(panel->othBtn));
}
}
}
@@ -72,18 +72,9 @@ WMRunAlertPanel(WMScreen *scrPtr, WMWindow *owner,
WMSetWindowInitialPosition(panel->win, px, py);
}
scrPtr->modalView = W_VIEW(panel->win);
WMMapWidget(panel->win);
scrPtr->modal = 1;
while (!panel->done || WMScreenPending(scrPtr)) {
XEvent event;
WMNextEvent(scrPtr->display, &event);
WMHandleEvent(&event);
}
scrPtr->modal = 0;
WMRunModalLoop(scrPtr, W_VIEW(panel->win));
tmp = panel->result;
@@ -109,6 +100,7 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
{
WMAlertPanel *panel;
int x, dw=0, aw=0, ow=0, w;
WMBox *hbox;
panel = wmalloc(sizeof(WMAlertPanel));
@@ -132,14 +124,23 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
WMSetWindowTitle(panel->win, "");
panel->vbox = WMCreateBox(panel->win);
WMSetBoxExpandsToParent(panel->vbox);
WMSetBoxHorizontal(panel->vbox, False);
WMMapWidget(panel->vbox);
hbox = WMCreateBox(panel->vbox);
WSetBoxHorizontal(hbox, True);
WMMapWidget(hbox);
WMAddBoxSubview(panel->vbox, WMWidgetView(hbox), False, True, 80, 0, 0, 5);
panel->iLbl = WMCreateLabel(hbox);
WMSetLabelImagePosition(panel->iLbl, WIPImageOnly);
WMMapWidget(panel->iLbl);
WMAddBoxSubview(hbox, WMWidgetView(panel->iLbl), False, True, 64, 0, 0, 10);
if (scrPtr->applicationIcon) {
panel->iLbl = WMCreateLabel(panel->win);
WMResizeWidget(panel->iLbl, scrPtr->applicationIcon->width,
scrPtr->applicationIcon->height);
WMMoveWidget(panel->iLbl, 8 + (64 - scrPtr->applicationIcon->width)/2,
(75 - scrPtr->applicationIcon->height)/2);
WMSetLabelImage(panel->iLbl, scrPtr->applicationIcon);
WMSetLabelImagePosition(panel->iLbl, WIPImageOnly);
}
if (title) {
@@ -147,9 +148,10 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
largeFont = WMBoldSystemFontOfSize(scrPtr, 24);
panel->tLbl = WMCreateLabel(panel->win);
WMMoveWidget(panel->tLbl, 80, (80 - WMFontHeight(largeFont))/2);
WMResizeWidget(panel->tLbl, 400 - 70, WMFontHeight(largeFont)+4);
panel->tLbl = WMCreateLabel(hbox);
WMMapWidget(panel->tLbl);
WMAddBoxSubview(hbox, WMWidgetView(panel->tLbl), True, True,
64, 0, 0, 0);
WMSetLabelText(panel->tLbl, title);
WMSetLabelTextAlignment(panel->tLbl, WALeft);
WMSetLabelFont(panel->tLbl, largeFont);
@@ -157,22 +159,28 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
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) {
panel->mLbl = WMCreateLabel(panel->win);
WMMoveWidget(panel->mLbl, 10, 83);
WMResizeWidget(panel->mLbl, 380, WMFontHeight(scrPtr->normalFont)*4);
WMMapWidget(panel->mLbl);
WMAddBoxSubview(panel->vbox, WMWidgetView(panel->mLbl), True, True,
WMFontHeight(scrPtr->normalFont)*4, 0, 0, 5);
WMSetLabelText(panel->mLbl, msg);
WMSetLabelTextAlignment(panel->mLbl, WACenter);
}
/* create divider line */
panel->line = WMCreateFrame(panel->win);
WMMoveWidget(panel->line, 0, 80);
WMResizeWidget(panel->line, 400, 2);
WMSetFrameRelief(panel->line, WRGroove);
hbox = WMCreateBox(panel->vbox);
WMSetBoxHorizontal(hbox, True);
WMMapWidget(hbox);
WMAddBoxSubview(panel->vbox, hbox, False, True, 24, 0, 0, 0);
/* create buttons */
if (otherButton)
@@ -214,8 +222,8 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
panel->defBtn = WMCreateCommandButton(panel->win);
WMSetButtonAction(panel->defBtn, alertPanelOnClick, panel);
WMMoveWidget(panel->defBtn, x, 144);
WMResizeWidget(panel->defBtn, dw, 24);
WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->defBtn),
False, True, dw, 0, 5);
WMSetButtonText(panel->defBtn, defaultButton);
WMSetButtonImage(panel->defBtn, scrPtr->buttonArrow);
WMSetButtonAltImage(panel->defBtn, scrPtr->pushedButtonArrow);
@@ -225,8 +233,8 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
x -= aw + 10;
panel->altBtn = WMCreateCommandButton(panel->win);
WMMoveWidget(panel->altBtn, x, 144);
WMResizeWidget(panel->altBtn, aw, 24);
WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->altBtn),
False, True, aw, 0, 5);
WMSetButtonAction(panel->altBtn, alertPanelOnClick, panel);
WMSetButtonText(panel->altBtn, alternateButton);
}
@@ -235,12 +243,12 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
panel->othBtn = WMCreateCommandButton(panel->win);
WMSetButtonAction(panel->othBtn, alertPanelOnClick, panel);
WMMoveWidget(panel->othBtn, x, 144);
WMResizeWidget(panel->othBtn, ow, 24);
WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->othBtn),
False, True, ow, 0, 5);
WMSetButtonText(panel->othBtn, otherButton);
}
panel->done = 0;
WMMapSubwidgets(hbox);
WMCreateEventHandler(W_VIEW(panel->win), KeyPressMask,
handleKeyPress, panel);
@@ -260,7 +268,7 @@ inputBoxOnClick(WMWidget *self, void *clientData)
{
WMInputPanel *panel = clientData;
panel->done = 1;
WMBreakModalLoop(WMWidgetScreen(self));
if (self == panel->defBtn) {
panel->result = WAPRDefault;
} else if (self == panel->altBtn) {
@@ -283,7 +291,7 @@ handleKeyPress2(XEvent *event, void *clientData)
WMPerformButtonClick(panel->altBtn);
} else {
/* printf("got esc\n");*/
panel->done = 1;
WMBreakModalLoop(WMWidgetScreen(panel->altBtn));
panel->result = WAPRDefault;
}
}
@@ -324,13 +332,7 @@ WMRunInputPanel(WMScreen *scrPtr, WMWindow *owner, char *title,
WMMapWidget(panel->win);
while (!panel->done || WMScreenPending(scrPtr)) {
XEvent event;
WMNextEvent(scrPtr->display, &event);
WMHandleEvent(&event);
}
WMRunModalLoop(scrPtr, W_VIEW(panel->win));
if (panel->result == WAPRDefault)
tmp = WMGetTextFieldText(panel->text);
@@ -368,7 +370,7 @@ endedEditingObserver(void *observerData, WMNotification *notification)
if (panel->altBtn)
WMPerformButtonClick(panel->altBtn);
else {
panel->done = 1;
WMBreakModalLoop(WMWidgetScreen(panel->defBtn));
panel->result = WAPRDefault;
}
break;
@@ -475,8 +477,6 @@ WMCreateInputPanel(WMScreen *scrPtr, WMWindow *owner, char *title, char *msg,
WMSetButtonText(panel->altBtn, cancelButton);
}
panel->done = 0;
WMCreateEventHandler(W_VIEW(panel->win), KeyPressMask,
handleKeyPress2, panel);