COMMAND_WINDOW Class Reference

#include <cmndwin.h>

Inheritance diagram for COMMAND_WINDOW:

VARIABLES_WINDOW List of all members.

Detailed Description

Class for dealing with command window.

Definition at line 39 of file cmndwin.h.

Public Member Functions

Protected Member Functions

Protected Attributes

Private Attributes

Static Private Attributes

Friends


Constructor & Destructor Documentation

COMMAND_WINDOW::COMMAND_WINDOW ( const char *  name,
MENU_ROOT menu_ptr 
)

COMMAND_WINDOW constructor

Definition at line 70 of file cmndwin.cpp.

References BOX::bottom(), create_window, FALSE, fd, FULLSIZEWIN, MENU_AREA_TOP_LEFT_X, MENU_AREA_TOP_LEFT_Y, menu_root, message_str, MIN_WINDOW_WIDTH, MSG_AREA_TOP_LEFT_X, MSG_AREA_TOP_LEFT_Y, next_win_x_pos, next_win_y_pos, plot(), prompt_str, MENU_ROOT::recalc_bounding_box(), SCROLLINGWIN, TRUE, vdc_extent, BOX::width(), win_name, window_width, x_pos, and y_pos.

00072                                 {
00073   BOX menu_box;
00074   INT16 window_height;
00075   INT8 window_type = FULLSIZEWIN;//Default
00076   INT16 xsize;
00077   INT16 ysize;
00078 
00079   message_str[0] = '\0';
00080   prompt_str[0] = '\0';
00081   strcpy(win_name, name); 
00082 
00083   menu_root = menu_ptr;
00084   menu_box = menu_root->recalc_bounding_box (MENU_AREA_TOP_LEFT_X,
00085     MENU_AREA_TOP_LEFT_Y);
00086 
00087   if (menu_box.width () > MIN_WINDOW_WIDTH) {
00088     window_width = menu_box.width ();
00089   }
00090   else {
00091     window_width = MIN_WINDOW_WIDTH;
00092   }
00093 
00094   window_height = MSG_AREA_TOP_LEFT_Y - menu_box.bottom ();
00095 
00096   xsize = window_width;
00097   ysize = window_height;
00098 
00099   if (window_width > editor_cmdwin_width) {
00100     window_type = SCROLLINGWIN;
00101     xsize = editor_cmdwin_width;
00102   }
00103 
00104   if (window_height > editor_cmdwin_height) {
00105     window_type = SCROLLINGWIN;
00106     ysize = editor_cmdwin_height;
00107   }
00108 
00109   if ((next_win_x_pos == 0) && (next_win_x_pos == 0)) {
00110                                  //Init for 1st win
00111     next_win_x_pos = editor_cmdwin_xpos1;
00112     next_win_y_pos = editor_cmdwin_ypos1;
00113   }
00114   x_pos = next_win_x_pos;
00115   y_pos = next_win_y_pos;
00116 
00117                                  //min x
00118   fd = create_window (name, window_type, x_pos, y_pos, xsize, ysize, MSG_AREA_TOP_LEFT_X,
00119     window_width,                //max x
00120     menu_box.bottom (),          //min y
00121     MSG_AREA_TOP_LEFT_Y,         //max_y
00122     TRUE,                        //mouse DOWN
00123     FALSE, FALSE, TRUE);         //key press
00124 
00125   vdc_extent (fd, 0, 0, xsize, ysize);
00126   next_win_x_pos += editor_cmdwin_xoffset;
00127   next_win_y_pos += editor_cmdwin_yoffset;
00128 
00129   plot(); 
00130 }


Member Function Documentation

void COMMAND_WINDOW::event ( GRAPHICS_EVENT g_event,
INT32 cmd_event,
char *  new_value 
)

COMMAND_WINDOW event handler

Definition at line 136 of file cmndwin.cpp.

References DOWN_EVENT, MENU_ROOT::event(), graphicsevent::key, KEYPRESS_EVENT, menu_root, message_str, NULL_COMMAND, plot(), prompt_str, graphicsevent::type, UNIDENTIFIED_COMMAND, graphicsevent::x, and graphicsevent::y.

Referenced by internal_prompt(), pgeditor_main(), and VARIABLES_WINDOW::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 COMMAND_WINDOW::internal_prompt ( const char *  msg_str,
char *  response_str 
) [protected, virtual]

Prompt for and read a response WITHOUT DOING a PLOT!

Reimplemented in VARIABLES_WINDOW.

Definition at line 253 of file cmndwin.cpp.

References ANY_EVENT, await_event, BACKSPACE_KEY, DARK_SLATE_BLUE, event(), FALSE, fd, fill_color_index, INT_SOLID, interior_style, KEYPRESS_EVENT, MAX_CHARS, message_str, overlap_picture_ops, plot_msg_area(), plot_prompt_area(), PROMPT_AREA_HEIGHT, PROMPT_AREA_TOP_LEFT_X, PROMPT_AREA_TOP_LEFT_Y, prompt_str, PROMPT_TEXT_START_X, PROMPT_TEXT_START_Y, rectangle, RETURN_KEY, text2d, TRUE, and window_width.

Referenced by STR_VAR_MENU_LEAF::event(), INT_VAR_MENU_LEAF::event(), DBL_VAR_MENU_LEAF::event(), VARIABLE_MENU_LEAF::event(), VARIABLES_WINDOW::internal_prompt(), and prompt().

00256                                        {
00257   GRAPHICS_EVENT event;
00258   INT8 pos;
00259   BOOL8 ok = TRUE;
00260 
00261   strcpy(message_str, msg_str); 
00262   strcpy(prompt_str, response_str); 
00263   plot_msg_area(); 
00264   plot_prompt_area(); 
00265   overlap_picture_ops(TRUE); 
00266 
00267   /* MODE THE UI SO THAT IT ONLY RESPONDS TO KEYPRESSes IN THE COMMAND WINDOW */
00268 
00269   event.key = '\0';
00270 
00271   while (event.key != RETURN_KEY) {
00272     await_event(fd,         //just cmd window
00273                 TRUE,       //wait for event
00274                 ANY_EVENT,  //ONLY keypresses
00275                 &event);
00276 
00277     if (event.type != KEYPRESS_EVENT) {
00278       ok = FALSE;
00279       response_str[0] = '\0';
00280       break;
00281     }
00282 
00283     pos = strlen (response_str);
00284     if (isprint (event.key) && pos < MAX_CHARS) {
00285       response_str[pos] = event.key;
00286       response_str[pos + 1] = '\0';
00287       text2d (fd,
00288         PROMPT_TEXT_START_X + (pos * menu_char_width),
00289         PROMPT_TEXT_START_Y, response_str + pos, 0, FALSE);
00290     }
00291     else {
00292       switch (event.key) {
00293         case BACKSPACE_KEY:
00294           if (pos > 0) {
00295             response_str[pos - 1] = '\0';
00296             fill_color_index(fd, DARK_SLATE_BLUE); 
00297             interior_style(fd, INT_SOLID, FALSE); 
00298 
00299             rectangle (fd,
00300               PROMPT_TEXT_START_X + (pos -
00301               1) * menu_char_width,
00302               PROMPT_AREA_TOP_LEFT_Y,
00303               PROMPT_AREA_TOP_LEFT_X + window_width - 1,
00304               PROMPT_AREA_TOP_LEFT_Y - PROMPT_AREA_HEIGHT);
00305           }
00306           break;
00307         case RETURN_KEY:
00308           break;
00309         default:
00310           sprintf (message_str, "NON PRINTING CHAR: %o", event.key);
00311           plot_msg_area(); 
00312       }
00313     }
00314     overlap_picture_ops(TRUE); 
00315   }
00316   message_str[0] = '\0';
00317   prompt_str[0] = '\0';
00318   #ifdef __UNIX__
00319   //   clear_event_queue(0);            //clear ALL win events
00320   #endif
00321   return ok;
00322 }

void COMMAND_WINDOW::msg ( const char *  msg_str  ) 

Message display

Definition at line 176 of file cmndwin.cpp.

References message_str, overlap_picture_ops, 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(), VARIABLES_WINDOW::v_event(), and VARIABLES_WINDOW::write_vars().

00178                           {
00179   strcpy(message_str, msg_str); 
00180   plot_msg_area(); 
00181   overlap_picture_ops(TRUE); 
00182 }

void COMMAND_WINDOW::plot (  ) 

Repaint/plot the window

Definition at line 188 of file cmndwin.cpp.

References character_height, clear_view_surface, fd, menu_root, MENU_NODE::plot(), plot_msg_area(), plot_prompt_area(), and text_font_index.

Referenced by COMMAND_WINDOW(), event(), press_radio_button(), prompt(), and 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 }

void COMMAND_WINDOW::plot_msg_area (  ) 

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, fd, fill_color_index, INT_SOLID, interior_style, 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 window_width.

Referenced by internal_prompt(), msg(), and plot().

void COMMAND_WINDOW::plot_prompt_area (  ) 

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, fd, fill_color_index, INT_SOLID, interior_style, MSG_AREA_HEIGHT, PROMPT_AREA_TOP_LEFT_X, PROMPT_AREA_TOP_LEFT_Y, prompt_str, PROMPT_TEXT_START_X, PROMPT_TEXT_START_Y, rectangle, text2d, text_color_index, WHITE, and window_width.

Referenced by internal_prompt(), and 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 
)

Change the selected button in a radio set

Definition at line 328 of file cmndwin.cpp.

References 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 
)

Prompt for and read a response

Definition at line 391 of file cmndwin.cpp.

References internal_prompt(), and plot().

Referenced by do_new_source(), do_write_file(), process_cmd_win_event(), smd_cmd(), and VARIABLES_WINDOW::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 
)

Change the label of a specified menu item

Definition at line 406 of file cmndwin.cpp.

References fd, MENU_NODE::new_label(), and MENU_NODE::plot().

Referenced by do_view_cmd().

00409                 {
00410   menu_item->new_label (new_label);
00411   menu_item->plot (fd);
00412 }

void COMMAND_WINDOW::set_toggle ( TOGGLE_MENU_LEAF menu_item,
BOOL8  new_value 
)

Change the value of a specified menu item

Definition at line 418 of file cmndwin.cpp.

References 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 (  ) 

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, fd, FULLSIZEWIN, MENU_AREA_TOP_LEFT_X, MENU_AREA_TOP_LEFT_Y, menu_root, MIN_WINDOW_WIDTH, MSG_AREA_TOP_LEFT_X, MSG_AREA_TOP_LEFT_Y, plot(), MENU_ROOT::recalc_bounding_box(), SCROLLINGWIN, TRUE, vdc_extent, BOX::width(), win_name, window_width, x_pos, and 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 }

WINDOW COMMAND_WINDOW::window (  )  [inline]

Definition at line 101 of file cmndwin.h.

References fd.

Referenced by pgeditor_main().

00101                     {  //Return window handle
00102       return fd;
00103     }


Friends And Related Function Documentation

friend class DBL_VAR_MENU_LEAF [friend]

Definition at line 42 of file cmndwin.h.

friend class INT_VAR_MENU_LEAF [friend]

Definition at line 43 of file cmndwin.h.

friend class STR_VAR_MENU_LEAF [friend]

Definition at line 44 of file cmndwin.h.

friend class VARIABLE_MENU_LEAF [friend]

Definition at line 41 of file cmndwin.h.


Member Data Documentation

WINDOW COMMAND_WINDOW::fd [protected]

Definition at line 57 of file cmndwin.h.

Referenced by COMMAND_WINDOW(), VARIABLES_WINDOW::internal_prompt(), internal_prompt(), plot(), plot_msg_area(), plot_prompt_area(), replace_menu_text(), set_toggle(), update_menu_tree(), VARIABLES_WINDOW::VARIABLES_WINDOW(), and window().

MENU_ROOT* COMMAND_WINDOW::menu_root [protected]

Definition at line 58 of file cmndwin.h.

Referenced by COMMAND_WINDOW(), event(), plot(), update_menu_tree(), and VARIABLES_WINDOW::write_vars().

char COMMAND_WINDOW::message_str[MAX_CHARS+1] [private]

Definition at line 48 of file cmndwin.h.

Referenced by COMMAND_WINDOW(), event(), internal_prompt(), msg(), and plot_msg_area().

INT16 COMMAND_WINDOW::next_win_x_pos [static, private]

Definition at line 53 of file cmndwin.h.

Referenced by COMMAND_WINDOW().

INT16 COMMAND_WINDOW::next_win_y_pos [static, private]

Definition at line 54 of file cmndwin.h.

Referenced by COMMAND_WINDOW().

char COMMAND_WINDOW::prompt_str[MAX_CHARS+1] [private]

Definition at line 49 of file cmndwin.h.

Referenced by COMMAND_WINDOW(), event(), internal_prompt(), and plot_prompt_area().

char COMMAND_WINDOW::win_name[MAX_CHARS+1] [private]

Definition at line 52 of file cmndwin.h.

Referenced by COMMAND_WINDOW(), and update_menu_tree().

INT16 COMMAND_WINDOW::window_width [private]

Definition at line 46 of file cmndwin.h.

Referenced by COMMAND_WINDOW(), internal_prompt(), plot_msg_area(), plot_prompt_area(), and update_menu_tree().

INT16 COMMAND_WINDOW::x_pos [private]

Definition at line 50 of file cmndwin.h.

Referenced by COMMAND_WINDOW(), and update_menu_tree().

INT16 COMMAND_WINDOW::y_pos [private]

Definition at line 51 of file cmndwin.h.

Referenced by COMMAND_WINDOW(), and update_menu_tree().


The documentation for this class was generated from the following files:
Generated on Wed Feb 28 19:49:31 2007 for Tesseract by  doxygen 1.5.1