static void RefreshView() { wTaskView->invalidate(); OrderedTaskPoint* tp = ordered_task->get_tp(active_index); if (!tp) return; Refreshing = true; // tell onChange routines not to save form! TPLabelObservationZone ozv; ObservationZoneConstVisitor &visitor = ozv; visitor.Visit(*tp->get_oz()); WndFrame* wfrm = NULL; wfrm = ((WndFrame*)wf->FindByName(_T("lblType"))); if (wfrm) wfrm->SetCaption(OrderedTaskPointName(ordered_task->get_factory().getType(*tp))); WndButton* wb; wb = ((WndButton*)wf->FindByName(_T("butPrevious"))); if (wb) wb->set_enabled(active_index > 0); wb = ((WndButton*)wf->FindByName(_T("butNext"))); if (wb) wb->set_enabled(active_index < (ordered_task->task_size() - 1)); wb = (WndButton*)wf->FindByName(_T("cmdOptionalStarts")); assert(wb); wb->set_visible(active_index == 0); if (ordered_task->optional_start_points_size() == 0) wb->SetCaption(_("Enable Alternate Starts")); else { TCHAR tmp[50]; _stprintf(tmp, _T("%s (%d)"), _("Edit Alternates"), ordered_task->optional_start_points_size()); wb->SetCaption(tmp); } EnableSizeEdit(ordered_task->get_factory_type() != TaskBehaviour::FACTORY_FAI_GENERAL); TCHAR bufType[100]; TCHAR bufNamePrefix[100]; TPLabelTaskPoint tpv(bufType, bufNamePrefix); TaskPointConstVisitor &tp_visitor = tpv; tp_visitor.Visit(*tp); wf->SetCaption(tpv.textType); wfrm = ((WndFrame*)wf->FindByName(_T("lblLocation"))); if (wfrm) { TCHAR buff[100]; _stprintf(buff, _T("%s %s"), tpv.textNamePrefix, tp->get_waypoint().Name.c_str()); wfrm->SetCaption(buff); } Refreshing = false; // reactivate onChange routines }
static void RefreshView() { WndFrame* wSummary = (WndFrame *)wf->FindByName(_T("frmSummary")); if (wSummary) { const TCHAR* text = OrderedTaskFactoryDescription(get_cursor_type()); wSummary->SetCaption(text); } }
static void UpdatePolarLabel() { StaticString<128> tmp; tmp.Format(_T("%s: %s"), _("Polar"), plane.polar_name.c_str()); WndFrame *label = ((WndFrame *)dialog->FindByName(_T("PolarLabel"))); assert(label != NULL); label->SetCaption(tmp); }
static void UpdatePolarLabel() { TCHAR tmp[128]; _stprintf(tmp, _("%s: %s"), _("Polar"), plane.polar_name.c_str()); WndFrame *label = ((WndFrame *)dialog->FindByName(_T("PolarLabel"))); assert(label != NULL); label->SetCaption(tmp); }
static void RedrawSampleFont(void) { GetLogFont(NewLogFont); #ifdef ENABLE_SDL // XXX #else /* !ENABLE_SDL */ NewFont.set(NewLogFont); #endif /* !ENABLE_SDL */ WndFrame *wp = (WndFrame *)wf->FindByName(_T("prpFontSample")); if (wp) { if (NewFont.defined()) { wp->SetFont(NewFont); wp->SetCaption(_("Sample Text\n123")); } else { wp->SetCaption(_("Font not found.")); } } }
void TaskListPanel::RefreshView() { wTasks->SetLength(task_store->Size()); wTaskView->invalidate(); WndFrame* wSummary = (WndFrame*)form.FindByName(_T("frmSummary1")); assert(wSummary != NULL); OrderedTask* ordered_task = get_task_to_display(); if (ordered_task == NULL) { wSummary->SetCaption(_T("")); return; } TCHAR text[300]; OrderedTaskSummary(ordered_task, text, false); wSummary->SetCaption(text); }
int dlgWaypointOutOfTerrain(TCHAR *Message){ WndFrame* wfrm; int res = 0; #ifdef HAVEEXCEPTIONS __try{ #endif char filename[MAX_PATH]; LocalPathS(filename, TEXT("dlgWaypointOutOfTerrain.xml")); wf = dlgLoadFromXML(CallBackTable, filename, hWndMainWindow, TEXT("IDR_XML_WAYPOINTTERRAIN")); if (wf) { wfrm = (WndFrame*)wf->FindByName(TEXT("frmWaypointOutOfTerrainText")); wfrm->SetCaption(Message); wfrm->SetCaptionStyle( DT_EXPANDTABS | DT_CENTER | DT_NOCLIP | DT_WORDBREAK); res = wf->ShowModal(); delete wf; } wf = NULL; #ifdef HAVEEXCEPTIONS }__except(EXCEPTION_EXECUTE_HANDLER ){ res = 0; // ToDo: log that problem }; #endif return(res); }
void TaskPointWidget::RefreshView() { map.Invalidate(); OrderedTaskPoint &tp = ordered_task.GetPoint(active_index); properties_dock.DeleteWidget(); ObservationZonePoint &oz = tp.GetObservationZone(); const bool is_fai_general = ordered_task.GetFactoryType() == TaskFactoryType::FAI_GENERAL; auto *properties_widget = CreateObservationZoneEditWidget(oz, is_fai_general); if (properties_widget != nullptr) { properties_widget->SetListener(this); properties_dock.SetWidget(properties_widget); } else properties_dock.SetWidget(new PanelWidget()); type_label.SetCaption(OrderedTaskPointName(ordered_task.GetFactory().GetType(tp))); previous_button->SetEnabled(active_index > 0); next_button->SetEnabled(active_index < (ordered_task.TaskSize() - 1)); optional_starts.SetVisible(active_index == 0); if (!ordered_task.HasOptionalStarts()) optional_starts.SetCaption(_("Enable Alternate Starts")); else { StaticString<50> tmp; tmp.Format(_T("%s (%d)"), _("Edit Alternates"), ordered_task.GetOptionalStartPointCount()); optional_starts.SetCaption(tmp); } if (tp.GetType() == TaskPointType::AST) { const ASTPoint &ast = (const ASTPoint &)tp; score_exit.Show(); score_exit.SetState(ast.GetScoreExit()); } else score_exit.Hide(); StaticString<100> name_prefix_buffer, type_buffer; switch (tp.GetType()) { case TaskPointType::START: type_buffer = _("Start point"); name_prefix_buffer = _T("Start: "); break; case TaskPointType::AST: type_buffer = _("Task point"); name_prefix_buffer.Format(_T("%d: "), active_index); break; case TaskPointType::AAT: type_buffer = _("Assigned area point"); name_prefix_buffer.Format(_T("%d: "), active_index); break; case TaskPointType::FINISH: type_buffer = _("Finish point"); name_prefix_buffer = _T("Finish: "); break; default: gcc_unreachable(); } dialog.SetCaption(type_buffer); { StaticString<100> buffer; buffer.Format(_T("%s %s"), name_prefix_buffer.c_str(), tp.GetWaypoint().name.c_str()); waypoint_name.SetCaption(buffer); } }
/** * Creates a control from the given XMLNode as a child of the given * parent. * * @param form the WndForm object * @param LookUpTable The parent CallBackTable * @param node The XMLNode that represents the control * @param eDialogStyle The parent's dialog style */ static Window * LoadChild(WndForm &form, ContainerWindow &parent, Color background_color, CallBackTableEntry *LookUpTable, XMLNode node, const DialogStyle eDialogStyle, int bottom_most=0) { Window *window = NULL; // Determine name, coordinates, width, height // and caption of the control const TCHAR* Name = GetName(node); const TCHAR* Caption = GetCaption(node); RECT rc = parent.get_client_rect(); ControlPosition pos = GetPosition(node, rc, bottom_most); if (!pos.no_scaling) pos.x = ScaleWidth(pos.x, eDialogStyle); ControlSize size = GetSize(node, rc, pos); if (!size.no_scaling) size.cx = ScaleWidth(size.cx, eDialogStyle); WindowStyle style; if (!StringToIntDflt(node.getAttribute(_T("Visible")), 1)) style.hide(); if (StringToIntDflt(node.getAttribute(_T("Border")), 0)) style.border(); bool advanced = _tcschr(Caption, _T('*')) != NULL; // PropertyControl (WndProperty) if (_tcscmp(node.getName(), _T("Edit")) == 0) { WndProperty *W; int CaptionWidth; bool ReadOnly; bool MultiLine; // Determine the width of the caption field CaptionWidth = StringToIntDflt(node.getAttribute(_T("CaptionWidth")), 0); if (Layout::ScaleSupported()) CaptionWidth = Layout::Scale(CaptionWidth); CaptionWidth = ScaleWidth(CaptionWidth, eDialogStyle); // Determine whether the control is multiline or readonly MultiLine = StringToIntDflt(node.getAttribute(_T("MultiLine")), 0); ReadOnly = StringToIntDflt(node.getAttribute(_T("ReadOnly")), 0); // Load the event callback properties WndProperty::DataChangeCallback_t DataNotifyCallback = (WndProperty::DataChangeCallback_t) GetCallBack(LookUpTable, node, _T("OnDataNotify")); WindowControl::OnHelpCallback_t OnHelpCallback = (WindowControl::OnHelpCallback_t) GetCallBack(LookUpTable, node, _T("OnHelp")); // Create the Property Control style.control_parent(); EditWindowStyle edit_style; if (ReadOnly) edit_style.read_only(); else edit_style.tab_stop(); if (is_embedded() || Layout::scale_1024 < 2048) /* sunken edge doesn't fit well on the tiny screen of an embedded device */ edit_style.border(); else edit_style.sunken_edge(); if (MultiLine) { edit_style.multiline(); edit_style.vscroll(); } window = W = new WndProperty(parent, Caption, pos.x, pos.y, size.cx, size.cy, CaptionWidth, background_color, style, edit_style, DataNotifyCallback); // Set the fore- and background color LoadColors(*W, node); // Set the help function event callback W->SetOnHelpCallback(OnHelpCallback); // Load the help text W->SetHelpText(StringToStringDflt(node.getAttribute(_T("Help")), _T(""))); // If the control has (at least) one DataField child control if (node.nChildNode(_T("DataField")) > 0){ // -> Load the first DataField control DataField *data_field = LoadDataField(node.getChildNode(_T("DataField"), 0), LookUpTable, eDialogStyle); if (data_field != NULL) // Tell the Property control about the DataField control W->SetDataField(data_field); } // ButtonControl (WndButton) } else if (_tcscmp(node.getName(), _T("Button")) == 0) { // Determine ClickCallback function WndButton::ClickNotifyCallback_t ClickCallback = (WndButton::ClickNotifyCallback_t) GetCallBack(LookUpTable, node, _T("OnClick")); // Create the ButtonControl ButtonWindowStyle bstyle(style); bstyle.tab_stop(); bstyle.multiline(); window = new WndButton(parent, Caption, pos.x, pos.y, size.cx, size.cy, bstyle, ClickCallback); } else if (_tcscmp(node.getName(), _T("CheckBox")) == 0) { // Determine ClickCallback function CheckBoxControl::ClickNotifyCallback_t ClickCallback = (CheckBoxControl::ClickNotifyCallback_t) GetCallBack(LookUpTable, node, _T("OnClick")); // Create the CheckBoxControl style.tab_stop(); window = new CheckBoxControl(parent, Caption, pos.x, pos.y, size.cx, size.cy, style, ClickCallback); // SymbolButtonControl (WndSymbolButton) not used yet } else if (_tcscmp(node.getName(), _T("SymbolButton")) == 0) { // Determine ClickCallback function WndButton::ClickNotifyCallback_t ClickCallback = (WndButton::ClickNotifyCallback_t) GetCallBack(LookUpTable, node, _T("OnClick")); // Create the SymbolButtonControl style.tab_stop(); window = new WndSymbolButton(parent, Caption, pos.x, pos.y, size.cx, size.cy, style, background_color, ClickCallback); // PanelControl (WndPanel) } else if (_tcscmp(node.getName(), _T("Panel")) == 0) { // Create the PanelControl style.control_parent(); PanelControl *frame = new PanelControl(parent, pos.x, pos.y, size.cx, size.cy, background_color, style); window = frame; // Load children controls from the XMLNode LoadChildrenFromXML(form, *frame, background_color, LookUpTable, &node, eDialogStyle); // KeyboardControl } else if (_tcscmp(node.getName(), _T("Keyboard")) == 0) { KeyboardControl::OnCharacterCallback_t CharacterCallback = (KeyboardControl::OnCharacterCallback_t) GetCallBack(LookUpTable, node, _T("OnCharacter")); // Create the KeyboardControl KeyboardControl *kb = new KeyboardControl(parent, pos.x, pos.y, size.cx, size.cy, background_color, CharacterCallback, style); window = kb; // DrawControl (WndOwnerDrawFrame) } else if (_tcscmp(node.getName(), _T("Canvas")) == 0) { // Determine DrawCallback function WndOwnerDrawFrame::OnPaintCallback_t PaintCallback = (WndOwnerDrawFrame::OnPaintCallback_t) GetCallBack(LookUpTable, node, _T("OnPaint")); // Create the DrawControl WndOwnerDrawFrame* canvas = new WndOwnerDrawFrame(parent, pos.x, pos.y, size.cx, size.cy, style, PaintCallback); window = canvas; // FrameControl (WndFrame) } else if (_tcscmp(node.getName(), _T("Label")) == 0){ // Create the FrameControl WndFrame* frame = new WndFrame(parent, pos.x, pos.y, size.cx, size.cy, background_color, style); // Set the caption frame->SetCaption(Caption); window = frame; // ListBoxControl (WndListFrame) } else if (_tcscmp(node.getName(), _T("List")) == 0){ // Determine ItemHeight of the list items unsigned item_height = Layout::Scale(StringToIntDflt(node.getAttribute(_T("ItemHeight")), 18)); // Create the ListBoxControl style.tab_stop(); if (is_embedded() || Layout::scale_1024 < 2048) /* sunken edge doesn't fit well on the tiny screen of an embedded device */ style.border(); else style.sunken_edge(); window = new WndListFrame(parent, pos.x, pos.y, size.cx, size.cy, style, item_height); // TabControl (Tabbed) } else if (_tcscmp(node.getName(), _T("Tabbed")) == 0) { // Create the TabControl style.control_parent(); TabbedControl *tabbed = new TabbedControl(parent, pos.x, pos.y, size.cx, size.cy, style); window = tabbed; const unsigned n = node.nChildNode(); for (unsigned i = 0; i < n; ++i) { // Load each child control from the child nodes Window *child = LoadChild(form, *tabbed, background_color, LookUpTable, node.getChildNode(i), eDialogStyle); if (child != NULL) tabbed->AddClient(child); continue; } } else if (_tcscmp(node.getName(), _T("Custom")) == 0) { // Create a custom Window object with a callback CreateWindowCallback_t create = (CreateWindowCallback_t)GetCallBack(LookUpTable, node, _T("OnCreate")); if (create == NULL) return NULL; window = create(parent, pos.x, pos.y, size.cx, size.cy, style); } if (window != NULL) { if (!string_is_empty(Name)) form.AddNamed(Name, window); if (advanced) form.AddAdvanced(window); form.AddDestruct(window); } return window; }
static void RefreshView() { wTaskView->Invalidate(); OrderedTaskPoint &tp = ordered_task->GetPoint(active_index); dock->SetWidget(new PanelWidget()); ObservationZonePoint &oz = tp.GetObservationZone(); const bool is_fai_general = ordered_task->GetFactoryType() == TaskFactoryType::FAI_GENERAL; properties_widget = CreateObservationZoneEditWidget(oz, is_fai_general); if (properties_widget != nullptr) { properties_widget->SetListener(&listener); dock->SetWidget(properties_widget); } WndFrame* wfrm = nullptr; wfrm = ((WndFrame*)wf->FindByName(_T("lblType"))); if (wfrm) wfrm->SetCaption(OrderedTaskPointName(ordered_task->GetFactory().GetType(tp))); SetFormControlEnabled(*wf, _T("butPrevious"), active_index > 0); SetFormControlEnabled(*wf, _T("butNext"), active_index < (ordered_task->TaskSize() - 1)); WndButton* wb; wb = (WndButton*)wf->FindByName(_T("cmdOptionalStarts")); assert(wb); wb->SetVisible(active_index == 0); if (!ordered_task->HasOptionalStarts()) wb->SetCaption(_("Enable Alternate Starts")); else { StaticString<50> tmp; tmp.Format(_T("%s (%d)"), _("Edit Alternates"), ordered_task->GetOptionalStartPointCount()); wb->SetCaption(tmp); } CheckBoxControl &score_exit = *(CheckBoxControl *) wf->FindByName(_T("ScoreExit")); if (tp.GetType() == TaskPointType::AST) { const ASTPoint &ast = (const ASTPoint &)tp; score_exit.Show(); score_exit.SetState(ast.GetScoreExit()); } else score_exit.Hide(); StaticString<100> name_prefix_buffer, type_buffer; switch (tp.GetType()) { case TaskPointType::START: type_buffer = _("Start point"); name_prefix_buffer = _T("Start: "); break; case TaskPointType::AST: type_buffer = _("Task point"); name_prefix_buffer.Format(_T("%d: "), active_index); break; case TaskPointType::AAT: type_buffer = _("Assigned area point"); name_prefix_buffer.Format(_T("%d: "), active_index); break; case TaskPointType::FINISH: type_buffer = _("Finish point"); name_prefix_buffer = _T("Finish: "); break; default: gcc_unreachable(); } wf->SetCaption(type_buffer); wfrm = ((WndFrame*)wf->FindByName(_T("lblLocation"))); if (wfrm) { StaticString<100> buffer; buffer.Format(_T("%s %s"), name_prefix_buffer.c_str(), tp.GetWaypoint().name.c_str()); wfrm->SetCaption(buffer); } }
static void RefreshView() { wTaskView->invalidate(); OrderedTaskPoint* tp = ordered_task->get_tp(active_index); if (!tp) return; Refreshing = true; // tell onChange routines not to save form! ShowFormControl(*wf, _T("frmOZLine"), false); ShowFormControl(*wf, _T("frmOZSector"), false); ShowFormControl(*wf, _T("frmOZCylinder"), false); const ObservationZonePoint &oz = *tp->get_oz(); switch (oz.shape) { case ObservationZonePoint::SECTOR: case ObservationZonePoint::ANNULAR_SECTOR: ShowFormControl(*wf, _T("frmOZSector"), true); LoadFormProperty(*wf, _T("prpOZSectorRadius"), ugDistance, ((const SectorZone &)oz).getRadius()); LoadFormProperty(*wf, _T("prpOZSectorStartRadial"), ((const SectorZone &)oz).getStartRadial().value_degrees()); LoadFormProperty(*wf, _T("prpOZSectorFinishRadial"), ((const SectorZone &)oz).getEndRadial().value_degrees()); if (oz.shape == ObservationZonePoint::ANNULAR_SECTOR) { LoadFormProperty(*wf, _T("prpOZSectorInnerRadius"), ugDistance, ((const AnnularSectorZone &)oz).getInnerRadius()); ShowFormControl(*wf, _T("prpOZSectorInnerRadius"), true); } else ShowFormControl(*wf, _T("prpOZSectorInnerRadius"), false); break; case ObservationZonePoint::LINE: ShowFormControl(*wf, _T("frmOZLine"), true); LoadFormProperty(*wf, _T("prpOZLineLength"), ugDistance, ((const LineSectorZone &)oz).getLength()); break; case ObservationZonePoint::CYLINDER: ShowFormControl(*wf, _T("frmOZCylinder"), true); LoadFormProperty(*wf, _T("prpOZCylinderRadius"), ugDistance, ((const CylinderZone &)oz).getRadius()); break; default: break; } WndFrame* wfrm = NULL; wfrm = ((WndFrame*)wf->FindByName(_T("lblType"))); if (wfrm) wfrm->SetCaption(OrderedTaskPointName(ordered_task->get_factory().getType(*tp))); SetFormControlEnabled(*wf, _T("butPrevious"), active_index > 0); SetFormControlEnabled(*wf, _T("butNext"), active_index < (ordered_task->TaskSize() - 1)); WndButton* wb; wb = (WndButton*)wf->FindByName(_T("cmdOptionalStarts")); assert(wb); wb->set_visible(active_index == 0); if (ordered_task->optional_start_points_size() == 0) wb->SetCaption(_("Enable Alternate Starts")); else { TCHAR tmp[50]; _stprintf(tmp, _T("%s (%d)"), _("Edit Alternates"), ordered_task->optional_start_points_size()); wb->SetCaption(tmp); } EnableSizeEdit(ordered_task->get_factory_type() != TaskBehaviour::FACTORY_FAI_GENERAL); TCHAR bufType[100]; TCHAR bufNamePrefix[100]; switch (tp->GetType()) { case TaskPoint::START: _tcscpy(bufType, _T("Start point")); _tcscpy(bufNamePrefix, _T("Start: ")); break; case TaskPoint::AST: _tcscpy(bufType, _T("Task point")); _stprintf(bufNamePrefix, _T("%d: "), active_index); break; case TaskPoint::AAT: _tcscpy(bufType, _T("Assigned area point")); _stprintf(bufNamePrefix, _T("%d: "), active_index); break; case TaskPoint::FINISH: _tcscpy(bufType, _T("Finish point")); _tcscpy(bufNamePrefix, _T("Finish: ")); break; default: assert(true); break; } wf->SetCaption(bufType); wfrm = ((WndFrame*)wf->FindByName(_T("lblLocation"))); if (wfrm) { TCHAR buff[100]; _stprintf(buff, _T("%s %s"), bufNamePrefix, tp->GetWaypoint().name.c_str()); wfrm->SetCaption(buff); } Refreshing = false; // reactivate onChange routines }
/** * 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; }
/** * Displays a MessageBox and returns the pressed button * @param lpText Text displayed inside the MessageBox * @param lpCaption Text displayed in the Caption of the MessageBox * @param uType Type of MessageBox to display (OK+Cancel, Yes+No, etc.) * @return */ int WINAPI MessageBoxX(LPCTSTR lpText, LPCTSTR lpCaption, UINT uType) { WndForm *wf = NULL; WndFrame *wText = NULL; int X, Y, Width, Height; WndButton *wButtons[10]; int ButtonCount = 0; int i, x, y, d, w, h, res, dY; RECT rc; assert(lpText != NULL); assert(lpCaption != NULL); // JMW this makes the first key if pressed quickly, ignored // TODO bug: doesn't work sometimes. buttons have to be pressed multiple times (TB) XCSoarInterface::Debounce(); rc = XCSoarInterface::main_window.get_screen_position(); #ifdef ALTAIRSYNC Width = Layout::Scale(220); Height = Layout::Scale(160); #else Width = Layout::Scale(200); Height = Layout::Scale(160); #endif X = ((rc.right - rc.left) - Width) / 2; Y = ((rc.bottom - rc.top) - Height) / 2; y = Layout::Scale(100); w = Layout::Scale(60); h = Layout::Scale(32); // Create dialog wf = new WndForm(&XCSoarInterface::main_window, _T("frmXcSoarMessageDlg"), lpCaption, X, Y, Width, Height); wf->SetFont(MapWindowBoldFont); wf->SetTitleFont(MapWindowBoldFont); wf->SetBackColor(Color(0xDA, 0xDB, 0xAB)); // Create text element wText = new WndFrame(wf, _T("frmMessageDlgText"), 0, Layout::Scale(5), Width, Height); wText->SetCaption(lpText); wText->SetFont(MapWindowBoldFont); wText->SetCaptionStyle(DT_EXPANDTABS | DT_CENTER | DT_NOCLIP | DT_WORDBREAK); // | DT_VCENTER /* TODO code: this doesnt work to set font height dY = wText->GetLastDrawTextHeight() - Height; */ dY = Layout::Scale(-40); wText->resize(Width, wText->GetTextHeight() + 5); wf->resize(Width, wf->get_size().cy + dY); y += dY; // Create buttons uType = uType & 0x000f; if (uType == MB_OK || uType == MB_OKCANCEL) { wButtons[ButtonCount] = new WndButton(wf, _T(""), gettext(_T("OK")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDOK); ButtonCount++; } if (uType == MB_YESNO || uType == MB_YESNOCANCEL) { wButtons[ButtonCount] = new WndButton(wf, _T(""), gettext(_T("Yes")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDYES); ButtonCount++; wButtons[ButtonCount] = new WndButton(wf, _T(""), gettext(_T("No")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDNO); ButtonCount++; } if (uType == MB_ABORTRETRYIGNORE || uType == MB_RETRYCANCEL) { wButtons[ButtonCount] = new WndButton(wf, _T(""), gettext(_T("Retry")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDRETRY); ButtonCount++; } if (uType == MB_OKCANCEL || uType == MB_RETRYCANCEL || uType == MB_YESNOCANCEL) { wButtons[ButtonCount] = new WndButton(wf, _T(""), gettext(_T("Cancel")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDCANCEL); ButtonCount++; } if (uType == MB_ABORTRETRYIGNORE) { wButtons[ButtonCount] = new WndButton(wf, _T(""), gettext(_T("Abort")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDABORT); ButtonCount++; wButtons[ButtonCount] = new WndButton(wf, _T(""), gettext(_T("Ignore")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDIGNORE); ButtonCount++; } d = Width / (ButtonCount); x = d / 2 - w / 2; // Move buttons to the right positions for (i = 0; i < ButtonCount; i++) { wButtons[i]->move(x, y); x += d; } // Show MessageBox and save result res = wf->ShowModal(); delete wf; #ifdef ALTAIRSYNC // force a refresh of the window behind InvalidateRect(hWnd,NULL,true); UpdateWindow(hWnd); #endif return(res); }