int Module::handle ( int m ) { switch ( m ) { case FL_KEYBOARD: { if ( Fl_Group::handle( m ) ) return 1; if ( Fl::event_key() == FL_Menu ) { menu_popup( &menu(), x(), y() ); return 1; } else return menu().test_shortcut() != 0; } case FL_PUSH: { take_focus(); if ( Fl_Group::handle( m ) ) return 1; else if ( test_press( FL_BUTTON3 ) ) { menu_popup( &menu() ); return 1; } else if ( test_press( FL_BUTTON1 ) ) { command_open_parameter_editor(); return 1; } else if ( test_press( FL_BUTTON3 | FL_CTRL ) ) { command_remove(); return 1; } else if ( test_press( FL_BUTTON2 ) ) { bypass( !bypass() ); redraw(); return 1; } return 0; } case FL_FOCUS: case FL_UNFOCUS: redraw(); return 1; } return Fl_Group::handle( m ); }
void menu_chanmenu (struct session *sess, GdkEventButton * event, char *chan) { GtkWidget *menu; int is_joined = FALSE; if (find_channel (sess->server, chan)) is_joined = TRUE; if (str_copy) free (str_copy); str_copy = strdup (chan); menu = gtk_menu_new (); menu_quick_item (0, chan, menu, XCMENU_SHADED, str_copy, 0); menu_quick_item (0, 0, menu, XCMENU_SHADED, str_copy, 0); if (!is_joined) menu_quick_item_with_callback (menu_chan_join, _("Join Channel"), menu, str_copy); else { menu_quick_item_with_callback (menu_chan_part, _("Part Channel"), menu, str_copy); menu_quick_item_with_callback (menu_chan_cycle, _("Cycle Channel"), menu, str_copy); } menu_add_plugin_items (menu, "\x5$CHAN", str_copy); menu_popup (menu, event, NULL); }
void menu_urlmenu(GdkEventButton * event, char *url) { GtkWidget *menu; char *tmp, *chop; if (str_copy) free(str_copy); str_copy = strdup(url); menu = gtk_menu_new(); /* more than 51 chars? Chop it */ if (g_utf8_strlen(str_copy, -1) >= 52) { tmp = strdup(str_copy); chop = g_utf8_offset_to_pointer(tmp, 48); chop[0] = chop[1] = chop[2] = '.'; chop[3] = 0; menu_quick_item(0, tmp, menu, XCMENU_SHADED, 0, 0); free(tmp); } else { menu_quick_item(0, str_copy, menu, XCMENU_SHADED, 0, 0); } menu_quick_item(0, 0, menu, XCMENU_SHADED, 0, 0); /* Two hardcoded entries */ if (strncmp(str_copy, "irc://", 6) == 0 || strncmp(str_copy, "ircs://", 7) == 0) menu_quick_item_with_callback(open_url_cb, _("Connect"), menu, str_copy); else menu_quick_item_with_callback(open_url_cb, _("Open Link in Browser"), menu, str_copy); menu_quick_item_with_callback(copy_to_clipboard_cb, _("Copy Selected Link"), menu, str_copy); /* custom ones from urlhandlers.conf */ menu_create(menu, urlhandler_list, str_copy, TRUE); menu_add_plugin_items(menu, "\x4$URL", str_copy); menu_popup(menu, event, NULL); }
void menu_middlemenu(session *sess, GdkEventButton * event) { GtkWidget *menu; GtkAccelGroup *accel_group; accel_group = gtk_accel_group_new(); menu = menu_create_main(accel_group, FALSE, sess->server->is_away, !sess->gui->is_tab, NULL); menu_popup(menu, event, accel_group); }
void Menuer::popupFloat() { EnableMenuItem(floatMenu_, IDM_CREATE, MF_BYCOMMAND | (option.number < MaxNumber ? MF_ENABLED : MF_GRAYED)); EnableMenuItem(floatMenu_, IDM_REMOVE, MF_BYCOMMAND | (option.number > MinNumber ? MF_ENABLED : MF_GRAYED)); menu_popup(floatMenu_, app_hwnd); }
void menu_pop_tray() { bool opt_shown = opt_hwnd && IsWindowVisible(opt_hwnd); EnableMenuItem(menu_tray, IDM_OPTION, MF_BYCOMMAND | (opt_shown ? MF_GRAYED : MF_ENABLED)); // Fix the issue that the menu doesn't disappear when user presses // ESCAPE key or clicks somewhere out of the menu SetForegroundWindow(app_hwnd); menu_popup(menu_tray, app_hwnd); }
void menu_nickmenu(window_t *sess, GdkEventButton * event, char *nick, int num_sel) { char buf[512]; GtkWidget *menu = gtk_menu_new(); userlist_t *user; if (str_copy) free(str_copy); str_copy = xstrdup(nick); submenu_list = NULL; /* first time through, might not be 0 */ /* [XXX, how does this work? memleak? */ /* more than 1 nick selected? */ if (num_sel > 1) { snprintf(buf, sizeof(buf), "%d nicks selected.", num_sel); menu_quick_item(0, buf, menu, 0, 0, 0); menu_quick_item(0, 0, menu, XCMENU_SHADED, 0, 0); } else { user = userlist_find(sess->session, nick); /* XXX, * jesli nadal nie ma uzytkownika, to szukaj go w konferencjach */ if (user) { GtkWidget *submenu = menu_quick_sub(nick, menu, NULL, XCMENU_DOLIST, -1); char *fmt = "<tt><b>%-11s</b></tt> %s"; /* XXX, gettext? (let the translators tweak this if need be) */ char *real; /* UID */ real = g_markup_escape_text(user->uid, -1); snprintf(buf, sizeof(buf), fmt, "UID:", real); g_free(real); menu_quick_item(0, buf, submenu, XCMENU_MARKUP, 0, 0); /* <separator> ? */ /* XXX, get more data using USERLIST_PRIVHANDLE (?) */ /* the same like above */ menu_quick_endsub(); menu_quick_item(0, 0, menu, XCMENU_SHADED, 0, 0); } } #if 0 if (num_sel > 1) menu_create(menu, popup_list, NULL, FALSE); else menu_create(menu, popup_list, str_copy, FALSE); if (num_sel == 0) /* xtext click */ menu_add_plugin_items(menu, "\x5$NICK", str_copy); else /* userlist treeview click */ menu_add_plugin_items(menu, "\x5$NICK", NULL); #endif menu_popup(menu, event, NULL); }
int Controller_Module::handle ( int m ) { switch ( m ) { case FL_PUSH: { if ( learn_mode() ) { tooltip( "Now learning control. Move the desired control on your controller" ); //connect_to( &module->control_input[port] ); Port *p = control_output[0].connected_port(); if ( p ) { const char * path = learn_by_number ? p->osc_number_path() : p->osc_path(); DMESSAGE( "Will learn %s", path ); mixer->osc_endpoint->learn( path ); } return 1; } if ( Fl::event_button3() ) { /* context menu */ /* if ( type() != SPATIALIZATION ) */ menu_popup( &menu() ); return 1; } else return Fl_Group::handle( m ); } } return Fl_Group::handle( m ); }
int Controller_Module::handle ( int m ) { switch ( m ) { case FL_PUSH: { if ( test_press( FL_BUTTON3 ) ) { /* context menu */ if ( type() != SPATIALIZATION ) menu_popup( &menu() ); return 1; } else return Fl_Group::handle( m ); } } return Fl_Group::handle( m ); }
void Track::cb_button ( Fl_Widget *w ) { Logger log(this); if ( w == name_field ) { name( name_field->value() ); } else if ( w == record_button ) { } else if ( w == mute_button ) { } else if ( w == solo_button ) { if ( solo_button->value() ) ++_soloing; else --_soloing; } else if ( w == show_all_takes_button ) { show_all_takes( show_all_takes_button->value() ); } else if ( w == overlay_controls_button ) { overlay_controls( overlay_controls_button->value() ); } else if ( w == menu_button ) { menu_popup( &menu(), menu_button->x(), menu_button->y() ); } }
static void form_event(int index, int external) { char spare[255]; bool is_button = false; bool checked = OBJ_SELECTED(index); char * tmp; MENU pop_menu, me_data; /* For font driver popup: */ int num_font_drivers = 2; /* Just a small collection of locales, each country has at least one ATARI-clone user! :) */ int num_locales = 15; short x, y; int choice, i; switch(index) { case SETTINGS_SAVE: OBJ_UNCHECK(index); OBJ_REDRAW(index); save_settings(); break; case SETTINGS_ABORT: OBJ_UNCHECK(index); OBJ_REDRAW(index); close_settings(); break; case SETTINGS_CB_USE_PROXY: if( checked ) { ENABLE_OBJ(SETTINGS_EDIT_PROXY_HOST); ENABLE_OBJ(SETTINGS_EDIT_PROXY_PORT); ENABLE_OBJ(SETTINGS_CB_PROXY_AUTH); } else { DISABLE_OBJ(SETTINGS_EDIT_PROXY_HOST); DISABLE_OBJ(SETTINGS_EDIT_PROXY_PORT); DISABLE_OBJ(SETTINGS_CB_PROXY_AUTH); } FORMEVENT(SETTINGS_CB_PROXY_AUTH); OBJ_REDRAW(SETTINGS_CB_USE_PROXY); break; case SETTINGS_CB_PROXY_AUTH: if( checked && OBJ_SELECTED( SETTINGS_CB_USE_PROXY ) ) { ENABLE_OBJ(SETTINGS_EDIT_PROXY_USERNAME); ENABLE_OBJ(SETTINGS_EDIT_PROXY_PASSWORD); } else { DISABLE_OBJ(SETTINGS_EDIT_PROXY_USERNAME); DISABLE_OBJ(SETTINGS_EDIT_PROXY_PASSWORD); } break; case SETTINGS_CB_ENABLE_ANIMATION: if( checked ) { ENABLE_OBJ( SETTINGS_EDIT_MIN_GIF_DELAY ); } else { DISABLE_OBJ( SETTINGS_EDIT_MIN_GIF_DELAY ); } break; case SETTINGS_BT_SEL_FONT_RENDERER: if( external ) { objc_offset(dlgtree, SETTINGS_BT_SEL_FONT_RENDERER, &x, &y); // point mn_tree tree to states popup: pop_menu.mn_tree = gemtk_obj_get_tree(POP_FONT_RENDERER); pop_menu.mn_menu = 0; pop_menu.mn_item = POP_FONT_RENDERER_INTERNAL; pop_menu.mn_scroll = SCROLL_NO; pop_menu.mn_keystate = 0; // find the selected menu item and uncheck others: for(i=pop_menu.mn_item; i<=num_font_drivers; i++) { get_string(pop_menu.mn_tree, i, spare); tmp = gemtk_obj_get_text(dlgtree, SETTINGS_BT_SEL_FONT_RENDERER); if (strcasecmp(&spare[2], tmp)) { menu_icheck(pop_menu.mn_tree, i, 0); } else { menu_icheck(pop_menu.mn_tree, i, 1); } set_string(pop_menu.mn_tree, i, spare); } menu_popup(&pop_menu, x, y, &me_data); choice = me_data.mn_item; if( choice > 0 && choice <= num_font_drivers ) { get_string(pop_menu.mn_tree, choice, spare); for(i=2; i<(int)strlen(spare); i++) { spare[i]= (char)tolower(spare[i]); } set_text(SETTINGS_BT_SEL_FONT_RENDERER, (char*)&spare[2], LABEL_FONT_RENDERER_MAX_LEN); OBJ_REDRAW(SETTINGS_BT_SEL_FONT_RENDERER); } } tmp = gemtk_obj_get_text(dlgtree, SETTINGS_BT_SEL_FONT_RENDERER); if (strcasecmp(tmp, "freetype") == 0) { ENABLE_OBJ(SETTINGS_CB_ANTI_ALIASING); } else { DISABLE_OBJ(SETTINGS_CB_ANTI_ALIASING); } break; case SETTINGS_BT_SEL_LOCALE: objc_offset(dlgtree, SETTINGS_BT_SEL_LOCALE, &x, &y); // point mn_tree tree to states popup: pop_menu.mn_tree = gemtk_obj_get_tree(POP_LANGUAGE); pop_menu.mn_menu = 0; pop_menu.mn_item = POP_LANGUAGE_CS; pop_menu.mn_scroll = SCROLL_NO; pop_menu.mn_keystate = 0; // find the selected menu item and uncheck others: for(i=pop_menu.mn_item; i<=num_locales; i++) { get_string(pop_menu.mn_tree, i, spare); tmp = gemtk_obj_get_text(dlgtree, SETTINGS_BT_SEL_LOCALE); if (strcasecmp(&spare[2], tmp)) { menu_icheck(pop_menu.mn_tree, i, 0); } else { menu_icheck(pop_menu.mn_tree, i, 1); } set_string(pop_menu.mn_tree, i, spare); } menu_popup(&pop_menu, x, y, &me_data); choice = me_data.mn_item; if( choice > 0 && choice <= num_locales ) { get_string(pop_menu.mn_tree, choice, spare); for(i=2; i<(int)strlen(spare); i++) { spare[i]= (char)tolower(spare[i]); } set_text(SETTINGS_BT_SEL_LOCALE, (char*)&spare[2], 5); } OBJ_REDRAW(SETTINGS_BT_SEL_LOCALE); break; /* case SETTINGS_INPUT_TOOLBAR_BGCOLOR: objc_offset( FORM(win), SETTINGS_INPUT_TOOLBAR_BGCOLOR, &x, &y ); choice = color_popup(x, y, tmp_option_atari_toolbar_bg); snprintf( spare, 255, "%06x", choice ); tmp_option_atari_toolbar_bg = choice; ObjcStrCpy( dlgtree, SETTINGS_INPUT_TOOLBAR_BGCOLOR, spare ); is_button = true; OBJ_REDRAW(SETTINGS_INPUT_TOOLBAR_BGCOLOR); break; */ /* case SETTINGS_BT_TOOLBAR_ICONSET: objc_offset( FORM(win), SETTINGS_BT_TOOLBAR_ICONSET, &x, &y ); tmp = toolbar_iconset_popup(x,y); if( tmp != NULL ){ ObjcStrCpy( dlgtree, SETTINGS_BT_TOOLBAR_ICONSET, tmp ); } is_button = true; break; */ case SETTINGS_INC_MEM_CACHE: case SETTINGS_DEC_MEM_CACHE: if( index == SETTINGS_DEC_MEM_CACHE ) tmp_option_memory_cache_size -= 0.1; else tmp_option_memory_cache_size += 0.1; if( tmp_option_memory_cache_size < 0.5 ) tmp_option_memory_cache_size = 0.5; if( tmp_option_memory_cache_size > 999.9 ) tmp_option_memory_cache_size = 999.9; snprintf( spare, 255, "%03.1f", tmp_option_memory_cache_size ); set_text( SETTINGS_STR_MAX_MEM_CACHE, spare, 5 ); is_button = true; OBJ_REDRAW(SETTINGS_STR_MAX_MEM_CACHE); break; case SETTINGS_INC_CACHED_CONNECTIONS: case SETTINGS_DEC_CACHED_CONNECTIONS: if( index == SETTINGS_INC_CACHED_CONNECTIONS ) tmp_option_max_cached_fetch_handles += 1; else tmp_option_max_cached_fetch_handles -= 1; if( tmp_option_max_cached_fetch_handles > 31 ) tmp_option_max_cached_fetch_handles = 31; snprintf( spare, 255, "%02d", tmp_option_max_cached_fetch_handles ); set_text( SETTINGS_EDIT_MAX_CACHED_CONNECTIONS, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MAX_CACHED_CONNECTIONS); break; case SETTINGS_INC_MAX_FETCHERS: case SETTINGS_DEC_MAX_FETCHERS: if( index == SETTINGS_INC_MAX_FETCHERS ) tmp_option_max_fetchers += 1; else tmp_option_max_fetchers -= 1; if( tmp_option_max_fetchers > 31 ) tmp_option_max_fetchers = 31; snprintf( spare, 255, "%02d", tmp_option_max_fetchers ); set_text( SETTINGS_EDIT_MAX_FETCHERS, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MAX_FETCHERS); break; case SETTINGS_INC_MAX_FETCHERS_PER_HOST: case SETTINGS_DEC_MAX_FETCHERS_PER_HOST: if( index == SETTINGS_INC_MAX_FETCHERS_PER_HOST ) tmp_option_max_fetchers_per_host += 1; else tmp_option_max_fetchers_per_host -= 1; if( tmp_option_max_fetchers_per_host > 31 ) tmp_option_max_fetchers_per_host = 31; snprintf( spare, 255, "%02d", tmp_option_max_fetchers_per_host ); set_text( SETTINGS_EDIT_MAX_FETCHERS_PER_HOST, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MAX_FETCHERS_PER_HOST); break; case SETTINGS_INC_HISTORY_AGE: case SETTINGS_DEC_HISTORY_AGE: if( index == SETTINGS_INC_HISTORY_AGE ) tmp_option_expire_url += 1; else tmp_option_expire_url -= 1; if( tmp_option_expire_url > 99 ) tmp_option_expire_url = 0; snprintf( spare, 255, "%02d", tmp_option_expire_url ); set_text( SETTINGS_EDIT_HISTORY_AGE, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_HISTORY_AGE); break; case SETTINGS_INC_GIF_DELAY: case SETTINGS_DEC_GIF_DELAY: if( index == SETTINGS_INC_GIF_DELAY ) tmp_option_minimum_gif_delay += 0.1; else tmp_option_minimum_gif_delay -= 0.1; if( tmp_option_minimum_gif_delay < 0.1 ) tmp_option_minimum_gif_delay = 0.1; if( tmp_option_minimum_gif_delay > 9.0 ) tmp_option_minimum_gif_delay = 9.0; snprintf( spare, 255, "%01.1f", tmp_option_minimum_gif_delay ); set_text( SETTINGS_EDIT_MIN_GIF_DELAY, spare, 3 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MIN_GIF_DELAY); break; case SETTINGS_INC_MIN_FONT_SIZE: case SETTINGS_DEC_MIN_FONT_SIZE: if( index == SETTINGS_INC_MIN_FONT_SIZE ) tmp_option_font_min_size += 1; else tmp_option_font_min_size -= 1; if( tmp_option_font_min_size > 500 ) tmp_option_font_min_size = 500; if( tmp_option_font_min_size < 10 ) tmp_option_font_min_size = 10; snprintf( spare, 255, "%03d", tmp_option_font_min_size ); set_text( SETTINGS_EDIT_MIN_FONT_SIZE, spare, 3 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MIN_FONT_SIZE); break; case SETTINGS_INC_DEF_FONT_SIZE: case SETTINGS_DEC_DEF_FONT_SIZE: if( index == SETTINGS_INC_DEF_FONT_SIZE ) tmp_option_font_size += 1; else tmp_option_font_size -= 1; if( tmp_option_font_size > 999 ) tmp_option_font_size = 999; if( tmp_option_font_size < 50 ) tmp_option_font_size = 50; snprintf( spare, 255, "%03d", tmp_option_font_size ); set_text( SETTINGS_EDIT_DEF_FONT_SIZE, spare, 3 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_DEF_FONT_SIZE); break; case SETTINGS_INC_INCREMENTAL_REFLOW: case SETTINGS_DEC_INCREMENTAL_REFLOW: if( index == SETTINGS_INC_INCREMENTAL_REFLOW ) tmp_option_min_reflow_period += 1; else tmp_option_min_reflow_period -= 1; if( tmp_option_min_reflow_period > 9999 ) tmp_option_min_reflow_period = 10; snprintf( spare, 255, "%04d", tmp_option_min_reflow_period ); set_text( SETTINGS_EDIT_MIN_REFLOW_PERIOD, spare, 4 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MIN_REFLOW_PERIOD); break; default: break; } if( is_button ) { // remove selection indicator from button element: OBJ_UNCHECK(index); OBJ_REDRAW(index); } }
/* driver_handler() * ================================================================ */ int driver_handler( void ) { int msg[8]; int button; int done; GRECT clip; int dummy; MENU Menu; MENU MData; GRECT rect; done = FALSE; do { button = xform_do( ad_tree, 0, msg ); switch( button ) { case DSETUP: done = TRUE; Deselect( DSETUP ); break; case DEXIT: CheckExit(); deselect( ad_tree, DEXIT ); break; case PMETA: case PMETA2: gl_meta ^= 1; if( gl_meta ) { objc_xywh( ad_driver, PMETA2, &clip ); msg[3] = wid; msg[4] = clip.g_x; msg[5] = clip.g_y; msg[6] = clip.g_w; msg[7] = clip.g_h; driver_redraw( msg ); } else ObjcDraw( ad_driver, PMETA2, MAX_DEPTH, NULL ); evnt_button( 1, 1, 0, &dummy, &dummy, &dummy, &dummy ); break; case PMEM: case PMEM2: gl_mem ^= 1; if( gl_mem ) { objc_xywh( ad_driver, PMEM2, &clip ); msg[3] = wid; msg[4] = clip.g_x; msg[5] = clip.g_y; msg[6] = clip.g_w; msg[7] = clip.g_h; driver_redraw( msg ); } else ObjcDraw( ad_driver, PMEM2, MAX_DEPTH, NULL ); evnt_button( 1, 1, 0, &dummy, &dummy, &dummy, &dummy ); break; case PBUTTON: select( ad_driver, PBUTTON ); evnt_button( 1, 1, 0, &dummy, &dummy, &dummy, &dummy ); select( ad_driver, PTITLE ); objc_xywh( ad_driver, PBUTTON, &rect ); Menu.mn_tree = ad_submenu; Menu.mn_menu = ROOT; Menu.mn_item = SNONE + gl_printer; Menu.mn_scroll = FALSE; if( menu_popup( &Menu, rect.g_x, rect.g_y, &MData )) { menu_icheck( ad_submenu, SNONE + gl_printer, 0 ); gl_printer = MData.mn_item - SNONE; menu_icheck( ad_submenu, SNONE + gl_printer, 1 ); if( gl_printer ) { ObString( PBUTTON ) = MenuNode[ gl_printer ].name; } else ObString( PBUTTON ) = anone; } deselect( ad_driver, PTITLE ); Deselect( PBUTTON ); objc_xywh( ad_driver, PBUTTON, &rect ); rect.g_x -= 1; rect.g_w += 2; ObjcDraw( ad_driver, PBUTTON, MAX_DEPTH, &rect ); break; default: if( button == NIL ) { switch( msg[0] ) { case WM_REDRAW: driver_redraw( msg ); break; case WM_CLOSED: return( FALSE ); break; case CT_KEY: if( msg[3] == K_F10 ) CheckExit(); break; default: break; } } break; } }while( !done ); return( TRUE ); }
int Track::handle ( int m ) { /* if ( m != FL_NO_EVENT ) */ /* DMESSAGE( "%s", event_name( m ) ); */ static Fl_Widget *dragging = NULL; switch ( m ) { case FL_DND_ENTER: case FL_DND_LEAVE: case FL_DND_DRAG: case FL_DND_RELEASE: case FL_PASTE: if ( Fl::event_x() > Track::width() ) return sequence()->handle(m); default: break; } switch ( m ) { case FL_KEYBOARD: { Fl_Menu_Button * men = &menu(); if ( Fl::event_key() == FL_Menu ) { menu_popup( men ); return 1; } else return men->test_shortcut() || Fl_Group::handle( m ); } case FL_MOUSEWHEEL: { Logger log( this ); if ( ! Fl::event_shift() ) return Fl_Group::handle( m ); int d = Fl::event_dy(); if ( d < 0 ) size( size() - 1 ); else size( size() + 1 ); return 1; } case FL_PUSH: { if ( Fl::event_button1() && Fl::event_inside( ((Track_Header*)child(0))->color_box ) ) { dragging = this; return 1; } if ( Fl::event_button1() && Fl::event_inside( ((Track_Header*)child(0))->output_connector_handle ) ) return 1; Logger log( this ); if ( Fl_Group::handle( m ) ) return 1; if ( test_press( FL_BUTTON3 ) && Fl::event_x() < Track::width() ) { menu_popup( &menu() ); return 1; } return 0; } /* we have to prevent Fl_Group::handle() from getting these, otherwise it will mess up Fl::belowmouse() */ case FL_ENTER: case FL_LEAVE: case FL_MOVE: if ( Fl::event_x() >= Track::width() ) { return Fl_Group::handle(m); } return 1; case FL_DND_ENTER: return 1; case FL_DND_LEAVE: if ( ! Fl::event_inside(this) && this == receptive_to_drop ) { receptive_to_drop = 0; redraw(); Fl::selection_owner(0); } return 1; case FL_RELEASE: if ( dragging == this ) { dragging = NULL; timeline->insert_track( this, timeline->event_inside() ); return 1; } return 0; break; case FL_DND_RELEASE: receptive_to_drop = 0; redraw(); Fl::selection_owner(0); return 1; case FL_DND_DRAG: { if ( receptive_to_drop == ((Track_Header*)child(0))->input_connector_handle ) return 1; if ( Fl::event_inside( ((Track_Header*)child(0))->input_connector_handle ) && receptive_to_drop != ((Track_Header*)child(0))->input_connector_handle ) { receptive_to_drop = ((Track_Header*)child(0))->input_connector_handle; redraw(); return 1; } else { receptive_to_drop = NULL; redraw(); return 0; } } case FL_PASTE: { receptive_to_drop = 0; redraw(); if (! Fl::event_inside( ((Track_Header*)child(0))->input_connector_handle ) ) return 0; /* NOW we get the text... */ const char *text = Fl::event_text(); DMESSAGE( "Got drop text \"%s\"",text); if ( strncmp( text, "jack.port://", strlen( "jack.port://" ) ) ) { return 0; } std::vector<std::string> port_names; char *port_name; int end; while ( sscanf( text, "jack.port://%a[^\r\n]\r\n%n", &port_name, &end ) > 0 ) { DMESSAGE( "Scanning %s", port_name ); port_names.push_back( port_name ); free(port_name ); text += end; } for ( unsigned int i = 0; i < input.size() && i < port_names.size(); i++) { const char *pn = port_names[i].c_str(); JACK::Port *ji = &input[i]; if ( ji->connected_to( pn ) ) { DMESSAGE( "Disconnecting from \"%s\"", pn ); ji->disconnect( pn ); } else { DMESSAGE( "Connecting to %s", pn ); ji->connect( pn ); } } Fl::selection_owner(0); return 1; } case FL_DRAG: { if ( this != Fl::selection_owner() && Fl::event_inside( ((Track_Header*)child(0))->output_connector_handle ) ) { char *s = (char*)malloc(256); s[0] = 0; for ( unsigned int i = 0; i < output.size(); ++i ) { char *s2; asprintf(&s2, "jack.port://%s:%s\r\n", instance_name, output[i].name() ); s = (char*)realloc( s, strlen( s ) + strlen( s2 ) + 1 ); strcat( s, s2 ); free( s2 ); } Fl::copy(s, strlen(s) + 1, 0); Fl::selection_owner(this); free( s ); Fl::dnd(); return 1; } else { return 1; } } default: return Fl_Group::handle( m ); } return 0; }
void menu_nickmenu (session *sess, GdkEventButton *event, char *nick, int num_sel) { char buf[512]; char *real, *fmt; struct User *user; struct away_msg *away; GtkWidget *submenu, *menu = gtk_menu_new (); if (str_copy) free (str_copy); str_copy = strdup (nick); submenu_list = 0; /* first time through, might not be 0 */ /* more than 1 nick selected? */ if (num_sel > 1) { snprintf (buf, sizeof (buf), "%d nicks selected.", num_sel); menu_quick_item (0, buf, menu, 0, 0, 0); menu_quick_item (0, 0, menu, XCMENU_SHADED, 0, 0); } else { user = userlist_find (sess, nick); /* lasttalk is channel specific */ if (!user) user = userlist_find_global (current_sess->server, nick); if (user) { submenu = menu_quick_sub (nick, menu, NULL, XCMENU_DOLIST, -1); /* let the translators tweak this if need be */ fmt = _("<tt><b>%-11s</b></tt> %s"); if (user->realname) { real = g_markup_escape_text (user->realname, -1); snprintf (buf, sizeof (buf), fmt, _("Real Name:"), real); g_free (real); } else { snprintf (buf, sizeof (buf), fmt, _("Real Name:"), _("Unknown")); } menu_quick_item (0, buf, submenu, XCMENU_MARKUP, 0, 0); snprintf (buf, sizeof (buf), fmt, _("User:"******"Unknown")); menu_quick_item (0, buf, submenu, XCMENU_MARKUP, 0, 0); snprintf (buf, sizeof (buf), fmt, _("Server:"), user->servername ? user->servername : _("Unknown")); menu_quick_item (0, buf, submenu, XCMENU_MARKUP, 0, 0); if (user->away) { away = server_away_find_message (current_sess->server, nick); if (away) { char *msg = strip_color (away->message ? away->message : _("Unknown"), -1, STRIP_ALL); real = g_markup_escape_text (msg, -1); free (msg); snprintf (buf, sizeof (buf), fmt, _("Away Msg:"), real); g_free (real); menu_quick_item (0, buf, submenu, XCMENU_MARKUP, 0, 0); } } if (user->lasttalk) { char min[96]; snprintf (min, sizeof (min), _("%u minutes ago"), (unsigned int) ((time (0) - user->lasttalk) / 60)); snprintf (buf, sizeof (buf), fmt, _("Last Msg:"), min); } else { snprintf (buf, sizeof (buf), fmt, _("Last Msg:"), _("Unknown")); } menu_quick_item (0, buf, submenu, XCMENU_MARKUP, 0, 0); menu_quick_endsub (); menu_quick_item (0, 0, menu, XCMENU_SHADED, 0, 0); } } if (num_sel > 1) menu_create (menu, popup_list, NULL, FALSE); else menu_create (menu, popup_list, str_copy, FALSE); if (num_sel == 0) /* xtext click */ menu_add_plugin_items (menu, "\x5$NICK", str_copy); else /* userlist treeview click */ menu_add_plugin_items (menu, "\x5$NICK", NULL); menu_popup (menu, event, NULL); }
int Module::handle ( int m ) { static unsigned long _event_state = 0; unsigned long evstate = Fl::event_state(); switch ( m ) { case FL_ENTER: // Fl::focus(this); case FL_LEAVE: return 1; } if ( Fl_Group::handle( m ) ) return 1; switch ( m ) { case FL_KEYBOARD: { if ( Fl::event_key() == FL_Menu ) { menu_popup( &menu(), x(), y() ); return 1; } else return menu().test_shortcut() != 0; } case FL_PUSH: take_focus(); _event_state = evstate; return 1; // if ( Fl::visible_focus() && handle( FL_FOCUS )) Fl::focus(this); case FL_DRAG: _event_state = evstate; return 1; case FL_RELEASE: { unsigned long e = _event_state; _event_state = 0; if ( ! Fl::event_inside( this ) ) return 1; if ( ( e & FL_BUTTON1 ) && ( e & FL_CTRL ) ) { Fl::focus(this); return 1; } else if ( e & FL_BUTTON1 ) { command_open_parameter_editor(); return 1; } else if ( e & FL_BUTTON3 && e & FL_CTRL ) { command_remove(); return 1; } else if ( e & FL_BUTTON3 ) { menu_popup( &menu() ); return 1; } else if ( e & FL_BUTTON2 ) { if ( !bypassable() ) { fl_alert( "Due to its channel configuration, this module cannot be bypassed." ); } else { bypass( !bypass() ); redraw(); } return 1; } /* else */ /* { */ /* take_focus(); */ /* } */ return 0; } case FL_FOCUS: case FL_UNFOCUS: redraw(); return 1; } return 0; }
/* MAIN() * ================================================================ */ VOID main( VOID ) { OBJECT *tree; WORD i; WORD button; GRECT box; GRECT xrect; WORD tempx; GRECT rect; MRETS mk; WORD ptitle, pitem, pmenu; OBJECT *ptree; BOOLEAN flag; BOOLEAN done; WORD dummy; WORD xvalue; appl_init(); phys_handle = graf_handle( &gl_wchar, &gl_hchar, &gl_wbox, &gl_hbox ); graf_mouse( ARROW, 0L ); rsrc_load( "TEST.RSC" ); rsrc_gaddr( 0, MENU1, &ad_tree ); rsrc_gaddr( 0, BIGBOX, &ad_box ); rsrc_gaddr( 0, COUNTRY, &ad_country ); rsrc_gaddr( 0, OTHER, &ad_other ); rsrc_gaddr( 0, MENUBAR, &ad_menubar ); rsrc_gaddr( 0, TREE6, &ad_extra ); ad_other[ ROOT ].ob_x = ad_other[ ROOT ].ob_y = 0; #if 0 /* test setting delay and height variables */ TData.Delay = 100L; TData.Drag = 10000L; TData.Delay = 250L; TData.Speed = 0L; TData.Height = 16; menu_settings( 1, &TData ); #endif /* test attaching submenus */ Menu.mn_tree = ad_country; Menu.mn_menu = ROOT; Menu.mn_item = Cur2; Menu.mn_scroll = TRUE; menu_attach( 1, ad_tree, DELETE, &Menu ); Menu.mn_tree = ad_other; Menu.mn_menu = DISNEY; Menu.mn_item = MICKEY; Menu.mn_scroll = FALSE; menu_attach( 1, ad_tree, FLOPPY, &Menu ); Menu.mn_tree = ad_other; Menu.mn_menu = MODEM; Menu.mn_item = Cur3; Menu.mn_scroll = FALSE; menu_attach( 1, ad_country, 5, &Menu ); Menu.mn_tree = ad_other; Menu.mn_menu = DISNEY; Menu.mn_item = MICKEY; Menu.mn_scroll = FALSE; menu_attach( 1, ad_country, 1, &Menu ); Menu.mn_tree = ad_other; Menu.mn_menu = DISNEY; Menu.mn_item = MICKEY; Menu.mn_scroll = FALSE; menu_attach( 1, ad_country, ARKANSAS, &Menu ); Menu.mn_tree = ad_other; Menu.mn_menu = QUOTES; Menu.mn_item = Cur4; Menu.mn_scroll = FALSE; menu_attach( 1, ad_other, 5, &Menu ); Menu.mn_tree = ad_country; Menu.mn_menu = ROOT; Menu.mn_item = Cur2; Menu.mn_scroll = TRUE; menu_attach( 1, ad_menubar, PASTE, &Menu ); Menu.mn_tree = ad_country; Menu.mn_menu = ROOT; Menu.mn_item = Cur2; Menu.mn_scroll = TRUE; menu_attach( 1, ad_menubar, FNEW, &Menu ); menu_icheck( ad_tree, Cur1, 1 ); menu_icheck( ad_country, Cur2, 1 ); menu_icheck( ad_other, Cur3, 1 ); menu_icheck( ad_other, Cur4, 1 ); menu_icheck( ad_other, Cur5, 1 ); ActiveTree( ad_box ); form_center( ad_box, &rect.g_x, &rect.g_y, &rect.g_w, &rect.g_h ); ObX( ROOT ) = rect.g_x; xrect = ObRect( TITLE1 ); objc_offset( ad_box, TITLE1, &xrect.g_x, &xrect.g_y ); tempx = xrect.g_x; xrect.g_x = (( xrect.g_x + 7 )/8 ) * 8; rect.g_x = rect.g_x + ( xrect.g_x - tempx ); ObX( ROOT ) = rect.g_x; rect.g_x -= 3; form_dial( FMD_START, rect.g_x, rect.g_y, rect.g_w, rect.g_h, rect.g_x, rect.g_y, rect.g_w, rect.g_h ); objc_draw( ad_box, ROOT, MAX_DEPTH, rect.g_x, rect.g_y, rect.g_w, rect.g_h ); do { ActiveTree( ad_box ); button = form_do( ad_box, 0L ); switch( button ) { case TITLE1: box = ObRect( TITLE1 ); objc_offset( ad_box, TITLE1, &box.g_x, &box.g_y ); Menu.mn_tree = ad_tree; Menu.mn_menu = ROOT; Menu.mn_item = Cur1; Menu.mn_scroll = FALSE; flag = menu_popup( &Menu, box.g_x, box.g_y, &MData ); if( flag ) MenuCheck( MData.mn_tree, MData.mn_menu, MData.mn_item ); break; case TITLE2: box = ObRect( TITLE2 ); objc_offset( ad_box, TITLE2, &box.g_x, &box.g_y ); Menu.mn_tree = ad_country; Menu.mn_menu = ROOT; Menu.mn_item = Cur2; Menu.mn_scroll = TRUE; flag = menu_popup( &Menu, box.g_x, box.g_y, &MData ); if( flag ) MenuCheck( MData.mn_tree, MData.mn_menu, MData.mn_item ); break; case TITLE3: box = ObRect( TITLE3 ); objc_offset( ad_box, TITLE3, &box.g_x, &box.g_y ); Menu.mn_tree = ad_other; Menu.mn_menu = MODEM; Menu.mn_item = Cur3; Menu.mn_scroll = FALSE; flag = menu_popup( &Menu, box.g_x, box.g_y, &MData ); if( flag ) MenuCheck( MData.mn_tree, MData.mn_menu, MData.mn_item ); break; case TITLE4: box = ObRect( TITLE4 ); objc_offset( ad_box, TITLE4, &box.g_x, &box.g_y ); Menu.mn_tree = ad_other; Menu.mn_menu = QUOTES; Menu.mn_item = Cur4; Menu.mn_scroll = FALSE; flag = menu_popup( &Menu, box.g_x, box.g_y, &MData ); if( flag ) MenuCheck( MData.mn_tree, MData.mn_menu, MData.mn_item ); break; default: break; } }while( button != XEXIT ); form_dial( FMD_FINISH, rect.g_x, rect.g_y, rect.g_w, rect.g_h, rect.g_x, rect.g_y, rect.g_w, rect.g_h ); evnt_button( 1, 1, 0, &dummy, &dummy, &dummy, &dummy ); /* display menubar stuff here */ ActiveTree( ad_menubar ); menu_bar( ad_menubar, TRUE ); do { evnt_mesag( msg ); if( msg[0] == MN_SELECTED ) { /* msg[7] is the parent of FQUIT - which the user can't know */ ptr = &msg[5]; if( ( *ptr == ad_menubar ) && ( msg[4] == FQUIT ) ) { button = form_alert( 1, "[1][ | EXIT PROGRAM? ][OK|Cancel]"); if( button == 1 ) done = TRUE; } else MenuCheck( *ptr, msg[7], msg[4] ); menu_tnormal( ad_menubar, msg[3], TRUE ); } }while( !done ); menu_bar( ad_menubar, FALSE ); rsrc_free(); graf_mouse( ARROW, 0L ); appl_exit(); }