+
+ // accessors and setters
+ // ---------------------
+
+ wxColour& GetColour() const { return const_cast<wxColour&>(m_colour); }
+ int GetWidth() const { return m_width; }
+ wxPenStyle GetStyle() const { return m_style; }
+ wxPenJoin GetJoin() const { return m_join; }
+ wxPenCap GetCap() const { return m_cap; }
+ wxDash* GetDash() const { return m_dash; }
+ int GetDashCount() const { return m_nbDash; }
+ wxBitmap* GetStipple() const { return const_cast<wxBitmap *>(&m_stipple); }
+
+ void SetColour(const wxColour& col) { Free(); m_colour = col; }
+ void SetWidth(int width) { Free(); m_width = width; }
+ void SetStyle(wxPenStyle style) { Free(); m_style = style; }
+ void SetStipple(const wxBitmap& stipple)
+ {
+ Free();
+
+ m_style = wxPENSTYLE_STIPPLE;
+ m_stipple = stipple;
+ }
+
+ void SetDashes(int nb_dashes, const wxDash *dash)
+ {
+ Free();
+
+ m_nbDash = nb_dashes;
+ m_dash = const_cast<wxDash *>(dash);
+ }
+
+ void SetJoin(wxPenJoin join) { Free(); m_join = join; }
+ void SetCap(wxPenCap cap) { Free(); m_cap = cap; }
+
+
+ // HPEN management
+ // ---------------
+
+ // create the HPEN if we don't have it yet
+ bool Alloc();
+
+ // get the HPEN creating it on demand
+ WXHPEN GetHPEN() const;
+
+ // return true if we have a valid HPEN
+ bool HasHPEN() const { return m_hPen != 0; }
+
+ // return true if we had a valid handle before, false otherwise
+ bool Free();
+
+private:
+ // initialize the fields which have reasonable default values
+ //
+ // doesn't initialize m_width and m_style which must be initialize in ctor
+ void Init()
+ {
+ m_join = wxJOIN_ROUND;
+ m_cap = wxCAP_ROUND;
+ m_nbDash = 0;
+ m_dash = NULL;
+ m_hPen = 0;
+ }
+