41 switch (fd.get_style()) {
42 case Pango::STYLE_NORMAL:
43 _slant = Cairo::FONT_SLANT_NORMAL;
45 case Pango::STYLE_OBLIQUE:
46 _slant = Cairo::FONT_SLANT_OBLIQUE;
48 case Pango::STYLE_ITALIC:
49 _slant = Cairo::FONT_SLANT_ITALIC;
53 switch (fd.get_weight()) {
54 case Pango::WEIGHT_ULTRALIGHT:
55 _weight = Cairo::FONT_WEIGHT_NORMAL;
58 case Pango::WEIGHT_LIGHT:
59 _weight = Cairo::FONT_WEIGHT_NORMAL;
62 case Pango::WEIGHT_NORMAL:
63 _weight = Cairo::FONT_WEIGHT_NORMAL;
66 case Pango::WEIGHT_SEMIBOLD:
67 _weight = Cairo::FONT_WEIGHT_BOLD;
70 case Pango::WEIGHT_BOLD:
71 _weight = Cairo::FONT_WEIGHT_BOLD;
74 case Pango::WEIGHT_ULTRABOLD:
75 _weight = Cairo::FONT_WEIGHT_BOLD;
78 case Pango::WEIGHT_HEAVY:
79 _weight = Cairo::FONT_WEIGHT_BOLD;
84 face = fd.get_family();
127 context->show_text (
_text);
136 vector<char> buf(lim+1);
138 double max_width = 0.0;
139 double max_height = 0.0;
140 Cairo::TextExtents ext;
147 for (
int digit = 0; digit < 10; digit++) {
149 for (n = 0; n < lim; ++n) {
150 buf[n] =
'0' + digit;
153 context->get_text_extents (&buf[0], ext);
155 max_width = max (ext.width + ext.x_bearing, max_width);
156 max_height = max (ext.height, max_height);
157 bsum += ext.x_bearing;
162 bbox.width = max_width + (bsum/10.0);
167 bbox.height = max_height;
179 Cairo::TextExtents ext;
184 const char* buf =
"8";
185 context->get_text_extents (buf, ext);
187 bbox.height = ext.height;
191 const char* buf =
":";
192 context->get_text_extents (buf, ext);
193 bbox.width = ext.width + (2.0 * ext.x_bearing);
203 , max_cell_height (0)
210 add_events (Gdk::POINTER_MOTION_HINT_MASK | Gdk::SCROLL_MASK | Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK |
211 Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::SCROLL_MASK);
212 set_flags (Gtk::CAN_FOCUS);
214 set_can_default (
true);
253 cells.push_back (cell);
290 Glib::RefPtr<Gdk::Window> win = get_window ();
293 std::cerr <<
"CET: no window to draw on\n";
297 Cairo::RefPtr<Cairo::Context> context = win->create_cairo_context();
303 context->rectangle (ev->area.x, ev->area.y, ev->area.width, ev->area.height);
306 Gtk::Allocation alloc = get_allocation ();
307 double width = alloc.get_width();
308 double height = alloc.get_height ();
315 context->rectangle (0, 0, width, height);
320 for (CellMap::iterator i =
cells.begin(); i !=
cells.end(); ++i) {
331 context->set_source_rgba (
r,
g,
b,
a);
344 Glib::RefPtr<Gdk::Window> win = get_window();
354 r.set_width (cell->
width());
355 r.set_height (cell->
height());
358 win->invalidate_region (rg,
true);
364 for (CellMap::iterator i =
cells.begin(); i !=
cells.end(); ++i) {
365 if ((*i)->covers (x, y)) {
411 Glib::RefPtr<Gdk::Window> win = get_window();
417 Cairo::RefPtr<Cairo::Context> context = win->create_cairo_context();
423 for (CellMap::iterator i =
cells.begin(); i !=
cells.end(); ++i) {
424 (*i)->set_size (context);
436 for (CellMap::iterator i =
cells.begin(); i !=
cells.end(); ++i) {
448 Misc::on_size_allocate (alloc);
456 CellMap::iterator i =
cells.begin();
458 while (i !=
cells.end()) {
464 if (++i !=
cells.end()) {
483 for (CellMap::iterator i =
cells.begin(); i !=
cells.end(); ++i) {
boost::shared_ptr< CairoFontDescription > font() const
CairoCharCell(int32_t id, char c)
static const double cairo_font_fudge
virtual void set_size(Cairo::RefPtr< Cairo::Context > &)
CairoCell * find_cell(uint32_t x, uint32_t y)
bool on_button_press_event(GdkEventButton *)
void set_font(boost::shared_ptr< CairoFontDescription > font)
bool on_focus_out_event(GdkEventFocus *)
boost::shared_ptr< CairoFontDescription > _font
void set_width_chars(CairoTextCell *cell, uint32_t)
sigc::signal< bool, GdkEventScroll *, CairoCell * > scroll
void render(Cairo::RefPtr< Cairo::Context > &)
sigc::signal< bool, GdkEventButton *, CairoCell * > button_press
void on_size_allocate(Gtk::Allocation &)
void set_text(const std::string &txt)
void on_size_request(GtkRequisition *)
void add_cell(CairoCell *)
bool on_focus_in_event(GdkEventFocus *)
bool on_expose_event(GdkEventExpose *)
bool on_scroll_event(GdkEventScroll *)
bool on_button_release_event(GdkEventButton *)
CairoTextCell(int32_t id, double width_chars, boost::shared_ptr< CairoFontDescription > font=boost::shared_ptr< CairoFontDescription >())
void set_size(Cairo::RefPtr< Cairo::Context > &context)
void set_position(double x, double y)
void set_width_chars(double wc)
void start_editing(CairoCell *)
bool intersects(GdkRectangle &r) const
CairoEditableText(boost::shared_ptr< CairoFontDescription > font=boost::shared_ptr< CairoFontDescription >())
virtual void render(Cairo::RefPtr< Cairo::Context > &)=0
void queue_draw_cell(CairoCell *target)
boost::shared_ptr< CairoFontDescription > _font
LIBGTKMM2EXT_API void rounded_rectangle(Cairo::RefPtr< Cairo::Context > context, double x, double y, double w, double h, double r=10)
CairoFontDescription(const std::string &f, Cairo::FontSlant s, Cairo::FontWeight w, double sz)
sigc::signal< bool, GdkEventButton *, CairoCell * > button_release
void apply(Cairo::RefPtr< Cairo::Context > context)
void set_text(CairoTextCell *cell, const std::string &)
void set_font(boost::shared_ptr< CairoFontDescription > font)