Changeset 1890:4a583e07d4b8 in lemon-0.x
- Timestamp:
- 01/11/06 16:49:06 (19 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2465
- Location:
- gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
gui/main_win.cc
r1889 r1890 458 458 { 459 459 int i=0; 460 for(;((i< tabnames.size())&&(tabnames[i]!=tabname));i++)460 for(;((i<(int)tabnames.size())&&(tabnames[i]!=tabname));i++) 461 461 { 462 462 } -
gui/new_map_win.h
r1887 r1890 12 12 #include <stack> 13 13 14 ///Graphical interface for node/edge map creation. 15 14 16 ///This class is responsible for creating a window, 15 17 ///on which the parameters of a new map can be set. 16 17 18 class NewMapWin : public Gtk::Dialog 18 19 { 20 ///The \ref NoteBookTab in which the new map has to be placed. 19 21 NoteBookTab & mytab; 20 22 21 23 public: 24 25 ///Struct to be able to evaluate expressions. 26 27 ///Initial values of map elements can be given 28 ///by numbers or by expressions. From expressions 29 ///we build first a tree. This is the data structure 30 ///that can store one tree element. 22 31 struct tree_node 23 32 { 33 ///Character stored in this tree element 24 34 char ch; 35 ///Left child of tree element. 25 36 tree_node * left_child; 37 ///Right child of tree element. 26 38 tree_node * right_child; 27 39 }; 28 40 29 ///Constructor of NewMapWin creates the widgets shown in NewMapWin. 41 ///Constructor of NewMapWin. 42 43 ///It creates the widgets shown in 44 ///NewMapWin. 30 45 NewMapWin(const std::string& title, NoteBookTab &, bool itisedge=true, bool edgenode=true); 31 46 32 ///Signal on button is connected to this function, 33 ///Therefore this function determines whether to 34 ///call the map/creatort function, and if yes, it 35 //tells it the attributes.(name, default value) 47 ///Callback function for OK button. It creates the map. 48 49 ///This function determines whether the input is correct: 50 ///the name of new map must not be already used, the expression 51 ///that gives tha initial values of map elements has to be valid. 52 ///If input is correct it creates and registrates the new map 53 ///to the correct place. (\ref mytab) 36 54 virtual void on_response(int response_id); 37 55 56 ///Close window if Esc key pressed. 38 57 virtual bool closeIfEscapeIsPressed(GdkEventKey*); 39 58 40 ///Function that creates a tree from an appropriately manipulated string 41 tree_node * weightedString2Tree(std::string, std::vector<unsigned int> &, int); 59 ///Function that creates a tree from an appropriately manipulated string. 42 60 43 ///Function that creates a string from a tree by postorder reading. 44 std::string postOrder(tree_node *); 61 ///Tree is builded according to priorities of operations in expression given by string. 62 ///Priorities are indicated in a vector that contains weights for each operation. 63 ///\param to_tree string to build tree from 64 ///\param weights weights (priorities) 65 ///\param offset this function call is recursive. This parameter tells us, 66 ///with which part of the string do we have to deal with. 67 tree_node * weightedString2Tree(std::string to_tree, std::vector<unsigned int> & weights, int offset); 45 68 46 std::string string2Polishform(std::string, bool);69 ///Function that creates a string from a tree by postorder reading. 47 70 48 bool validVariable(std::string, bool); 71 ///This is the last step of creating polishform 72 ///from a given expression string. 73 ///\param root the root of the tree to read through 74 std::string postOrder(tree_node * root); 49 75 50 void deleteTree(tree_node *);76 ///From the given expression it creates expression given in polish form. 51 77 78 ///First it substitutes variables and numbers in the given expression. 79 ///The substitutions will be one character long local variables. 80 ///The substituted-substitution pair is registrated in \ref ch2var. 81 ///After that it gives weights fo each character in substituted expression. 82 ///Weights are calculated according to the priority of operations in expression. 83 ///Then it creates tree (\ref tree_node) from the weighted string. (\ref weightedString2Tree) 84 ///\param to_polish the string to turn into polish_form 85 ///\param itisedge do we have to create an edgemap or a nodemap. 86 ///It is important, because variables are maps and if expression 87 ///citates a map that does not exists the expression is not valid. 88 ///But to determine, whether the map exists we have to know where 89 ///to search for it. And of course for a new edgemap only edgemaps can be serve with values. 90 std::string string2Polishform(std::string to_polish, bool itisedge); 91 92 ///Returns whether a string can be used as value in an expression. 93 94 ///The given string has to be either a mapname or a number. If it is a mapname 95 ///we have to know whether it is an edgemap or a nodemap. 96 ///\param variable the string about the function has to determine whether it is usable in expressions 97 ///\param itisedge should the mapname be between edgemaps, or nodemaps 98 bool validVariable(std::string variable, bool itisedge); 99 100 ///Deletes the whole tree created for translating string to polishform. 101 102 ///\param root 103 ///root of the tree 104 void deleteTree(tree_node * root); 105 106 ///Dictionary of substitutions in expression. 107 108 ///Variables and numbers are substituted with one character long variables in expressions. 109 ///This is the dictionary. 52 110 std::map<char, std::string> ch2var; 53 111 54 Gtk::Entry name, default_value; 112 ///Entry which gives us the name of new map. 113 Gtk::Entry name; 55 114 115 ///Entry which gives us the initial values of elements of new map. 116 117 ///Initial value can be a number or an expression after that the 118 ///initial value for each map element can be calculated. 119 Gtk::Entry default_value; 120 121 ///GTK Designing object. 56 122 Gtk::Table * table; 123 124 ///Information holder in window. 57 125 Gtk::Label * label; 58 126 59 Gtk::RadioButton node, edge; 127 ///If selected, nodemap will be created. 128 Gtk::RadioButton node; 129 130 ///If selected, edgemap will be created. 131 Gtk::RadioButton edge; 60 132 }; 61 133
Note: See TracChangeset
for help on using the changeset viewer.