Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
svmnode.h
Go to the documentation of this file.
1
2 // File: svmnode.h
3 // description_: ScrollView Menu Node
4 // Author: Joern Wanke
5 // Created: Thu Nov 29 2007
6 //
7 // (C) Copyright 2007, Google Inc.
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 //
19 //
20 // A SVMenuNode is an entity which contains the mapping from a menu entry on
21 // the server side to the corresponding associated commands on the client.
22 // It is designed to be a tree structure with a root node, which can then be
23 // used to generate the appropriate messages to the server to display the
24 // menu structure there.
25 // A SVMenuNode can both be used in the context_ of popup menus as well as
26 // menu bars.
27
28 #ifndef TESSERACT_VIEWER_SVMNODE_H__
29 #define TESSERACT_VIEWER_SVMNODE_H__
30
31 class ScrollView;
32
33 class SVMenuNode {
34 public:
35 // Creating the (empty) root menu node.
36 SVMenuNode();
37
38 // Destructor for every node.
39 ~SVMenuNode();
40
41 // Create a new sub menu node with just a caption. This is used to create
42 // nodes which act as parent nodes to other nodes (e.g. submenus).
43 SVMenuNode* AddChild(const char* txt);
44
45 // Create a "normal" menu node which is associated with a command event.
46 void AddChild(const char* txt, int command_event);
47
48 // Create a flag menu node.
49 void AddChild(const char* txt, int command_event, int tv);
50
51 // Create a menu node with an associated value (which might be changed
52 // through the gui).
53 void AddChild(const char* txt, int command_event, const char* val);
54
55 // Create a menu node with an associated value and description_.
56 void AddChild(const char* txt, int command_event,
57 const char* val, const char* desc);
58
59 // Build a menu structure for the server and send the necessary messages.
60 // Should be called on the root node. If menu_bar is true, a menu_bar menu
61 // is built (e.g. on top of the window), if it is false a popup menu is
62 // built which gets shown by right clicking on the window.
63 void BuildMenu(ScrollView *sv, bool menu_bar = true);
64
65 private:
66 // Constructor holding the actual node data.
67 SVMenuNode(int command_event, const char* txt, int tv,
68 bool check_box_entry, const char* val, const char* desc);
69
70 // Adds a new menu node to the current node.
71 void AddChild(SVMenuNode* svmn);
72
73 // The parent node of this node.
74 SVMenuNode* parent_;
75 // The first child of this node.
76 SVMenuNode* child_;
77 // The next "sibling" of this node (e.g. same parent).
78 SVMenuNode* next_;
79 // Whether this menu node actually is a flag.
80 bool is_check_box_entry_;
81
82 // The command event associated with a specific menu node. Should be unique.
83 int cmd_event_;
84 // The caption associated with a specific menu node.
85 char* text_;
86 // The value of the flag (if this menu node is a flag).
87 bool toggle_value_;
88 // The value of the menu node. (optional)
89 const char* value_;
90 // A description_ of the value. (optional)
91 const char* description_;
92 };
93
94 #endif // TESSERACT_VIEWER_SVMNODE_H__