summaryrefslogtreecommitdiff
path: root/dwr/label.hh
diff options
context:
space:
mode:
authorRodrigo Arias Mallo <rodarima@gmail.com>2024-12-10 22:30:12 +0100
committerRodrigo Arias Mallo <rodarima@gmail.com>2024-12-10 22:30:12 +0100
commit429d5f88b94ff28416cbfc6420b6389fa284df97 (patch)
treefb6fdaf7731de1ef396f98b748c56f3149801c84 /dwr/label.hh
Import RTFL 0.1.1v0.1.1
Diffstat (limited to 'dwr/label.hh')
-rw-r--r--dwr/label.hh87
1 files changed, 87 insertions, 0 deletions
diff --git a/dwr/label.hh b/dwr/label.hh
new file mode 100644
index 0000000..8a069b0
--- /dev/null
+++ b/dwr/label.hh
@@ -0,0 +1,87 @@
+#ifndef __DWR_LABEL_HH__
+#define __DWR_LABEL_HH__
+
+#include "dwr/hideable.hh"
+#include "lout/misc.hh"
+
+namespace rtfl {
+
+namespace dw {
+
+class Label: public Hideable
+{
+private:
+ class LabelIterator: public ::dw::core::Iterator
+ {
+ private:
+ int index;
+
+ LabelIterator (Label *label, ::dw::core::Content::Type mask, int index);
+
+ public:
+ LabelIterator (Label *label, ::dw::core::Content::Type mask, bool atEnd);
+
+ lout::object::Object *clone ();
+ int compareTo (lout::object::Comparable *other);
+
+ bool next ();
+ bool prev ();
+ void highlight (int start, int end, ::dw::core::HighlightLayer layer);
+ void unhighlight (int direction, ::dw::core::HighlightLayer layer);
+ void getAllocation (int start, int end,
+ ::dw::core::Allocation *allocation);
+ };
+
+ enum { ITALIC = 2, BOLD = 1 };
+
+ struct Word
+ {
+ char *text;
+ char styleIndex;
+ ::dw::core::Requisition size;
+ };
+
+ ::dw::core::style::Style *styles[4];
+ lout::misc::SimpleVector<Word> *words;
+ ::dw::core::Requisition totalSize;
+ bool selected, buttonDown;
+ int link;
+ ::dw::core::Layout::LinkEmitter linkEmitter;
+
+ void clearWords ();
+ void clearStyles ();
+ void ensureStyles ();
+
+protected:
+ void sizeRequestImplImpl (::dw::core::Requisition *requisition);
+ void getExtremesImplImpl (::dw::core::Extremes *extremes);
+ void drawImpl (::dw::core::View *view, ::dw::core::Rectangle *area);
+
+ bool buttonPressImpl (::dw::core::EventButton *event);
+ bool buttonReleaseImpl (::dw::core::EventButton *event);
+ void leaveNotifyImpl (::dw::core::EventCrossing *event);
+
+public:
+ static int CLASS_ID;
+
+ Label (const char *text, int link = -1);
+ ~Label ();
+
+ void setText (const char *text);
+ inline void setLink (int link) { this->link = link; }
+
+ ::dw::core::Iterator *iterator (::dw::core::Content::Type mask, bool atEnd);
+ void setStyle (::dw::core::style::Style *style);
+
+ void select ();
+ void unselect ();
+
+ inline void connectLink (::dw::core::Layout::LinkReceiver *receiver)
+ { linkEmitter.connectLink (receiver); }
+};
+
+} // namespace rtfl
+
+} // namespace dw
+
+#endif // __DWR_LABEL_HH__