void testButton(WMScreen * scr) { WMWindow *win; int i; char *types[] = { "MomentaryPush", "PushOnPushOff", "Toggle", "Switch", "Radio", "MomentaryChange", "OnOff", "MomentaryLigh" }; windowCount++; win = WMCreateWindow(scr, "testButton"); WMResizeWidget(win, 300, 300); WMSetWindowTitle(win, "Buttons"); WMSetWindowCloseAction(win, closeAction, NULL); for (i = 1; i < 9; i++) { WMButton *b; b = WMCreateButton(win, i); WMResizeWidget(b, 150, 24); WMMoveWidget(b, 20, i * 30); WMSetButtonText(b, types[i - 1]); } WMRealizeWidget(win); WMMapSubwidgets(win); WMMapWidget(win); }
void WMResizeScrollViewContent(WMScrollView *sPtr, unsigned int width, unsigned int height) { int w, h, x; w = width; h = height; x = 0; if (sPtr->flags.relief == WRSimple) { w += 2; h += 2; } else if (sPtr->flags.relief != WRFlat) { w += 4; h += 4; x = 1; } if (sPtr->flags.hasVScroller) { WMResizeWidget(sPtr->vScroller, 20, h); width -= W_VIEW(sPtr->vScroller)->size.width; } if (sPtr->flags.hasHScroller) { WMResizeWidget(sPtr->hScroller, w, 20); WMMoveWidget(sPtr->hScroller, x, h); height -= W_VIEW(sPtr->hScroller)->size.height; } W_ResizeView(sPtr->view, w, h); W_ResizeView(sPtr->viewport, width, height); }
void testSlider(WMScreen * scr) { WMWindow *win; WMSlider *s; windowCount++; win = WMCreateWindow(scr, "testSlider"); WMResizeWidget(win, 300, 300); WMSetWindowTitle(win, "Sliders"); WMSetWindowCloseAction(win, closeAction, NULL); s = WMCreateSlider(win); WMResizeWidget(s, 16, 100); WMMoveWidget(s, 100, 100); WMSetSliderKnobThickness(s, 8); WMSetSliderContinuous(s, False); WMSetSliderAction(s, sliderCallback, s); s = WMCreateSlider(win); WMResizeWidget(s, 100, 16); WMMoveWidget(s, 100, 10); WMSetSliderKnobThickness(s, 8); WMRealizeWidget(win); WMMapSubwidgets(win); WMMapWidget(win); }
void testTextField(WMScreen * scr) { WMWindow *win; WMTextField *field, *field2; windowCount++; win = WMCreateWindow(scr, "testTextField"); WMResizeWidget(win, 400, 300); WMSetWindowCloseAction(win, closeAction, NULL); field = WMCreateTextField(win); WMResizeWidget(field, 200, 20); WMMoveWidget(field, 20, 20); WMSetTextFieldText(field, "the little \xc2\xa9 sign"); field2 = WMCreateTextField(win); WMResizeWidget(field2, 200, 20); WMMoveWidget(field2, 20, 50); WMSetTextFieldAlignment(field2, WARight); WMRealizeWidget(win); WMMapSubwidgets(win); WMMapWidget(win); }
void testText(WMScreen * scr) { WMWindow *win; WMText *text; WMFont *font; void *tb; FILE *file = fopen("wm.html", "rb"); windowCount++; win = WMCreateWindow(scr, "testText"); WMResizeWidget(win, 500, 300); WMSetWindowCloseAction(win, closeAction, NULL); text = WMCreateText(win); WMResizeWidget(text, 480, 280); WMMoveWidget(text, 10, 10); WMSetTextHasVerticalScroller(text, True); WMSetTextEditable(text, False); WMSetTextIgnoresNewline(text, False); #define FNAME "Verdana,sans serif:pixelsize=12" #define MSG \ "Window Maker is the GNU window manager for the " \ "X Window System. It was designed to emulate the " \ "look and feel of part of the NEXTSTEP(tm) GUI. It's " \ "supposed to be relatively fast and small, feature " \ "rich, easy to configure and easy to use, with a simple " \ "and elegant appearance borrowed from NEXTSTEP(tm)." font = WMCreateFont(scr, FNAME ":autohint=false"); WMSetTextDefaultFont(text, font); WMReleaseFont(font); if (0 && file) { char buf[1024]; WMFreezeText(text); while (fgets(buf, 1023, file)) WMAppendTextStream(text, buf); fclose(file); WMThawText(text); } else { WMAppendTextStream(text, "First paragraph has autohinting turned off, " "while the second has it turned on:"); WMAppendTextStream(text, "\n\n\n"); WMAppendTextStream(text, MSG); WMAppendTextStream(text, "\n\n\n"); font = WMCreateFont(scr, FNAME ":autohint=true"); tb = WMCreateTextBlockWithText(text, MSG, font, WMBlackColor(scr), 0, strlen(MSG)); WMAppendTextBlock(text, tb); WMReleaseFont(font); } WMRealizeWidget(win); WMMapSubwidgets(win); WMMapWidget(win); }
void testScrollView(WMScreen * scr) { WMWindow *win; WMScrollView *sview; WMFrame *f; WMLabel *l; char buffer[128]; int i; windowCount++; /* creates the top-level window */ win = WMCreateWindow(scr, "testScroll"); WMSetWindowTitle(win, "Scrollable View"); WMSetWindowCloseAction(win, closeAction, NULL); /* set the window size */ WMResizeWidget(win, 300, 300); /* creates a scrollable view inside the top-level window */ sview = WMCreateScrollView(win); WMResizeWidget(sview, 200, 200); WMMoveWidget(sview, 30, 30); WMSetScrollViewRelief(sview, WRSunken); WMSetScrollViewHasVerticalScroller(sview, True); WMSetScrollViewHasHorizontalScroller(sview, True); /* create a frame with a bunch of labels */ f = WMCreateFrame(win); WMResizeWidget(f, 400, 400); WMSetFrameRelief(f, WRFlat); for (i = 0; i < 20; i++) { l = WMCreateLabel(f); WMResizeWidget(l, 50, 18); WMMoveWidget(l, 10, 20 * i); sprintf(buffer, "Label %i", i); WMSetLabelText(l, buffer); WMSetLabelRelief(l, WRSimple); } WMMapSubwidgets(f); WMMapWidget(f); WMSetScrollViewContentView(sview, WMWidgetView(f)); /* make the windows of the widgets be actually created */ WMRealizeWidget(win); /* Map all child widgets of the top-level be mapped. * You must call this for each container widget (like frames), * even if they are childs of the top-level window. */ WMMapSubwidgets(win); /* map the top-level window */ WMMapWidget(win); }
int main(int argc, char **argv) { Display *dpy; WMWindow *win; WMScreen *scr; WMButton *lab, *l0 = NULL; WMLabel *pos; int x, y, c; char buf[20]; WMInitializeApplication("FontView", &argc, argv); dpy = XOpenDisplay(""); if (!dpy) { wfatal("cant open display"); exit(0); } scr = WMCreateSimpleApplicationScreen(dpy); win = WMCreateWindow(scr, "main"); WMResizeWidget(win, 20 * 33, 20 + 20 * 9); WMSetWindowTitle(win, "Font Chars"); WMSetWindowCloseAction(win, quit, NULL); pos = WMCreateLabel(win); WMResizeWidget(pos, 20 * 33, 20); WMMoveWidget(pos, 10, 5); c = 0; for (y = 0; y < 8; y++) { for (x = 0; x < 32; x++, c++) { lab = WMCreateCustomButton(win, WBBStateLightMask); WMResizeWidget(lab, 20, 20); WMMoveWidget(lab, 10 + x * 20, 30 + y * 20); sprintf(buf, "%c", c); WMSetButtonText(lab, buf); WMSetButtonAction(lab, show, pos); WMHangData(lab, (void *)(uintptr_t) c); if (c > 0) { WMGroupButtons(l0, lab); } else { l0 = lab; } } } WMRealizeWidget(win); WMMapSubwidgets(win); WMMapWidget(win); WMScreenMainLoop(scr); return 0; }
void WMSetScrollViewHasVerticalScroller(WMScrollView *sPtr, Bool flag) { if (flag) { if (sPtr->flags.hasVScroller) return; sPtr->flags.hasVScroller = 1; sPtr->vScroller = WMCreateScroller(sPtr); WMSetScrollerAction(sPtr->vScroller, doScrolling, sPtr); WMSetScrollerArrowsPosition(sPtr->vScroller, WSAMaxEnd); /* make it a vert. scroller */ WMResizeWidget(sPtr->vScroller, 1, 2); if (W_VIEW_REALIZED(sPtr->view)) { WMRealizeWidget(sPtr->vScroller); } reorganizeInterior(sPtr); WMMapWidget(sPtr->vScroller); } else { if (!sPtr->flags.hasVScroller) return; sPtr->flags.hasVScroller = 0; WMUnmapWidget(sPtr->vScroller); WMDestroyWidget(sPtr->vScroller); sPtr->vScroller = NULL; reorganizeInterior(sPtr); } }
void WMSetScrollViewHasHorizontalScroller(WMScrollView *sPtr, Bool flag) { if (flag) { if (sPtr->flags.hasHScroller) return; sPtr->flags.hasHScroller = 1; sPtr->hScroller = WMCreateScroller(sPtr); WMSetScrollerAction(sPtr->hScroller, doScrolling, sPtr); /* make it a horiz. scroller */ WMResizeWidget(sPtr->hScroller, 2, 1); if (W_VIEW_REALIZED(sPtr->view)) { WMRealizeWidget(sPtr->hScroller); } reorganizeInterior(sPtr); WMMapWidget(sPtr->hScroller); } else { if (!sPtr->flags.hasHScroller) return; WMUnmapWidget(sPtr->hScroller); WMDestroyWidget(sPtr->hScroller); sPtr->hScroller = NULL; sPtr->flags.hasHScroller = 0; reorganizeInterior(sPtr); } }
WMTabView *WMCreateTabView(WMWidget * parent) { TabView *tPtr; WMScreen *scr = WMWidgetScreen(parent); tPtr = wmalloc(sizeof(TabView)); tPtr->widgetClass = WC_TabView; tPtr->view = W_CreateView(W_VIEW(parent)); if (!tPtr->view) { wfree(tPtr); return NULL; } tPtr->view->self = tPtr; tPtr->view->delegate = &delegate; tPtr->lightGray = WMCreateRGBColor(scr, 0xd9d9, 0xd9d9, 0xd9d9, False); tPtr->tabColor = WMCreateRGBColor(scr, 0x8420, 0x8420, 0x8420, False); tPtr->font = WMRetainFont(scr->normalFont); tPtr->flags.type = WTTopTabsBevelBorder; tPtr->flags.bordered = 1; tPtr->flags.uniformTabs = 0; tPtr->flags.enabled = 1; WMCreateEventHandler(tPtr->view, ExposureMask | StructureNotifyMask | ButtonPressMask, handleEvents, tPtr); WMResizeWidget(tPtr, DEFAULT_WIDTH, DEFAULT_HEIGHT); tPtr->tabHeight = WMFontHeight(tPtr->font) + 3; return tPtr; }
WMBox *WMCreateBox(WMWidget * parent) { Box *bPtr; bPtr = wmalloc(sizeof(Box)); bPtr->widgetClass = WC_Box; bPtr->view = W_CreateView(W_VIEW(parent)); if (!bPtr->view) { wfree(bPtr); return NULL; } bPtr->view->self = bPtr; bPtr->view->delegate = &delegate; bPtr->subviews = WMCreateArrayWithDestructor(2, wfree); WMCreateEventHandler(bPtr->view, StructureNotifyMask, handleEvents, bPtr); WMResizeWidget(bPtr, DEFAULT_WIDTH, DEFAULT_HEIGHT); return bPtr; }
static void willResizeBrowser(W_ViewDelegate * self, WMView * view, unsigned int *width, unsigned int *height) { WMBrowser *bPtr = (WMBrowser *) view->self; int cols = bPtr->maxVisibleColumns; int colX, colY; int i; /* Parameter not used, but tell the compiler that it is ok */ (void) self; assert(*width > 0); assert(*height > 0); bPtr->columnSize.width = (*width - (cols - 1) * COLUMN_SPACING) / cols; bPtr->columnSize.height = *height; if (bPtr->flags.isTitled) { colY = TITLE_SPACING + bPtr->titleHeight; bPtr->columnSize.height -= colY; } else { colY = 0; } if (bPtr->flags.hasScroller) { bPtr->columnSize.height -= SCROLLER_WIDTH + 4; if (bPtr->scroller) { WMResizeWidget(bPtr->scroller, *width - 2, 1); WMMoveWidget(bPtr->scroller, 1, *height - SCROLLER_WIDTH - 1); } } colX = 0; for (i = 0; i < bPtr->columnCount; i++) { WMResizeWidget(bPtr->columns[i], bPtr->columnSize.width, bPtr->columnSize.height); WMMoveWidget(bPtr->columns[i], colX, colY); if (COLUMN_IS_VISIBLE(bPtr, i)) { colX += bPtr->columnSize.width + COLUMN_SPACING; } } }
void WMSetBrowserMaxVisibleColumns(WMBrowser * bPtr, int columns) { int curMaxVisibleColumns; int newFirstVisibleColumn = 0; assert(bPtr != NULL); columns = (columns < MIN_VISIBLE_COLUMNS) ? MIN_VISIBLE_COLUMNS : columns; columns = (columns > MAX_VISIBLE_COLUMNS) ? MAX_VISIBLE_COLUMNS : columns; if (columns == bPtr->maxVisibleColumns) { return; } curMaxVisibleColumns = bPtr->maxVisibleColumns; bPtr->maxVisibleColumns = columns; /* browser not loaded */ if (!bPtr->flags.loaded) { if ((columns > curMaxVisibleColumns) && (columns > bPtr->columnCount)) { int i = columns - bPtr->columnCount; bPtr->usedColumnCount = bPtr->columnCount; while (i--) { WMAddBrowserColumn(bPtr); } bPtr->usedColumnCount = 0; } /* browser loaded and columns > curMaxVisibleColumns */ } else if (columns > curMaxVisibleColumns) { if (bPtr->usedColumnCount > columns) { newFirstVisibleColumn = bPtr->usedColumnCount - columns; } if (newFirstVisibleColumn > bPtr->firstVisibleColumn) { newFirstVisibleColumn = bPtr->firstVisibleColumn; } if (columns > bPtr->columnCount) { int i = columns - bPtr->columnCount; int curUsedColumnCount = bPtr->usedColumnCount; bPtr->usedColumnCount = bPtr->columnCount; while (i--) { WMAddBrowserColumn(bPtr); } bPtr->usedColumnCount = curUsedColumnCount; } /* browser loaded and columns < curMaxVisibleColumns */ } else { newFirstVisibleColumn = bPtr->firstVisibleColumn; if (newFirstVisibleColumn + columns >= bPtr->usedColumnCount) { removeColumn(bPtr, newFirstVisibleColumn + columns); } } 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); scrollToColumn(bPtr, newFirstVisibleColumn, True); } }
void testFrame(WMScreen * scr) { WMWindow *win; WMFrame *frame; int i; static char *titles[] = { "AboveTop", "AtTop", "BelowTop", "AboveBottom", "AtBottom", "BelowBottom" }; static WMTitlePosition pos[] = { WTPAboveTop, WTPAtTop, WTPBelowTop, WTPAboveBottom, WTPAtBottom, WTPBelowBottom }; windowCount++; win = WMCreateWindow(scr, "testFrame"); WMSetWindowTitle(win, "Frame"); WMSetWindowCloseAction(win, closeAction, NULL); WMResizeWidget(win, 400, 300); for (i = 0; i < 6; i++) { frame = WMCreateFrame(win); WMMoveWidget(frame, 8 + (i % 3) * 130, 8 + (i / 3) * 130); WMResizeWidget(frame, 120, 120); WMSetFrameTitle(frame, titles[i]); WMSetFrameTitlePosition(frame, pos[i]); } WMRealizeWidget(win); WMMapSubwidgets(win); WMMapWidget(win); }
void WMSetBrowserTitled(WMBrowser * bPtr, Bool flag) { int i; int columnX, columnY; flag = ((flag == 0) ? 0 : 1); if (bPtr->flags.isTitled == flag) return; columnX = 0; if (!bPtr->flags.isTitled) { columnY = TITLE_SPACING + bPtr->titleHeight; bPtr->columnSize.height -= columnY; for (i = 0; i < bPtr->columnCount; i++) { WMResizeWidget(bPtr->columns[i], bPtr->columnSize.width, bPtr->columnSize.height); columnX = WMWidgetView(bPtr->columns[i])->pos.x; WMMoveWidget(bPtr->columns[i], columnX, columnY); } } else { bPtr->columnSize.height += TITLE_SPACING + bPtr->titleHeight; for (i = 0; i < bPtr->columnCount; i++) { WMResizeWidget(bPtr->columns[i], bPtr->columnSize.width, bPtr->columnSize.height); columnX = WMWidgetView(bPtr->columns[i])->pos.x; WMMoveWidget(bPtr->columns[i], columnX, 0); } } bPtr->flags.isTitled = flag; }
static void resizeSplitView(XEvent * event, void *data) { WMSplitView *sPtr = (WMSplitView *) data; if (event->type == ConfigureNotify) { int width = event->xconfigure.width - 10; if (width < WMGetSplitViewDividerThickness(sPtr)) width = WMGetSplitViewDividerThickness(sPtr); if (width != WMWidgetWidth(sPtr) || event->xconfigure.height != WMWidgetHeight(sPtr)) WMResizeWidget(sPtr, width, event->xconfigure.height - 55); } }
void testBox(WMScreen * scr) { WMWindow *win; WMBox *box, *hbox; WMButton *btn; WMPopUpButton *pop; int i; windowCount++; win = WMCreateWindow(scr, "testBox"); WMSetWindowTitle(win, "Box"); WMSetWindowCloseAction(win, closeAction, NULL); WMResizeWidget(win, 400, 300); box = WMCreateBox(win); WMSetBoxBorderWidth(box, 5); WMSetViewExpandsToParent(WMWidgetView(box), 0, 0, 0, 0); /*WMSetBoxHorizontal(box, True); */ for (i = 0; i < 4; i++) { btn = WMCreateCommandButton(box); WMSetButtonText(btn, "bla"); WMMapWidget(btn); WMAddBoxSubview(box, WMWidgetView(btn), i & 1, True, 20, 0, 5); } pop = WMCreatePopUpButton(box); WMAddPopUpButtonItem(pop, "ewqeq"); WMAddPopUpButtonItem(pop, "ewqeqrewrw"); WMAddBoxSubview(box, WMWidgetView(pop), False, True, 20, 0, 5); WMMapWidget(pop); hbox = WMCreateBox(box); WMSetBoxHorizontal(hbox, True); WMAddBoxSubview(box, WMWidgetView(hbox), False, True, 24, 0, 0); WMMapWidget(hbox); for (i = 0; i < 4; i++) { btn = WMCreateCommandButton(hbox); WMSetButtonText(btn, "bla"); WMMapWidget(btn); WMAddBoxSubview(hbox, WMWidgetView(btn), 1, True, 60, 0, i < 3 ? 5 : 0); } WMRealizeWidget(win); WMMapSubwidgets(win); WMMapWidget(win); }
void testPullDown(WMScreen * scr) { WMWindow *win; WMPopUpButton *pop, *pop2; windowCount++; win = WMCreateWindow(scr, "pullDown"); WMResizeWidget(win, 400, 300); WMSetWindowCloseAction(win, closeAction, NULL); pop = WMCreatePopUpButton(win); WMResizeWidget(pop, 100, 20); WMMoveWidget(pop, 50, 60); WMSetPopUpButtonPullsDown(pop, True); WMSetPopUpButtonText(pop, "Commands"); WMAddPopUpButtonItem(pop, "Add"); WMAddPopUpButtonItem(pop, "Remove"); WMAddPopUpButtonItem(pop, "Check"); WMAddPopUpButtonItem(pop, "Eat"); pop2 = WMCreatePopUpButton(win); WMResizeWidget(pop2, 100, 20); WMMoveWidget(pop2, 200, 60); WMSetPopUpButtonText(pop2, "Select"); WMAddPopUpButtonItem(pop2, "Apples"); WMAddPopUpButtonItem(pop2, "Bananas"); WMAddPopUpButtonItem(pop2, "Strawberries"); WMAddPopUpButtonItem(pop2, "Blueberries"); WMRealizeWidget(win); WMMapSubwidgets(win); WMMapWidget(win); }
void testColorWell(WMScreen * scr) { WMWindow *win; WMColorWell *well1, *well2; windowCount++; win = WMCreateWindow(scr, "testColor"); WMResizeWidget(win, 300, 300); WMSetWindowCloseAction(win, closeAction, NULL); well1 = WMCreateColorWell(win); WMResizeWidget(well1, 60, 40); WMMoveWidget(well1, 100, 100); WMSetColorWellColor(well1, WMCreateRGBColor(scr, 0x8888, 0, 0x1111, True)); well2 = WMCreateColorWell(win); WMResizeWidget(well2, 60, 40); WMMoveWidget(well2, 200, 100); WMSetColorWellColor(well2, WMCreateRGBColor(scr, 0, 0, 0x8888, True)); WMRealizeWidget(win); WMMapSubwidgets(win); WMMapWidget(win); }
static WEditMenu *makeFactoryMenu(WMWidget * parent, int width) { WEditMenu *pad; pad = WCreateEditMenuPad(parent); WMResizeWidget(pad, width, 10); WSetEditMenuMinSize(pad, wmksize(width, 0)); WSetEditMenuMaxSize(pad, wmksize(width, 0)); WSetEditMenuSelectable(pad, False); WSetEditMenuEditable(pad, False); WSetEditMenuIsFactory(pad, True); WSetEditMenuDelegate(pad, &menuDelegate); return pad; }
static void setupScroller(WMBrowser * bPtr) { WMScroller *sPtr; int y; y = bPtr->view->size.height - SCROLLER_WIDTH - 1; sPtr = WMCreateScroller(bPtr); WMSetScrollerAction(sPtr, scrollCallback, bPtr); WMMoveWidget(sPtr, 1, y); WMResizeWidget(sPtr, bPtr->view->size.width - 2, SCROLLER_WIDTH); bPtr->scroller = sPtr; WMMapWidget(sPtr); }
static void resizeView(WMSplitView * sPtr, WMView * view, int size) { int width, height; if (sPtr->flags.vertical) { width = size; height = sPtr->view->size.height; } else { width = sPtr->view->size.width; height = size; } if (view->self) WMResizeWidget(view->self, width, height); else W_ResizeView(view, width, height); }
WMBrowser *WMCreateBrowser(WMWidget * parent) { WMBrowser *bPtr; int i; wassertrv(parent, NULL); bPtr = wmalloc(sizeof(WMBrowser)); bPtr->widgetClass = WC_Browser; bPtr->view = W_CreateView(W_VIEW(parent)); if (!bPtr->view) { wfree(bPtr); return NULL; } bPtr->view->self = bPtr; bPtr->view->delegate = &_BrowserViewDelegate; WMCreateEventHandler(bPtr->view, ExposureMask | StructureNotifyMask | ClientMessageMask, handleEvents, bPtr); /* default configuration */ bPtr->flags.hasScroller = DEFAULT_HAS_SCROLLER; bPtr->titleHeight = DEFAULT_TITLE_HEIGHT; bPtr->flags.isTitled = DEFAULT_IS_TITLED; bPtr->maxVisibleColumns = DEFAULT_MAX_VISIBLE_COLUMNS; WMResizeWidget(bPtr, DEFAULT_WIDTH, DEFAULT_HEIGHT); bPtr->pathSeparator = wstrdup(DEFAULT_SEPARATOR); if (bPtr->flags.hasScroller) setupScroller(bPtr); for (i = 0; i < bPtr->maxVisibleColumns; i++) { WMAddBrowserColumn(bPtr); } bPtr->usedColumnCount = 0; bPtr->selectedColumn = -1; return bPtr; }
static void resizeObserver(void *self, WMNotification *notif) { WMSize size = WMGetViewSize(WMWidgetView(win)); int x, y; WinSize = size.width; for (y = 0; y < Size; y++) { for (x = 0; x < Size; x++) { if (MAP(x,y) >= 0) { WMResizeWidget(Button[(int)MAP(x,y)], WinSize/Size, WinSize/Size); WMMoveWidget(Button[(int)MAP(x,y)], x*(WinSize/Size), y*(WinSize/Size)); } } } }
void testProgressIndicator(WMScreen * scr) { WMWindow *win; WMProgressIndicator *pPtr; windowCount++; win = WMCreateWindow(scr, "testProgressIndicator"); WMResizeWidget(win, 292, 32); WMSetWindowCloseAction(win, closeAction, NULL); pPtr = WMCreateProgressIndicator(win); WMMoveWidget(pPtr, 8, 8); WMSetProgressIndicatorValue(pPtr, 75); WMRealizeWidget(win); WMMapSubwidgets(win); WMMapWidget(win); }
int main (int argc, char **argv){ int i,j; WMColor *color; WMWindow * win; RImage *image; struct _pict pict; Drawable de; RColor one, two={0xaf, 0x0f,0xff,0x33}; one.red=247; one.green=251; one.blue=107; one.alpha=0xff; WMInitializeApplication("DrawWin", &argc, argv); display = XOpenDisplay(""); screen = WMCreateScreen(display, DefaultScreen(display)); win = WMCreateWindow(screen, ""); WMResizeWidget(win, WINWIDTH, WINHEIGHT); WMSetWindowCloseAction(win, closeAction, NULL); WMSetWindowTitle(win,"Graphics"); color = WMCreateRGBColor(screen,124<<9,206<<8,162<<8, False); WMSetWidgetBackgroundColor((WMWidget *)win, color); /* end setup main window */ image=RCreateImage( 100,100,0.5); RFillImage(image, &two); RDrawLine(image, 50,10,90,90,&one); RDrawLine(image, 10,90,50,10,&one); RDrawLine(image, 10,90,90,90,&one); g3=WMColorGC(screen->gray); XSetLineAttributes(display,g3,3,LineSolid,CapButt,JoinMiter); pict.segments[1].x1= pict.segments[0].x1=HOFF; pict.segments[0].x2=HOFF; pict.segments[0].y1=VOFF; pict.segments[1].y2= pict.segments[0].y2=VOFF; pict.segments[1].x2= HOFF+10; pict.segments[1].y1=VOFF+10; pict.seglen=2; for (i=9;i>0;i--){ j=2*(10-i); pict.segments[j+1].x1= pict.segments[j].x1=HOFF; pict.segments[j+1].y2= pict.segments[j].y2=VOFF; pict.segments[j].x2= i+pict.segments[j-1].x2; pict.segments[j].y1=i+pict.segments[j-1].y1; pict.segments[j+1].x2= i+pict.segments[j].x2; pict.segments[j+1].y1=i+pict.segments[j].y1; pict.seglen+=2; }; WMRealizeWidget(win); pict.dwin=W_VIEW_DRAWABLE(WMWidgetView(win)); pixmap=WMCreatePixmapFromRImage(screen, image,1); WMCreateEventHandler(WMWidgetView(win), ExposureMask,drawProcedure,&pict); WMMapWidget(win); WMScreenMainLoop(screen); }
static void createPanel(_Panel * p) { _Panel *panel = (_Panel *) p; WMScreen *scr = WMWidgetScreen(panel->parent); WMColor *black = WMBlackColor(scr); WMColor *white = WMWhiteColor(scr); WMColor *gray = WMGrayColor(scr); WMFont *bold = WMBoldSystemFontOfSize(scr, 12); WMFont *font = WMSystemFontOfSize(scr, 12); WMLabel *label; int width; menuDelegate.data = panel; panel->boldFont = bold; panel->normalFont = font; panel->black = black; panel->white = white; panel->gray = gray; { Pixmap pix; Display *dpy = WMScreenDisplay(scr); GC gc; WMPixmap *pixm; pixm = WMCreatePixmap(scr, 7, 7, WMScreenDepth(scr), True); pix = WMGetPixmapXID(pixm); XDrawLine(dpy, pix, WMColorGC(black), 0, 3, 6, 3); XDrawLine(dpy, pix, WMColorGC(black), 3, 0, 3, 6); /* XDrawLine(dpy, pix, WMColorGC(black), 1, 0, 3, 3); XDrawLine(dpy, pix, WMColorGC(black), 1, 6, 3, 3); XDrawLine(dpy, pix, WMColorGC(black), 0, 0, 0, 6); */ pix = WMGetPixmapMaskXID(pixm); gc = XCreateGC(dpy, pix, 0, NULL); XSetForeground(dpy, gc, 0); XFillRectangle(dpy, pix, gc, 0, 0, 7, 7); XSetForeground(dpy, gc, 1); XDrawLine(dpy, pix, gc, 0, 3, 6, 3); XDrawLine(dpy, pix, gc, 3, 0, 3, 6); panel->markerPix[ExternalInfo] = pixm; panel->markerPix[PipeInfo] = pixm; panel->markerPix[PLPipeInfo] = pixm; panel->markerPix[DirectoryInfo] = pixm; panel->markerPix[WSMenuInfo] = pixm; panel->markerPix[WWindowListInfo] = pixm; XFreeGC(dpy, gc); } panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); panel->typeP = WMCreatePopUpButton(panel->box); WMResizeWidget(panel->typeP, 150, 20); WMMoveWidget(panel->typeP, 10, 10); WMAddPopUpButtonItem(panel->typeP, _("New Items")); WMAddPopUpButtonItem(panel->typeP, _("Sample Commands")); WMAddPopUpButtonItem(panel->typeP, _("Sample Submenus")); WMSetPopUpButtonAction(panel->typeP, changedItemPad, panel); WMSetPopUpButtonSelectedItem(panel->typeP, 0); { WEditMenu *pad; pad = makeFactoryMenu(panel->box, 150); WMMoveWidget(pad, 10, 40); putNewItem(panel, pad, ExecInfo, _("Run Program")); putNewItem(panel, pad, CommandInfo, _("Internal Command")); putNewSubmenu(pad, _("Submenu")); putNewItem(panel, pad, ExternalInfo, _("External Submenu")); putNewItem(panel, pad, PipeInfo, _("Generated Submenu")); putNewItem(panel, pad, PLPipeInfo, _("Generated PL Menu")); putNewItem(panel, pad, DirectoryInfo, _("Directory Contents")); putNewItem(panel, pad, WSMenuInfo, _("Workspace Menu")); putNewItem(panel, pad, WWindowListInfo, _("Window List Menu")); panel->itemPad[0] = pad; } { WEditMenu *pad; ItemData *data; WMScrollView *sview; sview = WMCreateScrollView(panel->box); WMResizeWidget(sview, 150, 180); WMMoveWidget(sview, 10, 40); WMSetScrollViewHasVerticalScroller(sview, True); pad = makeFactoryMenu(panel->box, 130); WMSetScrollViewContentView(sview, WMWidgetView(pad)); data = putNewItem(panel, pad, ExecInfo, _("XTerm")); data->param.exec.command = "xterm -sb -sl 2000 -bg black -fg white"; data = putNewItem(panel, pad, ExecInfo, _("rxvt")); data->param.exec.command = "rxvt"; data = putNewItem(panel, pad, ExecInfo, _("ETerm")); data->param.exec.command = "eterm"; data = putNewItem(panel, pad, ExecInfo, _("Run...")); data->param.exec.command = _("%A(Run,Type command to run)"); data = putNewItem(panel, pad, ExecInfo, _("Firefox")); data->param.exec.command = "firefox"; data = putNewItem(panel, pad, ExecInfo, _("gimp")); data->param.exec.command = "gimp"; data = putNewItem(panel, pad, ExecInfo, _("epic")); data->param.exec.command = "xterm -e epic"; data = putNewItem(panel, pad, ExecInfo, _("ee")); data->param.exec.command = "ee"; data = putNewItem(panel, pad, ExecInfo, _("xv")); data->param.exec.command = "xv"; data = putNewItem(panel, pad, ExecInfo, _("Evince")); data->param.exec.command = "evince"; data = putNewItem(panel, pad, ExecInfo, _("ghostview")); data->param.exec.command = "gv"; data = putNewItem(panel, pad, CommandInfo, _("Exit Window Maker")); data->param.command.command = 3; WMMapWidget(pad); panel->itemPad[1] = sview; } { WEditMenu *pad, *smenu; ItemData *data; WMScrollView *sview; sview = WMCreateScrollView(panel->box); WMResizeWidget(sview, 150, 180); WMMoveWidget(sview, 10, 40); WMSetScrollViewHasVerticalScroller(sview, True); pad = makeFactoryMenu(panel->box, 130); WMSetScrollViewContentView(sview, WMWidgetView(pad)); data = putNewItem(panel, pad, ExternalInfo, _("Debian Menu")); data->param.pipe.command = "/etc/GNUstep/Defaults/menu.hook"; data = putNewItem(panel, pad, PipeInfo, _("RedHat Menu")); data->param.pipe.command = "wmconfig --output wmaker"; data = putNewItem(panel, pad, PipeInfo, _("Menu Conectiva")); data->param.pipe.command = "wmconfig --output wmaker"; data = putNewItem(panel, pad, DirectoryInfo, _("Themes")); data->param.directory.command = "setstyle"; data->param.directory.directory = "/usr/share/WindowMaker/Themes /usr/local/share/WindowMaker/Themes $HOME/GNUstep/Library/WindowMaker/Themes"; data->param.directory.stripExt = 1; data = putNewItem(panel, pad, DirectoryInfo, _("Bg Images (scale)")); data->param.directory.command = "wmsetbg -u -s"; data->param.directory.directory = "/opt/kde2/share/wallpapers /usr/share/WindowMaker/Backgrounds $HOME/GNUstep/Library/WindowMaker/Backgrounds"; data->param.directory.stripExt = 1; data = putNewItem(panel, pad, DirectoryInfo, _("Bg Images (tile)")); data->param.directory.command = "wmsetbg -u -t"; data->param.directory.directory = "/opt/kde2/share/wallpapers /usr/share/WindowMaker/Backgrounds $HOME/GNUstep/Library/WindowMaker/Backgrounds"; data->param.directory.stripExt = 1; smenu = putNewSubmenu(pad, _("Assorted XTerms")); data = putNewItem(panel, smenu, ExecInfo, _("XTerm Yellow on Blue")); data->param.exec.command = "xterm -sb -sl 2000 -bg midnightblue -fg yellow"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm White on Black")); data->param.exec.command = "xterm -sb -sl 2000 -bg black -fg white"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm Black on White")); data->param.exec.command = "xterm -sb -sl 2000 -bg white -fg black"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm Black on Beige")); data->param.exec.command = "xterm -sb -sl 2000 -bg '#bbbb99' -fg black"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm White on Green")); data->param.exec.command = "xterm -sb -sl 2000 -bg '#228822' -fg white"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm White on Olive")); data->param.exec.command = "xterm -sb -sl 2000 -bg '#335533' -fg white"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm Blue on Blue")); data->param.exec.command = "xterm -sb -sl 2000 -bg '#112244' -fg '#88aabb'"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm BIG FONTS")); data->param.exec.command = "xterm -sb -sl 2000 -bg black -fg white -fn 10x20"; WMMapWidget(pad); panel->itemPad[2] = sview; } width = FRAME_WIDTH - 20 - 150 - 10 - 2; panel->optionsF = WMCreateFrame(panel->box); WMResizeWidget(panel->optionsF, width, FRAME_HEIGHT - 15); WMMoveWidget(panel->optionsF, 10 + 150 + 10, 5); width -= 20; /* command */ panel->commandF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->commandF, width, 50); WMMoveWidget(panel->commandF, 10, 20); WMSetFrameTitle(panel->commandF, _("Program to Run")); WMSetFrameTitlePosition(panel->commandF, WTPAtTop); panel->commandT = WMCreateTextField(panel->commandF); WMResizeWidget(panel->commandT, width - 95, 20); WMMoveWidget(panel->commandT, 10, 20); panel->browseB = WMCreateCommandButton(panel->commandF); WMResizeWidget(panel->browseB, 70, 24); WMMoveWidget(panel->browseB, width - 80, 18); WMSetButtonText(panel->browseB, _("Browse")); WMSetButtonAction(panel->browseB, browseForFile, panel); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->commandT); #if 0 panel->xtermC = WMCreateSwitchButton(panel->commandF); WMResizeWidget(panel->xtermC, width - 20, 20); WMMoveWidget(panel->xtermC, 10, 50); WMSetButtonText(panel->xtermC, _("Run the program inside a Xterm")); #endif WMMapSubwidgets(panel->commandF); /* path */ panel->pathF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->pathF, width, 150); WMMoveWidget(panel->pathF, 10, 40); WMSetFrameTitle(panel->pathF, _("Path for Menu")); panel->pathT = WMCreateTextField(panel->pathF); WMResizeWidget(panel->pathT, width - 20, 20); WMMoveWidget(panel->pathT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->pathT); label = WMCreateLabel(panel->pathF); WMResizeWidget(label, width - 20, 80); WMMoveWidget(label, 10, 50); WMSetLabelText(label, _("Enter the path for a file containing a menu\n" "or a list of directories with the programs you\n" "want to have listed in the menu. Ex:\n" "~/GNUstep/Library/WindowMaker/menu\n" "or\n" "/usr/bin ~/xbin")); WMMapSubwidgets(panel->pathF); /* pipe */ panel->pipeF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->pipeF, width, 155); WMMoveWidget(panel->pipeF, 10, 30); WMSetFrameTitle(panel->pipeF, _("Command")); panel->pipeT = WMCreateTextField(panel->pipeF); WMResizeWidget(panel->pipeT, width - 20, 20); WMMoveWidget(panel->pipeT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->pipeT); label = WMCreateLabel(panel->pipeF); WMResizeWidget(label, width - 20, 40); WMMoveWidget(label, 10, 50); WMSetLabelText(label, _("Enter a command that outputs a menu\n" "definition to stdout when invoked.")); panel->pipeCacheB = WMCreateSwitchButton(panel->pipeF); WMResizeWidget(panel->pipeCacheB, width - 20, 40); WMMoveWidget(panel->pipeCacheB, 10, 110); WMSetButtonText(panel->pipeCacheB, _("Cache menu contents after opening for\n" "the first time")); WMMapSubwidgets(panel->pipeF); /* proplist pipe */ panel->plpipeF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->plpipeF, width, 155); WMMoveWidget(panel->plpipeF, 10, 30); WMSetFrameTitle(panel->plpipeF, _("Command")); panel->plpipeT = WMCreateTextField(panel->plpipeF); WMResizeWidget(panel->plpipeT, width - 20, 20); WMMoveWidget(panel->plpipeT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->plpipeT); label = WMCreateLabel(panel->plpipeF); WMResizeWidget(label, width - 20, 40); WMMoveWidget(label, 10, 50); WMSetLabelText(label, _("Enter a command that outputs a proplist menu\n" "definition to stdout when invoked.")); panel->plpipeCacheB = WMCreateSwitchButton(panel->plpipeF); WMResizeWidget(panel->plpipeCacheB, width - 20, 40); WMMoveWidget(panel->plpipeCacheB, 10, 110); WMSetButtonText(panel->plpipeCacheB, _("Cache menu contents after opening for\n" "the first time")); WMMapSubwidgets(panel->plpipeF); /* directory menu */ panel->dcommandF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->dcommandF, width, 90); WMMoveWidget(panel->dcommandF, 10, 25); WMSetFrameTitle(panel->dcommandF, _("Command to Open Files")); panel->dcommandT = WMCreateTextField(panel->dcommandF); WMResizeWidget(panel->dcommandT, width - 20, 20); WMMoveWidget(panel->dcommandT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->dcommandT); label = WMCreateLabel(panel->dcommandF); WMResizeWidget(label, width - 20, 45); WMMoveWidget(label, 10, 40); WMSetLabelText(label, _("Enter the command you want to use to open the\n" "files in the directories listed below.")); WMMapSubwidgets(panel->dcommandF); panel->dpathF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->dpathF, width, 80); WMMoveWidget(panel->dpathF, 10, 125); WMSetFrameTitle(panel->dpathF, _("Directories with Files")); panel->dpathT = WMCreateTextField(panel->dpathF); WMResizeWidget(panel->dpathT, width - 20, 20); WMMoveWidget(panel->dpathT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->dpathT); panel->dstripB = WMCreateSwitchButton(panel->dpathF); WMResizeWidget(panel->dstripB, width - 20, 20); WMMoveWidget(panel->dstripB, 10, 50); WMSetButtonText(panel->dstripB, _("Strip extensions from file names")); WMSetButtonAction(panel->dstripB, buttonClicked, panel); WMMapSubwidgets(panel->dpathF); /* shortcut */ panel->shortF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->shortF, width, 50); WMMoveWidget(panel->shortF, 10, 160); WMSetFrameTitle(panel->shortF, _("Keyboard Shortcut")); panel->shortT = WMCreateTextField(panel->shortF); WMResizeWidget(panel->shortT, width - 20 - 150, 20); WMMoveWidget(panel->shortT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->shortT); panel->sgrabB = WMCreateCommandButton(panel->shortF); WMResizeWidget(panel->sgrabB, 70, 24); WMMoveWidget(panel->sgrabB, width - 80, 18); WMSetButtonText(panel->sgrabB, _("Capture")); WMSetButtonAction(panel->sgrabB, sgrabClicked, panel); panel->sclearB = WMCreateCommandButton(panel->shortF); WMResizeWidget(panel->sclearB, 70, 24); WMMoveWidget(panel->sclearB, width - 155, 18); WMSetButtonText(panel->sclearB, _("Clear")); WMSetButtonAction(panel->sclearB, sgrabClicked, panel); WMMapSubwidgets(panel->shortF); /* internal command */ panel->icommandL = WMCreateList(panel->optionsF); WMResizeWidget(panel->icommandL, width, 80); WMMoveWidget(panel->icommandL, 10, 20); WMSetListAction(panel->icommandL, icommandLClicked, panel); WMAddNotificationObserver(dataChanged, panel, WMListSelectionDidChangeNotification, panel->icommandL); WMInsertListItem(panel->icommandL, 0, _("Arrange Icons")); WMInsertListItem(panel->icommandL, 1, _("Hide All Windows Except For The Focused One")); WMInsertListItem(panel->icommandL, 2, _("Show All Windows")); WMInsertListItem(panel->icommandL, 3, _("Exit Window Maker")); WMInsertListItem(panel->icommandL, 4, _("Exit X Session")); WMInsertListItem(panel->icommandL, 5, _("Restart Window Maker")); WMInsertListItem(panel->icommandL, 6, _("Start Another Window Manager : (")); WMInsertListItem(panel->icommandL, 7, _("Save Current Session")); WMInsertListItem(panel->icommandL, 8, _("Clear Saved Session")); WMInsertListItem(panel->icommandL, 9, _("Refresh Screen")); WMInsertListItem(panel->icommandL, 10, _("Open Info Panel")); WMInsertListItem(panel->icommandL, 11, _("Open Copyright Panel")); panel->paramF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->paramF, width, 50); WMMoveWidget(panel->paramF, 10, 105); WMSetFrameTitle(panel->paramF, _("Window Manager to Start")); panel->paramT = WMCreateTextField(panel->paramF); WMResizeWidget(panel->paramT, width - 20, 20); WMMoveWidget(panel->paramT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->paramT); WMMapSubwidgets(panel->paramF); panel->quickB = WMCreateSwitchButton(panel->optionsF); WMResizeWidget(panel->quickB, width, 20); WMMoveWidget(panel->quickB, 10, 120); WMSetButtonText(panel->quickB, _("Do not confirm action.")); WMSetButtonAction(panel->quickB, buttonClicked, panel); label = WMCreateLabel(panel->optionsF); WMResizeWidget(label, width + 5, FRAME_HEIGHT - 50); WMMoveWidget(label, 7, 20); WMSetLabelText(label, _("Instructions:\n\n" " - drag items from the left to the menu to add new items\n" " - drag items out of the menu to remove items\n" " - drag items in menu to change their position\n" " - drag items with Control pressed to copy them\n" " - double click in a menu item to change the label\n" " - click on a menu item to change related information")); WMMapWidget(label); WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); WMMapWidget(panel->box); { int i; for (i = 0; i < wlengthof(panel->itemPad); i++) WMUnmapWidget(panel->itemPad[i]); } changedItemPad(panel->typeP, panel); panel->sections[NoInfo][0] = label; panel->sections[ExecInfo][0] = panel->commandF; panel->sections[ExecInfo][1] = panel->shortF; panel->sections[CommandInfo][0] = panel->icommandL; panel->sections[CommandInfo][1] = panel->shortF; panel->sections[ExternalInfo][0] = panel->pathF; panel->sections[PipeInfo][0] = panel->pipeF; panel->sections[PLPipeInfo][0] = panel->plpipeF; panel->sections[DirectoryInfo][0] = panel->dpathF; panel->sections[DirectoryInfo][1] = panel->dcommandF; panel->currentType = NoInfo; showData(panel); { WMPoint pos; pos = WMGetViewScreenPosition(WMWidgetView(panel->box)); if (pos.x < 200) { pos.x += FRAME_WIDTH + 20; } else { pos.x = 10; } pos.y = WMAX(pos.y - 100, 0); if (panel->menu) WEditMenuShowAt(panel->menu, pos.x, pos.y); } }
static void createPanel(Panel *p) { _Panel *panel = (_Panel *) p; WMScreen *scr = WMWidgetScreen(panel->parent); WMPixmap *icon1, *icon2; RImage *xis = NULL; RContext *rc = WMScreenRContext(scr); char *path; int i, j, k; char *buf1, *buf2; path = LocateImage(ARQUIVO_XIS); if (path) { xis = RLoadImage(rc, path, 0); if (!xis) { wwarning(_("could not load image file %s"), path); } wfree(path); } panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); /***************** Auto-delays *****************/ buf1 = wmalloc(strlen(DELAY_ICON) + 1); buf2 = wmalloc(strlen(DELAY_ICON_S) + 1); for (k = 0; k < 2; k++) { panel->autoDelayF[k] = WMCreateFrame(panel->box); WMResizeWidget(panel->autoDelayF[k], 365, 100); WMMoveWidget(panel->autoDelayF[k], 15, 10 + k * 110); if (k == 0) WMSetFrameTitle(panel->autoDelayF[k], _("Delays in milliseconds for autocollapsing clips")); else WMSetFrameTitle(panel->autoDelayF[k], _("Delays in milliseconds for autoraising clips")); for (i = 0; i < 2; i++) { panel->autoDelayL[i + k * 2] = WMCreateLabel(panel->autoDelayF[k]); WMResizeWidget(panel->autoDelayL[i + k * 2], 165, 20); WMMoveWidget(panel->autoDelayL[i + k * 2], 10, 27 + 40 * i); WMSetLabelText(panel->autoDelayL[i + k * 2], _(auto_delay[i + k * 2].string)); WMSetLabelTextAlignment(panel->autoDelayL[i + k * 2], WARight); for (j = 0; j < 5; j++) { panel->autoDelayB[i + k * 2][j] = WMCreateCustomButton(panel->autoDelayF[k], WBBStateChangeMask); WMResizeWidget(panel->autoDelayB[i + k * 2][j], 25, 25); WMMoveWidget(panel->autoDelayB[i + k * 2][j], 175 + (25 * j), 25 + 40 * i); WMSetButtonBordered(panel->autoDelayB[i + k * 2][j], False); WMSetButtonImagePosition(panel->autoDelayB[i + k * 2][j], WIPImageOnly); WMSetButtonAction(panel->autoDelayB[i + k * 2][j], pushAutoDelayButton, panel); if (j > 0) WMGroupButtons(panel->autoDelayB[i + k * 2][0], panel->autoDelayB[i + k * 2][j]); sprintf(buf1, DELAY_ICON, j); CreateImages(scr, rc, NULL, buf1, &icon1, NULL); if (icon1) { WMSetButtonImage(panel->autoDelayB[i + k * 2][j], icon1); WMReleasePixmap(icon1); } else { wwarning(_("could not load icon file %s"), buf1); } sprintf(buf2, DELAY_ICON_S, j); CreateImages(scr, rc, NULL, buf2, &icon2, NULL); if (icon2) { WMSetButtonAltImage(panel->autoDelayB[i + k * 2][j], icon2); WMReleasePixmap(icon2); } else { wwarning(_("could not load icon file %s"), buf2); } } panel->autoDelayT[i + k * 2] = WMCreateTextField(panel->autoDelayF[k]); WMResizeWidget(panel->autoDelayT[i + k * 2], 36, 20); WMMoveWidget(panel->autoDelayT[i + k * 2], 310, 27 + 40 * i); WMAddNotificationObserver(autoDelayChanged, panel, WMTextDidChangeNotification, panel->autoDelayT[i + k * 2]); } WMMapSubwidgets(panel->autoDelayF[k]); } wfree(buf1); wfree(buf2); /***************** Enable/disable clip/dock/drawers *****************/ panel->dockF = WMCreateFrame(panel->box); WMResizeWidget(panel->dockF, 115, 210); WMMoveWidget(panel->dockF, 390, 10); WMSetFrameTitle(panel->dockF, _("Dock/Clip/Drawer")); for (i = 0; i < 3; i++) { panel->docksB[i] = WMCreateButton(panel->dockF, WBTToggle); WMResizeWidget(panel->docksB[i], 56, 56); WMMoveWidget(panel->docksB[i], 30, 20 + 62 * i); WMSetButtonImagePosition(panel->docksB[i], WIPImageOnly); CreateImages(scr, rc, xis, dock_config[i].icon_file, &icon1, &icon2); if (icon2) { WMSetButtonImage(panel->docksB[i], icon2); WMReleasePixmap(icon2); } if (icon1) { WMSetButtonAltImage(panel->docksB[i], icon1); WMReleasePixmap(icon1); } switch(i) { case 0: WMSetBalloonTextForView(_("Disable/enable the application Dock (the\n" "vertical icon bar in the side of the screen)."), WMWidgetView(panel->docksB[i])); break; case 1: WMSetBalloonTextForView(_("Disable/enable the Clip (that thing with\n" "a paper clip icon)."), WMWidgetView(panel->docksB[i])); break; case 2: WMSetBalloonTextForView(_("Disable/enable Drawers (a dock that stores\n" "application icons horizontally). The dock is required."), WMWidgetView(panel->docksB[i])); break; } WMSetButtonAction(panel->docksB[i], pushDockButton, panel); } WMMapSubwidgets(panel->dockF); if (xis) RReleaseImage(xis); WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); showData(panel); }
static void createPanel(Panel * p) { _Panel *panel = (_Panel *) p; WMScreen *scr = WMWidgetScreen(panel->parent); WMPixmap *icon; char *buf1, *buf2; int i; RColor color; char *path; color.red = 0xae; color.green = 0xaa; color.blue = 0xae; panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); /**************** Mouse Speed ****************/ panel->speedF = WMCreateFrame(panel->box); WMResizeWidget(panel->speedF, 219, 85); WMMoveWidget(panel->speedF, 9, 54); WMSetFrameTitle(panel->speedF, _("Mouse Speed")); panel->speedL = WMCreateLabel(panel->speedF); WMResizeWidget(panel->speedL, 40, 46); WMMoveWidget(panel->speedL, 8, 10); WMSetLabelImagePosition(panel->speedL, WIPImageOnly); path = LocateImage(SPEED_ICON_FILE); if (path) { icon = WMCreateBlendedPixmapFromFile(scr, path, &color); if (icon) { WMSetLabelImage(panel->speedL, icon); WMReleasePixmap(icon); } else { wwarning(_("could not load icon %s"), path); } wfree(path); } panel->speedS = WMCreateSlider(panel->speedF); WMResizeWidget(panel->speedS, 150, 15); WMMoveWidget(panel->speedS, 58, 30); WMSetSliderMinValue(panel->speedS, 0); WMSetSliderMaxValue(panel->speedS, 40); WMSetSliderContinuous(panel->speedS, False); WMSetSliderAction(panel->speedS, speedChange, panel); panel->acceL = WMCreateLabel(panel->speedF); WMResizeWidget(panel->acceL, 50, 16); WMMoveWidget(panel->acceL, 8, 58); WMSetLabelTextAlignment(panel->acceL, WARight); WMSetLabelText(panel->acceL, _("Accel.:")); panel->acceT = WMCreateTextField(panel->speedF); WMResizeWidget(panel->acceT, 40, 20); WMMoveWidget(panel->acceT, 58, 56); WMAddNotificationObserver(returnPressed, panel, WMTextDidEndEditingNotification, panel->acceT); panel->threL = WMCreateLabel(panel->speedF); WMResizeWidget(panel->threL, 80, 16); WMMoveWidget(panel->threL, 98, 58); WMSetLabelTextAlignment(panel->threL, WARight); WMSetLabelText(panel->threL, _("Threshold:")); panel->threT = WMCreateTextField(panel->speedF); WMResizeWidget(panel->threT, 30, 20); WMMoveWidget(panel->threT, 178, 56); WMAddNotificationObserver(returnPressed, panel, WMTextDidEndEditingNotification, panel->threT); WMMapSubwidgets(panel->speedF); /* ************** Grab Modifier **************** */ panel->grabF = WMCreateFrame(panel->box); WMResizeWidget(panel->grabF, 219, 46); WMMoveWidget(panel->grabF, 9, 5); WMSetFrameTitle(panel->grabF, _("Mouse Grab Modifier")); WMSetBalloonTextForView(_("Keyboard modifier to use for actions that\n" "involve dragging windows with the mouse,\n" "clicking inside the window."), WMWidgetView(panel->grabF)); panel->grabP = WMCreatePopUpButton(panel->grabF); WMResizeWidget(panel->grabP, 178, 20); WMMoveWidget(panel->grabP, 20, 17); fillModifierPopUp(panel->grabP); WMMapSubwidgets(panel->grabF); /***************** Doubleclick Delay ****************/ panel->ddelaF = WMCreateFrame(panel->box); WMResizeWidget(panel->ddelaF, 219, 80); WMMoveWidget(panel->ddelaF, 9, 142); WMSetFrameTitle(panel->ddelaF, _("Double-Click Delay")); buf1 = wmalloc(strlen(DELAY_ICON) + 2); buf2 = wmalloc(strlen(DELAY_ICON_S) + 2); for (i = 0; i < wlengthof(panel->ddelaB); i++) { panel->ddelaB[i] = WMCreateCustomButton(panel->ddelaF, WBBStateChangeMask); WMResizeWidget(panel->ddelaB[i], 25, 25); WMMoveWidget(panel->ddelaB[i], 18 + (40 * i), 18); WMSetButtonBordered(panel->ddelaB[i], False); WMSetButtonImagePosition(panel->ddelaB[i], WIPImageOnly); WMSetButtonAction(panel->ddelaB[i], doubleClick, panel); if (i > 0) { WMGroupButtons(panel->ddelaB[0], panel->ddelaB[i]); } sprintf(buf1, DELAY_ICON, i + 1); sprintf(buf2, DELAY_ICON_S, i + 1); path = LocateImage(buf1); if (path) { icon = WMCreatePixmapFromFile(scr, path); if (icon) { WMSetButtonImage(panel->ddelaB[i], icon); WMReleasePixmap(icon); } else { wwarning(_("could not load icon file %s"), path); } wfree(path); } path = LocateImage(buf2); if (path) { icon = WMCreatePixmapFromFile(scr, path); if (icon) { WMSetButtonAltImage(panel->ddelaB[i], icon); WMReleasePixmap(icon); } else { wwarning(_("could not load icon file %s"), path); } wfree(path); } } wfree(buf1); wfree(buf2); panel->tester = CreateDoubleTest(panel->ddelaF, _("Test")); WMResizeWidget(panel->tester, 84, 24); WMMoveWidget(panel->tester, 20, 48); panel->ddelaT = WMCreateTextField(panel->ddelaF); WMResizeWidget(panel->ddelaT, 40, 20); WMMoveWidget(panel->ddelaT, 130, 50); panel->ddelaL = WMCreateLabel(panel->ddelaF); WMResizeWidget(panel->ddelaL, 40, 16); WMMoveWidget(panel->ddelaL, 173, 54); { WMFont *font; WMColor *color; font = WMSystemFontOfSize(scr, 10); color = WMDarkGrayColor(scr); WMSetLabelTextColor(panel->ddelaL, color); WMSetLabelFont(panel->ddelaL, font); WMReleaseFont(font); WMReleaseColor(color); } WMSetLabelText(panel->ddelaL, _("ms")); WMMapSubwidgets(panel->ddelaF); /* ************** Workspace Action Buttons **************** */ panel->menuF = WMCreateFrame(panel->box); WMResizeWidget(panel->menuF, 276, 217); WMMoveWidget(panel->menuF, 236, 5); WMSetFrameTitle(panel->menuF, _("Workspace Mouse Actions")); panel->disaB = WMCreateSwitchButton(panel->menuF); WMResizeWidget(panel->disaB, 254, 18); WMMoveWidget(panel->disaB, 10, 15); WMSetButtonText(panel->disaB, _("Disable mouse actions")); WMSetButtonAction(panel->disaB, toggle_disabling_of_mouse_actions, panel); for (i = 0; i < wlengthof(button_list); i++) { int j; panel->mouse_action[i].label = WMCreateLabel(panel->menuF); WMResizeWidget(panel->mouse_action[i].label, 115, 20); WMMoveWidget(panel->mouse_action[i].label, 4, 37 + 25 * i); WMSetLabelTextAlignment(panel->mouse_action[i].label, WARight); WMSetLabelText(panel->mouse_action[i].label, _(button_list[i].display_label)); panel->mouse_action[i].popup = WMCreatePopUpButton(panel->menuF); WMResizeWidget(panel->mouse_action[i].popup, 145, 20); WMMoveWidget(panel->mouse_action[i].popup, 121, 37 + 25 * i); if (button_list[i].type == T_BUTTON) { for (j = 0; j < wlengthof(button_actions); j++) WMAddPopUpButtonItem(panel->mouse_action[i].popup, _(button_actions[j].label)); } else { for (j = 0; j < wlengthof(wheel_actions); j++) WMAddPopUpButtonItem(panel->mouse_action[i].popup, _(wheel_actions[j].label)); } } WMMapSubwidgets(panel->menuF); WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); showData(panel); }
static void createPanel(Panel * p) { _Panel *panel = (_Panel *) p; panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); panel->saveB = WMCreateCommandButton(panel->box); WMResizeWidget(panel->saveB, 154, 24); WMMoveWidget(panel->saveB, 15, 10); WMSetButtonText(panel->saveB, _("Save Current Theme")); panel->list = WMCreateList(panel->box); WMResizeWidget(panel->list, 154, 150); WMMoveWidget(panel->list, 15, 40); panel->loadB = WMCreateCommandButton(panel->box); WMResizeWidget(panel->loadB, 74, 24); WMMoveWidget(panel->loadB, 15, 200); WMSetButtonText(panel->loadB, _("Load")); panel->instB = WMCreateCommandButton(panel->box); WMResizeWidget(panel->instB, 74, 24); WMMoveWidget(panel->instB, 95, 200); WMSetButtonText(panel->instB, _("Install")); /**************** Tile of the day ****************/ panel->totF = WMCreateFrame(panel->box); WMResizeWidget(panel->totF, 210, 105); WMMoveWidget(panel->totF, 240, 10); WMSetFrameTitle(panel->totF, _("Tile of The Day")); panel->totL = WMCreateLabel(panel->totF); WMResizeWidget(panel->totL, 67, 67); WMMoveWidget(panel->totL, 25, 25); WMSetLabelRelief(panel->totL, WRSunken); panel->totB = WMCreateCommandButton(panel->totF); WMResizeWidget(panel->totB, 86, 24); WMMoveWidget(panel->totB, 105, 45); WMSetButtonText(panel->totB, _("Download")); WMSetButtonAction(panel->totB, downloadCallback, panel); WMMapSubwidgets(panel->totF); /**************** Bar of the day ****************/ panel->botF = WMCreateFrame(panel->box); WMResizeWidget(panel->botF, 315, 95); WMMoveWidget(panel->botF, 190, 125); WMSetFrameTitle(panel->botF, _("Bar of The Day")); panel->botL = WMCreateLabel(panel->botF); WMResizeWidget(panel->botL, 285, 32); WMMoveWidget(panel->botL, 15, 20); WMSetLabelRelief(panel->botL, WRSunken); panel->botB = WMCreateCommandButton(panel->botF); WMResizeWidget(panel->botB, 86, 24); WMMoveWidget(panel->botB, 110, 60); WMSetButtonText(panel->botB, _("Download")); WMSetButtonAction(panel->botB, downloadCallback, panel); WMMapSubwidgets(panel->botF); WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); showData(panel); }