]> git.saurik.com Git - wxWidgets.git/blobdiff - src/qt/brush.cpp
Improved selection mode handling in wxGrid::SelectBlock
[wxWidgets.git] / src / qt / brush.cpp
index 155b0c400bae3538bad7d77a8d452acffd0483f3..587080575b37dbcaab8d9d0681d95f9b7e449116 100644 (file)
@@ -1,10 +1,11 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        brush.cpp
-// Purpose:
-// Author:      Robert Roebling
-// Created:     01/02/97
-// Id:
-// Copyright:   (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
+// Purpose:     wxBrush
+// Author:      AUTHOR
+// Modified by:
+// Created:     ??/??/98
+// RCS-ID:      $Id$
+// Copyright:   (c) AUTHOR
 // Licence:    wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 #pragma implementation "brush.h"
 #endif
 
+#include "wx/setup.h"
+#include "wx/utils.h"
 #include "wx/brush.h"
 
-//-----------------------------------------------------------------------------
-// wxBrush
-//-----------------------------------------------------------------------------
+IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
 
-class wxBrushRefData: public wxObjectRefData
+wxBrushRefData::wxBrushRefData()
 {
-  public:
-  
-    wxBrushRefData(void);
-  
-    int        m_style;
-    wxBitmap   m_stipple;
-    wxColour   m_colour;
-};
-
-wxBrushRefData::wxBrushRefData(void)
-{
-  m_style = 0;
-};
-
-//-----------------------------------------------------------------------------
-
-#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
-
-IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject)
+    m_style = wxSOLID;
+// TODO: null data
+}
 
-wxBrush::wxBrush(void)
+wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
 {
-  if (wxTheBrushList) wxTheBrushList->AddBrush( this );
-};
+  m_style = data.m_style;
+  m_stipple = data.m_stipple;
+  m_colour = data.m_colour;
+/* TODO: null data
+  m_hBrush = 0;
+*/
+}
 
-wxBrush::wxBrush( const wxColour &colour, int style )
+wxBrushRefData::~wxBrushRefData()
 {
-  m_refData = new wxBrushRefData();
-  M_BRUSHDATA->m_style = style;
-  M_BRUSHDATA->m_colour = colour;
-  
-  if (wxTheBrushList) wxTheBrushList->AddBrush( this );
-};
-
-wxBrush::wxBrush( const wxString &colourName, int style )
-{
-  m_refData = new wxBrushRefData();
-  M_BRUSHDATA->m_style = style;
-  M_BRUSHDATA->m_colour = colourName;
-  
-  if (wxTheBrushList) wxTheBrushList->AddBrush( this );
-};
-
-wxBrush::wxBrush( const wxBitmap &stippleBitmap )
+// TODO: delete data
+}
+
+// Brushes
+wxBrush::wxBrush()
 {
-  m_refData = new wxBrushRefData();
-  M_BRUSHDATA->m_style = wxSTIPPLE;
-  M_BRUSHDATA->m_colour = *wxBLACK;
-  M_BRUSHDATA->m_stipple = stippleBitmap;
-  
-  if (wxTheBrushList) wxTheBrushList->AddBrush( this );
-};
-
-wxBrush::wxBrush( const wxBrush &brush )
+    if ( wxTheBrushList )
+        wxTheBrushList->AddBrush(this);
+}
+
+wxBrush::~wxBrush()
 {
-  Ref( brush );
-  
-  if (wxTheBrushList) wxTheBrushList->AddBrush( this );
-};
+    if ( wxTheBrushList )
+        wxTheBrushList->RemoveBrush(this);
+}
 
-wxBrush::wxBrush( const wxBrush *brush )
+wxBrush::wxBrush(const wxColour& col, int Style)
 {
-  if (brush) Ref( *brush );
-  
-  if (wxTheBrushList) wxTheBrushList->Append( this );
-};
+    m_refData = new wxBrushRefData;
 
-wxBrush::~wxBrush(void)
+    M_BRUSHDATA->m_colour = col;
+    M_BRUSHDATA->m_style = Style;
+
+    RealizeResource();
+
+    if ( wxTheBrushList )
+        wxTheBrushList->AddBrush(this);
+}
+
+wxBrush::wxBrush(const wxString& col, int Style)
 {
-  if (wxTheBrushList) wxTheBrushList->RemoveBrush( this );
-};
+    m_refData = new wxBrushRefData;
+
+    // Implicit conversion from string to wxColour via colour database
+    M_BRUSHDATA->m_colour = col;
+    M_BRUSHDATA->m_style = Style;
 
-wxBrush& wxBrush::operator = ( const wxBrush& brush )
+    RealizeResource();
+
+    if ( wxTheBrushList )
+        wxTheBrushList->AddBrush(this);
+}
+
+wxBrush::wxBrush(const wxBitmap& stipple)
 {
-  if (*this == brush) return (*this); 
-  Ref( brush ); 
-  return *this; 
-};
-  
-bool wxBrush::operator == ( const wxBrush& brush )
+    m_refData = new wxBrushRefData;
+
+    M_BRUSHDATA->m_style = wxSTIPPLE;
+    M_BRUSHDATA->m_stipple = stipple;
+
+    RealizeResource();
+
+    if ( wxTheBrushList )
+        wxTheBrushList->AddBrush(this);
+}
+
+void wxBrush::Unshare()
 {
-  return m_refData == brush.m_refData; 
-};
+       // Don't change shared data
+       if (!m_refData)
+    {
+               m_refData = new wxBrushRefData();
+       }
+    else
+    {
+               wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
+               UnRef();
+               m_refData = ref;
+       }
+}
 
-bool wxBrush::operator != ( const wxBrush& brush )
+void wxBrush::SetColour(const wxColour& col)
 {
-  return m_refData != brush.m_refData; 
-};
+    Unshare();
+
+    M_BRUSHDATA->m_colour = col;
 
-bool wxBrush::Ok(void) const
+    RealizeResource();
+}
+
+void wxBrush::SetColour(const wxString& col)
 {
-  return ((m_refData) && M_BRUSHDATA->m_colour.Ok());
-};
+    Unshare();
+
+    M_BRUSHDATA->m_colour = col;
+
+    RealizeResource();
+}
 
-int wxBrush::GetStyle(void) const
+void wxBrush::SetColour(const unsigned char r, const unsigned char g, const unsigned char b)
 {
-  return M_BRUSHDATA->m_style;
-};
+    Unshare();
 
-wxColour &wxBrush::GetColour(void) const
+    M_BRUSHDATA->m_colour.Set(r, g, b);
+
+    RealizeResource();
+}
+
+void wxBrush::SetStyle(int Style)
 {
-  return M_BRUSHDATA->m_colour;
-};
+    Unshare();
+
+    M_BRUSHDATA->m_style = Style;
+
+    RealizeResource();
+}
 
-wxBitmap *wxBrush::GetStipple(void) const
+void wxBrush::SetStipple(const wxBitmap& Stipple)
 {
-  return &M_BRUSHDATA->m_stipple;
-};
+    Unshare();
 
+    M_BRUSHDATA->m_stipple = Stipple;
+
+    RealizeResource();
+}
+
+void wxBrush::RealizeResource()
+{
+// TODO: create the brush
+}