📄 wxr2xml.cpp
字号:
s += _T("wxWS_EX_VALIDATE_RECURSIVELY|"); if (style & wxSTAY_ON_TOP) s += _T("wxSTAY_ON_TOP|"); if (style & wxCAPTION) s += _T("wxCAPTION|"); if (style & wxRESIZE_BORDER) s += _T("wxRESIZE_BORDER|");#if WXWIN_COMPATIBILITY_2_6 if (style & wxRESIZE_BOX) s += _T("wxRESIZE_BOX|");#endif // WXWIN_COMPATIBILITY_2_6 if (style & wxRESIZE_BORDER) s += _T("wxRESIZE_BORDER|"); if (style & wxSYSTEM_MENU) s += _T("wxSYSTEM_MENU|"); if (style & wxCLIP_CHILDREN) s += _T("wxCLIP_CHILDREN|"); } if (restype == _T("wxPanel")) { if (style & wxCLIP_CHILDREN) s += _T("wxCLIP_CHILDREN|");#if WXWIN_COMPATIBILITY_2_6 if (style & wxNO_3D) s += _T("wxNO_3D|");#endif // WXWIN_COMPATIBILITY_2_6 if (style & wxTAB_TRAVERSAL) s += _T("wxTAB_TRAVERSAL|"); if (style & wxWS_EX_VALIDATE_RECURSIVELY) s += _T("wxWS_EX_VALIDATE_RECURSIVELY|"); } if (restype == _T("wxComboBox")) { if (style & wxCB_SORT) s += _T("wxCB_SORT|"); if (style & wxCB_SIMPLE) s += _T("wxCB_SIMPLE|"); if (style & wxCB_READONLY) s += _T("wxCB_READONLY|"); if (style & wxCB_DROPDOWN) s += _T("wxCB_DROPDOWN|"); } if (restype == _T("wxGauge")) { if (style & wxGA_HORIZONTAL) s += _T("wxGA_HORIZONTAL|"); if (style & wxGA_VERTICAL) s += _T("wxGA_VERTICAL|"); // windows only if (style & wxGA_SMOOTH) s += _T("wxGA_SMOOTH|"); } if (restype == _T("wxRadioButton")) { if (style & wxRB_GROUP) s += _T("wxRB_GROUP|"); } if (restype == _T("wxStaticText")) { if (style & wxST_NO_AUTORESIZE) s += _T("wxST_NO_AUTORESIZEL|"); } if (restype == _T("wxRadioBox")) { if (style & wxRA_HORIZONTAL) s += _T("wxRA_HORIZONTAL|"); if (style & wxRA_SPECIFY_COLS) s += _T("wxRA_SPECIFY_COLS|"); if (style & wxRA_SPECIFY_ROWS) s += _T("wxRA_SPECIFY_ROWS|"); if (style & wxRA_VERTICAL) s += _T("wxRA_VERTICAL|"); } if (restype == _T("wxListBox")) { if (style & wxLB_SINGLE) s += _T("wxLB_SINGLE|"); if (style & wxLB_MULTIPLE) s += _T("wxLB_MULTIPLE|"); if (style & wxLB_EXTENDED) s += _T("wxLB_EXTENDED|"); if (style & wxLB_HSCROLL) s += _T("wxLB_HSCROLL|"); if (style & wxLB_ALWAYS_SB) s += _T("wxLB_ALWAYS_SB|"); if (style & wxLB_NEEDED_SB) s += _T("wxLB_NEEDED_SB|"); if (style & wxLB_SORT) s += _T("wxLB_SORT|"); } if (restype == _T("wxTextCtrl")) { if (style & wxTE_PROCESS_ENTER) s += _T("wxTE_PROCESS_ENTER|"); if (style & wxTE_PROCESS_TAB) s += _T("wxTE_PROCESS_TAB|"); if (style & wxTE_MULTILINE) s += _T("wxTE_MULTILINE|"); if (style & wxTE_PASSWORD) s += _T("wxTE_PASSWORD|"); if (style & wxTE_READONLY) s += _T("wxTE_READONLY|"); if (style & wxHSCROLL) s += _T("wxHSCROLL|"); } if (restype == _T("wxScrollBar")) { if (style & wxSB_HORIZONTAL) s += _T("wxSB_HORIZONTAL|"); if (style & wxSB_VERTICAL) s += _T("wxSB_VERTICAL|"); } int l = s.length(); // No styles defined if (l == 11) return wxEmptyString; // Trim off last | s = s.Truncate(l - 1); s += _T("</style>\n"); return s;}wxString wxr2xml::GetDimension(wxItemResource * res){ wxString msg; msg << _T("\t\t\t\t<dimension>") << res->GetValue1() << _T("</dimension>\n"); return msg;}wxString wxr2xml::GenerateName(wxItemResource * res){ wxString name; name = _T(" name=\""); switch (res->GetId()) { case wxID_OK: name += _T("wxID_OK"); break; case wxID_CANCEL: name += _T("wxID_CANCEL"); break; default: name += res->GetName(); } name += _T("\""); return name;}void wxr2xml::ParseMenuBar(wxItemResource * res){ wxItemResource *child; wxNode *node = res->GetChildren().GetFirst(); // Get Menu Bar Name m_xmlfile.Write(_T("\t<object class=\"wxMenuBar\" ")); m_xmlfile.Write(GenerateName(res)); m_xmlfile.Write(_T(">\n")); while (node) { child = (wxItemResource *) node->GetData(); ParseMenu(child); node = node->GetNext(); } m_xmlfile.Write(_T("\t</object> \n\n"));}void wxr2xml::ParseMenu(wxItemResource * res){ wxItemResource *child; wxNode *node = res->GetChildren().GetFirst(); // Get Menu m_xmlfile.Write(_T("\t\t\t<object class=\"wxMenu\" ")); wxString menuname; menuname << _T("name = \"menu_") << res->GetValue1() << _T("\""); m_xmlfile.Write(menuname); m_xmlfile.Write(_T(">\n")); m_xmlfile.Write(_T("\t\t\t\t<label>") + FixMenuString(res->GetTitle()) + _T("</label>\n")); if (!res->GetValue4().empty()) m_xmlfile.Write(_T("\t\t\t\t<help>") + res->GetValue4() + _T("</help>\n")); // Read in menu items and additional menus while (node) { child = (wxItemResource *) node->GetData(); if (!child->GetChildren().GetFirst()) ParseMenuItem(child); else ParseMenu(child); node = node->GetNext(); } m_xmlfile.Write(_T("\t\t\t</object> \n"));}void wxr2xml::ParseMenuItem(wxItemResource * res){ // Get Menu Item or Separator if (res->GetTitle().empty()) { m_xmlfile.Write(_T("\t\t\t<object class=\"separator\"/>\n")); } else { m_xmlfile.Write(_T("\t\t\t\t<object class=\"wxMenuItem\" ")); wxString menuname; menuname << _T("name = \"menuitem_") << res->GetValue1() << _T("\""); m_xmlfile.Write(menuname); m_xmlfile.Write(_T(">\n")); m_xmlfile.Write(_T("\t\t\t<label>") + FixMenuString(res->GetTitle()) + _T("</label>\n")); if (!res->GetValue4().empty()) m_xmlfile.Write(_T("\t\t\t<help>") + res->GetValue4() + _T("</help>\n")); if (res->GetValue2()) m_xmlfile.Write(_T("\t\t\t\t<checkable>1</checkable>\n")); m_xmlfile.Write(_T("\t\t\t</object> \n")); }}wxString wxr2xml::FixMenuString(wxString phrase){ phrase.Replace(_T("&"), _T("$")); return phrase;}void wxr2xml::ParseStaticBitmap(wxItemResource * res){ m_xmlfile.Write(_T("\t\t\t<object class=\"wxStaticBitmap\"")); WriteControlInfo(res); // value4 holds bitmap name wxString bitmapname; bitmapname = res->GetValue4(); wxBitmap bitmap; bitmap = wxResourceCreateBitmap(bitmapname, &m_table); bitmapname += _T(".bmp"); bitmap.SaveFile(bitmapname, wxBITMAP_TYPE_BMP); m_xmlfile.Write(_T("\n\t\t\t\t<bitmap>") + bitmapname + _T("</bitmap>")); m_xmlfile.Write(_T("\t\t\t</object>\n")); // bitmap5}//Parse a bitmap resourcevoid wxr2xml::ParseBitmap(wxItemResource * res){ m_xmlfile.Write(_T("\t<object class=\"wxBitmap\" ")); m_xmlfile.Write(GenerateName(res)+_T(">")); wxString bitmapname; bitmapname = res->GetName(); wxBitmap bitmap; bitmap = wxResourceCreateBitmap(bitmapname, &m_table); bitmapname += _T(".bmp"); bitmap.SaveFile(bitmapname, wxBITMAP_TYPE_BMP); m_xmlfile.Write(bitmapname); m_xmlfile.Write(_T("</object>\n\n"));}void wxr2xml::PanelStuff(wxItemResource * res){ if ((res->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0) m_dlgunits = true; else m_dlgunits = false; // If this is true ignore fonts, background color and use system // defaults instead if ((res->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) != 0) m_systemdefaults = true; else m_systemdefaults = false;}wxString wxr2xml::GetValue2(wxItemResource *res){ wxString msg; msg << res->GetValue2(); return msg;}wxString wxr2xml::GetValue3(wxItemResource *res){ wxString msg; msg << res->GetValue3(); return msg;}wxString wxr2xml::GetValue5(wxItemResource *res){ wxString msg; msg << res->GetValue5(); return msg;}void wxr2xml::ParseBitmapButton(wxItemResource *res){ m_xmlfile.Write(_T("\t\t\t<object class=\"wxBitmapButton\"")); WriteControlInfo(res); // value4 holds bitmap name wxString bitmapname; bitmapname = res->GetValue4(); wxBitmap bitmap; bitmap = wxResourceCreateBitmap(bitmapname, &m_table); bitmapname += _T(".bmp"); bitmap.SaveFile(bitmapname, wxBITMAP_TYPE_BMP); m_xmlfile.Write(_T("\t\t\t\t<bitmap>") + bitmapname + _T("</bitmap>\n")); m_xmlfile.Write(_T("\t\t\t</object>\n"));}void wxr2xml::WriteFontInfo(wxItemResource *res){//if systems_defaults true just ignore the fonts if (m_systemdefaults) return; wxFont font; font=res->GetFont(); if (!font.GetRefData()) return; m_xmlfile.Write(_T("\t\t\t<font>\n")); //Get font point size,font family,weight,font style,underline int pt; wxString msg; pt=font.GetPointSize(); msg<<_T("\t\t\t\t<size>")<<pt<<_T("</size>\n"); m_xmlfile.Write(msg); GetFontFace(font); GetFontStyle(font); GetFontWeight(font); if (font.GetUnderlined()) m_xmlfile.Write(_T("\t\t\t\t<underlined>1</underlined>\n")); m_xmlfile.Write(_T("\t\t\t</font>\n"));}//WARNING possible make here//I wasn't really sure the right way to do this.void wxr2xml::GetFontFace(wxFont font){ int family=font.GetFamily(); switch (family) { case wxDEFAULT: break; case wxDECORATIVE: m_xmlfile.Write(_T("\t\t\t\t<face>decorative</face>\n")); break; case wxROMAN: m_xmlfile.Write(_T("\t\t\t\t<face>roman</face>\n")); break; case wxSCRIPT: m_xmlfile.Write(_T("\t\t\t\t<face>script</face>\n")); break; case wxSWISS: m_xmlfile.Write(_T("\t\t\t\t<face>swiss</face>\n")); break; case wxMODERN: m_xmlfile.Write(_T("\t\t\t\t<face>modern</face>\n")); break; default: wxLogError(_T("Unknown font face")); }}void wxr2xml::GetFontStyle(wxFont font){ int style=font.GetStyle(); switch (style) {//since this is default no point in making file any larger case wxNORMAL: break; case wxITALIC: m_xmlfile.Write(_T("<style>italic</style>\n")); break; case wxSLANT: m_xmlfile.Write(_T("<style>slant</style>\n")); break; default: wxLogError(_T("Unknown font style")); }}void wxr2xml::GetFontWeight(wxFont font){ int weight=font.GetWeight(); switch (weight) {//since this is default no point in making file any larger case wxNORMAL: break; case wxLIGHT: m_xmlfile.Write(_T("\t\t\t\t<weight>light</weight>\n")); break; case wxBOLD: m_xmlfile.Write(_T("\t\t\t\t<weight>bold</weight>\n")); break; default: wxLogError(_T("Unknown font weight")); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -