cstring header was included. (Compile in Debian)
[gtkmmProject.git] / src / EventBox.cpp
blob867410f6601d7a4e72e395f1403596078f70e70d
1 #include <gtkmm/label.h>
2 #include <gtkmm/separator.h>
4 #include <iostream>
5 #include "EventBox.h"
6 #include <cstring>
8 NewEventBox::NewEventBox() :
9 Gtk::EventBox ()
11 add (vBox);
12 vBox.pack_start (hBoxUp);
13 vBox.pack_start (hBoxDown);
14 Gtk::Label* lB0 = new Gtk::Label ("rrr");
15 hBoxUp.pack_start (*lB0);
16 for (int i=0; i<5; i++)
18 Gtk::Widget* w = new Gtk::HSeparator;
19 hBoxUp.pack_start (*w);
21 Gtk::Label* lB1 = new Gtk::Label ("ttt");
22 hBoxUp.pack_start (*lB1);
23 // hbox.add(btn1);
24 // hbox.add(btn2);
25 show_all();
28 bool NewEventBox::on_expose_event (GdkEventExpose* event)
30 bool rv = Gtk::EventBox::on_expose_event (event);
31 int scale = 1;
32 int width = get_allocation().get_width();
33 int height = get_allocation().get_height();
34 double scale_x = (double)width / scale;
35 double scale_y = (double)height / scale;
37 Cairo::RefPtr<Cairo::Context> cr = this->get_window()->create_cairo_context();
39 //cr->move_to(get_allocation().get_width()/2,get_allocation().get_height()/2);
40 cr->save ();
41 cr->translate (width/2.0, height/2.0);
42 double radius = 400;//width < height ? width-40 : height-40;
43 radius /= 2.0;
44 cr->scale (radius, radius);
45 cr->arc (0.0, 0.0, 1.0, 0.0, 2 * 3.14);
46 cr->arc_negative (0.0, 0.0, 1.0, 0.0, 2 * 3.14);
47 cr->fill ();
48 cr->restore ();
49 cr->stroke ();
51 return rv;
54 void NewEventBox::on_realize (void)
57 // Base class call
59 Gtk::EventBox::on_realize ();
61 ensure_style ();
63 std::cout << __FUNCTION__ << std::endl;
66 // Create window
69 GdkWindowAttr attributes;
70 memset (&attributes, 0, sizeof(attributes));
72 Gtk::Allocation allocation = get_allocation ();
75 // Set initial position and size of the Gdk::Window:
77 attributes.x = allocation.get_x();
78 attributes.y = allocation.get_y();
79 attributes.width = allocation.get_width();
80 attributes.height = allocation.get_height();
82 attributes.event_mask = get_events () | Gdk::EXPOSURE_MASK;
83 attributes.window_type = GDK_WINDOW_CHILD;
84 attributes.wclass = GDK_INPUT_OUTPUT;
87 // set colors
89 Gdk::Color bgCol;
90 bgCol.set_rgb_p (0.7, 0.4, 0.4);
91 Gdk::Color fgCol;
92 fgCol.set_rgb_p (0.0, 0.0, 0.0);
93 modify_bg (Gtk::STATE_NORMAL , bgCol);
94 modify_fg (Gtk::STATE_NORMAL , fgCol);