~ubuntu-branches/ubuntu/raring/workrave/raring

« back to all changes in this revision

Viewing changes to frontend/gtkmm/src/TimeBar.cc

  • Committer: Package Import Robot
  • Author(s): Francois Marier, Francois Marier, Jordi Mallach
  • Date: 2012-05-28 11:29:40 UTC
  • mfrom: (1.2.9)
  • Revision ID: package-import@ubuntu.com-20120528112940-bbbsjkk30fom9s8x
Tags: 1.9.909+abc941eb70-1
[ Francois Marier ]
* New upstream snapshot
  - Drop leak-fix patch (applied upstream)
  - Document how the tarball is built in README.source
* Build GNOME applets and use gsettings
* Massive update of Build-Depends as per configure.ac

* Update README.source with snapshot instructions
* Switch to machine-readable copyright file
* Update alioth git repo links
* Bump debhelper version to 9
* Bump Standards-Version to 3.9.3

[ Jordi Mallach ]
* Avoid references to GNU/Linux in manpage.
* Drop build dependency on libgnet-dev, it's obsolete and unneeded.
* Add myself to Uploaders.
* Rewrite d/rules into dh style.
  - Move all install tweaks to .install files.
  - Install manpages using dh_installman.
* As a side effect, the package installs arch-dependant data in the
  arch triplet directory; add the required Pre-Depends for m-a-support.
* Bring back GNOME Panel applet (for GNOME 3 fallback mode) and ship the
  new GNOME Shell extension (closes: #642514, #666100).
* Add private_dirs.patch: move libworkrave-private and GObject
  Introspection files to a private dir, so they are really out of the
  way, but disable it for now as it breaks the Shell extension.
* Move typelib out of the triplet dir as gobject-introspection is not
  M-A ready yet.
* Enable dh_autoreconf for the above patches.
* Add lintian overrides.
* Add necessary Breaks/Replaces as the xpm icon has moved to workrave-data.
* Prefix all debhelper files with package name.
* Suggest gnome-shell and gnome-panel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// TimeBar.cc --- Time Bar
2
2
//
3
 
// Copyright (C) 2002 - 2009 Rob Caelers & Raymond Penners
 
3
// Copyright (C) 2002 - 2009, 2011, 2012 Rob Caelers & Raymond Penners
4
4
// All rights reserved.
5
5
//
6
6
// This program is free software: you can redistribute it and/or modify
76
76
}
77
77
 
78
78
 
79
 
void TimeBar::on_realize()
80
 
{
81
 
  // FIXME: for some reason, the timebar get realized EACH TIME
82
 
  //        the timerbox is cycled...
83
 
  // We need to call the base on_realize()
84
 
  Gtk::DrawingArea::on_realize();
85
 
 
86
 
  // Now we can allocate any additional resources we need
87
 
  Glib::RefPtr<Gdk::Window> window = get_window();
88
 
  window_gc = Gdk::GC::create(window);
89
 
 
90
 
  Glib::RefPtr<Gtk::Style> style = get_style();
91
 
  Gdk::Color bg = style->get_bg(Gtk::STATE_NORMAL);
92
 
  bar_colors[COLOR_ID_BG] = bg;
93
 
 
94
 
  Glib::RefPtr<Gdk::Colormap> colormap = get_colormap();
95
 
  for (int i = 0; i < COLOR_ID_SIZEOF; i++)
96
 
    {
97
 
      colormap->alloc_color(bar_colors[i]);
98
 
    }
99
 
  window->clear();
100
 
}
101
 
 
102
 
 
103
 
void
104
 
TimeBar::on_size_request(GtkRequisition *requisition)
105
 
{
106
 
  int width, height;
107
 
 
108
 
  get_preferred_size(width, height);
109
 
 
110
 
  if (rotation == 0 || rotation == 180)
111
 
    {
112
 
      requisition->width = width;
113
 
      requisition->height = height;
114
 
    }
115
 
  else
116
 
    {
117
 
      requisition->width = height;
118
 
      requisition->height = width;
119
 
    }
 
79
//! Sets the time progress to be displayed.
 
80
void
 
81
TimeBar::set_progress(int value, int max_value)
 
82
{
 
83
  if (value > max_value)
 
84
    {
 
85
      value = max_value;
 
86
    }
 
87
 
 
88
  bar_value = value;
 
89
  bar_max_value = max_value;
 
90
}
 
91
 
 
92
 
 
93
//! Sets the secondary time progress to be displayed.
 
94
void
 
95
TimeBar::set_secondary_progress(int value, int max_value)
 
96
{
 
97
  if (value > max_value)
 
98
    {
 
99
      value = max_value;
 
100
    }
 
101
 
 
102
  secondary_bar_value = value;
 
103
  secondary_bar_max_value = max_value;
 
104
}
 
105
 
 
106
 
 
107
//! Sets the text to be displayed.
 
108
void
 
109
TimeBar::set_text(string text)
 
110
{
 
111
  bar_text = text;
 
112
}
 
113
 
 
114
 
 
115
//! Sets text alignment
 
116
void
 
117
TimeBar::set_text_alignment(int align)
 
118
{
 
119
  bar_text_align = align;
 
120
}
 
121
 
 
122
 
 
123
//! Sets the color of the bar.
 
124
void
 
125
TimeBar::set_bar_color(ColorId color)
 
126
{
 
127
  bar_color = color;
 
128
}
 
129
 
 
130
 
 
131
//! Sets the color of the secondary bar.
 
132
void
 
133
TimeBar::set_secondary_bar_color(ColorId color)
 
134
{
 
135
  secondary_bar_color = color;
 
136
}
 
137
 
 
138
 
 
139
//! Sets the text color.
 
140
void
 
141
TimeBar::set_text_color(Gdk::Color color)
 
142
{
 
143
  bar_text_color = color;
 
144
}
 
145
 
 
146
 
 
147
void
 
148
TimeBar::set_rotation(int r)
 
149
{
 
150
  rotation = r;
 
151
  queue_resize();
 
152
}
 
153
 
 
154
 
 
155
//! Updates the screen.
 
156
void TimeBar::update()
 
157
{
 
158
  queue_draw();
120
159
}
121
160
 
122
161
 
126
165
  //Use the offered allocation for this container:
127
166
  set_allocation(allocation);
128
167
 
129
 
  if (is_realized())
 
168
  if (
 
169
#ifdef HAVE_GTK3
 
170
      get_realized()
 
171
#else
 
172
      is_realized()
 
173
#endif
 
174
      )
130
175
    {
131
176
      get_window()->move_resize(allocation.get_x(),
132
177
                                allocation.get_y(),
137
182
 
138
183
//! Returns the preferred size.
139
184
void
140
 
TimeBar::get_preferred_size(int &width, int &height)
 
185
TimeBar::get_preferred_size(int &width, int &height) const
141
186
{
142
 
  Glib::RefPtr<Pango::Layout> pl = create_pango_layout(bar_text);
 
187
  // Not sure why create_pango_layout is not const...
 
188
  Glib::RefPtr<Pango::Layout> pl = const_cast<TimeBar *>(this)->create_pango_layout(bar_text);
143
189
 
144
 
  string min_string = Text::time_to_string(-(59+59*60+9*60*60));;
145
 
  Glib::RefPtr<Pango::Layout> plmin = create_pango_layout(min_string);
 
190
  string min_string = Text::time_to_string(-(59+59*60+9*60*60));
 
191
  Glib::RefPtr<Pango::Layout> plmin = const_cast<TimeBar *>(this)->create_pango_layout(min_string);
146
192
 
147
193
  Glib::RefPtr<Pango::Context> pcl = pl->get_context();
148
194
  Glib::RefPtr<Pango::Context> pcmin = plmin->get_context();
167
213
}
168
214
 
169
215
 
 
216
#ifndef HAVE_GTK3
 
217
 
 
218
void TimeBar::on_realize()
 
219
{
 
220
  // FIXME: for some reason, the timebar get realized EACH TIME
 
221
  //        the timerbox is cycled...
 
222
  // We need to call the base on_realize()
 
223
  Gtk::DrawingArea::on_realize();
 
224
 
 
225
  // Now we can allocate any additional resources we need
 
226
  Glib::RefPtr<Gdk::Window> window = get_window();
 
227
  window_gc = Gdk::GC::create(window);
 
228
 
 
229
  Glib::RefPtr<Gtk::Style> style = get_style();
 
230
  Gdk::Color bg = style->get_bg(Gtk::STATE_NORMAL);
 
231
  bar_colors[COLOR_ID_BG] = bg;
 
232
 
 
233
  Glib::RefPtr<Gdk::Colormap> colormap = get_colormap();
 
234
  for (int i = 0; i < COLOR_ID_SIZEOF; i++)
 
235
    {
 
236
      colormap->alloc_color(bar_colors[i]);
 
237
    }
 
238
  window->clear();
 
239
}
 
240
 
 
241
 
 
242
void
 
243
TimeBar::on_size_request(GtkRequisition *requisition)
 
244
{
 
245
  int width, height;
 
246
 
 
247
  get_preferred_size(width, height);
 
248
 
 
249
  if (rotation == 0 || rotation == 180)
 
250
    {
 
251
      requisition->width = width;
 
252
      requisition->height = height;
 
253
    }
 
254
  else
 
255
    {
 
256
      requisition->width = height;
 
257
      requisition->height = width;
 
258
    }
 
259
}
 
260
 
 
261
 
170
262
//! Draws the timebar
171
263
bool
172
264
TimeBar::on_expose_event(GdkEventExpose *e)
173
265
{
174
 
  TRACE_ENTER("TimeBar::on_expose_event");
175
266
  const int border_size = 2;
176
267
  Gtk::Allocation allocation = get_allocation();
177
268
 
182
273
    {
183
274
      colormap->alloc_color(bar_colors[i]);
184
275
    }
185
 
  
 
276
 
186
277
  // Physical width/height
187
278
  int win_w = allocation.get_width();
188
279
  int win_h = allocation.get_height();
207
298
 
208
299
  Gdk::Color bg = style->get_bg(Gtk::STATE_NORMAL);
209
300
  bar_colors[COLOR_ID_BG] = bg;
210
 
  
 
301
 
211
302
  // Draw background
212
303
  window_gc->set_foreground(bar_colors[COLOR_ID_BG]);
213
304
  style->paint_shadow(window, Gtk::STATE_NORMAL, Gtk::SHADOW_IN, area,
312
403
  Glib::RefPtr<Pango::Context> pc1 = pl1->get_context();
313
404
 
314
405
  Pango::Matrix matrix = PANGO_MATRIX_INIT;
315
 
  
 
406
 
316
407
  pango_matrix_rotate(&matrix, 360 - rotation);
317
408
  pc1->set_matrix(matrix);
318
409
 
384
475
 
385
476
  Gdk::Color textcolor = style->get_fg(Gtk::STATE_NORMAL);
386
477
 
387
 
  TRACE_MSG(textcolor.get_red() << " " <<
388
 
            textcolor.get_green() << " " <<
389
 
            textcolor.get_blue());
390
 
  
391
478
  Glib::RefPtr<Gdk::GC> window_gc1 = Gdk::GC::create(window);
392
479
 
393
480
  window_gc1->set_clip_origin(0,0);
398
485
  window_gc1->set_foreground(textcolor);
399
486
  window_gc1->set_clip_rectangle(rect2);
400
487
  window->draw_layout(window_gc1, text_x, text_y, pl1);
401
 
  TRACE_EXIT();
402
488
  return true;
403
489
}
404
490
 
405
491
 
406
 
//! Sets the time progress to be displayed.
407
 
void
408
 
TimeBar::set_progress(int value, int max_value)
409
 
{
410
 
  if (value > max_value)
411
 
    {
412
 
      value = max_value;
413
 
    }
414
 
 
415
 
  bar_value = value;
416
 
  bar_max_value = max_value;
417
 
}
418
 
 
419
 
 
420
 
//! Sets the secondary time progress to be displayed.
421
 
void
422
 
TimeBar::set_secondary_progress(int value, int max_value)
423
 
{
424
 
  if (value > max_value)
425
 
    {
426
 
      value = max_value;
427
 
    }
428
 
 
429
 
  secondary_bar_value = value;
430
 
  secondary_bar_max_value = max_value;
431
 
}
432
 
 
433
 
 
434
 
//! Sets the text to be displayed.
435
 
void
436
 
TimeBar::set_text(string text)
437
 
{
438
 
  bar_text = text;
439
 
}
440
 
 
441
 
 
442
 
//! Sets text alignment
443
 
void
444
 
TimeBar::set_text_alignment(int align)
445
 
{
446
 
  bar_text_align = align;
447
 
}
448
 
 
449
 
 
450
 
//! Sets the color of the bar.
451
 
void
452
 
TimeBar::set_bar_color(ColorId color)
453
 
{
454
 
  bar_color = color;
455
 
}
456
 
 
457
 
 
458
 
//! Sets the color of the secondary bar.
459
 
void
460
 
TimeBar::set_secondary_bar_color(ColorId color)
461
 
{
462
 
  secondary_bar_color = color;
463
 
}
464
 
 
465
 
 
466
 
//! Sets the text color.
467
 
void
468
 
TimeBar::set_text_color(Gdk::Color color)
469
 
{
470
 
  bar_text_color = color;
471
 
}
472
 
 
473
 
 
474
 
void
475
 
TimeBar::set_rotation(int r)
476
 
{
477
 
  rotation = r;
478
 
  queue_resize();
479
 
}
480
 
 
481
 
 
482
 
//! Updates the screen.
483
 
void TimeBar::update()
484
 
{
485
 
  queue_draw();
486
 
}
487
 
 
488
 
 
489
492
void
490
493
TimeBar::draw_bar(Glib::RefPtr<Gdk::Window> &window,
491
494
                  const Glib::RefPtr<Gdk::GC> &gc,
503
506
      window->draw_rectangle(gc, filled, y, winw - x - width, height, width);
504
507
    }
505
508
}
 
509
 
 
510
#else
 
511
 
 
512
Gtk::SizeRequestMode
 
513
TimeBar::get_request_mode_vfunc() const
 
514
{
 
515
  return Gtk::Widget::get_request_mode_vfunc();
 
516
}
 
517
 
 
518
void
 
519
TimeBar::get_preferred_width_vfunc(int &minimum_width, int &natural_width) const
 
520
{
 
521
  int width, height;
 
522
  get_preferred_size(width, height);
 
523
 
 
524
  if (rotation == 0 || rotation == 180)
 
525
    {
 
526
      minimum_width = natural_width = width;
 
527
    }
 
528
  else
 
529
    {
 
530
      minimum_width = natural_width = height;
 
531
    }
 
532
}
 
533
 
 
534
void
 
535
TimeBar::get_preferred_height_vfunc(int &minimum_height, int &natural_height) const
 
536
{
 
537
  int width, height;
 
538
  get_preferred_size(width, height);
 
539
 
 
540
  if (rotation == 0 || rotation == 180)
 
541
    {
 
542
      minimum_height = natural_height = height;
 
543
    }
 
544
  else
 
545
    {
 
546
      minimum_height = natural_height = width;
 
547
    }
 
548
}
 
549
 
 
550
void
 
551
TimeBar::get_preferred_width_for_height_vfunc(int /* height */, int &minimum_width, int &natural_width) const
 
552
{
 
553
  get_preferred_width_vfunc(minimum_width, natural_width);
 
554
}
 
555
 
 
556
void
 
557
TimeBar::get_preferred_height_for_width_vfunc(int /* width */, int &minimum_height, int &natural_height) const
 
558
{
 
559
  get_preferred_height_vfunc(minimum_height, natural_height);
 
560
}
 
561
 
 
562
bool
 
563
TimeBar::on_draw(const Cairo::RefPtr<Cairo::Context> &cr)
 
564
{
 
565
  const int border_size = 1;
 
566
 
 
567
  Glib::RefPtr<Gtk::StyleContext> style_context = get_style_context();
 
568
  Gtk::Allocation allocation = get_allocation();
 
569
 
 
570
  style_context->context_save();
 
571
  style_context->add_class(GTK_STYLE_CLASS_FRAME);
 
572
 
 
573
  // Physical width/height
 
574
  int win_w = allocation.get_width() - 2; // FIXME:
 
575
  int win_h = allocation.get_height();
 
576
 
 
577
  // Logical width/height
 
578
  // width = direction of bar
 
579
  int win_lw, win_lh;
 
580
  if (rotation == 0 || rotation == 180)
 
581
    {
 
582
      win_lw = win_w;
 
583
      win_lh = win_h;
 
584
    }
 
585
  else
 
586
    {
 
587
      win_lw = win_h;
 
588
      win_lh = win_w;
 
589
    }
 
590
 
 
591
  // Draw background
 
592
  style_context->set_state(Gtk::STATE_FLAG_ACTIVE);
 
593
  Gdk::RGBA back_color = style_context->get_background_color();
 
594
  set_color(cr, back_color);
 
595
 
 
596
  // clip to the area indicated by the expose event so that we only redraw
 
597
  // the portion of the window that needs to be redrawn
 
598
  cr->rectangle(0, 0, win_w, win_h);
 
599
  cr->clip();
 
600
 
 
601
  style_context->context_save();
 
602
  style_context->set_state((Gtk::StateFlags)Gtk::STATE_FLAG_ACTIVE);
 
603
  style_context->render_background(cr, 0, 0, win_w - 1, win_h -1);
 
604
  style_context->render_frame(cr, 0, 0, win_w - 1, win_h -1);
 
605
  style_context->context_restore();
 
606
 
 
607
  // set_color(cr, back_color);
 
608
  // cr->rectangle(border_size, border_size, win_w - 2*border_size, win_h - 2*border_size);
 
609
  // cr->fill();
 
610
 
 
611
  // Bar
 
612
  int bar_width = 0;
 
613
  if (bar_max_value > 0)
 
614
    {
 
615
      bar_width = (bar_value * (win_lw - 2 * border_size - 1)) / bar_max_value;
 
616
    }
 
617
 
 
618
  // Secondary bar
 
619
  int sbar_width = 0;
 
620
  if (secondary_bar_max_value >  0)
 
621
    {
 
622
      sbar_width = (secondary_bar_value * (win_lw - 2 * border_size - 1)) / secondary_bar_max_value;
 
623
    }
 
624
 
 
625
  int bar_height = win_lh - 2 * border_size - 1;
 
626
 
 
627
  if (sbar_width > 0)
 
628
    {
 
629
      // Overlap
 
630
 
 
631
      // We should assert() because this is not supported
 
632
      // but there are some weird boundary cases
 
633
      // in which this still happens.. need to check
 
634
      // this out some time.
 
635
      // assert(secondary_bar_color == COLOR_ID_INACTIVE);
 
636
      ColorId overlap_color;
 
637
      switch (bar_color)
 
638
        {
 
639
        case COLOR_ID_ACTIVE:
 
640
          overlap_color = COLOR_ID_INACTIVE_OVER_ACTIVE;
 
641
          break;
 
642
        case COLOR_ID_OVERDUE:
 
643
          overlap_color = COLOR_ID_INACTIVE_OVER_OVERDUE;
 
644
          break;
 
645
        default:
 
646
          // We could abort() because this is not supported
 
647
          // but there are some weird boundary cases
 
648
          // in which this still happens.. need to check
 
649
          // this out some time.
 
650
          overlap_color = COLOR_ID_INACTIVE_OVER_ACTIVE;
 
651
        }
 
652
 
 
653
      if (sbar_width >= bar_width)
 
654
        {
 
655
          if (bar_width)
 
656
            {
 
657
              set_color(cr, bar_colors[overlap_color]);
 
658
              draw_bar(cr,
 
659
                       border_size, border_size,
 
660
                       bar_width, bar_height,
 
661
                       win_lw, win_lh);
 
662
            }
 
663
          if (sbar_width > bar_width)
 
664
            {
 
665
              set_color(cr, bar_colors[secondary_bar_color]);
 
666
              draw_bar(cr,
 
667
                       border_size + bar_width, border_size,
 
668
                       sbar_width - bar_width, bar_height,
 
669
                       win_lw, win_lh);
 
670
            }
 
671
        }
 
672
      else
 
673
        {
 
674
          if (sbar_width)
 
675
            {
 
676
              set_color(cr, bar_colors[overlap_color]);
 
677
              draw_bar(cr,
 
678
                       border_size, border_size,
 
679
                       sbar_width, bar_height,
 
680
                       win_lw, win_lh);
 
681
            }
 
682
          set_color(cr, bar_colors[bar_color]);
 
683
          draw_bar(cr,
 
684
                   border_size + sbar_width, border_size,
 
685
                   bar_width - sbar_width, bar_height,
 
686
                   win_lw, win_lh);
 
687
        }
 
688
    }
 
689
  else
 
690
    {
 
691
      // No overlap
 
692
      set_color(cr, bar_colors[bar_color]);
 
693
      draw_bar(cr,
 
694
               border_size, border_size,
 
695
               bar_width, bar_height, win_lw, win_lh);
 
696
    }
 
697
 
 
698
 
 
699
  // Text
 
700
  Pango::Matrix matrix = PANGO_MATRIX_INIT;
 
701
  pango_matrix_rotate(&matrix, 360 - rotation);
 
702
 
 
703
  Glib::RefPtr<Pango::Layout> pl1 = create_pango_layout(bar_text);
 
704
  Glib::RefPtr<Pango::Context> pc1 = pl1->get_context();
 
705
 
 
706
  pc1->set_matrix(matrix);
 
707
 
 
708
  int text_width, text_height;
 
709
  pl1->get_pixel_size(text_width, text_height);
 
710
 
 
711
  int text_x, text_y;
 
712
 
 
713
  Gdk::Rectangle rect1, rect2;
 
714
 
 
715
  if (rotation == 0 || rotation == 180)
 
716
    {
 
717
      if (win_w - text_width - MARGINX > 0)
 
718
        {
 
719
          if (bar_text_align > 0)
 
720
            text_x = (win_w - text_width - MARGINX);
 
721
          else if (bar_text_align < 0)
 
722
            text_x = MARGINX;
 
723
          else
 
724
            text_x = (win_w - text_width) / 2;
 
725
        }
 
726
      else
 
727
        {
 
728
          text_x = MARGINX;
 
729
        }
 
730
      text_y = (win_h - text_height) / 2;
 
731
 
 
732
      int left_width = (bar_width > sbar_width) ? bar_width : sbar_width;
 
733
      left_width += border_size;
 
734
 
 
735
      Gdk::Rectangle left_rect(0, 0, left_width, win_h);
 
736
      Gdk::Rectangle right_rect(left_width, 0, win_w - left_width, win_h);
 
737
 
 
738
      rect1 = left_rect;
 
739
      rect2 = right_rect;
 
740
    }
 
741
  else
 
742
    {
 
743
      if (win_h - text_width - MARGINY > 0)
 
744
        {
 
745
          int a = bar_text_align;
 
746
          if (rotation == 270)
 
747
            {
 
748
              a *= -1;
 
749
            }
 
750
          if (a > 0)
 
751
            text_y = (win_h - text_width - MARGINY);
 
752
          else if (a < 0)
 
753
            text_y = MARGINY;
 
754
          else
 
755
            text_y = (win_h - text_width) / 2;
 
756
        }
 
757
      else
 
758
        {
 
759
          text_y = MARGINY;
 
760
        }
 
761
 
 
762
      text_x = (win_w - text_height) / 2;
 
763
 
 
764
      int left_width = (bar_width > sbar_width) ? bar_width : sbar_width;
 
765
      left_width += border_size;
 
766
 
 
767
      Gdk::Rectangle up_rect(0, 0, win_w, left_width);
 
768
      Gdk::Rectangle down_rect(0, left_width, win_w, win_h - left_width);
 
769
 
 
770
      rect1 = up_rect;
 
771
      rect2 = down_rect;
 
772
    }
 
773
 
 
774
  cr->reset_clip();
 
775
  cr->rectangle(rect1.get_x(), rect1.get_y(), rect1.get_width(), rect1.get_height());
 
776
  cr->clip();
 
777
 
 
778
  cr->move_to(text_x, text_y);
 
779
  set_color(cr, bar_text_color);
 
780
  pl1->show_in_cairo_context(cr);
 
781
 
 
782
  Gdk::RGBA front_color = style_context->get_color();
 
783
  cr->reset_clip();
 
784
  cr->rectangle(rect2.get_x(), rect2.get_y(), rect2.get_width(), rect2.get_height());
 
785
  cr->clip();
 
786
  cr->move_to(text_x, text_y);
 
787
  set_color(cr, front_color);
 
788
  pl1->show_in_cairo_context(cr);
 
789
 
 
790
  style_context->context_restore();
 
791
 
 
792
  return Gtk::Widget::on_draw(cr);
 
793
}
 
794
 
 
795
void
 
796
TimeBar::set_color(const Cairo::RefPtr<Cairo::Context>& cr, const Gdk::Color &color)
 
797
{
 
798
  cr->set_source_rgb(color.get_red_p(), color.get_green_p(), color.get_blue_p());
 
799
}
 
800
 
 
801
 
 
802
void
 
803
TimeBar::set_color(const Cairo::RefPtr<Cairo::Context>& cr, const Gdk::RGBA &color)
 
804
{
 
805
  cr->set_source_rgb(color.get_red(), color.get_green(), color.get_blue());
 
806
}
 
807
 
 
808
void
 
809
TimeBar::draw_bar(const Cairo::RefPtr<Cairo::Context>& cr,
 
810
                  int x, int y, int width, int height,
 
811
                  int winw, int winh)
 
812
{
 
813
  (void) winh;
 
814
 
 
815
  if (rotation == 0 || rotation == 180)
 
816
    {
 
817
      cr->rectangle(x, y, width, height);
 
818
      cr->fill();
 
819
    }
 
820
  else
 
821
    {
 
822
      cr->rectangle(y, winw - x- width, height, width);
 
823
      cr->fill();
 
824
    }
 
825
}
 
826
 
 
827
#endif