/** Initializes the controls of this view */ XRESULT D2DMessageBox::InitControls(ED2D_MB_TYPE type) { D2DSubView::InitControls(); // Create message label Message = new SV_Label(MainView, MainPanel); Message->SetSize(GetSize()); Message->AlignUnder(Header, 5.0f); Message->SetRect(D2D1::RectF(5.0f, Message->GetRect().top, ViewRect.right - 5.0f, ViewRect.bottom - 5.0f)); Message->SetCaption("Text"); SetPositionCentered(D2D1::Point2F(MainView->GetRenderTarget()->GetSize().width / 2, MainView->GetRenderTarget()->GetSize().height / 2), D2D1::SizeF(400, 150)); switch(type) { case D2D_MBT_YES_NO: YesButton = AddButton("Yes", ButtonPressed, this); NoButton = AddButton("No", ButtonPressed, this); break; case D2D_MBT_OK: default: OkButton = AddButton("Ok", ButtonPressed, this); break; } return XR_SUCCESS; }
/** * This function returns a WndForm created either from the ressources or * from the XML file in XCSoarData(if found) * @param LookUpTable The CallBackTable * @param FileName The XML filename to search for in XCSoarData * @param Parent The parent window (e.g. XCSoarInterface::main_window) * @param resource The resource to look for * @return The WndForm object */ WndForm * LoadDialog(CallBackTableEntry *LookUpTable, SingleWindow &Parent, const TCHAR* resource) { WndForm *form = NULL; // Find XML file or resource and load XML data out of it XMLNode node = xmlOpenResourceHelper(resource); // TODO code: put in error checking here and get rid of exits in xmlParser // If XML error occurred -> Error messagebox + cancel if (node.isEmpty()) { ShowXMLError(); return NULL; } // If the main XMLNode is of type "Form" if (_tcsicmp(node.getName(), _T("Form")) != 0) // Get the first child node of the type "Form" // and save it as the dialog node node = node.getChildNode(_T("Form")); // If Node does not exists -> Error messagebox + cancel if (node.isEmpty()) { ShowXMLError(); return NULL; } // Determine the dialog style of the dialog DialogStyle dialog_style = GetDialogStyle(node); // Determine the dialog size const TCHAR* Caption = GetCaption(node); const RECT rc = Parent.get_client_rect(); ControlPosition pos = GetPosition(node, rc); ControlSize size = GetSize(node, rc, pos); InitScaleWidth(size, rc, dialog_style); // Correct dialog size and position for dialog style switch (dialog_style) { case dsFullWidth: pos.x = rc.left; pos.y = rc.top; size.cx = rc.right - rc.left; // stretch form to full width of screen size.cy = rc.bottom - rc.top; break; case dsScaledCentered: pos = SetPositionCentered(pos, rc, size); break; case dsScaled: case dsFixed: break; } // Create the dialog WindowStyle style; style.hide(); style.control_parent(); form = new WndForm(Parent, pos.x, pos.y, size.cx, size.cy, Caption, style); // Set fore- and background colors Color color; if (StringToColor(node.getAttribute(_T("BackColor")), color)) form->SetBackColor(color); // Load the children controls LoadChildrenFromXML(*form, form->GetClientAreaWindow(), form->GetBackColor(), LookUpTable, &node, dialog_style); // If XML error occurred -> Error messagebox + cancel if (XMLNode::GlobalError) { ShowXMLError(); delete form; return NULL; } // Return the created form return form; }
/** * This function returns a WndForm created either from the ressources or * from the XML file in XCSoarData(if found) * @param LookUpTable The CallBackTable * @param FileName The XML filename to search for in XCSoarData * @param Parent The parent window (e.g. XCSoarInterface::main_window) * @param resource The resource to look for * @param targetRect The area where to move the dialog if not parent * @return The WndForm object */ WndForm * LoadDialog(const CallBackTableEntry *lookup_table, SingleWindow &parent, const TCHAR *resource, const PixelRect *target_rc) { WndForm *form = NULL; // Find XML file or resource and load XML data out of it XMLNode *node = LoadXMLFromResource(resource); // TODO code: put in error checking here and get rid of exits in xmlParser // If XML error occurred -> Error messagebox + cancel assert(node != NULL); // If the main XMLNode is of type "Form" assert(StringIsEqual(node->getName(), _T("Form"))); // Determine the dialog size const TCHAR* caption = GetCaption(*node); const PixelRect rc = target_rc ? *target_rc : parent.get_client_rect(); ControlPosition pos = GetPosition(*node, rc, 0); ControlSize size = GetSize(*node, rc, pos); InitScaleWidth(size, rc); // Correct dialog size and position for dialog style switch (UIGlobals::GetDialogSettings().dialog_style) { case dsFullWidth: pos.x = rc.left; pos.y = rc.top; size.cx = rc.right - rc.left; // stretch form to full width of screen size.cy = rc.bottom - rc.top; break; case dsScaledCentered: pos = SetPositionCentered(pos, rc, size); break; case dsScaled: case dsFixed: break; case dsScaledBottom: size.cx = rc.right - rc.left; // stretch form to full width of screen pos.y = rc.bottom - size.cy; // position at bottom of screen break; } // Create the dialog WindowStyle style; style.Hide(); style.ControlParent(); PixelRect form_rc; form_rc.left = pos.x; form_rc.top = pos.y; form_rc.right = form_rc.left + size.cx; form_rc.bottom = form_rc.top + size.cy; form = new WndForm(parent, *xml_dialog_look, form_rc, caption, style); // Load the children controls LoadChildrenFromXML(*form, form->GetClientAreaWindow(), lookup_table, node); delete node; // If XML error occurred -> Error messagebox + cancel assert(!XMLNode::GlobalError); // Return the created form return form; }