GUITopLevelDescription MainWindow::get_window_description() { GUITopLevelDescription desc; desc.set_title("ClanLib Texture Packer"); desc.set_allow_resize(true); desc.set_position(Rect(200, 200, 1024, 768), false); return desc; }
MessageBoxResult message_box_impl( T *owner, std::string title, std::string detail_text, MessageBoxButtons buttons, MessageBoxIcon icon, const Rect owner_geometry) { GUITopLevelDescription desc; desc.set_title(title); desc.set_dialog_window(true); desc.set_allow_resize(true); desc.set_position(Rect(100,100,200,200), false); desc.set_visible(false); GUIComponent window(owner, desc, "window"); MessageBoxComponent mb(&window, detail_text, buttons, icon); Size content_size = mb.layout_content(); window.func_close().set(&mb, &MessageBoxComponent::on_window_close, &window); DisplayWindow disp_win = window.get_display_window(); Point win_tl = window.get_window_geometry().get_top_left(); Point cont_tl = disp_win.client_to_screen(Point(0,0)); Point decorations_top_left = cont_tl - win_tl; Point win_br = window.get_window_geometry().get_bottom_right(); Rect client = window.get_content_box(); Point cont_br = disp_win.client_to_screen(client.get_bottom_right()); Point decorations_bottom_right = win_br - cont_br; Rect win_geometry; int wing_width = decorations_top_left.x + content_size.width + decorations_bottom_right.x; int wing_height = decorations_top_left.y + content_size.height + decorations_bottom_right.y; win_geometry.left = owner_geometry.get_center().x - wing_width/2; win_geometry.top = owner_geometry.get_center().y - wing_height/2; win_geometry.right = win_geometry.left + wing_width; win_geometry.bottom = win_geometry.top + wing_height; window.set_window_geometry(win_geometry); mb.set_geometry(Rect(0,0,content_size.width, content_size.height)); window.set_visible(); MessageBoxResult reason = MessageBoxResult(window.exec()); return reason; }