Changeset 1973 in orxonox.OLD for orxonox/branches
- Timestamp:
- Jun 17, 2004, 6:29:33 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/gui/guicc/orxonox_gui.cc
r1965 r1973 4 4 5 5 int main( int argc, char *argv[] ) 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 6 { 7 gtk_init (&argc, &argv); 8 Window* orxonoxGUI = new Window("Graphical Orxonox Launcher"); 9 orxonoxGUI->connectSignal ("destroy", orxonoxGUI->orxonox_gui_quit); 10 orxonoxGUI->connectSignal ("delete_event", orxonoxGUI->orxonox_gui_quit); 11 12 Frame* Frametest = new Frame ("Test"); 13 orxonoxGUI->fill((Frame*) Frametest); 14 Box* box = new Box ('v'); 15 Frametest->fill(box); 16 17 CheckButton* button = new CheckButton("test"); 18 button->connectSignal ("clicked", orxonoxGUI->orxonox_gui_quit); 19 box->fill(button); 20 Slider* slider = new Slider("testslider", 0, 100); 21 slider->connectSignal ("value_changed", slider->OptionChange); 22 box->fill(slider); 23 24 orxonoxGUI->showall (); 25 26 gtk_main(); 27 return 0; 28 } 29 29 30 30 … … 32 32 void Widget::show() 33 33 { 34 /** 35 * Function to Show any Widget 36 */ 34 37 gtk_widget_show (widget); 35 38 } … … 37 40 void Widget::connectSignal (char* event, gint ( *signal)( GtkWidget*, GdkEvent*, void *)) 38 41 { 42 /** 43 * Connect any signal to any given Sub-widget 44 */ 39 45 g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), NULL); 40 46 } … … 42 48 void Widget::connectSignal (char* event, gint ( *signal)( GtkWidget*, Widget *)) 43 49 { 50 /** 51 * Connect a signal with additionally passing the whole Object 52 */ 44 53 g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), this); 45 54 } … … 49 58 void Container::fill (Widget *lowerWidget) 50 59 { 60 /** 61 * fill any given Container with a lowerwidet 62 */ 51 63 gtk_container_add (GTK_CONTAINER(this->widget), lowerWidget->widget); 52 64 this->down = lowerWidget; … … 59 71 Window::Window (void) 60 72 { 73 /** 74 * Creating a Window 75 */ 61 76 widget = gtk_window_new (GTK_WINDOW_TOPLEVEL); 62 77 gtk_window_set_policy(GTK_WINDOW(widget), TRUE, TRUE, TRUE); … … 65 80 Window::Window (char* windowName) 66 81 { 82 /** 83 * Creating a Window with passing a name 84 */ 67 85 widget = gtk_window_new (GTK_WINDOW_TOPLEVEL); 68 86 gtk_window_set_policy(GTK_WINDOW(widget), TRUE, TRUE, TRUE); … … 71 89 72 90 Window::~Window () 73 {} 91 { 92 /** 93 * Destoying a Window (not implemented) 94 */ 95 } 74 96 75 97 void Window::showall () 76 98 { 99 /** 100 * Shows all Widgets that are included within this Widget 101 */ 77 102 gtk_widget_show_all (widget); 78 103 } … … 80 105 void Window::setTitle (char* title) 81 106 { 107 /** 108 * Set The Window title to title 109 */ 82 110 gtk_window_set_title (GTK_WINDOW (widget), title); 83 111 } … … 86 114 gint Window::orxonox_gui_quit ( GtkWidget *widget, GdkEvent *event, gpointer data) 87 115 { 116 /** 117 * Quits the orxonox_GUI 118 */ 88 119 gtk_main_quit(); 89 120 return FALSE; … … 95 126 Frame::Frame (void) 96 127 { 128 /** 129 * Creates a new Frame without a name 130 */ 97 131 widget = gtk_frame_new (""); 98 132 } 99 133 Frame::Frame (char* title) 100 134 { 135 /** 136 * Creates a new Frame with name title 137 */ 101 138 widget = gtk_frame_new (title); 102 139 } 103 140 Frame::~Frame () 104 {} 141 { 142 /** 143 * Destroys given Frame (not implemented yet) 144 */ 145 } 105 146 106 147 void Frame::setTitle (char* title) 107 148 { 149 /** 150 * Sets the Frames name to title 151 */ 108 152 gtk_frame_set_label (GTK_FRAME (widget), title); 109 153 } … … 115 159 Box::Box (void) 116 160 { 161 /** 162 * Creates a new horizontal Box 163 */ 117 164 widget = gtk_hbox_new(FALSE, 0); 118 165 } 119 166 Box::Box (char boxtype) 120 167 { 168 /** 169 * Creates a new Box if boxtype is 'v' it will be vertically, if 'h' it will be horizontally 170 */ 121 171 if (boxtype == 'v') 122 172 { … … 130 180 131 181 Box::~Box () 132 {} 182 { 183 /** 184 * Destroys given Frame (not implemented yet) 185 */ 186 } 133 187 134 188 void Box::fill (Widget *lowerWidget) 135 189 { 190 /** 191 * Fill a Box with its lowerwidgets 192 */ 136 193 gtk_box_pack_start (GTK_BOX(this->widget), lowerWidget->widget, TRUE, TRUE, 0); 137 194 } … … 143 200 Button::Button(char* buttonname) 144 201 { 202 /** 203 * Creates a new Button with name buttonname 204 */ 145 205 widget = gtk_button_new_with_label(buttonname); 206 option_name = buttonname; 146 207 } 147 208 … … 149 210 CheckButton::CheckButton(char* buttonname) 150 211 { 212 /** 213 * Creates a new CheckButton with name buttonname 214 */ 151 215 widget = gtk_check_button_new_with_label(buttonname); 216 option_name = buttonname; 152 217 } 153 218 … … 155 220 Slider::Slider (char* slidername, int start, int end) 156 221 { 222 /** 223 * Creates a new Slider with name slidername a beginning value of start and an end value of end. 224 */ 157 225 widget = gtk_hscale_new_with_range (start, end, 5); 158 226 value = start; … … 162 230 gint Slider::OptionChange (GtkWidget *widget, Widget* slider) 163 231 { 164 //Slider * superslider = dynamic_cast<Slider*>(slider) 165 // dynamic_cast<Slider*>(slider)->value = (int)gtk_range_get_value (GTK_RANGE((Slider*)slider->widget)); 166 cout << (int)gtk_range_get_value (GTK_RANGE((Slider*)slider->widget)) << endl; 167 } 232 /** 233 * Writes value, if changed on the slider, to the object. 234 */ 235 static_cast<Slider*>(slider)->value = (int)gtk_range_get_value (GTK_RANGE((Slider*)slider->widget)); 236 cout << static_cast<Slider*>(slider)->value << endl; 237 }
Note: See TracChangeset
for help on using the changeset viewer.