]> git.saurik.com Git - wxWidgets.git/commitdiff
1) added wxFrame support to wxrcedit
authorVáclav Slavík <vslavik@fastmail.fm>
Sat, 21 Dec 2002 00:20:35 +0000 (00:20 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Sat, 21 Dec 2002 00:20:35 +0000 (00:20 +0000)
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
contrib/utils/wxrcedit/df/wxFrame.df [new file with mode: 0644]
contrib/utils/wxrcedit/editor.cpp
contrib/utils/wxrcedit/pe_adv.cpp
contrib/utils/wxrcedit/preview.cpp
contrib/utils/wxrcedit/preview.h
contrib/utils/wxrcedit/propframe.cpp

index 7fef1561975680568f46101f10683e9d5c40c40b..d23876ba045e3b772ee37c2ecc241c122d20d893 100644 (file)
@@ -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 (file)
index 0000000..6b6c30e
--- /dev/null
@@ -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
index a84cc5f3369bbb76c691f41cf24f08c56f71f1c1..8b5a75951c3db678adf25f35e7e6284244fb6e59 100644 (file)
@@ -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"));
index 7d9c16777d27ed11698378bb9aa6f66b1a85722b..e4e45dfc810aa88f9e4cae3f2d51486a252cdf25 100644 (file)
@@ -118,6 +118,7 @@ void PropEditCtrlColor::OnDetails()
         clr = wxColour((tmp & 0xFF0000) >> 16, 
                        (tmp & 0x00FF00) >> 8, 
                        (tmp & 0x0000FF));
+
     clr = wxGetColourFromUser(NULL, clr);
     if (clr.Ok())
     {
index a7ffa2eacdc3c5f16e47fe3a2ea429edf98768a3..b939a4314eef5ba340589d3c3ece515ab508ba13 100644 (file)
@@ -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)
index 50b690a9df6d5544e6b6c0dd5aae55a5b26e57fd..e9e558a8337f6618f63958ef17616801bafe004d 100644 (file)
@@ -43,6 +43,7 @@ class PreviewFrame : public wxFrame
         void PreviewMenu();
         void PreviewToolbar();
         void PreviewPanel();
+               void PreviewWXFrame();
     
     private:
         static PreviewFrame *ms_Instance;
index 35022bd1267579179f2f528f4e10d76ea0a9e461..ce33f21d681b7ee9be9a8af7ed8d9ae0126fa013 100644 (file)
@@ -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);
             }
         }