My favorites | Sign in
Project Home Downloads Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
enum {
CTRL_NORMAL, CTRL_HOT, CTRL_PRESSED, CTRL_DISABLED,
CTRL_CHECKED, CTRL_HOTCHECKED
};

void CtrlsImageLook(Value *look, int i, int n = 4);
void CtrlsImageLook(Value *look, int i, const Image& image, const Color *color, int n = 4);
void CtrlsImageLook(Value *look, int i, const Image& image, int n = 4);

String DeAmp(const char *s);

Size GetSmartTextSize(const char *text, Font font = StdFont(), int cx = INT_MAX);
int GetSmartTextHeight(const char *s, int cx, Font font = StdFont());
void DrawSmartText(Draw& w, int x, int y, int cx, const char *text,
Font font = StdFont(), Color ink = DefaultInk, int accesskey = 0);

int ExtractAccessKey(const char *s, String& label);
bool CompareAccessKey(int accesskey, dword key);
int ChooseAccessKey(const char *s, dword used);

void DrawFocus(Draw& w, int x, int y, int cx, int cy, Color c = SColorText());
void DrawFocus(Draw& w, const Rect& r, Color c = SColorText());

void DrawHorzDrop(Draw& w, int x, int y, int cx);
void DrawVertDrop(Draw& w, int x, int y, int cy);

Point GetDragScroll(Ctrl *ctrl, Point p, Size max);
Point GetDragScroll(Ctrl *ctrl, Point p, int max = 16);

struct DrawLabel {
bool push;
bool focus;
bool disabled;
bool limg_never_hide;
bool rimg_never_hide;

PaintRect paintrect;
Image limg;
Color lcolor;
int lspc;
String text;
Font font;
Color ink, disabledink;
Image rimg;
Color rcolor;
int rspc;

int align, valign;

int accesskey;
int accesspos;

Size GetSize(int txtcx, Size sz1, int lspc, Size sz2, int rspc) const;
Size GetSize(int txtcx = INT_MAX) const;
Size Paint(Ctrl *ctrl, Draw& w, const Rect& r, bool visibleaccesskey = true) const;
Size Paint(Ctrl *ctrl, Draw& w, int x, int y, int cx, int cy, bool visibleaccesskey = true) const;
Size Paint(Draw& w, const Rect& r, bool visibleaccesskey = true) const;
Size Paint(Draw& w, int x, int y, int cx, int cy, bool visibleaccesskey = true) const;

DrawLabel();
};

Image DisabledImage(const Image& img, bool disabled = true);
Color GetLabelTextColor(const Ctrl *ctrl);

class LabelBase {
protected:
virtual void LabelUpdate();

DrawLabel lbl;

public:
LabelBase& SetLeftImage(const Image& bmp1, int spc = 0, bool never_hide = false);
LabelBase& SetPaintRect(const PaintRect& pr);
LabelBase& SetText(const char *text);
LabelBase& SetFont(Font font);
LabelBase& SetInk(Color color, Color disabledink);
LabelBase& SetInk(Color color) { return SetInk(color, color); }
LabelBase& SetRightImage(const Image& bmp2, int spc = 0, bool never_hide = false);
LabelBase& SetAlign(int align);
LabelBase& SetVAlign(int align);
LabelBase& SetImage(const Image& bmp, int spc = 0, bool never_hide = false)
{ SetLeftImage(bmp, spc, never_hide); return *this; }

int GetAlign() const { return lbl.align; }
int GetVAlign() const { return lbl.valign; }
PaintRect GetPaintRect() const { return lbl.paintrect; }
String GetText() const { return lbl.text; }
Font GetFont() const { return lbl.font; }
Color GetInk() const { return lbl.ink; }

Size PaintLabel(Ctrl *ctrl, Draw& w, const Rect& r,
bool disabled = false, bool push = false, bool focus = false, bool vak = true);
Size PaintLabel(Ctrl *ctrl, Draw& w, int x, int y, int cx, int cy,
bool disabled = false, bool push = false, bool focus = false, bool vak = true);
Size PaintLabel(Draw& w, const Rect& r,
bool disabled = false, bool push = false, bool focus = false, bool vak = true);
Size PaintLabel(Draw& w, int x, int y, int cx, int cy,
bool disabled = false, bool push = false, bool focus = false, bool vak = true);
Size GetLabelSize() const;

virtual ~LabelBase();
};

class DisplayPopup : public Ctrl, public Link<DisplayPopup> {
virtual void Paint(Draw& w);
virtual void LeftDown(Point p, dword);
virtual void LeftDrag(Point p, dword);
virtual void LeftDouble(Point p, dword);
virtual void RightDown(Point p, dword);
virtual void LeftUp(Point p, dword);
virtual void MouseWheel(Point p, int zdelta, dword keyflags);
virtual void MouseLeave();
virtual void MouseMove(Point p, dword);

private:
Ptr<Ctrl> ctrl;
Rect item;
Rect slim;

Value value;
Color paper, ink;
dword style;
const Display *display;
int margin;

Point Op(Point p);
void Sync();

static Link<DisplayPopup> *all();
static bool StateHook(Ctrl *, int reason);
static bool MouseHook(Ctrl *, bool, int, Point, int, dword);
static void SyncAll();

public:
void Set(Ctrl *ctrl, const Rect& item, const Value& v, const Display *display,
Color ink, Color paper, dword style, int margin = 0);
void Cancel();
bool IsOpen();
bool HasMouse();

DisplayPopup();
~DisplayPopup();
};

Change log

r4714 by cxl on Mar 23, 2012   Diff
*CtrlLib: Improved syncing of DisplayPopup
to avoid stall popups (e.g. in ide
navigator)
Go to: 
Project members, sign in to write a code review

Older revisions

r4457 by cxl on Jan 21, 2012   Diff
*uppsrc: Fixed many GCC warnings
r3887 by cxl on Sep 19, 2011   Diff
CtrlLib, Draw: Improved support for
dark visual themes (corrected text
color, icon inversion for toolbar /
menubar)
r2936 by cxl on Dec 27, 2010   Diff
CtrlLib: LabelBox visually supports
Disabled state, LabelBase has got
disabledink
All revisions of this file

File info

Size: 5182 bytes, 144 lines

File properties

svn:eol-style
native
Powered by Google Project Hosting