⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sbdmenu.cpp

📁 一OCR的相关资料。.希望对研究OCR的朋友有所帮助.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/********************************************************************** * File:        sbdmenu.cpp  (Formerly menu.c) * Description: Command Window MENU class * Author:      Phil Cheatle * Created:     Thu Oct 10 16:25:24 BST 1991 * * (C) Copyright 1991, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** http://www.apache.org/licenses/LICENSE-2.0 ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. * **********************************************************************/#include "mfcpch.h"#include "sbdmenu.h"#define MENU_COLUMN_SPACING   (menu_char_height / 2)#define MENU_ITEM_HEIGHT      (int)(menu_char_height * 1.5)#define MENU_SEPARATOR_HEIGHT MENU_COLUMN_SPACING#define MENU_TEXT_X_OFFSET      (menu_char_height / 2)#define MENU_TEXT_Y_OFFSET  menu_char_height/2#include          "notdll.h"ELISTIZE(MENU_L); const ERRCODE NOT_SUBMENU_NODE = "Button is not leaf of radio submenu";const ERRCODE SHOULDNT_BE_CALLED = "Should never get to here!!";INT_VAR (menu_char_width, 8, "Width of characters in menu text");INT_VAR (menu_char_height, 14, "Height characters in menu text");/********************************************************************** *********************************************************************** * *       LEAF_MENU_NODE     MEMBER FUNCTIONS * *********************************************************************** **********************************************************************//********************************************************************** * LEAF_MENU_NODE::plotx( ) * * The real plot.  Positions assumed already calculated. **********************************************************************/void LEAF_MENU_NODE::plotx(               //draw it                           WINDOW window  //in this window                          ) {  box.plot (window);  text2d (window,    box.left () + MENU_TEXT_X_OFFSET,    box.top () - MENU_TEXT_Y_OFFSET, name.string (), 0, FALSE);}/********************************************************************** *********************************************************************** * *       MENU_NODE     MEMBER FUNCTIONS * *********************************************************************** **********************************************************************//********************************************************************** * MENU_NODE::plot( ) * * Initialise, then call plotx to do the real work * (This means that we can initialise plotting once only REGARDLESS of what menu * subclass we start plotting.  (EG - we don't always start with a MENU_ROOT.) **********************************************************************/void MENU_NODE::plot(               //draw it                     WINDOW window  //window to draw in                    ) {  character_height(window, menu_char_height);   interior_style(window, INT_SOLID, TRUE);   perimeter_color_index(window, LIGHT_GREY);   text_color_index(window, WHITE);   fill_color_index(window, GREY);   plotx(window); }/********************************************************************** * MENU_NODE::recalc_bounding_box( ) * * SHOULD NEVER BE CALLED.  Compiler needs it as this can't be a pure virtual * function as not all classes provide it and the compiler will not let you do * "new" on a class which inherits a pure virtual function which it cannot * resolve into a real function. **********************************************************************/BOX &MENU_NODE::recalc_bounding_box(        // calculate size                                    INT16,  // start topleft x                                    INT16   // start topleft y                                   ) {  SHOULDNT_BE_CALLED.error ("MENU_ROOT::recalc_bounding_box", ABORT, NULL);  return box;}/********************************************************************** * MENU_NODE::recalc_fixed_width_bb( ) * * Calculate the selectable area of the menu item and hence its display * position.  Note that the width is predetermined. **********************************************************************/BOX &MENU_NODE::recalc_fixed_width_bb(             // calc BB                                      INT16 tl_x,  // start topleft x                                      INT16 tl_y,  // start topleft y                                      INT16 width  // width                                     ) {  box = BOX (ICOORD (tl_x, tl_y - MENU_ITEM_HEIGHT),    ICOORD (tl_x + width, tl_y));  return box;}/********************************************************************** *********************************************************************** * *       MENU_ROOT     MEMBER FUNCTIONS * *********************************************************************** **********************************************************************//********************************************************************** * MENU_ROOT::plotx( ) * * The real plot - only called internally after initialisation. * Display the menu recursively.  Positions assumed already calculated. **********************************************************************/void MENU_ROOT::plotx(               //draw it                      WINDOW window  //in this window                     ) {  MENU_L_IT it(&menu_list);   for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())    it.data ()->ptr->plotx (window);}/********************************************************************** * MENU_ROOT::recalc_bounding_box( ) * * Calculate the selectable areas of the menu items and hence their display * positions. **********************************************************************/BOX &MENU_ROOT::recalc_bounding_box(             // calculate size                                    INT16 tl_x,  // start topleft x                                    INT16 tl_y   // start topleft y                                   ) {  MENU_L_IT it(&menu_list);   box = BOX (ICOORD (tl_x, tl_y), ICOORD (tl_x, tl_y));  for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {    box += it.data ()->ptr->recalc_bounding_box (box.right (), box.top ());    box.move_right_edge (MENU_COLUMN_SPACING);  }  box.move_right_edge (-MENU_COLUMN_SPACING);  return box;}/********************************************************************** * MENU_ROOT::write_vars( ) * * Just propogate down the menu tree **********************************************************************/void MENU_ROOT::write_vars(                    //save config vars                           FILE *fp,           //in this file                           BOOL8 changes_only  //Changed vars only?                          ) {  MENU_L_IT it(&menu_list);   for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())    it.data ()->ptr->write_vars (fp, changes_only);}/********************************************************************** *********************************************************************** * *       NON_LEAF_MENU_NODE     MEMBER FUNCTIONS * *********************************************************************** **********************************************************************//********************************************************************** * NON_LEAF_MENU_NODE::link_child( MENU_NODE* ) * * Add a child to the end of the menu list **********************************************************************/void NON_LEAF_MENU_NODE::link_child(  //add to menu end                                    MENU_NODE *new_child) {  MENU_L_IT it(&menu_list);   it.add_to_end (new MENU_L (new_child));}/********************************************************************** * NON_LEAF_MENU_NODE::link_child_link( ) * * Add a child to the end of the menu list **********************************************************************/void NON_LEAF_MENU_NODE::link_child_link(  //add to menu                                         MENU_L *new_child) {  MENU_L_IT it(&menu_list);   it.add_to_end (new_child);}/********************************************************************** * NON_LEAF_MENU_NODE::event( ) * * Event selection **********************************************************************/void NON_LEAF_MENU_NODE::event(                          //User clicked...                               COMMAND_WINDOW *cmd_win,  //For UI, update etc                               FCOORD pt,                //here                               INT32 *cmd_event_id,      //Command selected                               char *new_value           //Edited value                              ) {  MENU_L_IT it(&menu_list);   if (box.contains (pt))    for (it.mark_cycle_pt ();    (*cmd_event_id == UNIDENTIFIED_COMMAND) && !it.cycled_list ();    it.forward ())  it.data ()->ptr->event (cmd_win, pt, cmd_event_id, new_value);}/********************************************************************** * NON_LEAF_MENU_NODE::max_num_chars( ) * * Calculate the max character width of any item of this and its children **********************************************************************/INT8 NON_LEAF_MENU_NODE::max_num_chars() {  //calc char width  MENU_L_IT it(&menu_list);   INT8 max_so_far = 0;  INT8 current_char_count = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -