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

[XaraXtreme-commits] Commit Complete



Commit by  : alex
Repository : xara
Revision   : 1504
Date       : Mon Jul 24 13:33:42 BST 2006

Changed paths:
   M /Trunk/XaraLX/wxOil/camresource.cpp
   M /Trunk/XaraLX/wxXtra/Makefile.am
   A /Trunk/XaraLX/wxXtra/slidercombo.cpp
   A /Trunk/XaraLX/wxXtra/slidercombo.h
   M /Trunk/XaraLX/wxXtra/wxXtra.h
   A /Trunk/XaraLX/wxXtra/xh_slidrcombo.cpp
   A /Trunk/XaraLX/wxXtra/xh_slidrcombo.h

Initial checking of Mart Raudsepp's pop-up slider code. It compiles, and doesn't crash the rest of the application, but is as yet untested.


Diff:
Index: Trunk/XaraLX/wxXtra/wxXtra.h
===================================================================
--- Trunk/XaraLX/wxXtra/wxXtra.h	(revision 1503)
+++ Trunk/XaraLX/wxXtra/wxXtra.h	(revision 1504)
@@ -19,3 +19,5 @@
 #include "advsplash.h"
 #include "treebook.h"
 #include "xh_treebk.h"
+#include "slidercombo.h"
+#include "xh_slidrcombo.h"
Index: Trunk/XaraLX/wxXtra/slidercombo.h
===================================================================
--- Trunk/XaraLX/wxXtra/slidercombo.h	(revision 0)
+++ Trunk/XaraLX/wxXtra/slidercombo.h	(revision 1504)
@@ -0,0 +1,89 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        slidercombo.h
+// Purpose:     A pop-up slider combo control
+// Author:      Mart Raudsepp
+// Modified by:
+// Created:     2006-07-05
+// RCS-ID:      $Id: $
+// Copyright:   (c) 2006 Mart Raudsepp
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WXXTRA_SLIDERCOMBO_H_
+#define _WXXTRA_SLIDERCOMBO_H_
+
+#include <wx/defs.h>
+
+#if wxUSE_COMBOCTRL
+#include <wx/combo.h>
+#else
+#include "combo.h"
+#endif
+
+#include <wx/string.h>
+
+class wxSlider;
+
+class WXDLLIMPEXP_ADV wxSliderCombo : public wxComboCtrl
+{
+public:
+
+    wxSliderCombo() { Init(); }
+
+    wxSliderCombo(wxWindow *parent,
+                  wxWindowID id = wxID_ANY,
+                  int value = 0,
+                  const wxPoint& pos = wxDefaultPosition,
+                  const wxSize& size = wxDefaultSize,
+                  long style = 0,
+                  const wxString& name = wxT("wxSliderComboBox"));
+
+    bool Create(wxWindow *parent,
+                wxWindowID id = wxID_ANY,
+                int value = 0,
+                const wxPoint& pos = wxDefaultPosition,
+                const wxSize& size = wxDefaultSize,
+                long style = 0,
+                const wxString& name = wxT("wxSliderComboBox"));
+
+    virtual ~wxSliderCombo();
+
+    // Suffix to automatically use after the integer value, e.g _("pix")
+    // Used if SetAutomaticUpdates(false) hasn't been called.
+    wxString GetValueSuffix() const;
+    void SetValueSuffix(wxString& suffix);
+
+    // Changes if the updates are done automatically (based on value and the
+    // given prefix) or left for the user to do on EVT_SCROLL. Default is TRUE.
+    bool GetAutomaticUpdates() const;
+    void SetAutomaticUpdates(bool);
+
+    // From wxSlider whatever is necessary... Events are the most important here
+    int GetSliderValue() const;
+    void SetSliderValue(int value);
+
+    // How much do we increase/decrease with page up/down?
+    int GetPageSize() const;
+    void SetPageSize(int pageSize);
+
+    // Default without having called this is 0..100
+    void SetRange(int minValue, int maxValue);
+
+    // Do we need floating point support? In this case this could be used to
+    // select it (and add some other floating point methods)
+    /* void SetRange(double minValue, double maxValue); */
+    // or the alternative (discussed in the end) with a better name:
+    /* void SetMappingConstant(double display_map_value); */
+
+protected:
+    wxSlider* m_slider;
+    wxString m_suffix;
+    bool m_automatic_updates;
+
+private:
+    void Init();
+
+    DECLARE_DYNAMIC_CLASS(wxSliderCombo)
+};
+
+#endif //_WX_SLIDERCOMBO_H_
Index: Trunk/XaraLX/wxXtra/xh_slidrcombo.h
===================================================================
--- Trunk/XaraLX/wxXtra/xh_slidrcombo.h	(revision 0)
+++ Trunk/XaraLX/wxXtra/xh_slidrcombo.h	(revision 1504)
@@ -0,0 +1,29 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        wx/xrc/xh_odcombo.h
+// Purpose:     XML resource handler for wxOwnerDrawnComboBox
+// Author:      Alex Bligh - based on wx/xrc/xh_combo.h
+// Created:     2006/06/19
+// RCS-ID:      $Id: xh_odcombo.h,v 1.1 2006/06/20 12:26:05 ABX Exp $
+// Copyright:   (c) 2006 Alex Bligh
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_XH_SLIDERCOMBO_H_
+#define _WX_XH_SLIDERCOMBO_H_
+
+#include <wx/xrc/xmlres.h>
+
+//#if wxUSE_SLIDERCOMBO
+
+class WXDLLIMPEXP_XRC wxSliderComboXmlHandler : public wxXmlResourceHandler
+{
+DECLARE_DYNAMIC_CLASS(wxSliderComboBoxHandler)
+public:
+    wxSliderComboXmlHandler();
+    virtual wxObject *DoCreateResource();
+    virtual bool CanHandle(wxXmlNode *node);
+};
+
+//#endif
+
+#endif // _WX_XH_SLIDERCOMBO_H_
Index: Trunk/XaraLX/wxXtra/slidercombo.cpp
===================================================================
--- Trunk/XaraLX/wxXtra/slidercombo.cpp	(revision 0)
+++ Trunk/XaraLX/wxXtra/slidercombo.cpp	(revision 1504)
@@ -0,0 +1,160 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        slidercombo.cpp
+// Purpose:     A pop-up slider combo control
+// Author:      Mart Raudsepp
+// Modified by:
+// Created:     2006-07-06
+// RCS-ID:      $Id: $
+// Copyright:   (c) 2006 Mart Raudsepp
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#include "slidercombo.h"
+
+#include <wx/slider.h>
+#ifdef __WXGTK20__
+#include <gtk/gtk.h>
+#endif
+
+class wxSliderComboPopup : public wxSlider, public wxComboPopup
+{
+public:
+
+    virtual void Init()
+    {
+    }
+
+    virtual bool Create( wxWindow* parent )
+    {
+        long style = m_combo->GetWindowStyleFlag();
+        style &= wxSL_HORIZONTAL | wxSL_VERTICAL | wxSL_LABELS | wxSL_INVERSE;
+        return wxSlider::Create(parent, wxID_ANY,
+                                50, 0, 100,
+                                wxDefaultPosition, wxDefaultSize,
+                                style | wxRAISED_BORDER);
+    }
+
+    virtual void OnShow()
+    {
+    }
+
+    virtual wxSize GetAdjustedSize( int minWidth,
+                                    int WXUNUSED(prefHeight),
+                                    int maxHeight )
+    {
+        wxSize sz = GetBestSize();
+        return wxSize(wxMax(120, minWidth), wxMin(sz.GetHeight(), maxHeight));
+    }
+
+    virtual wxWindow *GetControl() { return this; }
+
+    virtual void SetStringValue( const wxString& s )
+    {
+    }
+
+    virtual wxString GetStringValue() const
+    {
+    // FIXME: Does this get called in wxGTK? On wxMSW this gets called on popup close
+        return wxT("asdf");
+    }
+
+protected:
+    void OnSliderScrollEvent(wxScrollEvent& event)
+    {
+        wxScrollEvent ev( event.GetEventType(),
+                          m_combo->GetId(),
+                          event.GetPosition(),
+                          event.GetOrientation() );
+        ev.SetEventObject( m_combo );
+        m_combo->GetEventHandler()->ProcessEvent( ev );
+    }
+
+private:
+    DECLARE_EVENT_TABLE()
+};
+
+BEGIN_EVENT_TABLE(wxSliderComboPopup, wxSlider)
+    EVT_SCROLL(wxSliderComboPopup::OnSliderScrollEvent)
+END_EVENT_TABLE()
+
+
+IMPLEMENT_DYNAMIC_CLASS(wxSliderCombo, wxComboCtrl)
+
+void wxSliderCombo::Init()
+{
+    m_slider = NULL;
+    m_suffix = wxEmptyString;
+    m_automatic_updates = true;
+}
+
+wxSliderCombo::wxSliderCombo(wxWindow *parent, wxWindowID id, int value,
+                             const wxPoint& pos, const wxSize& size,
+                             long style, const wxString& name)
+// FIXME: initial string and validator should maybe be in our ctor too?
+    : wxComboCtrl(parent, id, wxEmptyString, pos, size, style, wxDefaultValidator, name)
+{
+    Init();
+    Create(parent, id, value, pos, size, style, name);
+}
+
+bool wxSliderCombo::Create(wxWindow *parent, wxWindowID id,
+                           int value,
+                           const wxPoint& pos, const wxSize& size,
+                           long style, const wxString& name)
+{
+    wxSliderComboPopup* sliderpopup = new wxSliderComboPopup();
+    m_slider = sliderpopup;
+    SetPopupControl(sliderpopup);
+    m_slider->SetValue(value);
+    return true;
+}
+
+wxSliderCombo::~wxSliderCombo()
+{
+}
+
+wxString wxSliderCombo::GetValueSuffix() const
+{
+    return m_suffix;
+}
+
+void wxSliderCombo::SetValueSuffix(wxString& suffix)
+{
+    m_suffix = suffix;
+}
+
+bool wxSliderCombo::GetAutomaticUpdates() const
+{
+    return m_automatic_updates;
+}
+
+void wxSliderCombo::SetAutomaticUpdates(bool automatic_updates)
+{
+    m_automatic_updates = automatic_updates;
+}
+
+int wxSliderCombo::GetSliderValue() const
+{
+    return m_slider->GetValue();
+}
+
+void wxSliderCombo::SetSliderValue(int value)
+{
+    m_slider->SetValue(value);
+}
+
+int wxSliderCombo::GetPageSize() const
+{
+    return m_slider->GetPageSize();
+}
+
+void wxSliderCombo::SetPageSize(int pageSize)
+{
+    m_slider->SetPageSize(pageSize);
+}
+
+void wxSliderCombo::SetRange(int minValue, int maxValue)
+{
+    m_slider->SetRange(minValue, maxValue);
+    // FIXME: Perhaps need to sync with text control
+}
Index: Trunk/XaraLX/wxXtra/Makefile.am
===================================================================
--- Trunk/XaraLX/wxXtra/Makefile.am	(revision 1503)
+++ Trunk/XaraLX/wxXtra/Makefile.am	(revision 1504)
@@ -9,7 +9,7 @@
 libwxXtra_a_SOURCES = \
 	framemanager.cpp floatpane.cpp dockart.cpp \
 	doublebuffer.cpp cwfrompoint.cpp combo.cpp combog.cpp odcombo.cpp xh_odcombo.cpp\
-	platform.cpp advsplash.cpp treebook.cpp xh_treebk.cpp
+	platform.cpp advsplash.cpp treebook.cpp xh_treebk.cpp slidercombo.cpp xh_slidrcombo.cpp
 
 # make sure this does NOT have our include files in the path
 # Don't use GTK includes for now - you will need this with sub-2.6.3 but that's not supported
Index: Trunk/XaraLX/wxXtra/xh_slidrcombo.cpp
===================================================================
--- Trunk/XaraLX/wxXtra/xh_slidrcombo.cpp	(revision 0)
+++ Trunk/XaraLX/wxXtra/xh_slidrcombo.cpp	(revision 1504)
@@ -0,0 +1,77 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        src/xrc/xh_slidrcombo.cpp
+// Purpose:     XRC resource for wxSliderCombo
+// Author:      Mart Raudsepp - Based on src/xrc/xh_odcombo.cpp
+// Created:     2006/07/24
+// RCS-ID:      $Id: $
+// Copyright:   (c) 2006 Mart Raudsepp
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+#if wxUSE_XRC //&& wxUSE_SLIDERCOMBO
+
+#include "xh_slidrcombo.h"
+#include <wx/intl.h>
+#include <wx/textctrl.h>
+
+#include "slidercombo.h"
+#include <wx/slider.h> // For wxSL_* styles
+
+IMPLEMENT_DYNAMIC_CLASS(wxSliderComboXmlHandler, wxXmlResourceHandler)
+
+wxSliderComboXmlHandler::wxSliderComboXmlHandler()
+                        :wxXmlResourceHandler()
+{
+    XRC_ADD_STYLE(wxCB_READONLY);
+    XRC_ADD_STYLE(wxCB_DROPDOWN);
+    XRC_ADD_STYLE(wxTE_PROCESS_ENTER);
+    XRC_ADD_STYLE(wxSL_HORIZONTAL);
+    XRC_ADD_STYLE(wxSL_VERTICAL);
+    XRC_ADD_STYLE(wxSL_LABELS);
+    XRC_ADD_STYLE(wxSL_INVERSE);
+    AddWindowStyles();
+}
+
+wxObject *wxSliderComboXmlHandler::DoCreateResource()
+{
+    XRC_MAKE_INSTANCE(control, wxSliderCombo)
+
+    control->Create(m_parentAsWindow,
+                    GetID(),
+                    GetLong(wxT("value")),
+                    GetPosition(), GetSize(),
+                    GetStyle(),
+                    GetName());
+
+    SetupWindow(control);
+
+    return control;
+}
+
+bool wxSliderComboXmlHandler::CanHandle(wxXmlNode *node)
+{
+#if wxCHECK_VERSION(2,7,0)
+
+    return (IsOfClass(node, wxT("wxSliderCombo")));
+
+#else
+
+//  Avoid GCC bug - this fails on certain GCC 3.3 and 3.4 builds for an unknown reason
+//  it is believed to be related to the fact IsOfClass is inline, and node->GetPropVal
+//  gets passed an invalid "this" pointer. On 2.7, the function is out of line, so the
+//  above should work fine. This code is left in here so this file can easily be used
+//  in a version backported to 2.6. All we are doing here is expanding the macro
+
+    bool fOurClass = node->GetPropVal(wxT("class"), wxEmptyString) == wxT("wxSliderCombo");
+    return (fOurClass);
+#endif
+}
+
+#endif // wxUSE_XRC //&& wxUSE_SLIDERCOMBO
Index: Trunk/XaraLX/wxOil/camresource.cpp
===================================================================
--- Trunk/XaraLX/wxOil/camresource.cpp	(revision 1503)
+++ Trunk/XaraLX/wxOil/camresource.cpp	(revision 1504)
@@ -1455,6 +1455,7 @@
 	wxXmlResource::Get()->AddHandler(new wxOwnerDrawnComboBoxXmlHandler);
 //	wxXmlResource::Get()->AddHandler(new wxComboControlXmlHandler);
 #endif
+	wxXmlResource::Get()->AddHandler(new wxSliderComboXmlHandler);
 #if WXXTRA_TREEBOOK
 	wxXmlResource::Get()->AddHandler(new wxTreebookXmlHandler);
 #endif


Xara