// This event is called when the user resizes the main_window. Note that unlike the other // events, this event is part of the drawable_window base class that main_window inherits from. // So you won't see any statements in the constructor that say "register the main_window::on_window_resized function" void main_window:: on_window_resized () { // when you override any of the drawable_window events you have to make sure you // call the drawable_window's version of them because it needs to process // the events as well. So we do that here. drawable_window::on_window_resized(); // The rest of this function positions the widgets on the window unsigned long width,height; get_size(width,height); // Don't do anything if the user just made the window too small. That is, leave // the widgets where they are. if (width < 500 || height < 350) return; // Set the size of the probability tables and the drawing area for the graph graph_drawer.set_size(width-370,height-10-mbar.height()); cpt_grid.set_size((width-graph_drawer.width())-35,height-237); ppt_grid.set_size((width-graph_drawer.width())-35,height-237); // tell the tabbed display to make itself just the right size to contain // the two probability tables. tables.fit_to_contents(); // Now position all the widgets in the window. Note that much of the positioning // is relative to other widgets. This part of the code I just figured out by // trying stuff and rerunning the program to see if it looked nice. sel_node_index.set_pos(graph_drawer.right()+14,graph_drawer.top()+18); sel_node_text_label.set_pos(sel_node_index.left(),sel_node_index.bottom()+5); sel_node_text.set_pos(sel_node_text_label.right()+5,sel_node_index.bottom()); sel_node_num_values_label.set_pos(sel_node_index.left(), sel_node_text.bottom()+5); sel_node_num_values.set_pos(sel_node_num_values_label.right(), sel_node_text.bottom()+5); sel_node_is_evidence.set_pos(sel_node_index.left(),sel_node_num_values.bottom()+5); sel_node_evidence_label.set_pos(sel_node_index.left(),sel_node_is_evidence.bottom()+5); sel_node_evidence.set_pos(sel_node_evidence_label.right()+5,sel_node_is_evidence.bottom()); tables.set_pos(sel_node_index.left(),sel_node_evidence.bottom()+5); sel_node_evidence.set_width(tables.right()-sel_node_evidence.left()+1); sel_node_text.set_width(tables.right()-sel_node_text.left()+1); sel_node_num_values.set_width(tables.right()-sel_node_num_values.left()+1); // Tell the named rectangle to position itself such that it fits around the // tabbed display that contains the probability tables and the label at the top of the // screen. selected_node_rect.wrap_around(sel_node_index.get_rect()+ tables.get_rect()); // finally set the button to be at the bottom of the named rectangle btn_calculate.set_pos(selected_node_rect.left(), selected_node_rect.bottom()+5); }