|
Revision 10, 2.2 kB
(checked in by t, 3 years ago)
|
Tailorization
Import of the upstream sources from
Repository: :pserver:anonymous@cvs.sf.net:/cvsroot/familyjewels
Kind: cvs
Module: FRII
Revision: 2005-12-09 09:00:54 by titus
Original author: tailor@vallista.idyll.org
Date: 2005-12-09 09:00:54
|
- Property svn:executable set to
*
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
#ifndef COLOR_PATCH_HH |
|---|
| 19 |
#define COLOR_PATCH_HH |
|---|
| 20 |
|
|---|
| 21 |
#include <FL/Fl.H> |
|---|
| 22 |
#include <FL/fl_draw.H> |
|---|
| 23 |
#include <FL/Fl_Box.H> |
|---|
| 24 |
#include <FL/fl_show_colormap.H> |
|---|
| 25 |
|
|---|
| 26 |
#include <vector> |
|---|
| 27 |
|
|---|
| 28 |
namespace gui { |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
class ColorChangeListener_ { |
|---|
| 35 |
protected: |
|---|
| 36 |
ColorChangeListener_() { }; |
|---|
| 37 |
public: |
|---|
| 38 |
virtual ~ColorChangeListener_() { }; |
|---|
| 39 |
virtual void notify(Fl_Color c) = 0; |
|---|
| 40 |
}; |
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
class ColorPatch : public Fl_Box { |
|---|
| 47 |
protected: |
|---|
| 48 |
std::vector<ColorChangeListener_*> _to_notify_list; |
|---|
| 49 |
Fl_Color _color; |
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
void draw() { fl_color(color()); fl_rectf(x(), y(), w(), h()); } |
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
int handle(int e) { |
|---|
| 56 |
if (e == FL_PUSH) { |
|---|
| 57 |
|
|---|
| 58 |
Fl_Color old_color = color(); |
|---|
| 59 |
Fl_Color new_color = fl_show_colormap(old_color); |
|---|
| 60 |
if (new_color != old_color) { |
|---|
| 61 |
color(new_color); |
|---|
| 62 |
redraw(); |
|---|
| 63 |
notify_changed(); |
|---|
| 64 |
} |
|---|
| 65 |
|
|---|
| 66 |
return 1; |
|---|
| 67 |
} else { |
|---|
| 68 |
return Fl_Widget::handle(e); |
|---|
| 69 |
} |
|---|
| 70 |
} |
|---|
| 71 |
|
|---|
| 72 |
void notify_changed() { |
|---|
| 73 |
Fl_Color c = color(); |
|---|
| 74 |
for (unsigned int i = 0; i < _to_notify_list.size(); i++) { |
|---|
| 75 |
_to_notify_list[i]->notify(c); |
|---|
| 76 |
} |
|---|
| 77 |
} |
|---|
| 78 |
public: |
|---|
| 79 |
|
|---|
| 80 |
ColorPatch(int x, int y, int w, int h, Fl_Color c) : |
|---|
| 81 |
Fl_Box(x, y, w, h), _color(c) { |
|---|
| 82 |
color(_color); |
|---|
| 83 |
}; |
|---|
| 84 |
|
|---|
| 85 |
virtual ~ColorPatch() { }; |
|---|
| 86 |
|
|---|
| 87 |
void add_change_listener(ColorChangeListener_* l) { |
|---|
| 88 |
_to_notify_list.push_back(l); |
|---|
| 89 |
} |
|---|
| 90 |
}; |
|---|
| 91 |
} |
|---|
| 92 |
|
|---|
| 93 |
#endif |
|---|
| 94 |
|
|---|