Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __HIPPSHAPE_H__
00022 #define __HIPPSHAPE_H__
00023
00024 #include "config.h"
00025
00026 #include <wx/object.h>
00027 #include <wx/stream.h>
00028 #include <wx/filename.h>
00029 #include <wx/wx.h>
00030 #include <cairomm/context.h>
00031 #include <map>
00032 #include <string>
00033 #include <iostream>
00034 #include <wx/dc.h>
00035 #include <xercesc/sax2/Attributes.hpp>
00036 #include <xercesc/util/XMLString.hpp>
00037 #include <boost/assign.hpp>
00038
00040 namespace hipp {
00041 static enum ShapeType {
00042 NotUsed, Polyline, Polygon, Line, Circle, Rectangle, Ellipse, Path, Image
00043 };
00044
00045 static std::map<std::string, ShapeType> ShapeTypeMap =
00046 boost::assign::map_list_of("polyline",Polyline)
00047 ("polygon",Polygon)
00048 ("line",Line)
00049 ("circle",Circle)
00050 ("rect", Rectangle)
00051 ("ellipse", Ellipse)
00052 ("path",Path)
00053 ("image",Image);
00054
00069 class HippShape: public wxEvtHandler {
00070 public:
00071 HippShape();
00072 ~HippShape();
00073
00085 virtual void LoadObject(const xercesc::Attributes& attrs, const XMLCh* const localnam);
00086
00102 virtual void LoadObject(const XMLCh* const chars);
00103 virtual std::ostream& SaveObject(std::ostream& stream);
00104 virtual void cloneMeta(HippShape* hs) const;
00105
00106
00107 virtual const wxRect& getBounds() const = 0;
00108
00109 virtual wxRect getFullBounds() const;
00110
00111 virtual bool containsPoint(wxPoint p) const = 0;
00112
00113 virtual void OnDraw(Cairo::RefPtr<Cairo::Context> context, bool isHaptic = true) const;
00114 virtual HippShape* clone() const = 0;
00115
00116 #if SHOW_SHAPE_BOUNDS
00117 virtual void DrawBounds(Cairo::RefPtr<Cairo::Context> context) const;
00118 #endif
00119
00120 virtual void move(int diffX, int diffY) = 0;
00121 virtual void zoom(double scaleX, double scaleY) = 0;
00122
00123 wxString getDescription() const {
00124 return m_desc;
00125 }
00126
00127 wxString getTitle() const {
00128 return m_title;
00129 }
00130
00131 wxString getTitleOrUntitled() const {
00132 return getTitle().IsEmpty() ? _("Untitled") : getTitle();
00133 }
00134
00135 void setDescription(wxString desc) {
00136 this->m_desc = desc;
00137 }
00138
00139 void setTitle(wxString title) {
00140 this->m_title = title;
00141 }
00142
00143 void toggleFill(){
00144 if (isFilled()){
00145 m_filling = wxNullColour;
00146 } else {
00147 if(getColourWhite()) m_filling.Set("white");
00148 else m_filling.Set("black");
00149 }
00150 }
00151
00152 bool isFilled() const {
00153 return m_filling.IsOk() ? true : false;
00154 }
00155
00156 int getLineWidth() const {
00157 return lineWidth;
00158 }
00159
00160 virtual void setLineWidth(int w) {
00161 if (w>0 && w<512*2) lineWidth = w;
00162 }
00163
00164 void setSoundFile (wxString soundfile) {
00165 this->m_soundfile = soundfile;
00166 wxLogDebug (m_soundfile);
00167 }
00168
00169 wxString getSoundFile () const {
00170 return m_soundfile;
00171 }
00172
00173
00174 void setColourWhite(bool c) {
00175 colourWhite = c;
00176 if(isFilled()){
00177 if(c) m_filling.Set("white");
00178 else m_filling.Set("black");
00179 }
00180 }
00181
00182 bool getColourWhite() const {
00183 return colourWhite;
00184 }
00185
00186 bool hasSound () const;
00187 bool hasMetaInfo() const;
00188 virtual ShapeType getShapeType()=0;
00189
00190 protected:
00191 wxString m_title;
00192 wxString m_desc;
00193 wxString m_soundfile;
00194
00195 bool colourWhite;
00196 wxColour m_filling;
00197 int lineWidth;
00198 private:
00199 wxString* awaiting_data;
00200 };
00201 }
00202 #endif