mirror of
https://github.com/gryf/window-maker.github.io.git
synced 2025-12-17 19:20:17 +01:00
Add WINGs tutorial
The original website is http://www.quantitativefinanceservices.com/OpenDir/WINGslib/WINGToc.html and it had the following notice at the bottom: Copyright (c) 2010 Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". So we are fine.
This commit is contained in:
committed by
Doug Torrance
parent
beb38913b4
commit
6c515667a7
70
WINGs_tutorial/EighthWindow.c
Normal file
70
WINGs_tutorial/EighthWindow.c
Normal file
@@ -0,0 +1,70 @@
|
||||
#include "editmenu.h"
|
||||
|
||||
#define WINWIDTH 300
|
||||
#define WINHEIGHT 400
|
||||
#define MENUWIDTH 80
|
||||
#define MENITEMHT 21
|
||||
|
||||
struct datacouple{WMWindow *window;
|
||||
WEditMenu *menu;
|
||||
} datacouple;
|
||||
|
||||
void closeAll(WMWidget *self,void *data){
|
||||
WMDestroyWidget(self);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void getMenu(WMWidget *self, void *data){
|
||||
WMPoint position;
|
||||
struct datacouple *tmp=(struct datacouple *)data;
|
||||
if(WMGetButtonSelected(self)){
|
||||
position=WMGetViewScreenPosition(WMWidgetView(tmp->window));
|
||||
WEditMenuShowAt(tmp->menu,(position.x>MENUWIDTH)?position.x-MENUWIDTH:0, position.y+MENITEMHT,tmp->window);
|
||||
}else
|
||||
WEditMenuHide(tmp->menu);
|
||||
}
|
||||
|
||||
int main (int argc, char **argv){
|
||||
|
||||
Display *display;
|
||||
WMScreen *screen;
|
||||
WMWindow *win;
|
||||
WEditMenu *submenu, *menu;
|
||||
WEditMenuItem * menuitem;
|
||||
struct datacouple Mainmenu;
|
||||
WMButton *Button;
|
||||
|
||||
WMInitializeApplication("MenuWindow", &argc, argv);
|
||||
display = XOpenDisplay("");
|
||||
screen = WMCreateScreen(display, DefaultScreen(display));
|
||||
win = WMCreateWindow(screen, "Menu");
|
||||
WMResizeWidget(win, WINWIDTH, WINHEIGHT);
|
||||
WMSetWindowCloseAction(win, closeAll, NULL);
|
||||
|
||||
submenu=WCreateEditMenu(screen,"Submenu");
|
||||
menuitem =WAddMenuItemWithTitle(submenu,"Submenu item");
|
||||
menu=WCreateEditMenu(screen,"Main menu");
|
||||
menuitem = WAddMenuItemWithTitle(menu,"To submenu");
|
||||
WSetEditMenuSubmenu(menu, menuitem , submenu);
|
||||
menuitem = WAddMenuItemWithTitle(menu,"Main item");
|
||||
|
||||
Mainmenu.window=win;
|
||||
Mainmenu.menu=menu;
|
||||
|
||||
Button =WMCreateButton(win,WBTPushOnPushOff);
|
||||
WMSetButtonText (Button, "Menu");
|
||||
WMSetButtonAction (Button, getMenu, &Mainmenu);
|
||||
WMMoveWidget(Button, 1,1);
|
||||
|
||||
WMRealizeWidget(win);
|
||||
WMRealizeWidget(Button);
|
||||
WMRealizeWidget(menu);
|
||||
WMRealizeWidget(submenu);
|
||||
|
||||
WMMapSubwidgets(win);
|
||||
WMMapWidget(win);
|
||||
|
||||
WMScreenMainLoop(screen);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user