|
tesseract 3.04.01
|
00001 00002 // File: svmnode.h 00003 // description_: ScrollView Menu Node 00004 // Author: Joern Wanke 00005 // Created: Thu Nov 29 2007 00006 // 00007 // (C) Copyright 2007, Google Inc. 00008 // Licensed under the Apache License, Version 2.0 (the "License"); 00009 // you may not use this file except in compliance with the License. 00010 // You may obtain a copy of the License at 00011 // http://www.apache.org/licenses/LICENSE-2.0 00012 // Unless required by applicable law or agreed to in writing, software 00013 // distributed under the License is distributed on an "AS IS" BASIS, 00014 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 // See the License for the specific language governing permissions and 00016 // limitations under the License. 00017 // 00019 // 00020 // A SVMenuNode is an entity which contains the mapping from a menu entry on 00021 // the server side to the corresponding associated commands on the client. 00022 // It is designed to be a tree structure with a root node, which can then be 00023 // used to generate the appropriate messages to the server to display the 00024 // menu structure there. 00025 // A SVMenuNode can both be used in the context_ of popup menus as well as 00026 // menu bars. 00027 00028 #ifndef TESSERACT_VIEWER_SVMNODE_H__ 00029 #define TESSERACT_VIEWER_SVMNODE_H__ 00030 00031 #include "strngs.h" 00032 00033 class ScrollView; 00034 00035 class SVMenuNode { 00036 public: 00037 // Creating the (empty) root menu node. 00038 SVMenuNode(); 00039 00040 // Destructor for every node. 00041 ~SVMenuNode(); 00042 00043 // Create a new sub menu node with just a caption. This is used to create 00044 // nodes which act as parent nodes to other nodes (e.g. submenus). 00045 SVMenuNode* AddChild(const char* txt); 00046 00047 // Create a "normal" menu node which is associated with a command event. 00048 void AddChild(const char* txt, int command_event); 00049 00050 // Create a flag menu node. 00051 void AddChild(const char* txt, int command_event, int tv); 00052 00053 // Create a menu node with an associated value (which might be changed 00054 // through the gui). 00055 void AddChild(const char* txt, int command_event, const char* val); 00056 00057 // Create a menu node with an associated value and description_. 00058 void AddChild(const char* txt, int command_event, 00059 const char* val, const char* desc); 00060 00061 // Build a menu structure for the server and send the necessary messages. 00062 // Should be called on the root node. If menu_bar is true, a menu_bar menu 00063 // is built (e.g. on top of the window), if it is false a popup menu is 00064 // built which gets shown by right clicking on the window. 00065 void BuildMenu(ScrollView *sv, bool menu_bar = true); 00066 00067 private: 00068 // Constructor holding the actual node data. 00069 SVMenuNode(int command_event, const char* txt, int tv, 00070 bool check_box_entry, const char* val, const char* desc); 00071 00072 // Adds a new menu node to the current node. 00073 void AddChild(SVMenuNode* svmn); 00074 00075 // The parent node of this node. 00076 SVMenuNode* parent_; 00077 // The first child of this node. 00078 SVMenuNode* child_; 00079 // The next "sibling" of this node (e.g. same parent). 00080 SVMenuNode* next_; 00081 // Whether this menu node actually is a flag. 00082 bool is_check_box_entry_; 00083 00084 // The command event associated with a specific menu node. Should be unique. 00085 int cmd_event_; 00086 // The caption associated with a specific menu node. 00087 STRING text_; 00088 // The value of the flag (if this menu node is a flag). 00089 bool toggle_value_; 00090 // The value of the menu node. (optional) 00091 STRING value_; 00092 // A description_ of the value. (optional) 00093 STRING description_; 00094 }; 00095 00096 #endif // TESSERACT_VIEWER_SVMNODE_H__