| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
#ifndef FEATURES_CONTAINER_HH |
|---|
| 24 |
#define FEATURES_CONTAINER_HH |
|---|
| 25 |
|
|---|
| 26 |
#include "FeatureList.hh" |
|---|
| 27 |
#include "ColorPatch.hh" |
|---|
| 28 |
|
|---|
| 29 |
namespace gui { |
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
class FeaturesContainerChanged_ { |
|---|
| 35 |
friend class FeaturesContainer; |
|---|
| 36 |
protected: |
|---|
| 37 |
virtual void notify() = 0; |
|---|
| 38 |
virtual ~FeaturesContainerChanged_() { } |
|---|
| 39 |
}; |
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
class FeaturesContainer { |
|---|
| 46 |
protected: |
|---|
| 47 |
std::vector<FeaturesContainerChanged_*> _to_notify_list; |
|---|
| 48 |
Fl_Color _color; |
|---|
| 49 |
bool _visible; |
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
void notify_changed() { |
|---|
| 53 |
for (unsigned int i = 0; i < _to_notify_list.size(); i++) { |
|---|
| 54 |
_to_notify_list[i]->notify(); |
|---|
| 55 |
} |
|---|
| 56 |
} |
|---|
| 57 |
|
|---|
| 58 |
FeaturesContainer() { _color = FL_BLACK; _visible = true; } |
|---|
| 59 |
public: |
|---|
| 60 |
|
|---|
| 61 |
void add_change_listener(FeaturesContainerChanged_* l) { |
|---|
| 62 |
_to_notify_list.push_back(l); |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
Fl_Color color() { return _color; } |
|---|
| 67 |
void color(Fl_Color c) { _color = c; notify_changed(); } |
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
bool visible() { return _visible; } |
|---|
| 71 |
void visible(bool v) { _visible = v; notify_changed(); } |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
virtual bool contains_alignments() const { |
|---|
| 75 |
return getFeatureList()->contains_alignments(); |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
virtual const FeatureList* getFeatureList() const = 0; |
|---|
| 82 |
virtual FeaturesContainer * copy_me() const = 0; |
|---|
| 83 |
|
|---|
| 84 |
virtual ~FeaturesContainer() { |
|---|
| 85 |
for (unsigned int i = 0; i < _to_notify_list.size(); i++) { |
|---|
| 86 |
delete _to_notify_list[i]; |
|---|
| 87 |
} |
|---|
| 88 |
} |
|---|
| 89 |
}; |
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
class FeaturesContainerChanged_Redrawer : public FeaturesContainerChanged_ { |
|---|
| 96 |
private: |
|---|
| 97 |
Fl_Widget * to_redraw; |
|---|
| 98 |
public: |
|---|
| 99 |
FeaturesContainerChanged_Redrawer(Fl_Widget * r) : to_redraw(r) { } |
|---|
| 100 |
void notify() { to_redraw->redraw(); } |
|---|
| 101 |
~FeaturesContainerChanged_Redrawer() { } |
|---|
| 102 |
}; |
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
class ColorChangeListener_FeaturesContainer : public ColorChangeListener_ { |
|---|
| 109 |
protected: |
|---|
| 110 |
FeaturesContainer * _cont; |
|---|
| 111 |
public: |
|---|
| 112 |
ColorChangeListener_FeaturesContainer(FeaturesContainer * c) { |
|---|
| 113 |
_cont = c; |
|---|
| 114 |
} |
|---|
| 115 |
virtual ~ColorChangeListener_FeaturesContainer() { }; |
|---|
| 116 |
|
|---|
| 117 |
void notify(Fl_Color c) { _cont->color(c); } |
|---|
| 118 |
}; |
|---|
| 119 |
|
|---|
| 120 |
} |
|---|
| 121 |
|
|---|
| 122 |
#endif |
|---|
| 123 |
|
|---|