[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

[XaraXtreme-commits] Commit Complete



Commit by  : alex
Repository : xara
Revision   : 1021
Date       : Fri May 12 13:36:34 BST 2006

Changed paths:
   M /Trunk/XaraLX/wxOil/camresource.cpp
   M /Trunk/XaraLX/wxXtra/combo.cpp
   M /Trunk/XaraLX/wxXtra/combo.h
   M /Trunk/XaraLX/wxXtra/combog.cpp
   M /Trunk/XaraLX/wxXtra/combog.h

More wxODComboBox work


Diff:
Index: Trunk/XaraLX/wxXtra/combo.cpp
===================================================================
--- Trunk/XaraLX/wxXtra/combo.cpp	(revision 1020)
+++ Trunk/XaraLX/wxXtra/combo.cpp	(revision 1021)
@@ -25,9 +25,10 @@
 #include <wx/wx.h>
 
 #include "combo.h"
-#if wxWXXTRA_COMBOCONTROL
+#if wxXTRA_COMBOCONTROL
 
 #include <wx/renderer.h>
+#include <wx/tooltip.h>
 
 // constants
 // ----------------------------------------------------------------------------
@@ -1178,12 +1179,13 @@
                 dc.SetBrush(bgCol);
                 dc.DrawRectangle(rect);
             }
-
+#if 0
+// Not available on 2.6 - Help!
             wxRendererNative::Get().DrawPushButton(this,
                                                    dc,
                                                    drawRect,
                                                    drawState);
-
+#endif
         }
         else
 
Index: Trunk/XaraLX/wxXtra/combo.h
===================================================================
--- Trunk/XaraLX/wxXtra/combo.h	(revision 1020)
+++ Trunk/XaraLX/wxXtra/combo.h	(revision 1021)
@@ -48,7 +48,6 @@
 #else
 #define wxXTRA_COMBOCONTROL 1
 
-
 class WXDLLEXPORT wxComboPopup;
 
 //
@@ -197,6 +196,7 @@
     virtual void Replace(long from, long to, const wxString& value);
     virtual void Remove(long from, long to);
     virtual void SetSelection(long from, long to);
+    virtual void SetSelection(long sel) {SetSelection(sel, sel);}
     virtual void Undo();
 
     //
Index: Trunk/XaraLX/wxXtra/combog.cpp
===================================================================
--- Trunk/XaraLX/wxXtra/combog.cpp	(revision 1020)
+++ Trunk/XaraLX/wxXtra/combog.cpp	(revision 1021)
@@ -350,6 +350,97 @@
 IMPLEMENT_DYNAMIC_CLASS(wxComboControl, wxGenericComboControl)
 #endif
 
+#ifdef WXXTRA_COMBO_XML_HANDLERS
+IMPLEMENT_DYNAMIC_CLASS(wxComboControlXmlHandler, wxXmlResourceHandler)
+
+wxComboControlXmlHandler::wxComboControlXmlHandler()
+: wxXmlResourceHandler() , m_insideBox(false)
+{
+    XRC_ADD_STYLE(wxCB_SIMPLE);
+    XRC_ADD_STYLE(wxCB_SORT);
+    XRC_ADD_STYLE(wxCB_READONLY);
+    XRC_ADD_STYLE(wxCB_DROPDOWN);
+    //        XRC_ADD_STYLE(wxODCB_STD_CONTROL_PAINT);
+    //        XRC_ADD_STYLE(wxCC_PAINTING_CONTROL);
+    XRC_ADD_STYLE(wxCC_SPECIAL_DCLICK);
+    XRC_ADD_STYLE(wxCC_ALT_KEYS);
+    XRC_ADD_STYLE(wxCC_STD_BUTTON);
+    XRC_ADD_STYLE(wxCC_BUTTON_OUTSIDE_BORDER);
+    XRC_ADD_STYLE(wxCC_POPUP_ON_MOUSE_UP);
+    XRC_ADD_STYLE(wxCC_NO_TEXT_AUTO_SELECT);
+    AddWindowStyles();
+}
+
+wxObject *wxComboControlXmlHandler::DoCreateResource()
+{
+    if( m_class == wxT("wxComboControl"))
+    {
+        // find the selection
+        long selection = GetLong( wxT("selection"), -1 );
+
+        // need to build the list of strings from children
+        m_insideBox = true;
+        CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
+        wxString *strings = (wxString *) NULL;
+        if (strList.GetCount() > 0)
+        {
+            strings = new wxString[strList.GetCount()];
+            int count = strList.GetCount();
+            for (int i = 0; i < count; i++)
+                strings[i]=strList[i];
+        }
+
+        XRC_MAKE_INSTANCE(control, wxComboControl)
+
+        control->Create(m_parentAsWindow,
+                        GetID(),
+                        GetText(wxT("value")),
+                        GetPosition(), GetSize(),
+                        /*strList.GetCount(),*/
+                        /*strings,*/
+                        GetStyle(),
+                        wxDefaultValidator,
+                        GetName());
+
+        if (selection != -1)
+            control->SetSelection(selection);
+
+        SetupWindow(control);
+
+        if (strings != NULL)
+            delete[] strings;
+        strList.Clear();    // dump the strings
+
+        return control;
+    }
+    else
+    {
+        // on the inside now.
+        // handle <item>Label</item>
+
+        // add to the list
+        wxString str = GetNodeContent(m_node);
+        if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
+            str = wxGetTranslation(str);
+        strList.Add(str);
+
+        return NULL;
+    }
+}
+
+bool wxComboControlXmlHandler::CanHandle(wxXmlNode *node)
+{
+// Avoid GCC bug
+//    return (IsOfClass(node, wxT("wxComboContro")) ||
+//           (m_insideBox && node->GetName() == wxT("item")));
+	bool fOurClass = node->GetPropVal(wxT("class"), wxEmptyString) == wxT("wxComboControl");
+    return (fOurClass ||
+           (m_insideBox && node->GetName() == wxT("item")));
+}
+
+
+#endif
+
 #endif // !wxCOMBOCONTROL_FULLY_FEATURED
 
 #endif // wxUSE_COMBOCONTROL
Index: Trunk/XaraLX/wxXtra/combog.h
===================================================================
--- Trunk/XaraLX/wxXtra/combog.h	(revision 1020)
+++ Trunk/XaraLX/wxXtra/combog.h	(revision 1021)
@@ -18,6 +18,7 @@
 #define _WXXTRA_GENERIC_COMBOCONTROL_H_
 
 #include <wx/wx.h>
+#include "wx/xrc/xmlres.h"
 
 #if wxUSE_COMBOCONTROL
 #undef wxXTRA_COMBOCONTROL
@@ -136,6 +137,20 @@
 
 #endif // _WX_COMBOCONTROL_H_
 
+#define WXXTRA_COMBO_XML_HANDLERS
+
+class WXDLLIMPEXP_XRC wxComboControlXmlHandler : public wxXmlResourceHandler
+{
+DECLARE_DYNAMIC_CLASS(wxComboControlXmlHandler)
+public:
+    wxComboControlXmlHandler();
+    virtual wxObject *DoCreateResource();
+    virtual bool CanHandle(wxXmlNode *node);
+private:
+    bool m_insideBox;
+    wxArrayString strList;
+};
+
 #else
 
 #define wxGenericComboControl   wxComboControl
Index: Trunk/XaraLX/wxOil/camresource.cpp
===================================================================
--- Trunk/XaraLX/wxOil/camresource.cpp	(revision 1020)
+++ Trunk/XaraLX/wxOil/camresource.cpp	(revision 1021)
@@ -1396,7 +1396,10 @@
 #if !defined(EXCLUDE_FROM_XARLIB)
 	wxXmlResource::Get()->AddHandler(new wxCamArtControlXmlHandler);
 	wxXmlResource::Get()->AddHandler(new wxCamDrawControlXmlHandler);
+#ifdef WXXTRA_COMBO_XML_HANDLERS
+	wxXmlResource::Get()->AddHandler(new wxComboControlXmlHandler);
 #endif
+#endif
 
 	if (!pwxFileSystem) pwxFileSystem = new wxFileSystem;
 	if (!pwxFileSystem)


Xara