//--------------------------------------------------------------------------- void __fastcall TMainForm::BlueMenuItemClick(TObject *Sender) { SearchButton->Appearance->Color = StringToColor("0x00EEDBC8"); SearchButton->Appearance->ColorMirror = StringToColor("0x00EEDBC8"); SearchButton->Appearance->ColorTo = StringToColor("0x00F6DDC9"); SearchButton->Appearance->ColorMirrorTo = StringToColor("0x00F6DDC9"); SearchButton->Appearance->BorderColor = StringToColor("0x00E0B99B"); ShowAllButton->Appearance->Color = StringToColor("0x00EEDBC8"); ShowAllButton->Appearance->ColorTo = StringToColor("0x00F6DDC9"); ShowAllButton->Appearance->ColorMirrorTo = StringToColor("0x00F6DDC9"); ShowAllButton->Appearance->BorderColor = StringToColor("0x00E0B99B"); DBGrid->FixedColor = StringToColor("0x00E0A57D"); //DBAdvGrid->ControlLook->FixedGradientFrom = StringToColor("0x00FCE1CB"); //DBAdvGrid->ControlLook->FixedGradientTo = StringToColor("0x00E0A57D"); AdvMenuOfficeStyler->Style = osOffice2003Blue; AdvToolBarOfficeStyler->Style = bsOffice2003Blue; AdvPanelStyler->Style = Advpanel::psOffice2003Blue; AdvOfficeStatusBarOfficeStyler->Style = Advofficestatusbarstylers::psOffice2003Blue; LunaMenuItem->Checked = false; SilverMenuItem->Checked = false; OliveMenuItem->Checked = false; Silver2MenuItem->Checked = false; styleIndex = 3; }
//--------------------------------------------------------------------- // ParseINI //--------------------------------------------------------------------- BOOL CSkinHighlightBar::ParseINI( CSystem_IniFile &iniFile, const CStdString §ionName, const CStdString &parentEntryName, const CStdString &childEntryName ) { CStdString entryName = parentEntryName; if( entryName == "" ) entryName = childEntryName; else entryName += "." + childEntryName; RECT rct = StringToRect( iniFile.GetProfileString( sectionName, entryName + ".Area", "" ) ); if( rct.left != VALUE_INVALID && rct.top != VALUE_INVALID && rct.right != VALUE_INVALID && rct.bottom != VALUE_INVALID ) { m_left = rct.left; m_top = rct.top; m_right = rct.right; m_bottom = rct.bottom; } // Parse the color, allowing either one color for all 4 corners, or individual colors BOOL colorSetup = FALSE; CStdString temp = iniFile.GetProfileString( sectionName, entryName + ".Color", "" ); if( temp != "" ) { m_cornerColors[0] = m_cornerColors[1] = m_cornerColors[2] = m_cornerColors[3] = StringToColor( temp ); colorSetup = TRUE; } else { temp = iniFile.GetProfileString( sectionName, entryName + ".Color.UpperLeft", "" ); if( temp != "" ) colorSetup = TRUE; m_cornerColors[0] = StringToColor( temp ); temp = iniFile.GetProfileString( sectionName, entryName + ".Color.UpperRight", "" ); if( temp != "" ) colorSetup = TRUE; m_cornerColors[1] = StringToColor( temp ); temp = iniFile.GetProfileString( sectionName, entryName + ".Color.LowerRight", "" ); if( temp != "" ) colorSetup = TRUE; m_cornerColors[2] = StringToColor( temp ); temp = iniFile.GetProfileString( sectionName, entryName + ".Color.LowerLeft", "" ); if( temp != "" ) colorSetup = TRUE; m_cornerColors[3] = StringToColor( temp ); } return colorSetup || (m_left != VALUE_INVALID && m_right != VALUE_INVALID && m_top != VALUE_INVALID && m_bottom != VALUE_INVALID ); }
int main() { std::cout << ColorToString(Red) << std::endl; std::cout << ColorToString(NOT_A_COLOR) << std::endl; std::cout << StringToColor("Green") << std::endl; std::cout << StringToColor("green") << std::endl; std::cout << StringToColor("Olive") << std::endl; return 0; }
/** * Loads the color information from the XMLNode and sets the fore- and * background color of the given WindowControl * @param wc The WindowControl * @param node The XMLNode */ static void LoadColors(WindowControl &wc, const XMLNode &node) { Color color; if (StringToColor(node.getAttribute(_T("BackColor")), color)) wc.SetBackColor(color); if (StringToColor(node.getAttribute(_T("ForeColor")), color)) wc.SetForeColor(color); }
WOGButton* OGSceneConfig::CreateButton(const QDomElement &element) { WOGButton* obj = new WOGButton; obj->id = element.attribute("id"); obj->depth = element.attribute("depth").toDouble(); obj->position = StringToPoint(element.attribute("x") , element.attribute("y")); obj->scale = StringToPoint(element.attribute("scalex") , element.attribute("scaley")); obj->rotation = element.attribute("rotation").toDouble(); obj->alpha = element.attribute("alpha", "1").toDouble(); obj->colorize = StringToColor(element.attribute("colorize" , "255,255,255")); obj->up = element.attribute("up"); obj->over = element.attribute("over"); obj->disabled = element.attribute("disabled"); obj->onclick = element.attribute("onclick"); obj->onmouseenter = element.attribute("onmouseenter"); obj->onmouseexit = element.attribute("onmouseexit"); obj->text = element.attribute("text"); obj->font = element.attribute("font"); return obj; }
void WindowBuilder::BuildBackground(View* v, tinyxml2::XMLElement* xml_element) { auto getBackground = [v]()->Background*{ if (!v->background()) { v->SetBackground(new Background); } return v->background(); }; { Color c; const char* val = xml_element->Attribute("background-color"); if (val && StringToColor(val, c)) { getBackground()->SetColor(c); } } { const char* val = xml_element->Attribute("background-image"); if (val) { //getBackground()->SetColor(c); } } }
void ColorDialog::updateItem(QTreeWidgetItem *it, QString value){ it->setText(1,value); if(value.isEmpty()){ return; } //qDebug() << "Load Color:" << it->whatsThis(0) << value; //Now try to load the color and set the sample QBrush brush(StringToColor(value)); it->setBackground(2, brush); }
//--------------------------------------------------------------------------- void TRegisterFormClass::SetEditColor(TRzEdit *curEdit, bool isActive) { AnsiString Color = "$00F5F6F7"; if (isActive) curEdit->Color = clWhite; else curEdit->Color = StringToColor(Color); }
WOGLevel* OGLevelConfig::Parser() { WOGLevel* level = new WOGLevel; level->ballsrequired = rootElement.attribute("ballsrequired").toInt(); level->letterboxed = StringToBool(rootElement.attribute("letterboxed")); level->visualdebug = StringToBool(rootElement.attribute("visualdebug")); level->autobounds = StringToBool(rootElement.attribute("autobounds")); level->textcolor = StringToColor(rootElement.attribute("textcolor")); level->texteffects = StringToBool(rootElement.attribute("texteffects")); level->timebugprobability = rootElement.attribute("timebugprobability").toDouble(); level->strandgeom = StringToBool(rootElement.attribute("strandgeom")); level->allowskip = StringToBool(rootElement.attribute("allowskip")); QDomNode node = rootElement.firstChild(); while (!node.isNull()) { QDomElement domElement = node.toElement(); if (domElement.tagName() == "camera") { level->camera << CreateCamera(domElement); } else if (domElement.tagName() == "music") { level->music.id = domElement.attribute("music"); } else if (domElement.tagName() == "BallInstance") { level->ball << CreateBallInstance(domElement); } else if (domElement.tagName() == "levelexit") { if (!level->levelexit) { level->levelexit = CreateLevelExit(domElement); } } else if (domElement.tagName() == "pipe") { if (!level->pipe) { level->pipe = CreatePipe(domElement); } } else if (domElement.tagName() == "Strand") { level->strand << CreateStrand(domElement); } node = node.nextSibling(); } return level; }
// 加载XML节点 BOOL CSelectBox::Load(TiXmlElement* pXmlElem, BOOL bLoadSubControl) { if(!__super::Load(pXmlElem)) { return FALSE; } // 使用XML节点初始化控件 if(pXmlElem != NULL) { // 加载图片和颜色列表 TiXmlElement* pControlElem = NULL; for (pControlElem = pXmlElem->FirstChildElement("item"); pControlElem != NULL; pControlElem=pControlElem->NextSiblingElement()) { if(pControlElem != NULL) { CString strImage = CEncodingUtil::AnsiToUnicode(pControlElem->Attribute("image")); CStringA strColor = pControlElem->Attribute("color"); if(!strImage.IsEmpty()) { if(strImage.Find(_T("skin:")) == 0) { strImage = CEncodingUtil::AnsiToUnicode(DuiSystem::Instance()->GetSkin(CEncodingUtil::UnicodeToAnsi(strImage))); } if(strImage.Find(_T(".")) != -1) // 加载图片文件 { CString strImgFile = DuiSystem::GetExePath() + strImage; SetBitmap(strImgFile); }else // 加载图片资源 { UINT nResourceID = _wtoi(strImage); if(!SetBitmap(nResourceID, -1, TEXT("PNG"))) { SetBitmap(nResourceID, -1, TEXT("BMP")); } } m_bImage = TRUE; }else if(!strColor.IsEmpty()) { Color color; if(strColor.Find(",") == -1) { color = HexStringToColor(strColor); }else { color = StringToColor(strColor); } SetColor(color); } } } } return TRUE; }
void FrameWindow::init(xml::node& node) { Panel::init(node); xml::node setting = node("Title"); if(!setting.empty()) { m_text = setting.first_child().value(); } setting = node("Font"); if(!setting.empty()) { m_font = m_system.getWindowManager().loadFont(setting.first_child().value()); } setting = node("Formatting"); if(!setting.empty()) { m_format = StringToFormatType(setting.first_child().value()); } setting = node("CaptionColor"); if(!setting.empty()) { m_captionColor = StringToColor(setting.first_child().value()); } setting = node("Movable"); if(!setting.empty()) { m_movable = StringToBool(setting.first_child().value()); } setting = node("ClampToScreen"); if(!setting.empty()) { m_clampToScreen = StringToBool(setting.first_child().value()); } xml::node frame = node("Caption"); if(!frame.empty()) { std::string setname = frame["Imageset"].value(); m_imgset = m_system.getWindowManager().loadImageset(setname); if(m_imgset) { const Imageset& set = *m_imgset; m_captionBackImg = set[frame("Background")["Image"].value()]; m_captionLeftImg = set[frame("Left")["Image"].value()]; m_captionRightImg = set[frame("Right")["Image"].value()]; } } }
// 加载XML节点 BOOL CSelectBox::Load(DuiXmlNode pXmlElem, BOOL bLoadSubControl) { if(!__super::Load(pXmlElem)) { return FALSE; } // 使用XML节点初始化控件 if(pXmlElem != NULL) { // 加载图片和颜色列表 DuiXmlNode pControlElem; for (DuiXmlNode pControlElem = pXmlElem.child(_T("item")); pControlElem; pControlElem=pControlElem.next_sibling(_T("item"))) { CString strImage = pControlElem.attribute(_T("image")).value(); CString strColor = pControlElem.attribute(_T("color")).value(); if(!strImage.IsEmpty()) { if(strImage.Find(_T("skin:")) == 0) { } if(strImage.Find(_T(".")) != -1) // 加载图片文件 { CString strImgFile = DuiSystem::GetExePath() + strImage; SetBitmap(strImgFile); }else // 加载图片资源 { UINT nResourceID = _wtoi(strImage); if(!SetBitmap(nResourceID, -1, TEXT("PNG"))) { SetBitmap(nResourceID, -1, TEXT("BMP")); } } m_bImage = TRUE; }else if(!strColor.IsEmpty()) { Color color; if(strColor.Find(_T(",")) == -1) { color = HexStringToColor(strColor); }else { color = StringToColor(strColor); } SetColor(color); } } } return TRUE; }
void ColorDialog::on_tool_getcolor_clicked(){ QTreeWidgetItem *it = ui->tree_color->currentItem(); if(it==0){ return; } //no item selected QColor ccol = StringToColor(it->text(1)); QColor ncol; if(it->whatsThis(0).contains("BASE")){ ncol = QColorDialog::getColor(ccol, this, tr("Select Color")); } else{ ncol = QColorDialog::getColor(ccol, this, tr("Select Color"), QColorDialog::ShowAlphaChannel ); } if(ncol.isValid()){ QString out; if(ncol.alpha()!=255){ //Convert to rgba out = "rgba("+QString::number(ncol.red())+","+QString::number(ncol.green())+","+QString::number(ncol.blue())+","+QString::number(ncol.alpha())+")"; }else{ //Convert to rgb out = "rgb("+QString::number(ncol.red())+","+QString::number(ncol.green())+","+QString::number(ncol.blue())+")"; } updateItem(it, out); } }
WOGSceneLayer* OGSceneConfig::CreateSceneLayer(const QDomElement &element) { WOGSceneLayer* obj = new WOGSceneLayer; obj->id = element.attribute("id"); obj->name = element.attribute("name"); obj->depth = element.attribute("depth").toDouble(); obj->position = StringToPoint(element.attribute("x") , element.attribute("y")); obj->scale = StringToPoint(element.attribute("scalex") , element.attribute("scaley")); obj->rotation = element.attribute("rotation").toDouble(); obj->alpha = element.attribute("alpha", "1").toDouble(); obj->colorize = StringToColor(element.attribute("colorize" , "255,255,255")); obj->image = element.attribute("image"); obj->anim = element.attribute("anim"); obj->animspeed = element.attribute("animspeed").toDouble(); return obj; }
int SChatEdit::_InsertFormatText(int iCaret,CHARFORMATW cf,pugi::xml_node xmlText,BOOL bCanUndo) { SStringW strText = xmlText.value(); if(xmlText.name() == KLabelSmiley) {//insert smiley SComPtr<ISoSmileyCtrl> pSmiley; HRESULT hr=::CoCreateInstance(CLSID_CSoSmileyCtrl,NULL,CLSCTX_INPROC,__uuidof(ISoSmileyCtrl),(LPVOID*)&pSmiley); if(FAILED(hr)) return 0; SComPtr<IRichEditOle> ole; if(SSendMessage(EM_GETOLEINTERFACE,0,(LPARAM)(void**)&ole) && ole) { SComPtr<IRichEditOleCallback> pCallback; hr=ole->QueryInterface(IID_IRichEditOleCallback,(void**)&pCallback); if(FAILED(hr)) return 0; SComPtr<ISmileyHost> host; hr = pCallback->QueryInterface(__uuidof(ISmileyHost),(void**)&host); if(FAILED(hr)) return 0; SComPtr<ISmileySource> pSource; hr = host->CreateSource(&pSource); if(FAILED(hr)) return 0; { UINT uID = xmlText.attribute(L"id").as_uint(-1); SStringW strPath = xmlText.attribute(L"path").value(); if(uID != -1) hr = pSource->LoadFromID(uID); else hr = pSource->LoadFromFile(strPath); if(SUCCEEDED(hr)) { pSmiley->SetSource(pSource); SSendMessage(EM_SETSEL,iCaret,iCaret); pSmiley->Insert2Richedit((DWORD_PTR)(void*)ole); } } } return SUCCEEDED(hr)?1:0; } CHARFORMATW cfNew = cf; cfNew.dwMask = 0; if(xmlText.name() == KLabelColor) { cfNew.crTextColor = StringToColor(xmlText.attribute(L"value").value()) & 0x00ffffff; cfNew.dwMask |= CFM_COLOR; }else if(xmlText.name()== KLabelFont) { wcscpy(cf.szFaceName,cfNew.szFaceName); wcscpy_s(cfNew.szFaceName,LF_FACESIZE-1,xmlText.attribute(L"value").value()); cfNew.dwMask |= CFM_FACE; }else if(xmlText.name()==KLabelUnderline) { cfNew.dwMask |=CFM_UNDERLINE; cfNew.dwEffects |= CFE_UNDERLINE; }else if(xmlText.name() == KLabelItalic) { cfNew.dwMask |=CFM_ITALIC; cfNew.dwEffects |= CFE_ITALIC; }else if(xmlText.name() == KLabelBold) { cfNew.dwMask |=CFM_BOLD; cfNew.dwEffects |= CFE_BOLD; }else if(xmlText.name() == KLabelStrike) { cfNew.dwMask |= CFM_STRIKEOUT; cfNew.dwEffects |= CFE_STRIKEOUT; }else if(xmlText.name() == KLabelLink) { cfNew.dwMask |= CFM_LINK; cfNew.dwEffects |= CFE_LINK; COLORREF cr = StringToColor(xmlText.attribute(L"color").value()); if(cr!=0) { cfNew.dwMask |= CFM_COLOR; cfNew.crTextColor = cr & 0x00ffffff; } }else if(xmlText.name() == KLabelSize) { cfNew.dwMask |= CFM_SIZE; HDC hdc=GetDC(NULL); LONG yPixPerInch = GetDeviceCaps(hdc, LOGPIXELSY); ReleaseDC(NULL,hdc); cfNew.yHeight = abs(MulDiv(xmlText.attribute(L"value").as_uint(12), LY_PER_INCH, yPixPerInch)); } int nRet = strText.GetLength(); SSendMessage(EM_REPLACESEL,bCanUndo,(LPARAM)(LPCWSTR)strText); int iEnd = iCaret + nRet; SSendMessage(EM_SETSEL,iCaret,iEnd); SSendMessage(EM_SETCHARFORMAT,SCF_SELECTION,(LPARAM)&cfNew); iCaret = iEnd; SSendMessage(EM_SETSEL,iCaret,iCaret); pugi::xml_node xmlChild = xmlText.first_child(); while(xmlChild) { int nSubLen = _InsertFormatText(iCaret,cfNew,xmlChild,bCanUndo); iCaret += nSubLen; nRet += nSubLen; xmlChild = xmlChild.next_sibling(); } if(cfNew.dwMask) { cf.dwMask = CFM_ALL; SSendMessage(EM_SETCHARFORMAT,SCF_SELECTION,(LPARAM)&cf); } return nRet; }
void WindowBuilder::BuildBorder(View* v, tinyxml2::XMLElement* xml_element) { auto getBorder = [v]()->Border*{ if (!v->border()) { v->SetBorder(new Border); } return v->border(); }; { Color c = Color_Transparent; int v = xml_element->IntAttribute("border-left-width"); if (v) { const char* val = xml_element->Attribute("border-left-color"); if (val) { StringToColor(val, c); } getBorder()->SetBorder(Border::LEFT, v, c); } } { Color c = Color_Transparent; int v = xml_element->IntAttribute("border-top-width"); if (v) { const char* val = xml_element->Attribute("border-top-color"); if (val) { StringToColor(val, c); } getBorder()->SetBorder(Border::TOP, v, c); } } { Color c = Color_Transparent; int v = xml_element->IntAttribute("border-right-width"); if (v) { const char* val = xml_element->Attribute("border-right-color"); if (val) { StringToColor(val, c); } getBorder()->SetBorder(Border::RIGHT, v, c); } } { Color c = Color_Transparent; int v = xml_element->IntAttribute("border-bottom-width"); if (v) { const char* val = xml_element->Attribute("border-bottom-color"); if (val) { StringToColor(val, c); } getBorder()->SetBorder(Border::BOTTOM, v, c); } } }
/** * 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; }
COLORREF Hex2Color(const SStringW & strColor,COLORREF crDef) { if(strColor.IsEmpty()) return crDef; return StringToColor(strColor); }
//--------------------------------------------------------------------------- void __fastcall TMainForm::LunaMenuItemClick(TObject *Sender) { SearchButton->Appearance->Color = StringToColor("0x00EEDBC8"); SearchButton->Appearance->ColorMirror = StringToColor("0x00EEDBC8"); SearchButton->Appearance->ColorTo = StringToColor("0x00F6DDC9"); SearchButton->Appearance->ColorMirrorTo = StringToColor("0x00F6DDC9"); SearchButton->Appearance->BorderColor = StringToColor("0x00E0B99B"); ShowAllButton->Appearance->Color = StringToColor("0x00EEDBC8"); ShowAllButton->Appearance->ColorMirror = StringToColor("0x00EEDBC8"); ShowAllButton->Appearance->ColorTo = StringToColor("0x00F6DDC9"); ShowAllButton->Appearance->ColorMirrorTo = StringToColor("0x00F6DDC9"); ShowAllButton->Appearance->BorderColor = StringToColor("0x00E0B99B"); DBGrid->FixedColor = StringToColor("clSkyBlue"); AdvMenuOfficeStyler->Style = osOffice2007Luna; AdvToolBarOfficeStyler->Style = bsOffice2007Luna; AdvPanelStyler->Style = Advpanel::psOffice2007Luna; AdvOfficeStatusBarOfficeStyler->Style = Advofficestatusbarstylers::psOffice2007Luna; SilverMenuItem->Checked = false; BlueMenuItem->Checked = false; OliveMenuItem->Checked = false; Silver2MenuItem->Checked = false; styleIndex = 1; }
WOGScene* OGSceneConfig::Parser() { WOGScene* scene = new WOGScene; scene->minx = rootElement.attribute("minx").toDouble(); scene->miny = rootElement.attribute("miny").toDouble(); scene->maxx = rootElement.attribute("maxx").toDouble(); scene->maxy = rootElement.attribute("maxy").toDouble(); scene->backgroundcolor = StringToColor(rootElement.attribute("backgroundcolor")); QDomNode node = rootElement.firstChild(); while (!node.isNull()) { QDomElement domElement = node.toElement(); if (domElement.tagName() == "SceneLayer") { scene->sceneLayer << CreateSceneLayer(domElement); } else if (domElement.tagName() == "label") { scene->label << CreateLabel(domElement); } else if (domElement.tagName() == "buttongroup") { scene->buttongroup << CreateButtonGroup(domElement); } else if (domElement.tagName() == "button") { scene->button << CreateButton(domElement); } else if (domElement.tagName() == "radialforcefield") { scene->radialforcefield << CreateRadialForceField(domElement); } else if (domElement.tagName() == "linearforcefield") { scene->linearforcefield << CreateLinearForceField(domElement); } else if (domElement.tagName() == "particles") { scene->particle << CreateParticle(domElement); } else if (domElement.tagName() == "circle") { scene->circle << CreateCircle(domElement); } else if (domElement.tagName() == "line") { scene->line << CreateLine(domElement); } else if (domElement.tagName() == "rectangle") { scene->rectangle << CreateRectanle(domElement); } node = node.nextSibling(); } return scene; }
void base_window::init(xml::node& node) { xml::node setting = node("Visible"); if(!setting.empty()) { m_visible = StringToBool(setting.first_child().value()); } setting = node("Align"); if(!setting.empty()) { m_alignment = StringToAlignment(setting.first_child().value()); } setting = node("Stick"); if(!setting.empty()) { m_stick = StringToAlignment(setting.first_child().value()); } setting = node("StickRect"); if(!setting.empty()) { m_stickRect = StringToRect(setting.first_child().value()); } setting = node("Area"); if(!setting.empty()) { m_area = StringToArea(setting.first_child().value()); } setting = node("Backcolor"); if(!setting.empty()) { m_backColor = StringToColor(setting.first_child().value()); } setting = node("Forecolor"); if(!setting.empty()) { m_foreColor = StringToColor(setting.first_child().value()); } setting = node("TabStop"); if(!setting.empty()) { m_tabstop = StringToBool(setting.first_child().value()); } setting = node("Draggable"); if(!setting.empty()) { m_draggable = StringToBool(setting.first_child().value()); } setting = node("AcceptDrop"); if(!setting.empty()) { m_acceptDrop = StringToBool(setting.first_child().value()); } setting = node("AlwaysOnTop"); if(!setting.empty()) { m_alwaysOnTop = StringToBool(setting.first_child().value()); } setting = node("Tooltip"); if(!setting.empty()) { m_tooltip = StringToBool(setting.first_child().value()); } setting = node("Size"); if(!setting.empty()) { setSize(StringToSize(setting.first_child().value())); } setting = node("Pos"); if(!setting.empty()) { setPosition(StringToPoint(setting.first_child().value())); } setting = node("IgnoreInputEvents"); if(!setting.empty()) { setIgnoreInputEvents(StringToBool(setting.first_child().value())); } setting = node("DisableRise"); if (!setting.empty()) { setDisableRise(StringToBool(setting.first_child().value())); } onMoved(); }
/** * 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; }
void __fastcall TsplashScreen::loadSettings() { TRegistry *reg = new TRegistry; bool r; ProgressBar->Position = 0; ProgressBar->Max = 26; reg->RootKey = HKEY_LOCAL_MACHINE; try { if ( reg->OpenKey("Software\\LN3GS Productions\\eLibrary", false) ) { ProgressBar->Position++; if( reg->ValueExists("Maximized") ) { r = reg->ReadBool("Maximized"); mainForm->WindowState = r? wsMaximized: wsNormal; } if( !r ) { ProgressBar->Position++; if( reg->ValueExists("Width") ) mainForm->Width = reg->ReadInteger("Width"); ProgressBar->Position++; if( reg->ValueExists("Height") ) mainForm->Height = reg->ReadInteger("Height"); ProgressBar->Position++; if( reg->ValueExists("Left") ) mainForm->Left = reg->ReadInteger("Left"); ProgressBar->Position++; if( reg->ValueExists("Top") ) mainForm->Top = reg->ReadInteger("Top"); } else ProgressBar->Position += 4; ProgressBar->Position++; if( reg->ValueExists("GridLines") ) if( !reg->ReadBool("GridLines") ) mainForm->mnuViewGridLines->Click(); ProgressBar->Position++; if( reg->ValueExists("Statusbar") ) if( !reg->ReadBool("Statusbar") ) mainForm->mnuViewStatusBar->Click(); ProgressBar->Position++; if( reg->ValueExists("Toolbar") ) if( !reg->ReadBool("Toolbar") ) mainForm->mnuViewToolbar->Click(); ProgressBar->Position++; mainForm->mySettings.server.server = "ibiblio.org"; if( reg->ValueExists("Server") ) mainForm->mySettings.server.server = reg->ReadString("Server"); ProgressBar->Position++; if( reg->ValueExists("ClearNewLine") ) mainForm->mySettings.addNewLine = reg->ReadBool("ClearNewLine"); ProgressBar->Position++; mainForm->mySettings.server.directory = "pub/docs/books/gutenberg/"; if( reg->ValueExists("ServerDir") ) mainForm->mySettings.server.directory = reg->ReadString("ServerDir" ); ProgressBar->Position++; if( reg->ValueExists("Password") ) mainForm->mySettings.server.password = reg->ReadString("Password"); ProgressBar->Position++; if( reg->ValueExists("Proxy") ) mainForm->mySettings.server.proxy = reg->ReadString("Proxy" ); ProgressBar->Position++; if( reg->ValueExists("ListFontName" ) ) { mainForm->mySettings.AppFont->Name = reg->ReadString("ListFontName" ); mainForm->BookList->Font->Name = mainForm->mySettings.AppFont->Name; mainForm->SearchList->Font->Name = mainForm->BookList->Font->Name; mainForm->MyLibraryList->Font->Name = mainForm->BookList->Font->Name; } ProgressBar->Position++; if( reg->ValueExists("ListFontSize") ) { mainForm->mySettings.AppFont->Size = reg->ReadInteger("ListFontSize" ); mainForm->BookList->Font->Size = mainForm->mySettings.AppFont->Size; mainForm->SearchList->Font->Size = mainForm->BookList->Font->Size; mainForm->MyLibraryList->Font->Size = mainForm->BookList->Font->Size; } ProgressBar->Position++; mainForm->mySettings.bookDir = appPath + "BookDir"; if( reg->ValueExists("BookDir") ) mainForm->mySettings.bookDir = reg->ReadString("BookDir"); ProgressBar->Position++; if( reg->ValueExists("HTMLFont") ) mainForm->mySettings.HTMLFont->Name = reg->ReadString("HTMLFont"); ProgressBar->Position++; if( reg->ValueExists("HTMLFontSize") ) mainForm->mySettings.HTMLFont->Size = reg->ReadInteger("HTMLFontSize"); ProgressBar->Position++; if( reg->ValueExists("HTMLFontColor") ) mainForm->mySettings.HTMLFont->Color = StringToColor(reg->ReadString("HTMLFontColor")); ProgressBar->Position++; if( reg->ValueExists("HTMLBackColor") ) mainForm->mySettings.HTMLBack = StringToColor( reg->ReadString("HTMLBackColor") ); //Get Reader Font information ProgressBar->Position++; if( reg->ValueExists("ReaderFont") ) mainForm->mySettings.ReaderFont->Name = reg->ReadString("ReaderFont"); ProgressBar->Position++; if( reg->ValueExists("ReaderFontSize") ) mainForm->mySettings.ReaderFont->Size = reg->ReadInteger("ReaderFontSize"); ProgressBar->Position++; if( reg->ValueExists("ReaderFontColor") ) mainForm->mySettings.ReaderFont->Color = StringToColor(reg->ReadString("ReaderFontColor")); //Set Reader font mainForm->memBook->Font = mainForm->mySettings.ReaderFont; //Get and Set Reader Back color ProgressBar->Position++; if( reg->ValueExists("ReaderBackColor") ) mainForm->mySettings.ReaderBack = StringToColor( reg->ReadString("ReaderBackColor") ); mainForm->memBook->Color = mainForm->mySettings.ReaderBack; ProgressBar->Position++; if( reg->ValueExists("HTMLLpp") ) mainForm->mySettings.HTMLLpp = reg->ReadInteger("HTMLLpp"); ProgressBar->Position++; if( reg->ValueExists("ReaderLpp") ) mainForm->mySettings.ReaderLpp = reg->ReadInteger("ReaderLpp"); if( reg->ValueExists("StripHeader") ) mainForm->mySettings.StripHeader = reg->ReadBool("StripHeader"); }// end of If was able to open key } __finally { delete reg; } }
inline void myFromString(const std::string& text, Gdiplus::Color& value) { value = StringToColor(text); }
void OGBallConfig::CreateCosmeticAttributes_(WOGBall* ball) { ball->attribute.cosmetic.blinkcolor = StringToColor(rootElement.attribute("blinkcolor")); }