From 6267a331cbe2b7191d455a6b6f755eaf2f45600e Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sat, 21 Dec 2002 00:20:35 +0000 Subject: [PATCH] 1) added wxFrame support to wxrcedit 2) fixes to wxrcedit so that generated files are compatible with new XRC (both in patch #648659) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18379 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/utils/wxrcedit/Makefile.in | 2 +- contrib/utils/wxrcedit/df/wxFrame.df | 8 ++++++ contrib/utils/wxrcedit/editor.cpp | 11 +++++++- contrib/utils/wxrcedit/pe_adv.cpp | 1 + contrib/utils/wxrcedit/preview.cpp | 40 ++++++++++++++++++++++++++-- contrib/utils/wxrcedit/preview.h | 1 + contrib/utils/wxrcedit/propframe.cpp | 22 +++++++++++---- 7 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 contrib/utils/wxrcedit/df/wxFrame.df diff --git a/contrib/utils/wxrcedit/Makefile.in b/contrib/utils/wxrcedit/Makefile.in index 7fef156197..d23876ba04 100644 --- a/contrib/utils/wxrcedit/Makefile.in +++ b/contrib/utils/wxrcedit/Makefile.in @@ -23,7 +23,7 @@ DATAFILES = df/break.df df/control.df df/menu_item.df df/notebookpage.df \ df/wxSlider.df df/wxSpinButton.df df/wxSpinCtrl.df \ df/wxStaticBitmap.df df/wxStaticBox.df df/wxStaticBoxSizer.df \ df/wxStaticLine.df df/wxStaticText.df df/wxTextCtrl.df \ - df/wxToolBar.df df/wxTreeCtrl.df + df/wxToolBar.df df/wxTreeCtrl.df df/wxFrame.df APPEXTRALIBS=$(top_builddir)/lib/lib@WX_LIBRARY_BASENAME@_xrc-@WX_RELEASE@.@WX_TARGET_LIBRARY_TYPE@ APPEXTRADEFS=-I$(top_srcdir)/contrib/include diff --git a/contrib/utils/wxrcedit/df/wxFrame.df b/contrib/utils/wxrcedit/df/wxFrame.df new file mode 100644 index 0000000000..6b6c30e363 --- /dev/null +++ b/contrib/utils/wxrcedit/df/wxFrame.df @@ -0,0 +1,8 @@ +node wxFrame +type panel +icon 1 +var title of text +var style of flags wxSTAY_ON_TOP,wxCAPTION,wxDEFAULT_FRAME_STYLE,wxSYSTEM_MENU,wxRESIZE_BORDER,wxICONIZE,wxMINIMIZE,wxMINIMIZE_BOX,wxMAXIMIZE,wxMAXIMIZE_BOX,wxSIMPLE_BORDER,wxFRAME_TOOL_WINDOW,wxFRAME_NO_TASKBAR,wxFRAME_FLOAT_ON_PARENT +var exstyle of flags wxFRAME_EX_CONTEXTHELP +var centered of bool +derived from panelbase diff --git a/contrib/utils/wxrcedit/editor.cpp b/contrib/utils/wxrcedit/editor.cpp index a84cc5f336..8b5a75951c 100644 --- a/contrib/utils/wxrcedit/editor.cpp +++ b/contrib/utils/wxrcedit/editor.cpp @@ -92,7 +92,7 @@ void wxXmlRcEditDocument::Upgrade() UpgradeNode(node); } node->DeleteProperty(wxT("version")); - node->AddProperty(wxT("version"), wxT(WX_XMLRES_CURRENT_VERSION_STRING)); + node->AddProperty(wxT("version"), WX_XMLRES_CURRENT_VERSION_STRING); } @@ -141,6 +141,7 @@ enum ID_COPY, ID_NEWDIALOG, + ID_NEWFRAME, ID_NEWPANEL, ID_NEWMENU, ID_NEWMENUBAR, @@ -341,7 +342,12 @@ void EditorFrame::NewFile() m_FileName = ""; m_Resource = new wxXmlRcEditDocument; m_Resource->SetRoot(new wxXmlNode(wxXML_ELEMENT_NODE, _("resource"))); + + m_Resource->SetFileEncoding("utf-8"); + m_Resource->GetRoot()->AddProperty(_T("version"), + WX_XMLRES_CURRENT_VERSION_STRING); + m_Modified = FALSE; RefreshTree(); RefreshTitle(); @@ -366,6 +372,7 @@ void EditorFrame::RefreshTree() wxXmlNode *sel = m_SelectedNode; m_TreeCtrl->DeleteAllItems(); + wxTreeItemId root = m_TreeCtrl->AddRoot("Resource: " + wxFileNameFromPath(m_FileName), 5, 5); wxXmlNode *n = m_Resource->GetRoot()->GetChildren(); @@ -613,6 +620,7 @@ void EditorFrame::OnNewNode(wxCommandEvent& event) switch (event.GetId()) { case ID_NEWDIALOG : name = _T("wxDialog"); break; + case ID_NEWFRAME : name = _T("wxFrame"); break; case ID_NEWPANEL : name = _T("wxPanel"); break; case ID_NEWMENU : name = _T("wxMenu"); break; case ID_NEWMENUBAR : name = _T("wxMenuBar"); break; @@ -637,6 +645,7 @@ void EditorFrame::OnRightClickTree(wxPoint pos) if (m_SelectedNode == NULL || m_SelectedNode == m_Resource->GetRoot()) { popup->Append(ID_NEWDIALOG, _("New wxDialog")); + popup->Append(ID_NEWFRAME, _("New wxFrame")); popup->Append(ID_NEWPANEL, _("New wxPanel")); popup->Append(ID_NEWMENU, _("New wxMenu")); popup->Append(ID_NEWMENUBAR, _("New wxMenuBar")); diff --git a/contrib/utils/wxrcedit/pe_adv.cpp b/contrib/utils/wxrcedit/pe_adv.cpp index 7d9c16777d..e4e45dfc81 100644 --- a/contrib/utils/wxrcedit/pe_adv.cpp +++ b/contrib/utils/wxrcedit/pe_adv.cpp @@ -118,6 +118,7 @@ void PropEditCtrlColor::OnDetails() clr = wxColour((tmp & 0xFF0000) >> 16, (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF)); + clr = wxGetColourFromUser(NULL, clr); if (clr.Ok()) { diff --git a/contrib/utils/wxrcedit/preview.cpp b/contrib/utils/wxrcedit/preview.cpp index a7ffa2eacd..b939a4314e 100644 --- a/contrib/utils/wxrcedit/preview.cpp +++ b/contrib/utils/wxrcedit/preview.cpp @@ -157,6 +157,9 @@ void PreviewFrame::Preview(wxXmlNode *node, wxXmlDocument *orig_doc) if (XmlGetClass(doc.GetRoot()->GetChildren()) == _T("wxDialog")) XmlSetClass(doc.GetRoot()->GetChildren(), _T("wxPanel")); + if (XmlGetClass(doc.GetRoot()->GetChildren()) == _T("wxFrame")) + XmlSetClass(doc.GetRoot()->GetChildren(), _T("wxPanel")); + doc.Save(m_TmpFile); // wxXmlResource will detect change automatically } @@ -186,7 +189,9 @@ void PreviewFrame::Preview(wxXmlNode *node, wxXmlDocument *orig_doc) PreviewToolbar(); else if (XmlGetClass(node) == _T("wxPanel") || XmlGetClass(node) == _T("wxDialog")) PreviewPanel(); - + else if (XmlGetClass(node) == _T("wxFrame")) + PreviewWXFrame(); + wxSetWorkingDirectory(oldcwd); wxLog::SetActiveTarget(oldlog); @@ -223,7 +228,7 @@ void PreviewFrame::PreviewToolbar() void PreviewFrame::PreviewPanel() { wxPanel *panel = m_RC->LoadPanel(m_ScrollWin, m_Node->GetPropVal(_T("name"), _T("-1"))); - + if (panel == NULL) wxLogError(_("Cannot preview the panel -- XML resource corrupted.")); else @@ -233,6 +238,37 @@ void PreviewFrame::PreviewPanel() } } +void PreviewFrame::PreviewWXFrame() +{ + //for this to work the frame MUST have a child panel! + + wxXmlNode* child = m_Node; + wxString name; + + while( child != NULL) + { + name = child->GetPropVal(_T("name"), _T("-1")); + + if(name != _T("-1")) + { + wxXmlNode* parent = child->GetParent(); + if(parent->GetPropVal(_T("class"),_T("-1")) == _T("wxPanel")) + break; + } + child = child->GetNext(); + } + + wxPanel *panel = m_RC->LoadPanel(m_ScrollWin, name); + + if (panel == NULL) + wxLogError(_("Cannot preview the panel -- XML resource corrupted.")); + else + { + m_ScrollWin->SetScrollbars(1, 1, panel->GetSize().x, panel->GetSize().y, + 0, 0, TRUE); + } + +} BEGIN_EVENT_TABLE(PreviewFrame, wxFrame) EVT_ENTER_WINDOW(PreviewFrame::OnMouseEnter) diff --git a/contrib/utils/wxrcedit/preview.h b/contrib/utils/wxrcedit/preview.h index 50b690a9df..e9e558a833 100644 --- a/contrib/utils/wxrcedit/preview.h +++ b/contrib/utils/wxrcedit/preview.h @@ -43,6 +43,7 @@ class PreviewFrame : public wxFrame void PreviewMenu(); void PreviewToolbar(); void PreviewPanel(); + void PreviewWXFrame(); private: static PreviewFrame *ms_Instance; diff --git a/contrib/utils/wxrcedit/propframe.cpp b/contrib/utils/wxrcedit/propframe.cpp index 35022bd126..ce33f21d68 100644 --- a/contrib/utils/wxrcedit/propframe.cpp +++ b/contrib/utils/wxrcedit/propframe.cpp @@ -38,7 +38,18 @@ class PropsTree: public wxRemotelyScrolledTreeCtrl PropsTree(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition, const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS) : wxRemotelyScrolledTreeCtrl(parent, id, pt, sz, style), - m_EditCtrl(NULL) {} + m_EditCtrl(NULL) + { +#if 0 + // VS: Don't do it, it is *extremely* ugly. + // FIXME: find a better solution. + + //make text larger so controls will fit properly + wxFont font = GetFont(); + font.SetPointSize(font.GetPointSize()*1.5); + SetFont(font); +#endif + } void OnPaint(wxPaintEvent& event) { @@ -50,8 +61,8 @@ class PropsTree: public wxRemotelyScrolledTreeCtrl dc.SetDeviceOrigin(0, 0); wxPen pen(wxColour(_T("BLACK")), 1, wxSOLID); - dc.SetPen(pen); - + dc.SetPen(pen); + dc.SetBrush(* wxTRANSPARENT_BRUSH); wxSize clientSize = GetClientSize(); @@ -63,6 +74,7 @@ class PropsTree: public wxRemotelyScrolledTreeCtrl if (h.IsOk() && GetBoundingRect(h, itemRect)) { cy = itemRect.GetTop(); + dc.DrawLine(0, cy, clientSize.x, cy); lastH = h; } @@ -73,7 +85,7 @@ class PropsTree: public wxRemotelyScrolledTreeCtrl dc.DrawLine(0, cy, clientSize.x, cy); } } - + void OnSelChange(wxTreeEvent& event) { if (m_EditCtrl != NULL) @@ -88,6 +100,7 @@ class PropsTree: public wxRemotelyScrolledTreeCtrl { wxRect bounding; GetBoundingRect(item, bounding); + bounding.SetX(0); bounding.SetWidth(GetCompanionWindow()->GetSize().x); dt->EditCtrl->BeginEdit(bounding, item); @@ -168,7 +181,6 @@ class PropsValueWindow: public wxTreeCompanionWindow wxTreeItemId item = GetTreeCtrl()->HitTest(wxPoint(1, event.GetY()), flags); if (item.IsOk()) { - GetTreeCtrl()->ScrollTo(item); GetTreeCtrl()->SelectItem(item); } } -- 2.45.2