#include #include #include #include #include #include #include #include #include #include #include using namespace fltk; static bool menuBarState = true; static bool fullscrState = false; static int windowX = 0; static int windowY = 0; static int windowW = 800; static int windowH = 500; void buildMenuBar(void *window); void cbMenuBarToggle(Widget *, void *menu); void cbFullscr(Widget *, void *windowMain); void cbQuit(Widget *, void *); int main(int argc, char **argv) { Window *windowMain = new Window(windowW, windowH); windowMain->begin(); buildMenuBar(windowMain); TabGroup *tabs = new TabGroup(0, 26, windowMain->w(), (windowMain->h() - 26)); tabs->begin(); tabs->textsize(18); Group *tab1 = new Group(0, 29, tabs->w(), ((tabs->h()) - 30), "Tab 1 "); tab1->begin(); tab1->textsize(18); tab1->end(); Group *tab2 = new Group(0, 29, tabs->w(), ((tabs->h()) - 30), "Tab 2 "); tab2->begin(); tab2->textsize(18); tab2->end(); tabs->end(); windowMain->resizable(tabs); windowMain->size_range(700, 400, 0, 0); windowMain->callback(cbQuit); windowMain->end(); windowMain->show(argc, argv); return run(); } void buildMenuBar(void *window) { Window *windowMain = (Window *) window; MenuBar *menuBar = new MenuBar(0, 0, windowMain->w(), 26); menuBar->begin(); menuBar->box(UP_BOX); ItemGroup *file = new ItemGroup("&File"); file->begin(); file->textsize(18); file->add("New &Window ", CTRL|'n', 0, 0, 0)->textsize(18); file->add("New &Tab ", CTRL|'t', 0, 0, 0)->textsize(18); file->add("&Open ", CTRL|'o', 0, 0, 0)->textsize(18); file->add("Close &Window ", CTRL|SHIFT|'w', 0, 0, 0)->textsize(18); file->add("Close &Tab ", CTRL|'t', 0, 0, 0)->textsize(18); new Divider(); file->add("&Save ", CTRL|'s', 0, 0, 0)->textsize(18); file->add("Save &As... ", CTRL|SHIFT|'s', 0, 0, 0)->textsize(18); new Divider(); file->add("Print Pre&view ", CTRL|SHIFT|'p', 0, 0, 0)->textsize(18); file->add("&Print ", CTRL|'p', 0, 0, 0)->textsize(18); new Divider(); file->add("&Quit ", CTRL|'q', cbQuit, 0, 0)->textsize(18); file->end(); ItemGroup *edit = new ItemGroup("&Edit"); edit->begin(); edit->textsize(18); edit->add("&Undo ", CTRL|'z', 0, 0, 0)->textsize(18); edit->add("&Redo ", CTRL|'y', 0, 0, 0)->textsize(18); new Divider(); edit->add("Cu&t ", CTRL|'x', 0, 0, 0)->textsize(18); edit->add("&Copy ", CTRL|'c', 0, 0, 0)->textsize(18); edit->add("&Paste ", CTRL|'v', 0, 0, 0)->textsize(18); edit->add("&Delete ", DeleteKey, 0, 0, 0)->textsize(18); new Divider(); edit->add("&Find ", CTRL|'f', 0, 0, 0)->textsize(18); edit->add("Find A&gain ", CTRL|'g', 0, 0, 0)->textsize(18); new Divider(); edit->add("Prefere&nces ", 0, 0, 0, 0)->textsize(18); edit->end(); ItemGroup *view = new ItemGroup("&View"); view->begin(); view->textsize(18); ItemGroup *toolbars = new ItemGroup("&Toolbars "); toolbars->begin(); toolbars->textsize(18); Item *menu = new Item("&Menu Bar "); menu->type(Item::TOGGLE); menu->shortcut(F10Key); menu->callback(cbMenuBarToggle, menuBar); menu->textsize(18); Item *tools = new Item("&Tools Bar "); tools->type(Item::TOGGLE); tools->textsize(18); Item *status = new Item("&Status Bar "); status->type(Item::TOGGLE); status->textsize(18); toolbars->end(); new Divider(); ItemGroup *zoom = new ItemGroup("&Zoom "); zoom->begin(); zoom->textsize(18); zoom->add("Zoom &In ", CTRL|'+', 0, 0, 0)->textsize(18); zoom->add("Zoom &Out ", CTRL|'-', 0, 0, 0)->textsize(18); zoom->add("&Reset ", CTRL|'0', 0, 0, 0)->textsize(18); new Divider(); Item *zoomText = new Item("Zoom &Text Only "); zoomText->type(Item::TOGGLE); zoomText->textsize(18); zoom->end(); Item *fullscreen = new Item("&Fullscreen "); fullscreen->type(Item::TOGGLE); fullscreen->shortcut(F11Key); fullscreen->callback(cbFullscr, windowMain); fullscreen->textsize(18); view->end(); ItemGroup *help = new ItemGroup("&Help"); help->begin(); help->textsize(18); help->add("&Help Contents ", F1Key, 0, 0, 0)->textsize(18); new Divider(); help->add("&Updates Check ", 0, 0, 0)->textsize(18); new Divider(); help->add("&About ", 0, 0, 0)->textsize(18); help->end(); menuBar->end(); } void cbMenuBarToggle(Widget *, void *menu) { MenuBar *menuBar = (MenuBar *) menu; if(menuBar) { menuBar->hide(); menuBarState = false; } else { menuBar->show(); menuBarState = true; } } void cbFullscr(Widget *, void *window) { Window *windowMain = (Window *) window; if(fullscrState) { windowMain->fullscreen_off(windowX, windowY, windowW, windowH); windowMain->hide(); windowMain->border(true); windowMain->show(); fullscrState = false; } else { windowX = windowMain->x(); windowY = windowMain->y(); windowW = windowMain->w(); windowH = windowMain->h(); windowMain->fullscreen(); fullscrState = true; } } void cbQuit(Widget *, void *) { if(event_key_state(EscapeKey)) { return; } exit(0); }