/*! \todo Finish function documentation!!! * \brief * \par Function Description * */ void x_window_create_main(GschemToplevel *w_current) { TOPLEVEL *toplevel = gschem_toplevel_get_toplevel (w_current); GtkPolicyType policy; GtkWidget *main_box=NULL; GtkWidget *menubar=NULL; GtkWidget *toolbar=NULL; GtkWidget *handlebox=NULL; GtkWidget *hscrollbar; GtkWidget *vscrollbar; GtkAdjustment *hadjustment; GtkAdjustment *vadjustment; char *right_button_text; /* used to signify that the window isn't mapped yet */ w_current->window = NULL; w_current->main_window = GTK_WIDGET (gschem_main_window_new ()); gtk_widget_set_name (w_current->main_window, "gschem"); gtk_window_set_policy (GTK_WINDOW (w_current->main_window), TRUE, TRUE, TRUE); /* We want the widgets to flow around the drawing area, so we don't * set a size of the main window. The drawing area's size is fixed, * see below */ /* * normally we let the window manager handle locating and sizing * the window. However, for some batch processing of schematics * (generating a pdf of all schematics for example) we want to * override this. Hence "auto_place_mode". */ if( auto_place_mode ) gtk_widget_set_uposition (w_current->main_window, 10, 10); /* this should work fine */ g_signal_connect (G_OBJECT (w_current->main_window), "delete_event", G_CALLBACK (i_callback_close_wm), w_current); /* Containers first */ main_box = gtk_vbox_new(FALSE, 1); gtk_container_border_width(GTK_CONTAINER(main_box), 0); gtk_container_add(GTK_CONTAINER(w_current->main_window), main_box); menubar = get_main_menu (w_current); if (w_current->handleboxes) { handlebox = gtk_handle_box_new (); gtk_box_pack_start(GTK_BOX(main_box), handlebox, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (handlebox), menubar); } else { gtk_box_pack_start(GTK_BOX(main_box), menubar, FALSE, FALSE, 0); } w_current->menubar = menubar; gtk_widget_realize (w_current->main_window); if (w_current->handleboxes && w_current->toolbars) { handlebox = gtk_handle_box_new (); gtk_box_pack_start (GTK_BOX (main_box), handlebox, FALSE, FALSE, 0); } if (w_current->toolbars) { toolbar = gtk_toolbar_new(); gtk_toolbar_set_orientation (GTK_TOOLBAR(toolbar), GTK_ORIENTATION_HORIZONTAL); gtk_toolbar_set_style (GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS); if (w_current->handleboxes) { gtk_container_add (GTK_CONTAINER (handlebox), toolbar); } else { gtk_box_pack_start(GTK_BOX(main_box), toolbar, FALSE, FALSE, 0); } gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), _("New"), _("New file"), "toolbar/new", x_window_stock_pixmap("new", w_current), (GtkSignalFunc) i_callback_toolbar_file_new, w_current); gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), _("Open"), _("Open file..."), "toolbar/open", x_window_stock_pixmap("open", w_current), (GtkSignalFunc) i_callback_toolbar_file_open, w_current); gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), _("Save"), _("Save file"), "toolbar/save", x_window_stock_pixmap("save", w_current), (GtkSignalFunc) i_callback_toolbar_file_save, w_current); gtk_toolbar_append_space (GTK_TOOLBAR(toolbar)); gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), _("Undo"), _("Undo last operation"), "toolbar/undo", x_window_stock_pixmap("undo", w_current), (GtkSignalFunc) i_callback_toolbar_edit_undo, w_current); gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), _("Redo"), _("Redo last undo"), "toolbar/redo", x_window_stock_pixmap("redo", w_current), (GtkSignalFunc) i_callback_toolbar_edit_redo, w_current); gtk_toolbar_append_space (GTK_TOOLBAR(toolbar)); /* not part of any radio button group */ gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), _("Component"), _("Add component...\nSelect library and component from list, move the mouse into main window, click to place\nRight mouse button to cancel"), "toolbar/component", x_window_stock_pixmap("insert-symbol", w_current), (GtkSignalFunc) i_callback_toolbar_add_component, w_current); w_current->toolbar_net = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_CHILD_RADIOBUTTON, NULL, _("Nets"), _("Add nets mode\nRight mouse button to cancel"), "toolbar/nets", x_window_stock_pixmap("insert-net", w_current), (GtkSignalFunc) i_callback_toolbar_add_net, w_current); w_current->toolbar_bus = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_CHILD_RADIOBUTTON, w_current->toolbar_net, _("Bus"), _("Add buses mode\nRight mouse button to cancel"), "toolbar/bus", x_window_stock_pixmap("insert-bus", w_current), (GtkSignalFunc) i_callback_toolbar_add_bus, w_current); /* not part of any radio button group */ gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), _("Text"), _("Add Text..."), "toolbar/text", x_window_stock_pixmap("insert-text", w_current), (GtkSignalFunc) i_callback_toolbar_add_text, w_current); gtk_toolbar_append_space (GTK_TOOLBAR(toolbar)); w_current->toolbar_select = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_CHILD_RADIOBUTTON, w_current->toolbar_bus, _("Select"), _("Select mode"), "toolbar/select", x_window_stock_pixmap("select", w_current), (GtkSignalFunc) i_callback_toolbar_edit_select, w_current); gtk_toolbar_append_space (GTK_TOOLBAR(toolbar)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w_current->toolbar_select), TRUE); } /* Try to create popup menu (appears in right mouse button */ w_current->popup_menu = (GtkWidget *) get_main_popup(w_current); /* Setup a GtkScrolledWindow for the drawing area */ hadjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, toplevel->init_right, 100.0, 100.0, 10.0)); vadjustment = GTK_ADJUSTMENT (gtk_adjustment_new (toplevel->init_bottom, 0.0, toplevel->init_bottom, 100.0, 100.0, 10.0)); w_current->scrolled = gtk_scrolled_window_new (hadjustment, vadjustment); gtk_container_add(GTK_CONTAINER(main_box), w_current->scrolled); x_window_create_drawing(w_current->scrolled, w_current); x_window_setup_draw_events(w_current); policy = (w_current->scrollbars_flag) ? GTK_POLICY_ALWAYS : GTK_POLICY_NEVER; gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (w_current->scrolled), policy, policy); hscrollbar = gtk_scrolled_window_get_hscrollbar (GTK_SCROLLED_WINDOW (w_current->scrolled)); gtk_range_set_update_policy (GTK_RANGE (hscrollbar), GTK_UPDATE_CONTINUOUS); vscrollbar = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (w_current->scrolled)); gtk_range_set_update_policy (GTK_RANGE (vscrollbar), GTK_UPDATE_CONTINUOUS); /* macro box */ w_current->macro_widget = GTK_WIDGET (g_object_new (GSCHEM_TYPE_MACRO_WIDGET, NULL)); gtk_box_pack_start (GTK_BOX (main_box), w_current->macro_widget, FALSE, FALSE, 0); g_signal_connect (w_current->macro_widget, "response", G_CALLBACK (&x_window_invoke_macro), w_current); /* bottom box */ if (default_third_button == POPUP_ENABLED) { right_button_text = _("Menu/Cancel"); } else { right_button_text = _("Pan/Cancel"); } w_current->bottom_widget = GTK_WIDGET (g_object_new (GSCHEM_TYPE_BOTTOM_WIDGET, "grid-mode", gschem_options_get_grid_mode (w_current->options), "grid-size", gschem_options_get_snap_size (w_current->options), /* x_grid_query_drawn_spacing (w_current), -- occurs before the page is set */ "left-button-text", _("Pick"), "middle-button-text", _("none"), "right-button-text", right_button_text, "snap-mode", gschem_options_get_snap_mode (w_current->options), "snap-size", gschem_options_get_snap_size (w_current->options), "status-text", _("Select Mode"), NULL)); i_update_middle_button (w_current, NULL, NULL); gtk_box_pack_start (GTK_BOX (main_box), w_current->bottom_widget, FALSE, FALSE, 0); gtk_widget_show_all (w_current->main_window); w_current->window = w_current->drawing_area->window; w_current->drawable = w_current->window; x_window_setup_gc(w_current); }
void set_menu(void* hwnd, wchar_t const* filename) { CFBundleRef mainBundle = CFBundleGetMainBundle(); CFURLRef pluginURL = CFBundleCopyBuiltInPlugInsURL(mainBundle); CFStringRef fn = CFStringCreateWithWString(kCFAllocatorDefault, filename, kCFStringEncodingUTF8); CFURLRef path = CFURLCreateCopyAppendingPathComponent(NULL, pluginURL, fn, FALSE); CFBundleRef bundle = CFBundleCreate(kCFAllocatorSystemDefault, path); CFRelease(path); CFRelease(fn); CFRelease(pluginURL); if (bundle==NULL) throw filename; FuncLoadMenu func = reinterpret_cast<FuncLoadMenu>(CFBundleGetFunctionPointerForName(bundle, CFSTR("load_menu"))); if (func==NULL) { CFRelease(bundle); throw filename; } #elif _MSC_VER void set_menu(HWND hwnd, wchar_t const* filename) { wstring path = wstring(L"dll\\")+filename; HMODULE handle = LoadLibrary(path.c_str()); FuncLoadMenu func = (FuncLoadMenu)GetProcAddress(handle, "load_menu"); if (func==0) throw path.c_str(); #endif unordered_map<int, wstring> menu; func(menu); #ifdef __APPLE__ HMENU hmenu = get_main_menu(); unsigned int main_menu_id = get_file_menu_pos(hmenu); int mii = NULL; #elif _MSC_VER HMENU hmenu = CreateMenu(); UINT main_menu_id = 0; MENUITEMINFO mii; #else #error Not implemented #endif //////////////////////////////////////////////////////////////////////////////// // FILE #ifdef __APPLE__ HMENU hmenu_file = get_file_menu(hmenu); ++main_menu_id; #else HMENU hmenu_file = create_submenu(mii, hmenu, main_menu_id, menu, IDM_FILE); #endif { #ifndef __APPLE__ unsigned int pos = 0; create_menuitem(mii, hmenu_file, pos, menu, IDM_FILE_CANCEL); create_separator(mii, hmenu_file, pos); create_menuitem(mii, hmenu_file, pos, menu, IDM_FILE_QUIT); #endif } //////////////////////////////////////////////////////////////////////////////// // EDIT HMENU hmenu_edit = create_submenu(mii, hmenu, main_menu_id, menu, IDM_EDIT); { unsigned int pos = 0; HMENU hmenu_edit_select_current = create_submenu(mii, hmenu_edit, pos, menu, IDM_EDIT_MARK_ON_CURRENT_LAYER); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_ALL_NODES_ON_CURRENT_LAYER); create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_ALL_EDGES_ON_CURRENT_LAYER); create_separator(mii, hmenu_edit_select_current, pos); create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_NODES_INSIDE_COMMUNITY_ON_CURRENT_LAYER); create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_EDGES_INSIDE_COMMUNITY_ON_CURRENT_LAYER); create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_ELEMENTS_INSIDE_COMMUNITY_ON_CURRENT_LAYER); create_separator(mii, hmenu_edit_select_current, pos); create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_NODES_OUTSIDE_COMMUNITY_ON_CURRENT_LAYER); create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_EDGES_OUTSIDE_COMMUNITY_ON_CURRENT_LAYER); create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_ELEMENTS_OUTSIDE_COMMUNITY_ON_CURRENT_LAYER); create_separator(mii, hmenu_edit_select_current, pos); create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_NODES_IN_SELECTED_COMMUNITY_CONTINUUMS_ON_CURRENT_LAYER); create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_EDGES_IN_SELECTED_COMMUNITY_CONTINUUMS_ON_CURRENT_LAYER); create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_ELEMENTS_IN_SELECTED_COMMUNITY_CONTINUUMS_ON_CURRENT_LAYER); create_separator(mii, hmenu_edit_select_current, pos); create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_ALL_ELEMENTS_ON_CURRENT_LAYER); create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_INVERT_MARK_ON_CURRENT_LAYER); } HMENU hmenu_edit_select_all = create_submenu(mii, hmenu_edit, pos, menu, IDM_EDIT_MARK_ON_EACH_LAYER); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_ALL_NODES_ON_EACH_LAYER); create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_ALL_EDGES_ON_EACH_LAYER); create_separator(mii, hmenu_edit_select_all, pos); create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_NODES_INSIDE_COMMUNITY_ON_EACH_LAYER); create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_EDGES_INSIDE_COMMUNITY_ON_EACH_LAYER); create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_ELEMENTS_INSIDE_COMMUNITY_ON_EACH_LAYER); create_separator(mii, hmenu_edit_select_all, pos); create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_NODES_OUTSIDE_COMMUNITY_ON_EACH_LAYER); create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_EDGES_OUTSIDE_COMMUNITY_ON_EACH_LAYER); create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_ELEMENTS_OUTSIDE_COMMUNITY_ON_EACH_LAYER); create_separator(mii, hmenu_edit_select_all, pos); create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_NODES_IN_SELECTED_COMMUNITY_CONTINUUMS_ON_EACH_LAYER); create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_EDGES_IN_SELECTED_COMMUNITY_CONTINUUMS_ON_EACH_LAYER); create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_ELEMENTS_IN_SELECTED_COMMUNITY_CONTINUUMS_ON_EACH_LAYER); create_separator(mii, hmenu_edit_select_all, pos); create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_ALL_ELEMENTS_ON_EACH_LAYER); create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_INVERT_MARK_ON_EACH_LAYER); } create_separator(mii, hmenu_edit, pos); HMENU hmenu_edit_hide = create_submenu(mii, hmenu_edit, pos, menu, IDM_EDIT_HIDE_MARKED_ELEMENTS); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_edit_hide, pos, menu, IDM_EDIT_HIDE_MARKED_NODES_ON_CURRENT_LAYER); create_menuitem(mii, hmenu_edit_hide, pos, menu, IDM_EDIT_HIDE_MARKED_EDGES_ON_CURRENT_LAYER); create_menuitem(mii, hmenu_edit_hide, pos, menu, IDM_EDIT_HIDE_MARKED_ELEMENTS_ON_CURRENT_LAYER); create_separator(mii, hmenu_edit_hide, pos); create_menuitem(mii, hmenu_edit_hide, pos, menu, IDM_EDIT_HIDE_MARKED_NODES_ON_EACH_LAYER); create_menuitem(mii, hmenu_edit_hide, pos, menu, IDM_EDIT_HIDE_MARKED_EDGES_ON_EACH_LAYER); create_menuitem(mii, hmenu_edit_hide, pos, menu, IDM_EDIT_HIDE_MARKED_ELEMENTS_ON_EACH_LAYER); } HMENU hmenu_edit_hide_all = create_submenu(mii, hmenu_edit, pos, menu, IDM_EDIT_HIDE_MARKED_ELEMENTS_ALL); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_edit_hide_all, pos, menu, IDM_EDIT_HIDE_MARKED_NODES_ON_CURRENT_LAYER_ALL); create_menuitem(mii, hmenu_edit_hide_all, pos, menu, IDM_EDIT_HIDE_MARKED_EDGES_ON_CURRENT_LAYER_ALL); create_menuitem(mii, hmenu_edit_hide_all, pos, menu, IDM_EDIT_HIDE_MARKED_ELEMENTS_ON_CURRENT_LAYER_ALL); create_separator(mii, hmenu_edit_hide_all, pos); create_menuitem(mii, hmenu_edit_hide_all, pos, menu, IDM_EDIT_HIDE_MARKED_NODES_ON_EACH_LAYER_ALL); create_menuitem(mii, hmenu_edit_hide_all, pos, menu, IDM_EDIT_HIDE_MARKED_EDGES_ON_EACH_LAYER_ALL); create_menuitem(mii, hmenu_edit_hide_all, pos, menu, IDM_EDIT_HIDE_MARKED_ELEMENTS_ON_EACH_LAYER_ALL); } HMENU hmenu_edit_show = create_submenu(mii, hmenu_edit, pos, menu, IDM_EDIT_SHOW_HIDDEN_ELEMENTS); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_edit_show, pos, menu, IDM_EDIT_SHOW_HIDDEN_NODES_ON_CURRENT_LAYER); create_menuitem(mii, hmenu_edit_show, pos, menu, IDM_EDIT_SHOW_HIDDEN_EDGES_ON_CURRENT_LAYER); create_menuitem(mii, hmenu_edit_show, pos, menu, IDM_EDIT_SHOW_HIDDEN_ELEMENTS_ON_CURRENT_LAYER); create_separator(mii, hmenu_edit_show, pos); create_menuitem(mii, hmenu_edit_show, pos, menu, IDM_EDIT_SHOW_HIDDEN_NODES_ON_EACH_LAYER); create_menuitem(mii, hmenu_edit_show, pos, menu, IDM_EDIT_SHOW_HIDDEN_EDGES_ON_EACH_LAYER); create_menuitem(mii, hmenu_edit_show, pos, menu, IDM_EDIT_SHOW_HIDDEN_ELEMENTS_ON_EACH_LAYER); } create_separator(mii, hmenu_edit, pos); HMENU hmenu_edit_remove = create_submenu(mii, hmenu_edit, pos, menu, IDM_EDIT_REMOVE_MARKED_ELEMENTS); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_edit_remove, pos, menu, IDM_EDIT_REMOVE_MARKED_NODES_ON_CURRENT_LAYER); create_menuitem(mii, hmenu_edit_remove, pos, menu, IDM_EDIT_REMOVE_MARKED_EDGES_ON_CURRENT_LAYER); create_menuitem(mii, hmenu_edit_remove, pos, menu, IDM_EDIT_REMOVE_MARKED_ELEMENTS_ON_CURRENT_LAYER); create_separator(mii, hmenu_edit_remove, pos); create_menuitem(mii, hmenu_edit_remove, pos, menu, IDM_EDIT_REMOVE_MARKED_NODES_ON_EACH_LAYER); create_menuitem(mii, hmenu_edit_remove, pos, menu, IDM_EDIT_REMOVE_MARKED_EDGES_ON_EACH_LAYER); create_menuitem(mii, hmenu_edit_remove, pos, menu, IDM_EDIT_REMOVE_MARKED_ELEMENTS_ON_EACH_LAYER); } HMENU hmenu_edit_remove_all = create_submenu(mii, hmenu_edit, pos, menu, IDM_EDIT_REMOVE_MARKED_ELEMENTS_ALL); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_edit_remove_all, pos, menu, IDM_EDIT_REMOVE_MARKED_NODES_ON_CURRENT_LAYER_ALL); create_menuitem(mii, hmenu_edit_remove_all, pos, menu, IDM_EDIT_REMOVE_MARKED_EDGES_ON_CURRENT_LAYER_ALL); create_menuitem(mii, hmenu_edit_remove_all, pos, menu, IDM_EDIT_REMOVE_MARKED_ELEMENTS_ON_CURRENT_LAYER_ALL); create_separator(mii, hmenu_edit_remove_all, pos); create_menuitem(mii, hmenu_edit_remove_all, pos, menu, IDM_EDIT_REMOVE_MARKED_NODES_ON_EACH_LAYER_ALL); create_menuitem(mii, hmenu_edit_remove_all, pos, menu, IDM_EDIT_REMOVE_MARKED_EDGES_ON_EACH_LAYER_ALL); create_menuitem(mii, hmenu_edit_remove_all, pos, menu, IDM_EDIT_REMOVE_MARKED_ELEMENTS_ON_EACH_LAYER_ALL); } } //////////////////////////////////////////////////////////////////////////////// // VIEW HMENU hmenu_view = create_submenu(mii, hmenu, main_menu_id, menu, IDM_VIEW); { unsigned int pos = 0; create_menuitem(mii, hmenu_view, pos, menu, IDM_VIEW_SHOW_NODE); create_menuitem(mii, hmenu_view, pos, menu, IDM_VIEW_SHOW_EDGE); create_menuitem(mii, hmenu_view, pos, menu, IDM_VIEW_SHOW_COMMUNITY); create_menuitem(mii, hmenu_view, pos, menu, IDM_VIEW_SHOW_COMMUNITY_EDGE); create_separator(mii, hmenu_view, pos); HMENU hmenu_view_node_size = create_submenu(mii, hmenu_view, pos, menu, IDM_VIEW_NODE_SIZE); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_view_node_size, pos, menu, IDM_VIEW_NODE_SIZE_UPDATE); create_menuitem(mii, hmenu_view_node_size, pos, menu, IDM_VIEW_NODE_SIZE_CANCEL); create_separator(mii, hmenu_view_node_size, pos); create_menuitem(mii, hmenu_view_node_size, pos, menu, IDM_VIEW_NODE_SIZE_UNIFORM); create_menuitem(mii, hmenu_view_node_size, pos, menu, IDM_VIEW_NODE_SIZE_WEIGHT); create_menuitem(mii, hmenu_view_node_size, pos, menu, IDM_VIEW_NODE_SIZE_DEGREE_CENTRALITY); create_menuitem(mii, hmenu_view_node_size, pos, menu, IDM_VIEW_NODE_SIZE_CLOSENESS_CENTRALITY); create_menuitem(mii, hmenu_view_node_size, pos, menu, IDM_VIEW_NODE_SIZE_BETWEENNESS_CENTRALITY); create_menuitem(mii, hmenu_view_node_size, pos, menu, IDM_VIEW_NODE_SIZE_PAGERANK); create_menuitem(mii, hmenu_view_node_size, pos, menu, IDM_VIEW_NODE_SIZE_POINT); } HMENU hmenu_view_edge_width = create_submenu(mii, hmenu_view, pos, menu, IDM_VIEW_EDGE_WIDTH); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_view_edge_width, pos, menu, IDM_VIEW_EDGE_WIDTH_UPDATE); create_menuitem(mii, hmenu_view_edge_width, pos, menu, IDM_VIEW_EDGE_WIDTH_CANCEL); create_separator(mii, hmenu_view_edge_width, pos); create_menuitem(mii, hmenu_view_edge_width, pos, menu, IDM_VIEW_EDGE_WIDTH_UNIFORM); create_menuitem(mii, hmenu_view_edge_width, pos, menu, IDM_VIEW_EDGE_WIDTH_WEIGHT); create_menuitem(mii, hmenu_view_edge_width, pos, menu, IDM_VIEW_EDGE_WIDTH_BETWEENNESS_CENTRALITY); } create_separator(mii, hmenu_view, pos); HMENU hmenu_view_node_style = create_submenu(mii, hmenu_view, pos, menu, IDM_VIEW_NODE_STYLE); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_view_node_style, pos, menu, IDM_VIEW_NODE_STYLE_POLYGON); create_menuitem(mii, hmenu_view_node_style, pos, menu, IDM_VIEW_NODE_STYLE_TEXTURE); } HMENU hmenu_view_edge_style = create_submenu(mii, hmenu_view, pos, menu, IDM_VIEW_EDGE_STYLE); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_view_edge_style, pos, menu, IDM_VIEW_EDGE_STYLE_LINE); create_menuitem(mii, hmenu_view_edge_style, pos, menu, IDM_VIEW_EDGE_STYLE_POLYGON); } HMENU hmenu_view_community_style = create_submenu(mii, hmenu_view, pos, menu, IDM_VIEW_COMMUNITY_STYLE); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_view_community_style, pos, menu, IDM_VIEW_COMMUNITY_STYLE_POLYGON_CIRCLE); create_menuitem(mii, hmenu_view_community_style, pos, menu, IDM_VIEW_COMMUNITY_STYLE_TEXTURE); } HMENU hmenu_view_community_edge_style = create_submenu(mii, hmenu_view, pos, menu, IDM_VIEW_COMMUNITY_EDGE_STYLE); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_view_community_edge_style, pos, menu, IDM_VIEW_COMMUNITY_EDGE_STYLE_LINE); create_menuitem(mii, hmenu_view_community_edge_style, pos, menu, IDM_VIEW_COMMUNITY_EDGE_STYLE_POLYGON); } } //////////////////////////////////////////////////////////////////////////////// // STRING HMENU hmenu_string = create_submenu(mii, hmenu, main_menu_id, menu, IDM_STRING); { unsigned int pos = 0; create_menuitem(mii, hmenu_string, pos, menu, IDM_STRING_SHOW_NODE_NAME); create_menuitem(mii, hmenu_string, pos, menu, IDM_STRING_SHOW_EDGE_NAME); create_menuitem(mii, hmenu_string, pos, menu, IDM_STRING_SHOW_COMMUNITY_NAME); create_menuitem(mii, hmenu_string, pos, menu, IDM_STRING_SHOW_COMMUNITY_EDGE_NAME); create_separator(mii, hmenu_string, pos); HMENU hmenu_string_node_name_size = create_submenu(mii, hmenu_string, pos, menu, IDM_STRING_NODE_NAME_SIZE); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_string_node_name_size, pos, menu, IDM_STRING_NODE_NAME_SIZE_VARIABLE); create_separator(mii, hmenu_string_node_name_size, pos); create_menuitem(mii, hmenu_string_node_name_size, pos, menu, IDM_STRING_NODE_NAME_SIZE_0); create_menuitem(mii, hmenu_string_node_name_size, pos, menu, IDM_STRING_NODE_NAME_SIZE_1); create_menuitem(mii, hmenu_string_node_name_size, pos, menu, IDM_STRING_NODE_NAME_SIZE_2); create_menuitem(mii, hmenu_string_node_name_size, pos, menu, IDM_STRING_NODE_NAME_SIZE_3); create_menuitem(mii, hmenu_string_node_name_size, pos, menu, IDM_STRING_NODE_NAME_SIZE_4); } HMENU hmenu_string_edge_name_size = create_submenu(mii, hmenu_string, pos, menu, IDM_STRING_EDGE_NAME_SIZE); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_string_edge_name_size, pos, menu, IDM_STRING_EDGE_NAME_SIZE_VARIABLE); create_separator(mii, hmenu_string_edge_name_size, pos); create_menuitem(mii, hmenu_string_edge_name_size, pos, menu, IDM_STRING_EDGE_NAME_SIZE_0); create_menuitem(mii, hmenu_string_edge_name_size, pos, menu, IDM_STRING_EDGE_NAME_SIZE_1); create_menuitem(mii, hmenu_string_edge_name_size, pos, menu, IDM_STRING_EDGE_NAME_SIZE_2); create_menuitem(mii, hmenu_string_edge_name_size, pos, menu, IDM_STRING_EDGE_NAME_SIZE_3); create_menuitem(mii, hmenu_string_edge_name_size, pos, menu, IDM_STRING_EDGE_NAME_SIZE_4); } HMENU hmenu_string_community_name_size = create_submenu(mii, hmenu_string, pos, menu, IDM_STRING_COMMUNITY_NAME_SIZE); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_string_community_name_size, pos, menu, IDM_STRING_COMMUNITY_NAME_SIZE_VARIABLE); create_separator(mii, hmenu_string_community_name_size, pos); create_menuitem(mii, hmenu_string_community_name_size, pos, menu, IDM_STRING_COMMUNITY_NAME_SIZE_0); create_menuitem(mii, hmenu_string_community_name_size, pos, menu, IDM_STRING_COMMUNITY_NAME_SIZE_1); create_menuitem(mii, hmenu_string_community_name_size, pos, menu, IDM_STRING_COMMUNITY_NAME_SIZE_2); create_menuitem(mii, hmenu_string_community_name_size, pos, menu, IDM_STRING_COMMUNITY_NAME_SIZE_3); create_menuitem(mii, hmenu_string_community_name_size, pos, menu, IDM_STRING_COMMUNITY_NAME_SIZE_4); } HMENU hmenu_string_community_edge_name_size = create_submenu(mii, hmenu_string, pos, menu, IDM_STRING_COMMUNITY_EDGE_NAME_SIZE); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_string_community_edge_name_size, pos, menu, IDM_STRING_COMMUNITY_EDGE_NAME_SIZE_VARIABLE); create_separator(mii, hmenu_string_community_edge_name_size, pos); create_menuitem(mii, hmenu_string_community_edge_name_size, pos, menu, IDM_STRING_COMMUNITY_EDGE_NAME_SIZE_0); create_menuitem(mii, hmenu_string_community_edge_name_size, pos, menu, IDM_STRING_COMMUNITY_EDGE_NAME_SIZE_1); create_menuitem(mii, hmenu_string_community_edge_name_size, pos, menu, IDM_STRING_COMMUNITY_EDGE_NAME_SIZE_2); create_menuitem(mii, hmenu_string_community_edge_name_size, pos, menu, IDM_STRING_COMMUNITY_EDGE_NAME_SIZE_3); create_menuitem(mii, hmenu_string_community_edge_name_size, pos, menu, IDM_STRING_COMMUNITY_EDGE_NAME_SIZE_4); } create_separator(mii, hmenu_string, pos); HMENU hmenu_string_type = create_submenu(mii, hmenu_string, pos, menu, IDM_STRING_FONT_TYPE); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_string_type, pos, menu, IDM_STRING_FONT_TYPE_POLYGON); create_menuitem(mii, hmenu_string_type, pos, menu, IDM_STRING_FONT_TYPE_TEXTURE); } create_separator(mii, hmenu_string, pos); create_menuitem(mii, hmenu_string, pos, menu, IDM_STRING_SHOW_LAYER_NAME); create_menuitem(mii, hmenu_string, pos, menu, IDM_STRING_SHOW_FPS); } //////////////////////////////////////////////////////////////////////////////// // LAYOUT HMENU hmenu_layout = create_submenu(mii, hmenu, main_menu_id, menu, IDM_LAYOUT); { unsigned int pos = 0; create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_UPDATE); create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_CANCEL); create_separator(mii, hmenu_layout, pos); create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_KAMADA_KAWAI_METHOD); HMENU hmenu_layout_hde = create_submenu(mii, hmenu_layout, pos, menu, IDM_LAYOUT_HIGH_DIMENSIONAL_EMBEDDING); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_layout_hde, pos, menu, IDM_LAYOUT_HIGH_DIMENSIONAL_EMBEDDING_1_2); create_menuitem(mii, hmenu_layout_hde, pos, menu, IDM_LAYOUT_HIGH_DIMENSIONAL_EMBEDDING_1_3); create_menuitem(mii, hmenu_layout_hde, pos, menu, IDM_LAYOUT_HIGH_DIMENSIONAL_EMBEDDING_2_3); } create_separator(mii, hmenu_layout, pos); create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_CIRCLE); create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_CIRCLE_IN_SIZE_ORDER); create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_LATTICE); create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_RANDOM); create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_CARTOGRAMS); create_separator(mii, hmenu_layout, pos); HMENU hmenu_layout_fde = create_submenu(mii, hmenu_layout, pos, menu, IDM_LAYOUT_FORCE_DIRECTION); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_layout_fde, pos, menu, IDM_LAYOUT_FORCE_DIRECTION_RUN); create_separator(mii, hmenu_layout_fde, pos); create_menuitem(mii, hmenu_layout_fde, pos, menu, IDM_LAYOUT_FORCE_DIRECTION_KAMADA_KAWAI_METHOD); create_menuitem(mii, hmenu_layout_fde, pos, menu, IDM_LAYOUT_FORCE_DIRECTION_KAMADA_KAWAI_METHOD_WITH_COMMUNITY_SEPARATION); create_menuitem(mii, hmenu_layout_fde, pos, menu, IDM_LAYOUT_FORCE_DIRECTION_COMMUNITY_ORIENTED); create_separator(mii, hmenu_layout_fde, pos); create_menuitem(mii, hmenu_layout_fde, pos, menu, IDM_LAYOUT_FORCE_DIRECTION_SPRING_AND_REPULSIVE_FORCE); create_menuitem(mii, hmenu_layout_fde, pos, menu, IDM_LAYOUT_FORCE_DIRECTION_LATTICE_GAS_METHOD); #if 0 create_menuitem(mii, hmenu_layout_fde, pos, menu, IDM_LAYOUT_FORCE_DIRECTION_DESIGNTIDE); #endif } create_separator(mii, hmenu_layout, pos); create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_SHOW_LAYOUT_FRAME); create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_INITIALIZE_LAYOUT_FRAME); create_separator(mii, hmenu_layout, pos); create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_SHOW_GRID); create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_SHOW_CENTER); create_separator(mii, hmenu_layout, pos); create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_INITIALIZE_EYEPOINT); create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_ZOOM_IN); create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_ZOOM_OUT); } //////////////////////////////////////////////////////////////////////////////// // COMMUNITY HMENU hmenu_community = create_submenu(mii, hmenu, main_menu_id, menu, IDM_COMMUNITY_DETECTION); { unsigned int pos = 0; create_menuitem(mii, hmenu_community, pos, menu, IDM_COMMUNITY_DETECTION_UPDATE); create_menuitem(mii, hmenu_community, pos, menu, IDM_COMMUNITY_DETECTION_CANCEL); create_separator(mii, hmenu_community, pos); HMENU hmenu_community_connected_components = create_submenu(mii, hmenu_community, pos, menu, IDM_COMMUNITY_DETECTION_CONNECTED_COMPONENTS); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_community_connected_components, pos, menu, IDM_COMMUNITY_DETECTION_WEAKLY_CONNECTED_COMPONENTS); create_menuitem(mii, hmenu_community_connected_components, pos, menu, IDM_COMMUNITY_DETECTION_STRONGLY_CONNECTED_COMPONENTS); } HMENU hmenu_community_modularity_maximization = create_submenu(mii, hmenu_community, pos, menu, IDM_COMMUNITY_DETECTION_MODULARITY_MAXIMIZATION); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_community_modularity_maximization, pos, menu, IDM_COMMUNITY_DETECTION_MODULARITY_MAXIMIZATION_USING_GREEDY_METHOD); create_menuitem(mii, hmenu_community_modularity_maximization, pos, menu, IDM_COMMUNITY_DETECTION_MODULARITY_MAXIMIZATION_USING_TEO_METHOD); create_separator(mii, hmenu_community_modularity_maximization, pos); create_menuitem(mii, hmenu_community_modularity_maximization, pos, menu, IDM_COMMUNITY_DETECTION_USE_WEIGHTED_MODULARITY); } HMENU hmenu_community_clique_percolaion = create_submenu(mii, hmenu_community, pos, menu, IDM_COMMUNITY_DETECTION_CLIQUE_PERCOLATION); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_community_clique_percolaion, pos, menu, IDM_COMMUNITY_DETECTION_CLIQUE_PERCOLATION_3); create_menuitem(mii, hmenu_community_clique_percolaion, pos, menu, IDM_COMMUNITY_DETECTION_CLIQUE_PERCOLATION_4); create_menuitem(mii, hmenu_community_clique_percolaion, pos, menu, IDM_COMMUNITY_DETECTION_CLIQUE_PERCOLATION_5); } HMENU hmenu_community_others = create_submenu(mii, hmenu_community, pos, menu, IDM_COMMUNITY_DETECTION_OTHERS); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_community_others, pos, menu, IDM_COMMUNITY_DETECTION_BETWEENNESS_CENTRALITY_SEPARATION); #if 0 create_menuitem(mii, hmenu_community_others, pos, menu, IDM_COMMUNITY_DETECTION_INFORMATION_FLOW_MAPPING); #endif } create_separator(mii, hmenu_community, pos); create_menuitem(mii, hmenu_community, pos, menu, IDM_COMMUNITY_TRANSITION_DIAGRAM); create_menuitem(mii, hmenu_community, pos, menu, IDM_COMMUNITY_TRANSITION_DIAGRAM_SCOPE_WIDER); create_menuitem(mii, hmenu_community, pos, menu, IDM_COMMUNITY_TRANSITION_DIAGRAM_SCOPE_NARROWER); create_separator(mii, hmenu_community, pos); create_menuitem(mii, hmenu_community, pos, menu, IDM_COMMUNITY_DETECTION_CLEAR); } //////////////////////////////////////////////////////////////////////////////// // TIMELINE HMENU hmenu_timeline = create_submenu(mii, hmenu, main_menu_id, menu, IDM_TIMELINE); { unsigned int pos = 0; create_menuitem(mii, hmenu_timeline, pos, menu, IDM_TIMELINE_NEXT); create_menuitem(mii, hmenu_timeline, pos, menu, IDM_TIMELINE_PREV); create_separator(mii, hmenu_timeline, pos); HMENU hmenu_timeline_auto = create_submenu(mii, hmenu_timeline, pos, menu, IDM_TIMELINE_AUTO_RUN); { #ifdef __APPLE__ unsigned int pos = 0; #endif create_menuitem(mii, hmenu_timeline_auto, pos, menu, IDM_TIMELINE_STOP); create_separator(mii, hmenu_timeline_auto, pos); create_menuitem(mii, hmenu_timeline_auto, pos, menu, IDM_TIMELINE_FORWARD_1); create_menuitem(mii, hmenu_timeline_auto, pos, menu, IDM_TIMELINE_FORWARD_2); create_menuitem(mii, hmenu_timeline_auto, pos, menu, IDM_TIMELINE_FORWARD_3); create_menuitem(mii, hmenu_timeline_auto, pos, menu, IDM_TIMELINE_FORWARD_4); create_separator(mii, hmenu_timeline_auto, pos); create_menuitem(mii, hmenu_timeline_auto, pos, menu, IDM_TIMELINE_BACKWARD_1); create_menuitem(mii, hmenu_timeline_auto, pos, menu, IDM_TIMELINE_BACKWARD_2); create_menuitem(mii, hmenu_timeline_auto, pos, menu, IDM_TIMELINE_BACKWARD_3); create_menuitem(mii, hmenu_timeline_auto, pos, menu, IDM_TIMELINE_BACKWARD_4); } create_separator(mii, hmenu_timeline, pos); create_menuitem(mii, hmenu_timeline, pos, menu, IDM_TIMELINE_SHOW_SLIDER); } #ifdef __APPLE__ CFRelease(bundle); #elif _MSC_VER SetMenu(hwnd, hmenu); FreeLibrary(handle); #else #error Not implemented #endif }
/*! \todo Finish function documentation!!! * \brief * \par Function Description * */ void x_window_create_main(GSCHEM_TOPLEVEL *w_current) { TOPLEVEL *toplevel = w_current->toplevel; GtkWidget *label=NULL; GtkWidget *main_box=NULL; GtkWidget *menubar=NULL; GtkWidget *drawbox=NULL; GtkWidget *bottom_box=NULL; GtkWidget *toolbar=NULL; GtkWidget *handlebox=NULL; /* used to signify that the window isn't mapped yet */ w_current->window = NULL; w_current->main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_set_name (w_current->main_window, "gschem"); gtk_window_set_policy (GTK_WINDOW (w_current->main_window), TRUE, TRUE, TRUE); /* We want the widgets to flow around the drawing area, so we don't * set a size of the main window. The drawing area's size is fixed, * see below */ /* * normally we let the window manager handle locating and sizing * the window. However, for some batch processing of schematics * (generating a pdf of all schematics for example) we want to * override this. Hence "auto_place_mode". */ if( auto_place_mode ) gtk_widget_set_uposition (w_current->main_window, 10, 10); /* this should work fine */ g_signal_connect (G_OBJECT (w_current->main_window), "delete_event", G_CALLBACK (i_callback_close_wm), w_current); /* Containers first */ main_box = gtk_vbox_new(FALSE, 1); gtk_container_border_width(GTK_CONTAINER(main_box), 0); gtk_container_add(GTK_CONTAINER(w_current->main_window), main_box); menubar = get_main_menu (w_current); if (w_current->handleboxes) { handlebox = gtk_handle_box_new (); gtk_box_pack_start(GTK_BOX(main_box), handlebox, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (handlebox), menubar); } else { gtk_box_pack_start(GTK_BOX(main_box), menubar, FALSE, FALSE, 0); } w_current->menubar = menubar; gtk_widget_realize (w_current->main_window); if (w_current->handleboxes && w_current->toolbars) { handlebox = gtk_handle_box_new (); gtk_box_pack_start (GTK_BOX (main_box), handlebox, FALSE, FALSE, 0); } if (w_current->toolbars) { toolbar = gtk_toolbar_new(); gtk_toolbar_set_orientation (GTK_TOOLBAR(toolbar), GTK_ORIENTATION_HORIZONTAL); gtk_toolbar_set_style (GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS); if (w_current->handleboxes) { gtk_container_add (GTK_CONTAINER (handlebox), toolbar); } else { gtk_box_pack_start(GTK_BOX(main_box), toolbar, FALSE, FALSE, 0); } gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), _("New"), _("New file"), "toolbar/new", x_window_stock_pixmap("new", w_current), (GtkSignalFunc) i_callback_toolbar_file_new, w_current); gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), _("Open"), _("Open file..."), "toolbar/open", x_window_stock_pixmap("open", w_current), (GtkSignalFunc) i_callback_toolbar_file_open, w_current); gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), _("Save"), _("Save file"), "toolbar/save", x_window_stock_pixmap("save", w_current), (GtkSignalFunc) i_callback_toolbar_file_save, w_current); gtk_toolbar_append_space (GTK_TOOLBAR(toolbar)); gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), _("Undo"), _("Undo last operation"), "toolbar/undo", x_window_stock_pixmap("undo", w_current), (GtkSignalFunc) i_callback_toolbar_edit_undo, w_current); gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), _("Redo"), _("Redo last undo"), "toolbar/redo", x_window_stock_pixmap("redo", w_current), (GtkSignalFunc) i_callback_toolbar_edit_redo, w_current); gtk_toolbar_append_space (GTK_TOOLBAR(toolbar)); /* not part of any radio button group */ gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), _("Component"), _("Add component...\nSelect library and component from list, move the mouse into main window, click to place\nRight mouse button to cancel"), "toolbar/component", x_window_stock_pixmap("comp", w_current), (GtkSignalFunc) i_callback_toolbar_add_component, w_current); w_current->toolbar_net = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_CHILD_RADIOBUTTON, NULL, _("Nets"), _("Add nets mode\nRight mouse button to cancel"), "toolbar/nets", x_window_stock_pixmap("net", w_current), (GtkSignalFunc) i_callback_toolbar_add_net, w_current); w_current->toolbar_bus = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_CHILD_RADIOBUTTON, w_current->toolbar_net, _("Bus"), _("Add buses mode\nRight mouse button to cancel"), "toolbar/bus", x_window_stock_pixmap("bus", w_current), (GtkSignalFunc) i_callback_toolbar_add_bus, w_current); /* not part of any radio button group */ gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), _("Text"), _("Add Text..."), "toolbar/text", x_window_stock_pixmap("text", w_current), (GtkSignalFunc) i_callback_toolbar_add_text, w_current); gtk_toolbar_append_space (GTK_TOOLBAR(toolbar)); w_current->toolbar_select = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_CHILD_RADIOBUTTON, w_current->toolbar_bus, _("Select"), _("Select mode"), "toolbar/select", x_window_stock_pixmap("select", w_current), (GtkSignalFunc) i_callback_toolbar_edit_select, w_current); gtk_toolbar_append_space (GTK_TOOLBAR(toolbar)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w_current->toolbar_select), TRUE); } /* Try to create popup menu (appears in right mouse button */ w_current->popup_menu = (GtkWidget *) get_main_popup(w_current); drawbox = gtk_hbox_new(FALSE, 0); gtk_container_border_width(GTK_CONTAINER(drawbox), 0); gtk_container_add(GTK_CONTAINER(main_box), drawbox); x_window_create_drawing(drawbox, w_current); x_window_setup_draw_events(w_current); if (w_current->scrollbars_flag == TRUE) { /* setup scroll bars */ w_current->v_adjustment = GTK_ADJUSTMENT ( gtk_adjustment_new (toplevel->init_bottom, 0.0, toplevel->init_bottom, 100.0, 100.0, 10.0)); w_current->v_scrollbar = gtk_vscrollbar_new (w_current->v_adjustment); gtk_range_set_update_policy (GTK_RANGE (w_current->v_scrollbar), GTK_UPDATE_CONTINUOUS); gtk_box_pack_start (GTK_BOX (drawbox), w_current->v_scrollbar, FALSE, FALSE, 0); g_signal_connect (w_current->v_adjustment, "value_changed", G_CALLBACK (x_event_vschanged), w_current); w_current->h_adjustment = GTK_ADJUSTMENT ( gtk_adjustment_new (0.0, 0.0, toplevel->init_right, 100.0, 100.0, 10.0)); w_current->h_scrollbar = gtk_hscrollbar_new (w_current->h_adjustment); gtk_range_set_update_policy (GTK_RANGE (w_current->h_scrollbar), GTK_UPDATE_CONTINUOUS); gtk_box_pack_start (GTK_BOX (main_box), w_current->h_scrollbar, FALSE, FALSE, 0); g_signal_connect (w_current->h_adjustment, "value_changed", G_CALLBACK (x_event_hschanged), w_current); } /* macro box */ w_current->macro_entry = gtk_entry_new(); g_signal_connect(w_current->macro_entry, "activate", G_CALLBACK(&x_window_invoke_macro), w_current); w_current->macro_box = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(w_current->macro_box), w_current->macro_entry, TRUE, TRUE, 2); gtk_container_border_width(GTK_CONTAINER(w_current->macro_box), 1); gtk_box_pack_start (GTK_BOX (main_box), w_current->macro_box, FALSE, FALSE, 0); /* bottom box */ bottom_box = gtk_hbox_new(FALSE, 0); gtk_container_border_width(GTK_CONTAINER(bottom_box), 1); gtk_box_pack_start (GTK_BOX (main_box), bottom_box, FALSE, FALSE, 0); /* label = gtk_label_new ("Mouse buttons:"); gtk_box_pack_start (GTK_BOX (bottom_box), label, FALSE, FALSE, 10); */ label = gtk_label_new (" "); gtk_box_pack_start (GTK_BOX (bottom_box), label, FALSE, FALSE, 2); w_current->left_label = gtk_label_new (_("Pick")); gtk_box_pack_start (GTK_BOX (bottom_box), w_current->left_label, FALSE, FALSE, 0); label = gtk_label_new ("|"); gtk_box_pack_start (GTK_BOX (bottom_box), label, FALSE, FALSE, 5); if (w_current->middle_button == STROKE) { #ifdef HAVE_LIBSTROKE w_current->middle_label = gtk_label_new (_("Stroke")); #else w_current->middle_label = gtk_label_new (_("none")); #endif } else if (w_current->middle_button == ACTION) { w_current->middle_label = gtk_label_new (_("Action")); } else { w_current->middle_label = gtk_label_new (_("Repeat/none")); } gtk_box_pack_start (GTK_BOX (bottom_box), w_current->middle_label, FALSE, FALSE, 0); label = gtk_label_new ("|"); gtk_box_pack_start (GTK_BOX (bottom_box), label, FALSE, FALSE, 5); if (default_third_button == POPUP_ENABLED) { w_current->right_label = gtk_label_new (_("Menu/Cancel")); } else { w_current->right_label = gtk_label_new (_("Pan/Cancel")); } gtk_box_pack_start (GTK_BOX (bottom_box), w_current->right_label, FALSE, FALSE, 0); label = gtk_label_new (" "); gtk_box_pack_start (GTK_BOX (bottom_box), label, FALSE, FALSE, 5); w_current->grid_label = gtk_label_new (" "); gtk_box_pack_start (GTK_BOX (bottom_box), w_current->grid_label, FALSE, FALSE, 10); w_current->status_label = gtk_label_new (_("Select Mode")); gtk_box_pack_end (GTK_BOX (bottom_box), w_current->status_label, FALSE, FALSE, 10); gtk_widget_show_all (w_current->main_window); gtk_widget_hide(w_current->macro_box); w_current->window = w_current->drawing_area->window; w_current->drawable = w_current->window; x_window_setup_gc(w_current); }
int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *main_vbox; GtkWidget *menubar; GtkWidget *vbox; g_thread_init(NULL); gtk_init(&argc, &argv); gdk_init (&argc, &argv); gdk_rgb_init(); // buf= (unsigned char *)malloc (ROWS * COLS * DEPTH * sizeof (unsigned char)); //if (!buf) { // perror ("malloc buf"); // exit(0); // } open_dev(); /* abre e inicializa video */ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(gtk_main_quit), "WM destroy"); gtk_window_set_title(GTK_WINDOW(window), "NutoScope"); //gtk_widget_set_usize(GTK_WIDGET(window), COLS, ROWS); main_vbox = gtk_vbox_new(FALSE, 1); gtk_container_border_width(GTK_CONTAINER(main_vbox), 1); gtk_container_add(GTK_CONTAINER(window), main_vbox); gtk_widget_show(main_vbox); get_main_menu(window, &menubar); gtk_box_pack_start(GTK_BOX(main_vbox), menubar, FALSE, TRUE, 0); gtk_widget_show(menubar); darea = gtk_drawing_area_new(); gtk_box_pack_start (GTK_BOX (main_vbox), darea, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (darea), "expose-event", GTK_SIGNAL_FUNC (on_darea_expose), (gpointer) darea); gtk_drawing_area_size (GTK_DRAWING_AREA (darea), COLS, ROWS); gtk_widget_show(darea); status = gtk_statusbar_new (); gtk_box_pack_start (GTK_BOX (main_vbox), status, FALSE, FALSE, 0); context_id = gtk_statusbar_get_context_id( GTK_STATUSBAR(status), "Ready"); gtk_widget_show (status); gtk_widget_show(window); // load 50x50x3 logo logo_image=malloc(50*50*3); if (!logo_image) { perror("malloc logo "); exit; } load_pnm("logo.pnm", logo_image); // Queue frames for(frame=0; frame<grab_vm.frames; frame++) { grab_buf.frame = frame; if(ioctl(grab_fd, VIDIOCMCAPTURE, &grab_buf)<0) { perror("VIDIOCMCAPTURE"); exit(-1); } } gtk_timeout_add(25, send_expose, NULL); gdk_threads_enter(); gtk_main(); gdk_threads_leave(); return (0); }