virtual void Prepare(ContainerWindow &parent, const PixelRect &rc) override { WindowStyle style; style.Hide(); ButtonWindowStyle button_style(style); button_style.TabStop(); quit.Create(parent, _("Quit"), rc, style, action_listener, mrCancel); logo.Create(parent, rc, style); }
void TaskManagerDialog::Create(SingleWindow &parent) { WndForm::Create(parent, parent.GetClientRect(), _("Task Manager")); task = protected_task_manager->TaskClone(); /* create the controls */ ContainerWindow &client_area = GetClientAreaWindow(); const TaskManagerLayout layout = CalculateTaskManagerLayout(client_area.GetClientRect()); task_view_position = layout.task_view; WindowStyle hidden; hidden.Hide(); task_view = new TaskMapWindow(UIGlobals::GetMapLook(), *this, MAP); task_view->Create(client_area, layout.task_view, hidden); ButtonWindowStyle button_style(hidden); button_style.TabStop(); target_button = new WndButton(client_area, GetLook(), _("Target"), layout.target_button, button_style, *this, TARGET); WindowStyle tab_style; tab_style.ControlParent(); tab_bar = new TabBarControl(client_area, GetLook(), layout.tab_bar, tab_style, layout.vertical); tab_bar->SetPageFlippedCallback([this]() { UpdateCaption(); }); /* create pages */ TaskPropertiesPanel *wProps = new TaskPropertiesPanel(*this, &task, &modified); TaskClosePanel *wClose = new TaskClosePanel(*this, &modified); TaskCalculatorPanel *wCalculator = new TaskCalculatorPanel(UIGlobals::GetDialogLook(), &modified); wCalculator->SetTargetButton(target_button); const MapLook &look = UIGlobals::GetMapLook(); Widget *wEdit = CreateTaskEditPanel(*this, look.task, look.airspace, &task, &modified); TaskMiscPanel *list_tab = new TaskMiscPanel(*this, &task, &modified); const bool enable_icons = CommonInterface::GetUISettings().dialog.tab_style == DialogSettings::TabStyle::Icon; const IconLook &icons = UIGlobals::GetIconLook(); const Bitmap *CalcIcon = enable_icons ? &icons.hBmpTabCalculator : NULL; const Bitmap *TurnPointIcon = enable_icons ? &icons.hBmpTabTask : NULL; const Bitmap *BrowseIcon = enable_icons ? &icons.hBmpTabWrench : NULL; const Bitmap *PropertiesIcon = enable_icons ? &icons.hBmpTabSettings : NULL; tab_bar->AddTab(wCalculator, _("Calculator"), CalcIcon); if (layout.vertical) { tab_bar->AddTab(wEdit, _("Turn Points"), TurnPointIcon); TurnpointTab = 1; tab_bar->AddTab(list_tab, _("Manage"), BrowseIcon); tab_bar->AddTab(wProps, _("Rules"), PropertiesIcon); PropertiesTab = 3; tab_bar->AddTab(wClose, _("Close")); tab_bar->SetCurrentPage(0); } else { tab_bar->AddTab(wClose, _("Close")); tab_bar->AddTab(wEdit, _("Turn Points"), TurnPointIcon); TurnpointTab = 2; tab_bar->AddTab(list_tab, _("Manage"), BrowseIcon); tab_bar->AddTab(wProps, _("Rules"), PropertiesIcon); PropertiesTab = 4; tab_bar->SetCurrentPage(0); } UpdateCaption(); }
/** * Creates a control from the given XMLNode as a child of the given * parent. * * @param form the SubForm object * @param LookUpTable The parent CallBackTable * @param node The XMLNode that represents the control */ static Window * LoadChild(SubForm &form, ContainerWindow &parent, const CallBackTableEntry *lookup_table, XMLNode node, int bottom_most, WindowStyle style) { Window *window = NULL; // Determine name, coordinates, width, height // and caption of the control const TCHAR* name = GetName(node); const TCHAR* caption = GetCaption(node); PixelRect rc = parent.get_client_rect(); ControlPosition pos = GetPosition(node, rc, bottom_most); if (!pos.no_scaling) pos.x = ScaleWidth(pos.x); ControlSize size = GetSize(node, rc, pos); if (!size.no_scaling) size.cx = ScaleWidth(size.cx); if (!StringToIntDflt(node.getAttribute(_T("Visible")), 1)) style.Hide(); if (StringToIntDflt(node.getAttribute(_T("Border")), 0)) style.Border(); rc.left = pos.x; rc.top = pos.y; rc.right = rc.left + size.cx; rc.bottom = rc.top + size.cy; bool expert = (StringToIntDflt(node.getAttribute(_T("Expert")), 0) == 1); // PropertyControl (WndProperty) if (StringIsEqual(node.getName(), _T("Edit"))) { // Determine the width of the caption field int caption_width = StringToIntDflt(node.getAttribute(_T("CaptionWidth")), 0); if (Layout::ScaleSupported()) caption_width = Layout::Scale(caption_width); caption_width = ScaleWidth(caption_width); // Determine whether the control is multiline or readonly bool multi_line = StringToIntDflt(node.getAttribute(_T("MultiLine")), 0); bool read_only = StringToIntDflt(node.getAttribute(_T("ReadOnly")), 0); // Load the event callback properties WndProperty::DataChangeCallback_t data_notify_callback = (WndProperty::DataChangeCallback_t) GetCallBack(lookup_table, node, _T("OnDataNotify")); WindowControl::HelpCallback help_callback = (WindowControl::HelpCallback) GetCallBack(lookup_table, node, _T("OnHelp")); // Create the Property Control style.ControlParent(); EditWindowStyle edit_style; edit_style.vertical_center(); if (read_only) edit_style.read_only(); else edit_style.TabStop(); if (IsEmbedded() || Layout::scale_1024 < 2048) /* sunken edge doesn't fit well on the tiny screen of an embedded device */ edit_style.Border(); else edit_style.SunkenEdge(); if (multi_line) { edit_style.multiline(); edit_style.VerticalScroll(); } WndProperty *property; window = property = new WndProperty(parent, *xml_dialog_look, caption, rc, caption_width, style, edit_style, data_notify_callback); // Set the help function event callback property->SetOnHelpCallback(help_callback); // Load the help text property->SetHelpText(StringToStringDflt(node.getAttribute(_T("Help")), NULL)); // If the control has (at least) one DataField child control const XMLNode *data_field_node = node.getChildNode(_T("DataField")); if (data_field_node != NULL) { // -> Load the first DataField control DataField *data_field = LoadDataField(*data_field_node, lookup_table); if (data_field != NULL) // Tell the Property control about the DataField control property->SetDataField(data_field); } } else if (StringIsEqual(node.getName(), _T("TextEdit"))) { // Determine whether the control is multiline or readonly bool multi_line = StringToIntDflt(node.getAttribute(_T("MultiLine")), 0); bool read_only = StringToIntDflt(node.getAttribute(_T("ReadOnly")), 0); EditWindowStyle edit_style(style); if (read_only) edit_style.read_only(); else edit_style.TabStop(); if (IsEmbedded() || Layout::scale_1024 < 2048) /* sunken edge doesn't fit well on the tiny screen of an embedded device */ edit_style.Border(); else edit_style.SunkenEdge(); if (multi_line) { edit_style.multiline(); edit_style.VerticalScroll(); } EditWindow *edit; window = edit = new EditWindow(); edit->set(parent, pos.x, pos.y, size.cx, size.cy, edit_style); edit->InstallWndProc(); edit->set_font(*xml_dialog_look->text_font); // ButtonControl (WndButton) } else if (StringIsEqual(node.getName(), _T("Button"))) { // Determine ClickCallback function WndButton::ClickNotifyCallback click_callback = (WndButton::ClickNotifyCallback) GetCallBack(lookup_table, node, _T("OnClick")); // Create the ButtonControl ButtonWindowStyle button_style(style); button_style.TabStop(); button_style.multiline(); window = new WndButton(parent, *xml_dialog_look, caption, rc, button_style, click_callback); } else if (StringIsEqual(node.getName(), _T("CheckBox"))) { // Determine click_callback function CheckBoxControl::ClickNotifyCallback click_callback = (CheckBoxControl::ClickNotifyCallback) GetCallBack(lookup_table, node, _T("OnClick")); // Create the CheckBoxControl style.TabStop(); window = new CheckBoxControl(parent, *xml_dialog_look, caption, rc, style, click_callback); // SymbolButtonControl (WndSymbolButton) not used yet } else if (StringIsEqual(node.getName(), _T("SymbolButton"))) { // Determine ClickCallback function WndButton::ClickNotifyCallback click_callback = (WndButton::ClickNotifyCallback) GetCallBack(lookup_table, node, _T("OnClick")); // Create the SymbolButtonControl style.TabStop(); window = new WndSymbolButton(parent, *xml_dialog_look, caption, rc, style, click_callback); // PanelControl (WndPanel) } else if (StringIsEqual(node.getName(), _T("Panel"))) { // Create the PanelControl style.ControlParent(); PanelControl *frame = new PanelControl(parent, *xml_dialog_look, rc, style); window = frame; // Load children controls from the XMLNode LoadChildrenFromXML(form, *frame, lookup_table, &node); // KeyboardControl } else if (StringIsEqual(node.getName(), _T("Keyboard"))) { KeyboardControl::OnCharacterCallback_t character_callback = (KeyboardControl::OnCharacterCallback_t) GetCallBack(lookup_table, node, _T("OnCharacter")); // Create the KeyboardControl KeyboardControl *kb = new KeyboardControl(parent, *xml_dialog_look, pos.x, pos.y, size.cx, size.cy, character_callback, style); window = kb; // DrawControl (WndOwnerDrawFrame) } else if (StringIsEqual(node.getName(), _T("Canvas"))) { // Determine DrawCallback function WndOwnerDrawFrame::OnPaintCallback_t paint_callback = (WndOwnerDrawFrame::OnPaintCallback_t) GetCallBack(lookup_table, node, _T("OnPaint")); // Create the DrawControl WndOwnerDrawFrame* canvas = new WndOwnerDrawFrame(parent, pos.x, pos.y, size.cx, size.cy, style, paint_callback); window = canvas; // FrameControl (WndFrame) } else if (StringIsEqual(node.getName(), _T("Label"))){ // Create the FrameControl WndFrame* frame = new WndFrame(parent, *xml_dialog_look, pos.x, pos.y, size.cx, size.cy, style); // Set the caption frame->SetCaption(caption); // Set caption color Color color; if (StringToColor(node.getAttribute(_T("CaptionColor")), color)) frame->SetCaptionColor(color); window = frame; // ListBoxControl (WndListFrame) } else if (StringIsEqual(node.getName(), _T("List"))){ // Determine ItemHeight of the list items UPixelScalar item_height = Layout::Scale(StringToIntDflt(node.getAttribute(_T("ItemHeight")), 18)); // Create the ListBoxControl style.TabStop(); if (IsEmbedded() || Layout::scale_1024 < 2048) /* sunken edge doesn't fit well on the tiny screen of an embedded device */ style.Border(); else style.SunkenEdge(); window = new WndListFrame(parent, *xml_dialog_look, pos.x, pos.y, size.cx, size.cy, style, item_height); // TabControl (Tabbed) } else if (StringIsEqual(node.getName(), _T("Tabbed"))) { // Create the TabControl style.ControlParent(); TabbedControl *tabbed = new TabbedControl(parent, pos.x, pos.y, size.cx, size.cy, style); window = tabbed; for (auto i = node.begin(), end = node.end(); i != end; ++i) { // Load each child control from the child nodes Window *child = LoadChild(form, *tabbed, lookup_table, *i); if (child != NULL) tabbed->AddClient(child); } // TabBarControl (TabBar) } else if (StringIsEqual(node.getName(), _T("TabBar"))) { // Create the TabBarControl bool flip_orientation = false; if ( (Layout::landscape && StringToIntDflt(node.getAttribute(_T("Horizontal")), 0)) || (!Layout::landscape && StringToIntDflt(node.getAttribute(_T("Vertical")), 0) ) ) flip_orientation = true; style.ControlParent(); TabBarControl *tabbar = new TabBarControl(parent, *xml_dialog_look, pos.x, pos.y, size.cx, size.cy, style, flip_orientation); window = tabbar; // TabMenuControl (TabMenu) } else if (StringIsEqual(node.getName(), _T("TabMenu"))) { // Create the TabMenuControl style.ControlParent(); TabMenuControl *tabmenu = new TabMenuControl(parent, /* XXX this cast is an ugly hack! Please rewrite: */ (WndForm &)form, *xml_dialog_look, caption, pos.x, pos.y, size.cx, size.cy, style); window = tabmenu; } else if (StringIsEqual(node.getName(), _T("Custom"))) { // Create a custom Window object with a callback CreateWindowCallback_t create_callback = (CreateWindowCallback_t)GetCallBack(lookup_table, node, _T("OnCreate")); if (create_callback == NULL) return NULL; window = create_callback(parent, pos.x, pos.y, size.cx, size.cy, style); } else if (StringIsEqual(node.getName(), _T("Widget"))) { style.ControlParent(); DockWindow *dock = new DockWindow(); dock->set(parent, rc, style); window = dock; } if (window != NULL) { if (!StringIsEmpty(name)) form.AddNamed(name, window); if (expert) form.AddExpert(window); form.AddDestruct(window); } return window; }