Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

properties.h

Go to the documentation of this file.
00001 #ifndef _LIBGNOMECANVASMM_PROPERTIES_H_ 00002 #define _LIBGNOMECANVASMM_PROPERTIES_H_ 00003 00004 // -*- c++ -*- 00005 /* $Id: properties.h,v 1.1 2002/12/10 12:39:03 aholzmann Exp $ */ 00006 00007 /* properties.h 00008 * 00009 * Copyright (C) 1999-2002 The Free Software Foundation 00010 * 00011 * This library is free software; you can redistribute it and/or 00012 * modify it under the terms of the GNU Library General Public 00013 * License as published by the Free Software Foundation; either 00014 * version 2 of the License, or (at your option) any later version. 00015 * 00016 * This library is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 * Library General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Library General Public 00022 * License along with this library; if not, write to the Free 00023 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00024 */ 00025 00026 //#include <gtk/gtkpacker.h> //For GtkAnchorType. 00027 00028 00029 #include <glibmm/propertyproxy.h> 00030 #include <gdkmm/color.h> 00031 #include <gdkmm/bitmap.h> 00032 #include <pangomm/fontdescription.h> 00033 #include <gtkmm/enums.h> 00034 00035 namespace Gnome 00036 { 00037 00038 namespace Canvas 00039 { 00040 00041 namespace Properties 00042 { 00043 00044 class PropertyBase 00045 { 00046 public: 00047 PropertyBase(const char* name); 00048 ~PropertyBase(); 00049 00050 const char* get_name() const; 00051 00052 protected: 00053 const char* name_; 00054 }; 00055 00056 template <class T_Value> 00057 class Property : public PropertyBase 00058 { 00059 public: 00060 Property(const char* name, const T_Value& value) 00061 : PropertyBase(name), value_(value) 00062 {} 00063 00064 void set_value_in_object(Glib::Object& object) const 00065 { 00066 Glib::PropertyProxy<T_Value> proxy(&object, get_name()); 00067 proxy.set_value(value_); 00068 } 00069 00070 protected: 00071 T_Value value_; 00072 }; 00073 00074 00079 template <class O, class T> 00080 O& operator << (O& object, const Property<T>& property) 00081 { 00082 property.set_value_in_object(object); 00083 return object; 00084 } 00085 00086 /********* specializations *********/ 00087 00088 //Colors can be specified with a string or a Gdk::Color, or an rgba guint. 00089 template<> 00090 class Property<Gdk::Color> : public PropertyBase 00091 { 00092 public: 00093 Property(const char* name, const Gdk::Color& value); 00094 Property(const char* name, const Glib::ustring& color); 00095 Property(const char* name, const guint& rgba_color); 00096 00097 void set_value_in_object(Glib::Object& object) const; 00098 00099 protected: 00100 Gdk::Color value_; 00101 bool value_gobj_used_; //Whether the Gdk::Value was intialised in the constructor. 00102 Glib::ustring value_string_; 00103 bool value_string_used_; 00104 guint value_rgba_; 00105 }; 00106 00107 //Font can be specified with a string or a Pango::FontDescription. 00108 template<> 00109 class Property<Pango::FontDescription> : public PropertyBase 00110 { 00111 public: 00112 Property(const char* name, const Pango::FontDescription& value); 00113 Property(const char* name, const Glib::ustring& font); 00114 00115 void set_value_in_object(Glib::Object& object) const; 00116 00117 protected: 00118 Pango::FontDescription value_; 00119 Glib::ustring value_string_; 00120 }; 00121 00122 00123 //We now define some specific properties. 00124 //Some of these are unusual, so we define them manually. 00125 //Others are regular so we define them with a macro: 00126 00127 00128 class font : public Property<Pango::FontDescription> //Used by CanvasText. 00129 { 00130 public: 00131 font(const Pango::FontDescription& v); 00132 00133 font(const Glib::ustring& v); 00134 }; 00135 00136 template<> 00137 class Property< Glib::RefPtr<Gdk::Bitmap> > : public PropertyBase 00138 { 00139 public: 00140 Property(const char* name, const Glib::RefPtr<Gdk::Bitmap>& value); 00141 00142 void set_value_in_object(Glib::Object& object) const; 00143 00144 protected: 00145 Glib::RefPtr<Gdk::Bitmap> value_; 00146 }; 00147 00148 class fill_color : public Property<Gdk::Color> 00149 { 00150 public: 00151 fill_color(const Gdk::Color& v); 00152 00153 fill_color(const Glib::ustring& v); 00154 }; 00155 00156 class outline_color : public Property<Gdk::Color> 00157 { 00158 public: 00159 outline_color(const Gdk::Color& v); 00160 00161 outline_color(const Glib::ustring& v); 00162 }; 00163 00164 00165 // GNOMEMM_PROPERTY(C++ name, C property name, C++ type) 00166 #define GNOMEMM_PROPERTY(N,N2,T) \ 00167 class N : public Property<T> \ 00168 { \ 00169 public: \ 00170 N(const T& v); \ 00171 }; 00172 00173 00174 // CanvasLine 00175 GNOMEMM_PROPERTY(arrow_shape_a,arrow_shape_a,double) 00176 GNOMEMM_PROPERTY(arrow_shape_b,arrow_shape_b,double) 00177 GNOMEMM_PROPERTY(arrow_shape_c,arrow_shape_c,double) 00178 GNOMEMM_PROPERTY(cap_style,cap_style,Gdk::CapStyle) 00179 GNOMEMM_PROPERTY(first_arrowhead,first_arrowhead,bool) 00180 GNOMEMM_PROPERTY(join_style,join_style,Gdk::JoinStyle) 00181 GNOMEMM_PROPERTY(last_arrowhead,last_arrowhead,bool) 00182 GNOMEMM_PROPERTY(line_style,line_style,Gdk::LineStyle) 00183 GNOMEMM_PROPERTY(smooth,smooth,bool) 00184 GNOMEMM_PROPERTY(spline_steps,spline_steps,guint) 00185 00186 // CanvasText 00187 GNOMEMM_PROPERTY(clip,clip,bool) 00188 GNOMEMM_PROPERTY(clip_height,clip_height,double) 00189 GNOMEMM_PROPERTY(clip_width,clip_width,double) 00190 GNOMEMM_PROPERTY(justification,justification,Gtk::Justification) 00191 GNOMEMM_PROPERTY(direction,direction,Gtk::DirectionType) 00192 GNOMEMM_PROPERTY(wrap_mode,wrap_mode,Gtk::WrapMode) 00193 GNOMEMM_PROPERTY(text_height,text_height,double) 00194 GNOMEMM_PROPERTY(text_width,text_width,double) 00195 GNOMEMM_PROPERTY(x_offset,x_offset,double) 00196 GNOMEMM_PROPERTY(y_offset,y_offset,double) 00197 GNOMEMM_PROPERTY(text,text,Glib::ustring) 00198 GNOMEMM_PROPERTY(markup,markup,Glib::ustring) 00199 GNOMEMM_PROPERTY(editable,editable,bool) 00200 GNOMEMM_PROPERTY(visible,visible,bool) 00201 GNOMEMM_PROPERTY(cursor_visible,cursor_visible,bool) 00202 GNOMEMM_PROPERTY(cursor_blink,cursor_blink,bool) 00203 GNOMEMM_PROPERTY(grow_height,grow_height,bool) 00204 GNOMEMM_PROPERTY(pixels_above_lines,pixels_above_lines,int) 00205 GNOMEMM_PROPERTY(pixels_below_lines,pixels_below_lines,int) 00206 GNOMEMM_PROPERTY(pixels_inside_wrap,pixels_inside_wrap,int) 00207 GNOMEMM_PROPERTY(left_margin,left_margin,int) 00208 GNOMEMM_PROPERTY(right_margin,right_margin,int) 00209 GNOMEMM_PROPERTY(indent,indent,int) 00210 00211 // CanvasWidget 00212 GNOMEMM_PROPERTY(size_pixels,size_pixels,bool) 00213 00214 // CanvasImage, CanvasWidget 00215 GNOMEMM_PROPERTY(height,height,double) 00216 GNOMEMM_PROPERTY(width,width,double) 00217 00218 // CanvasRect, CanvasEllipse 00219 GNOMEMM_PROPERTY(x1,x1,double) 00220 GNOMEMM_PROPERTY(x2,x2,double) 00221 GNOMEMM_PROPERTY(y1,y1,double) 00222 GNOMEMM_PROPERTY(y2,y2,double) 00223 00224 // CanvasImage, CanvasText, CanvasWidget 00225 GNOMEMM_PROPERTY(anchor,anchor,Gtk::AnchorType) 00226 00227 // CanvasPolygon, CanvasRect, CanvasEllipse 00228 GNOMEMM_PROPERTY(outline_stipple,outline_stipple,Glib::RefPtr<Gdk::Bitmap>) 00229 GNOMEMM_PROPERTY(wind,wind,guint) 00230 GNOMEMM_PROPERTY(miterlimit,miterlimit,double) 00231 00232 // CanvasLine, CanvasPolygon, CanvasRect, CanvasEllipse 00233 GNOMEMM_PROPERTY(width_pixels,width_pixels,guint) 00234 GNOMEMM_PROPERTY(width_units,width_units,double) 00235 00236 // CanvasGroup, CanvasImage, CanvasText, CanvasWidget 00237 GNOMEMM_PROPERTY(x,x,double) 00238 GNOMEMM_PROPERTY(y,y,double) 00239 00240 // CanvasLine, CanvasPolygon, CanvasRect, CanvasEllipse, CanvasText 00241 GNOMEMM_PROPERTY(fill_stipple,fill_stipple,Glib::RefPtr<Gdk::Bitmap>) 00242 00243 } /* namespace Properties */ 00244 } /* namespace Canvas */ 00245 } /* namespace Gnome */ 00246 00247 #endif /* _LIBGNOMECANVASMM_PROPERTIES_H_ */ 00248

Generated on Thu Jul 22 19:48:58 2004 for libgnomecanvasmm by doxygen 1.3.7