- Glib::RefPtr<Gdk::Window> win (darea.get_window());
- Widget* parent;
- gint x1, x2, y1, y2;
- gint w, h;
- double fract;
-
- w = darea.get_width() - 2;
- h = darea.get_height() - 2;
-
- fract = ((adjustment.get_value() - adjustment.get_lower()) /
- (adjustment.get_upper() - adjustment.get_lower()));
-
- switch (_style) {
- case Line:
- x1 = (gint) floor (w * fract);
- x2 = x1;
- y1 = 0;
- y2 = h - 1;
-
- if (use_parent) {
- parent = get_parent();
-
- if (parent) {
- win->draw_rectangle (parent->get_style()->get_fg_gc (parent->get_state()),
- true,
- 0, 0, darea.get_width(), darea.get_height());
- }
- } else {
- win->draw_rectangle (get_style()->get_bg_gc (get_state()),
- true,
- 0, 0, darea.get_width(), darea.get_height());
- }
-
- if (fract == 0.0) {
- win->draw_rectangle (get_style()->get_fg_gc (get_state()),
- true, x1, 1, 2, darea.get_height() - 2);
- } else {
- win->draw_rectangle (get_style()->get_fg_gc (get_state()),
- true, x1 - 1, 1, 3, darea.get_height() - 2);
- }
- break;
-
- case CenterOut:
- break;
-
- case LeftToRight:
- x1 = 0;
- x2 = (gint) floor (w * fract);
- y1 = 0;
- y2 = h - 1;
-
- win->draw_rectangle (get_style()->get_bg_gc (get_state()),
- false,
- 0, 0, darea.get_width() - 1, darea.get_height() - 1);
-
- /* draw active box */
-
- win->draw_rectangle (get_style()->get_fg_gc (get_state()),
- true,
- 1 + x1,
- 1 + y1,
- x2,
- 1 + y2);
-
- /* draw inactive box */
-
- win->draw_rectangle (get_style()->get_fg_gc (STATE_INSENSITIVE),
- true,
- 1 + x2,
- 1 + y1,
- w - x2,
- 1 + y2);
-
- break;
-
- case RightToLeft:
- break;
- case TopToBottom:
- break;
- case BottomToTop:
- break;
- }
-
- if (with_text) {
- /* draw label */
-
- char buf[64];
- buf[0] = '\0';
-
- label_callback (buf, 64);
-
- if (buf[0] != '\0') {
-
- layout->set_text (buf);
-
- int width, height;
- layout->get_pixel_size (width, height);
-
- int xpos;
-
- xpos = max (3, 1 + (x2 - (width/2)));
- xpos = min (darea.get_width() - width - 3, xpos);
-
- win->draw_layout (get_style()->get_text_gc (get_state()),
- xpos,
- (darea.get_height()/2) - (height/2),
- layout);
- }