cartctl.h

Go to the documentation of this file.
00001 // $Id: cartctl.h 987 2006-05-09 19:45:07Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 
00099 #ifndef INC_CARTCTL
00100 #define INC_CARTCTL
00101 
00102 #include "cartprov.h"
00103 #include "ctrllist.h"
00104 
00105 enum wxCamArtControlStyle
00106 {
00107     // Caching flags start here - the art provider may have a different bitmap depending on the
00108     // state of these flags...
00109     wxCACS_TOOLBACKGROUND   = CAF_TOOLBACKGROUND,
00110     wxCACS_PUSHBUTTON       = CAF_PUSHBUTTON,
00111     wxCACS_TOGGLEBUTTON     = CAF_TOGGLEBUTTON, // wxCACS_PUSHBUTTON should also be set if this is set
00112     wxCACS_ALWAYS3D         = CAF_ALWAYS3D,
00113     wxCACS_ALLOWHOVER       = CAF_ALLOWHOVER,
00114     wxCACS_NOINTERNALBORDER = CAF_NOINTERNALBORDER,
00115     wxCACS_TEXT             = CAF_TEXT,
00116     wxCACS_EXACTFIT         = CAF_EXACTFIT,
00117     wxCACS_HALFHEIGHT       = CAF_HALFHEIGHT,
00118     wxCACS_TOP              = CAF_TOP,
00119     wxCACS_BOTTOM           = CAF_BOTTOM,
00120     wxCACS_LEFT             = CAF_LEFT,
00121     wxCACS_RIGHT            = CAF_RIGHT,
00122     wxCACS_NOAUTOREPEAT     = CAF_NOAUTOREPEAT,
00123     wxCACS_STATUSBARTEXT    = CAF_STATUSBARTEXT,
00124 
00125     wxCACS_DEFAULT          = 0
00126 };
00127 
00128 /*******************************************************************************************
00129 
00130 >   class wxCamArtControlEvent : public wxEvent
00131 
00132     Author:     Alex_Bligh <alex@alex.org.uk>
00133 o   Created:    19/12/2005
00134     Purpose:    A derived event to allow for postprocessing of autorepeat on buttons
00135     Notes:      In the OIL
00136     See Also:   
00137 
00138 ********************************************************************************************/
00139 
00140 class wxCamArtControlEvent : public wxEvent
00141 {
00142 public:
00143     // Aargh note wxEvent's constructor has paramaters the otherway around from this - designed to match wxCommandEvent
00144     wxCamArtControlEvent(wxEventType commandType = wxEVT_NULL, INT32 id=0 ) : wxEvent(id, commandType) {}
00145 
00146     wxCamArtControlEvent(const wxCamArtControlEvent& event) : wxEvent(event) {}
00147 
00148     virtual wxEvent *Clone() const {return new wxCamArtControlEvent(*this); }
00149 
00150     DECLARE_DYNAMIC_CLASS(wxCamArtControlEvent);
00151 
00152 };
00153 
00154 typedef void (wxEvtHandler::*wxCamArtControlEventFunction)(wxCamArtControlEvent &);
00155 
00156 DECLARE_EVENT_TYPE(wxEVT_CAMARTCONTROL_INVOKE, -1);
00157 
00158 #define EVT_CAMARTCONTROL_INVOKE(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CAMARTCONTROL_INVOKE, id, -1, \
00159     (wxObjectEventFunction)(wxEventFunction)(wxCamArtControlEventFunction) &fn, (wxObject *) NULL),
00160 
00161 /*******************************************************************************************
00162 
00163 >   class wxCamArtControl : public wxEvtHandler
00164 
00165     Author:     Alex_Bligh <alex@alex.org.uk>
00166     Created:    19/12/2005
00167     Purpose:    A base class for controls using the CamArtProvider to paint themselves
00168     Notes:      In the OIL
00169     See Also:   
00170 
00171 This class is specificly written so it will provided cached vector-drawn art.
00172 
00173 ********************************************************************************************/
00174 
00175 class wxCamArtControl : public wxControl
00176 {
00177     DECLARE_DYNAMIC_CLASS(wxControl)
00178     DECLARE_EVENT_TABLE()
00179 public:
00180     // Creation
00181     BOOL Create( wxWindow * parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
00182                      /*TYPENOTE: Correct*/ long style = 0, const wxValidator& validator = wxDefaultValidator,
00183                      wxCamArtControlStyle cacstyle = wxCACS_DEFAULT,
00184                      wxString opdesc = wxString(_T("")));
00185 
00186     // Common init
00187     void Init() {
00188                     m_Value=0;
00189                     m_CamArtControlStyle=wxCACS_DEFAULT;
00190                     m_BestSize=wxDefaultSize;
00191                     m_State=CAF_DEFAULT;
00192                     m_OpDesc=wxString(_T(""));
00193                     m_Timer.SetOwner(this, _R(IDC_WXCAMARTCONTROL_AUTOREPEAT));
00194                     m_ARDelay=500;
00195                     m_ARRepeat=50;
00196                     m_AREventPending=FALSE;
00197                     m_BitmapId=0;
00198                 }
00199 
00200     // Constructors
00201     wxCamArtControl() { Init(); }
00202     wxCamArtControl( wxWindow * parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
00203                      /*TYPENOTE: Correct*/ long style = 0, const wxValidator& validator = wxDefaultValidator,
00204                      wxCamArtControlStyle cacstyle = wxCACS_DEFAULT,
00205                      wxString opdesc = wxString(_T("")))
00206                     {
00207                         Init();
00208                         ControlList::Get()->NewControl(this);
00209                         Create(parent, id, pos, size, style, validator, cacstyle, opdesc);
00210                     }
00211     ~wxCamArtControl() { m_Timer.Stop(); }
00212     // Override
00213     wxSize DoGetBestSize() const;
00214 
00215     // EventHandlers
00216     void OnPaint(wxPaintEvent & event);
00217     void OnMouseEvent(wxMouseEvent & event);
00218     void OnTimer(wxTimerEvent& event);
00219     void OnInvoke(wxCamArtControlEvent& event);
00220 
00221     // Reload bitmap
00222     void NewBitmap() {FindBitmap(); Refresh();}
00223     
00224     virtual void SetStyle(wxCamArtControlStyle style) { m_CamArtControlStyle=style; NewBitmap(); }
00225     virtual wxCamArtControlStyle GetStyle() const { return m_CamArtControlStyle;}
00226 
00227     virtual void SetValue(UINT32 value)
00228         {
00229             m_Value=value;
00230             CamArtFlags o=m_State;
00231             if (value) m_State=(CamArtFlags)(m_State | CAF_SELECTED); else m_State =(CamArtFlags)(m_State & ~CAF_SELECTED);
00232             if (o!=m_State) Refresh();
00233         }
00234     virtual UINT32 GetValue() { return m_Value;}
00235 
00236     // override Enable to clear hover flag when control disabled
00237     virtual /*TYPENOTE: Correct*/ bool Enable(bool /*TYPENOTE: Correct*/ enable = true)
00238         {
00239             if (!enable)
00240             {
00241                 m_State = (CamArtFlags)(m_State & ~CAF_BUTTONHOVER);
00242                 m_Timer.Stop(); // Don't process more events
00243             }
00244             return wxControl::Enable(enable);
00245         }
00246 
00247     virtual void SetLabel(const wxString& label) {if (label!=GetLabel()) {wxControl::SetLabel(label); Refresh(TRUE);}}
00248 
00249     wxString GetOpDesc() {return m_OpDesc;}
00250 
00251     const ResourceID GetBitmapId() {return m_BitmapId?m_BitmapId:GetId();}
00252     void SetBitmapId(ResourceID r=0) {m_BitmapId=r; NewBitmap();}
00253 
00254 protected:
00255     wxCamArtControlStyle m_CamArtControlStyle;
00256     UINT32 m_Value;
00257     wxSize m_BestSize;
00258     CamArtFlags m_State;
00259 
00260     wxTimer m_Timer;
00261     UINT32 m_ARDelay;
00262     UINT32 m_ARRepeat;
00263     BOOL m_AREventPending;
00264 
00265     wxString m_OpDesc;
00266 
00267     void Invoke();
00268 
00269     void FindBitmap();
00270     CamArtFlags GetArtFlags() {return (CamArtFlags)(m_CamArtControlStyle | m_State | (IsEnabled()?0:CAF_GREYED));}
00271 
00272     ResourceID m_BitmapId;
00273 
00274 };
00275 
00276 /*******************************************************************************************
00277 
00278 >   class wxCamArtControlXmlHandler : public wxXmlResourceHandler
00279 
00280     Author:     Alex_Bligh <alex@alex.org.uk>
00281     Created:    19/12/2005
00282     Purpose:    A resource handler to enable wxCamArtControl items to be loaded from XML
00283     Notes:      In the OIL
00284     See Also:   
00285 
00286 ********************************************************************************************/
00287 
00288 class wxCamArtControlXmlHandler : public wxXmlResourceHandler
00289 {
00290 DECLARE_DYNAMIC_CLASS(wxCamArtControlXmlHandler)
00291 public:
00292     wxCamArtControlXmlHandler();
00293     virtual wxObject *DoCreateResource();
00294     virtual bool /*TYPENOTE: Correct*/ CanHandle(wxXmlNode *node);
00295 };
00296 
00297 
00298 #endif
00299 

Generated on Sat Nov 10 03:48:12 2007 for Camelot by  doxygen 1.4.4