#include <varblwin.h>
Inheritance diagram for VARIABLES_WINDOW:
The chief difference is that this window type awaits interrupts.
Definition at line 93 of file varblwin.h.
VARIABLES_WINDOW::VARIABLES_WINDOW | ( | const char * | name, | |
MENU_ROOT * | menu_root, | |||
VAR_SUB_MENU * | creator | |||
) |
Constructor for a variables window
Definition at line 201 of file varblwin.cpp.
References COMMAND_WINDOW::fd, interrupt_handler(), my_creator, set_click_handler, and win_assocs.
00206 : 00207 COMMAND_WINDOW(name, menu_root) { 00208 win_assocs.add (fd, this); 00209 my_creator = creator; 00210 set_click_handler(fd, VARIABLES_WINDOW::interrupt_handler); 00211 }
void COMMAND_WINDOW::event | ( | GRAPHICS_EVENT & | g_event, | |
INT32 * | cmd_event, | |||
char * | new_value | |||
) | [inherited] |
COMMAND_WINDOW event handler
Definition at line 136 of file cmndwin.cpp.
References DOWN_EVENT, MENU_ROOT::event(), graphicsevent::key, KEYPRESS_EVENT, COMMAND_WINDOW::menu_root, COMMAND_WINDOW::message_str, NULL_COMMAND, COMMAND_WINDOW::plot(), COMMAND_WINDOW::prompt_str, graphicsevent::type, UNIDENTIFIED_COMMAND, graphicsevent::x, and graphicsevent::y.
Referenced by COMMAND_WINDOW::internal_prompt(), pgeditor_main(), and v_event().
00140 { 00141 message_str[0] = '\0'; 00142 prompt_str[0] = '\0'; 00143 *cmd_event = UNIDENTIFIED_COMMAND; 00144 new_value[0] = '\0'; 00145 00146 switch (g_event.type) { 00147 case DOWN_EVENT: 00148 { 00149 menu_root->event (this, FCOORD (g_event.x, g_event.y), 00150 cmd_event, new_value); 00151 if (*cmd_event == UNIDENTIFIED_COMMAND) 00152 *cmd_event = NULL_COMMAND; 00153 break; 00154 } 00155 case KEYPRESS_EVENT: 00156 { 00157 if (g_event.key == 3) { //Control C 00158 exit (0); 00159 } 00160 } 00161 default: 00162 { 00163 // sprintf( message_str, "ERROR: Unrecognised graphics event %d", 00164 // g_event.type ); 00165 *cmd_event = NULL_COMMAND; 00166 break; 00167 } 00168 } 00169 plot(); 00170 }
BOOL8 VARIABLES_WINDOW::internal_prompt | ( | const char * | msg_str, | |
char * | response_str | |||
) | [virtual] |
Disable interrupts during prompting
Reimplemented from COMMAND_WINDOW.
Definition at line 171 of file varblwin.cpp.
References COMMAND_WINDOW::fd, COMMAND_WINDOW::internal_prompt(), interrupt_handler(), set_click_handler, and win_assocs.
00174 { 00175 BOOL8 result; 00176 00177 win_assocs.turn_off_interrupts (); 00178 result = COMMAND_WINDOW::internal_prompt (msg_str, response_str); 00179 win_assocs.turn_on_interrupts (VARIABLES_WINDOW::interrupt_handler); 00180 set_click_handler(fd, VARIABLES_WINDOW::interrupt_handler); 00181 return result; 00182 }
void VARIABLES_WINDOW::interrupt_handler | ( | GRAPHICS_EVENT * | g_event | ) | [static, private] |
Forward the event to the VARIABLES_WINDOW responsible for handling events for the window where the event occured.
Definition at line 189 of file varblwin.cpp.
References graphicsevent::fd, overlap_picture_ops, TRUE, v_event(), and win_assocs.
Referenced by internal_prompt(), and VARIABLES_WINDOW().
00191 { 00192 (win_assocs.lookup (g_event->fd))->v_event (*g_event); 00193 //forward to 00194 overlap_picture_ops(TRUE); 00195 }
void COMMAND_WINDOW::msg | ( | const char * | msg_str | ) | [inherited] |
Message display
Definition at line 176 of file cmndwin.cpp.
References COMMAND_WINDOW::message_str, overlap_picture_ops, COMMAND_WINDOW::plot_msg_area(), and TRUE.
Referenced by do_new_source(), do_write_file(), VAR_SUB_MENU::event(), STR_VAR_MENU_LEAF::event(), INT_VAR_MENU_LEAF::event(), DBL_VAR_MENU_LEAF::event(), BOOL_VAR_MENU_LEAF::event(), extend_moded_commands(), extend_unmoded_commands(), pgeditor_main(), pgeditor_msg(), pgeditor_show_point(), process_cmd_win_event(), process_image_event(), show_point(), v_event(), and write_vars().
00178 { 00179 strcpy(message_str, msg_str); 00180 plot_msg_area(); 00181 overlap_picture_ops(TRUE); 00182 }
void COMMAND_WINDOW::plot | ( | ) | [inherited] |
Repaint/plot the window
Definition at line 188 of file cmndwin.cpp.
References character_height, clear_view_surface, COMMAND_WINDOW::fd, COMMAND_WINDOW::menu_root, MENU_NODE::plot(), COMMAND_WINDOW::plot_msg_area(), COMMAND_WINDOW::plot_prompt_area(), and text_font_index.
Referenced by COMMAND_WINDOW::COMMAND_WINDOW(), COMMAND_WINDOW::event(), COMMAND_WINDOW::press_radio_button(), COMMAND_WINDOW::prompt(), and COMMAND_WINDOW::update_menu_tree().
00188 { 00189 clear_view_surface(fd); 00190 text_font_index (fd, 1); 00191 character_height(fd, menu_char_height); 00192 00193 plot_msg_area(); 00194 plot_prompt_area(); 00195 00196 menu_root->plot (fd); 00197 }
static void VARIABLES_WINDOW::plot_all | ( | ) | [inline, static] |
Definition at line 120 of file varblwin.h.
References win_assocs.
Referenced by pgeditor_main().
00120 { //Redisplay all vars 00121 win_assocs.plot_all (); 00122 }
void COMMAND_WINDOW::plot_msg_area | ( | ) | [inherited] |
plot_msg_area ??
Primitive to build a filled box and put text in it
Definition at line 205 of file cmndwin.cpp.
References DARK_SLATE_BLUE, FALSE, COMMAND_WINDOW::fd, fill_color_index, INT_SOLID, interior_style, COMMAND_WINDOW::message_str, MSG_AREA_HEIGHT, MSG_AREA_TOP_LEFT_X, MSG_AREA_TOP_LEFT_Y, MSG_TEXT_START_X, MSG_TEXT_START_Y, rectangle, text2d, text_color_index, WHITE, and COMMAND_WINDOW::window_width.
Referenced by COMMAND_WINDOW::internal_prompt(), COMMAND_WINDOW::msg(), and COMMAND_WINDOW::plot().
00205 { 00206 fill_color_index(fd, DARK_SLATE_BLUE); 00207 interior_style(fd, INT_SOLID, FALSE); 00208 00209 rectangle (fd, 00210 MSG_AREA_TOP_LEFT_X, MSG_AREA_TOP_LEFT_Y, 00211 MSG_AREA_TOP_LEFT_X + window_width - 1, 00212 MSG_AREA_TOP_LEFT_Y - MSG_AREA_HEIGHT); 00213 00214 text_color_index(fd, WHITE); 00215 text2d (fd, MSG_TEXT_START_X, MSG_TEXT_START_Y, message_str, 0, FALSE); 00216 }
void COMMAND_WINDOW::plot_prompt_area | ( | ) | [inherited] |
plot_prompt_area ??
Primitive to build a filled box and get user's input in it
Definition at line 224 of file cmndwin.cpp.
References DARK_SLATE_BLUE, FALSE, COMMAND_WINDOW::fd, fill_color_index, INT_SOLID, interior_style, MSG_AREA_HEIGHT, PROMPT_AREA_TOP_LEFT_X, PROMPT_AREA_TOP_LEFT_Y, COMMAND_WINDOW::prompt_str, PROMPT_TEXT_START_X, PROMPT_TEXT_START_Y, rectangle, text2d, text_color_index, WHITE, and COMMAND_WINDOW::window_width.
Referenced by COMMAND_WINDOW::internal_prompt(), and COMMAND_WINDOW::plot().
00224 { 00225 INT8 i; 00226 INT8 prompt_len; 00227 char char_str[2]; 00228 00229 fill_color_index(fd, DARK_SLATE_BLUE); 00230 interior_style(fd, INT_SOLID, FALSE); 00231 00232 rectangle (fd, 00233 PROMPT_AREA_TOP_LEFT_X, PROMPT_AREA_TOP_LEFT_Y, 00234 PROMPT_AREA_TOP_LEFT_X + window_width - 1, 00235 PROMPT_AREA_TOP_LEFT_Y - MSG_AREA_HEIGHT); 00236 00237 text_color_index(fd, WHITE); 00238 prompt_len = strlen (prompt_str); 00239 char_str[1] = '\0'; 00240 00241 for (i = 0; i < prompt_len; i++) { 00242 char_str[0] = prompt_str[i]; 00243 text2d (fd, 00244 PROMPT_TEXT_START_X + (i * menu_char_width), 00245 PROMPT_TEXT_START_Y, char_str, 0, FALSE); 00246 } 00247 }
void COMMAND_WINDOW::press_radio_button | ( | RADIO_MENU * | radio_sub_menu_item, | |
RADIO_MENU_LEAF * | button_menu_item | |||
) | [inherited] |
Change the selected button in a radio set
Definition at line 328 of file cmndwin.cpp.
References COMMAND_WINDOW::plot(), and RADIO_MENU::press_radio_button().
Referenced by process_cmd_win_event().
00330 { 00331 radio_sub_menu_item->press_radio_button (button_menu_item); 00332 plot(); 00333 }
BOOL8 COMMAND_WINDOW::prompt | ( | const char * | msg_str, | |
char * | response_str | |||
) | [inherited] |
Prompt for and read a response
Definition at line 391 of file cmndwin.cpp.
References COMMAND_WINDOW::internal_prompt(), and COMMAND_WINDOW::plot().
Referenced by do_new_source(), do_write_file(), process_cmd_win_event(), smd_cmd(), and write_vars().
00394 { 00395 BOOL8 ok; 00396 00397 ok = internal_prompt (msg_str, response_str); 00398 plot(); 00399 return ok; 00400 }
void COMMAND_WINDOW::replace_menu_text | ( | LEAF_MENU_NODE * | menu_item, | |
const char * | new_label | |||
) | [inherited] |
Change the label of a specified menu item
Definition at line 406 of file cmndwin.cpp.
References COMMAND_WINDOW::fd, MENU_NODE::new_label(), and MENU_NODE::plot().
Referenced by do_view_cmd().
void COMMAND_WINDOW::set_toggle | ( | TOGGLE_MENU_LEAF * | menu_item, | |
BOOL8 | new_value | |||
) | [inherited] |
Change the value of a specified menu item
Definition at line 418 of file cmndwin.cpp.
References COMMAND_WINDOW::fd, MENU_NODE::plot(), and TOGGLE_MENU_LEAF::set_toggle().
00420 { 00421 menu_item->set_toggle (new_value); 00422 menu_item->plot (fd); 00423 }
void COMMAND_WINDOW::update_menu_tree | ( | ) | [inherited] |
Recalculate window
Following a CHANGE to the menu tree, the boundng boxes must be recalculated, this may require the window to be re-created, the window must then be re-displayed.
Definition at line 343 of file cmndwin.cpp.
References BOX::bottom(), create_window, destroy_window, FALSE, COMMAND_WINDOW::fd, FULLSIZEWIN, MENU_AREA_TOP_LEFT_X, MENU_AREA_TOP_LEFT_Y, COMMAND_WINDOW::menu_root, MIN_WINDOW_WIDTH, MSG_AREA_TOP_LEFT_X, MSG_AREA_TOP_LEFT_Y, COMMAND_WINDOW::plot(), MENU_ROOT::recalc_bounding_box(), SCROLLINGWIN, TRUE, vdc_extent, BOX::width(), COMMAND_WINDOW::win_name, COMMAND_WINDOW::window_width, COMMAND_WINDOW::x_pos, and COMMAND_WINDOW::y_pos.
00343 { 00344 BOX menu_box; 00345 INT16 window_height; 00346 INT8 window_type = FULLSIZEWIN;//Default 00347 INT16 xsize; 00348 INT16 ysize; 00349 00350 menu_box = menu_root->recalc_bounding_box (MENU_AREA_TOP_LEFT_X, 00351 MENU_AREA_TOP_LEFT_Y); 00352 if (menu_box.width () > MIN_WINDOW_WIDTH) { 00353 window_width = menu_box.width (); 00354 } 00355 else { 00356 window_width = MIN_WINDOW_WIDTH; 00357 } 00358 00359 window_height = MSG_AREA_TOP_LEFT_Y - menu_box.bottom (); 00360 00361 xsize = window_width; 00362 ysize = window_height; 00363 00364 if (window_width > editor_cmdwin_width) { 00365 window_type = SCROLLINGWIN; 00366 xsize = editor_cmdwin_width; 00367 } 00368 00369 if (window_height > editor_cmdwin_height) { 00370 window_type = SCROLLINGWIN; 00371 ysize = editor_cmdwin_height; 00372 } 00373 destroy_window(fd); 00374 //min x 00375 fd = create_window (win_name, window_type, x_pos, y_pos, 00376 xsize, ysize, MSG_AREA_TOP_LEFT_X, 00377 window_width, //max x 00378 menu_box.bottom (), //min y 00379 MSG_AREA_TOP_LEFT_Y, //max_y 00380 TRUE, //mouse DOWN 00381 FALSE, FALSE, TRUE); //key press 00382 00383 vdc_extent (fd, 0, 0, xsize, ysize); 00384 plot(); 00385 }
void VARIABLES_WINDOW::v_event | ( | GRAPHICS_EVENT & | g_event | ) | [private] |
Do non standard event handling for specified commands
Definition at line 138 of file varblwin.cpp.
References VAR_SUB_MENU::child_closed(), destroy_window, COMMAND_WINDOW::event(), FALSE, graphicsevent::fd, INT32FORMAT, KILL_WINDOW_CMD, COMMAND_WINDOW::msg(), my_creator, NULL_COMMAND, TRUE, win_assocs, WRITE_ALL_CMD, WRITE_CHANGED_CMD, and write_vars().
Referenced by interrupt_handler().
00139 { 00140 INT32 cmd_event; //Command event type 00141 char new_value[80]; //of menu item 00142 char buff[80]; 00143 00144 COMMAND_WINDOW::event(g_event, &cmd_event, new_value); 00145 00146 switch (cmd_event) { 00147 case NULL_COMMAND: 00148 break; 00149 case WRITE_ALL_CMD: 00150 write_vars(new_value, FALSE); 00151 break; 00152 case WRITE_CHANGED_CMD: 00153 write_vars(new_value, TRUE); 00154 break; 00155 case KILL_WINDOW_CMD: 00156 win_assocs.remove (g_event.fd); 00157 destroy_window (g_event.fd); 00158 my_creator->child_closed (); 00159 delete this; 00160 break; 00161 default: 00162 sprintf (buff, "UNPROCESSED EVENT code " INT32FORMAT, cmd_event); 00163 msg(buff); 00164 } 00165 }
WINDOW COMMAND_WINDOW::window | ( | ) | [inline, inherited] |
Definition at line 101 of file cmndwin.h.
References COMMAND_WINDOW::fd.
Referenced by pgeditor_main().
00101 { //Return window handle 00102 return fd; 00103 }
void VARIABLES_WINDOW::write_vars | ( | char * | filename, | |
BOOL8 | changes_only | |||
) | [private] |
Write the variables to a config file
Definition at line 217 of file varblwin.cpp.
References MAX_CHARS, COMMAND_WINDOW::menu_root, COMMAND_WINDOW::msg(), NULL, COMMAND_WINDOW::prompt(), and MENU_ROOT::write_vars().
Referenced by v_event().
00220 { 00221 FILE *fp; //input file 00222 char msg_str[MAX_CHARS + 1]; 00223 char response_str[MAX_CHARS + 1]; 00224 char *token; //first response token 00225 00226 //if file exists 00227 if ((fp = fopen (filename, "r")) != NULL) { 00228 fclose(fp); 00229 sprintf (msg_str, "Overwrite file " "%s" "? (Y/N)", filename); 00230 response_str[0] = '\0'; 00231 if (!prompt (msg_str, response_str)) 00232 return; 00233 token = strtok (response_str, " "); 00234 if (tolower (token[0]) != 'y') 00235 return; // dont write 00236 } 00237 00238 fp = fopen (filename, "w"); //can we write to it? 00239 if (fp == NULL) { 00240 sprintf (msg_str, "Cant write to file " "%s" "", filename); 00241 msg(msg_str); 00242 return; 00243 } 00244 menu_root->write_vars (fp, changes_only); 00245 fclose(fp); 00246 }
WINDOW COMMAND_WINDOW::fd [protected, inherited] |
Definition at line 57 of file cmndwin.h.
Referenced by COMMAND_WINDOW::COMMAND_WINDOW(), internal_prompt(), COMMAND_WINDOW::internal_prompt(), COMMAND_WINDOW::plot(), COMMAND_WINDOW::plot_msg_area(), COMMAND_WINDOW::plot_prompt_area(), COMMAND_WINDOW::replace_menu_text(), COMMAND_WINDOW::set_toggle(), COMMAND_WINDOW::update_menu_tree(), VARIABLES_WINDOW(), and COMMAND_WINDOW::window().
MENU_ROOT* COMMAND_WINDOW::menu_root [protected, inherited] |
Definition at line 58 of file cmndwin.h.
Referenced by COMMAND_WINDOW::COMMAND_WINDOW(), COMMAND_WINDOW::event(), COMMAND_WINDOW::plot(), COMMAND_WINDOW::update_menu_tree(), and write_vars().
VAR_SUB_MENU* VARIABLES_WINDOW::my_creator [private] |
ASSOCIATION_LIST VARIABLES_WINDOW::win_assocs [static, private] |
Definition at line 97 of file varblwin.h.
Referenced by internal_prompt(), interrupt_handler(), plot_all(), v_event(), and VARIABLES_WINDOW().