inlib
1.2.0
|
00001 // Copyright (C) 2010, Guy Barrand. All rights reserved. 00002 // See the file inlib.license for terms. 00003 00004 #ifndef inlib_sg_base_text 00005 #define inlib_sg_base_text 00006 00007 // inheritance : 00008 #include "node" 00009 00010 #include "sf" 00011 #include "mf" 00012 #include "sfs" 00013 #include "enums" //hjust,vjust 00014 //#include "../box3f" 00015 00016 namespace inlib { 00017 namespace sg { 00018 00019 class base_text : public inlib::sg::node { 00020 void add_fields(){ 00021 add_field(&strings); 00022 add_field(&height); 00023 add_field(&hjust); 00024 add_field(&vjust); 00025 } 00026 public: 00027 virtual float ascent(float) = 0; 00028 virtual float descent(float) = 0; 00029 virtual float y_advance(float) = 0; 00030 virtual void get_bounds(float, 00031 float&,float&,float&, 00032 float&,float&,float&) = 0; 00033 00034 virtual bool truncate(const std::string&,float,float,std::string&) = 0; 00035 public: 00036 inlib::sg::mf_string strings; 00037 inlib::sg::sf<float> height; 00038 inlib::sg::sf_enum<inlib::sg::hjust> hjust; 00039 inlib::sg::sf_enum<inlib::sg::vjust> vjust; 00040 public: 00041 base_text() 00042 : inlib::sg::node() 00043 ,height(1.0f) 00044 ,hjust(inlib::sg::left) 00045 ,vjust(inlib::sg::bottom) 00046 { 00047 add_fields(); 00048 } 00049 virtual ~base_text(){} 00050 protected: 00051 base_text(const base_text& a_from) 00052 : inlib::sg::node(a_from) 00053 ,strings(a_from.strings) 00054 ,height(a_from.height) 00055 ,hjust(a_from.hjust) 00056 ,vjust(a_from.vjust) 00057 { 00058 add_fields(); 00059 } 00060 base_text& operator=(const base_text& a_from){ 00061 inlib::sg::node::operator=(a_from); 00062 height = a_from.height; 00063 strings = a_from.strings; 00064 hjust = a_from.hjust; 00065 vjust = a_from.vjust; 00066 return *this; 00067 } 00068 public: 00069 00070 // void get_bounds(float a_height,inlib::box3f& a_box) { 00071 // //for backward compatibility. 00072 // float mn_x,mn_y,mn_z; 00073 // float mx_x,mx_y,mx_z; 00074 // get_bounds(a_height,mn_x,mn_y,mn_z,mx_x,mx_y,mx_z); 00075 // a_box.set_bounds(mn_x,mn_y,mn_z,mx_x,mx_y,mx_z); 00076 // } 00077 00078 }; 00079 00080 }} 00081 00082 #endif