Tesseract
3.02
|
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 class ScrollView; 00032 00033 class SVMenuNode { 00034 public: 00035 // Creating the (empty) root menu node. 00036 SVMenuNode(); 00037 00038 // Destructor for every node. 00039 ~SVMenuNode(); 00040 00041 // Create a new sub menu node with just a caption. This is used to create 00042 // nodes which act as parent nodes to other nodes (e.g. submenus). 00043 SVMenuNode* AddChild(const char* txt); 00044 00045 // Create a "normal" menu node which is associated with a command event. 00046 void AddChild(const char* txt, int command_event); 00047 00048 // Create a flag menu node. 00049 void AddChild(const char* txt, int command_event, int tv); 00050 00051 // Create a menu node with an associated value (which might be changed 00052 // through the gui). 00053 void AddChild(const char* txt, int command_event, const char* val); 00054 00055 // Create a menu node with an associated value and description_. 00056 void AddChild(const char* txt, int command_event, 00057 const char* val, const char* desc); 00058 00059 // Build a menu structure for the server and send the necessary messages. 00060 // Should be called on the root node. If menu_bar is true, a menu_bar menu 00061 // is built (e.g. on top of the window), if it is false a popup menu is 00062 // built which gets shown by right clicking on the window. 00063 void BuildMenu(ScrollView *sv, bool menu_bar = true); 00064 00065 private: 00066 // Constructor holding the actual node data. 00067 SVMenuNode(int command_event, const char* txt, int tv, 00068 bool check_box_entry, const char* val, const char* desc); 00069 00070 // Adds a new menu node to the current node. 00071 void AddChild(SVMenuNode* svmn); 00072 00073 // The parent node of this node. 00074 SVMenuNode* parent_; 00075 // The first child of this node. 00076 SVMenuNode* child_; 00077 // The next "sibling" of this node (e.g. same parent). 00078 SVMenuNode* next_; 00079 // Whether this menu node actually is a flag. 00080 bool is_check_box_entry_; 00081 00082 // The command event associated with a specific menu node. Should be unique. 00083 int cmd_event_; 00084 // The caption associated with a specific menu node. 00085 char* text_; 00086 // The value of the flag (if this menu node is a flag). 00087 bool toggle_value_; 00088 // The value of the menu node. (optional) 00089 const char* value_; 00090 // A description_ of the value. (optional) 00091 const char* description_; 00092 }; 00093 00094 #endif // TESSERACT_VIEWER_SVMNODE_H__