tesseract  5.0.0-alpha-619-ge9db
svmnode.h
Go to the documentation of this file.
1 // 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 #include <tesseract/strngs.h>
32 
33 class ScrollView;
34 
35 class SVMenuNode {
36  public:
37  // Creating the (empty) root menu node.
38  SVMenuNode();
39 
40  // Destructor for every node.
41  ~SVMenuNode();
42 
43  // Create a new sub menu node with just a caption. This is used to create
44  // nodes which act as parent nodes to other nodes (e.g. submenus).
45  SVMenuNode* AddChild(const char* txt);
46 
47  // Create a "normal" menu node which is associated with a command event.
48  void AddChild(const char* txt, int command_event);
49 
50  // Create a flag menu node.
51  void AddChild(const char* txt, int command_event, int tv);
52 
53  // Create a menu node with an associated value (which might be changed
54  // through the gui).
55  void AddChild(const char* txt, int command_event, const char* val);
56 
57  // Create a menu node with an associated value and description_.
58  void AddChild(const char* txt, int command_event,
59  const char* val, const char* desc);
60 
61  // Build a menu structure for the server and send the necessary messages.
62  // Should be called on the root node. If menu_bar is true, a menu_bar menu
63  // is built (e.g. on top of the window), if it is false a popup menu is
64  // built which gets shown by right clicking on the window.
65  void BuildMenu(ScrollView *sv, bool menu_bar = true);
66 
67  private:
68  // Constructor holding the actual node data.
69  SVMenuNode(int command_event, const char* txt, int tv,
70  bool check_box_entry, const char* val, const char* desc);
71 
72  // Adds a new menu node to the current node.
73  void AddChild(SVMenuNode* svmn);
74 
75  // The parent node of this node.
76  SVMenuNode* parent_;
77  // The first child of this node.
78  SVMenuNode* child_;
79  // The next "sibling" of this node (e.g. same parent).
80  SVMenuNode* next_;
81  // Whether this menu node actually is a flag.
82  bool is_check_box_entry_;
83 
84  // The command event associated with a specific menu node. Should be unique.
85  int cmd_event_;
86  // The caption associated with a specific menu node.
87  STRING text_;
88  // The value of the flag (if this menu node is a flag).
89  bool toggle_value_;
90  // The value of the menu node. (optional)
91  STRING value_;
92  // A description_ of the value. (optional)
93  STRING description_;
94 };
95 
96 #endif // TESSERACT_VIEWER_SVMNODE_H_
ScrollView
Definition: scrollview.h:97
strngs.h
SVMenuNode::SVMenuNode
SVMenuNode()
Definition: svmnode.cpp:44
SVMenuNode::AddChild
SVMenuNode * AddChild(const char *txt)
Definition: svmnode.cpp:58
STRING
Definition: strngs.h:45
SVMenuNode::BuildMenu
void BuildMenu(ScrollView *sv, bool menu_bar=true)
Definition: svmnode.cpp:120
SVMenuNode
Definition: svmnode.h:35
SVMenuNode::~SVMenuNode
~SVMenuNode()
Definition: svmnode.cpp:53