1 enum {
2 	CTRL_NORMAL, CTRL_HOT, CTRL_PRESSED, CTRL_DISABLED,
3 	CTRL_CHECKED, CTRL_HOTCHECKED
4 };
5 
6 void CtrlsImageLook(Value *look, int i, int n = 4);
7 void CtrlsImageLook(Value *look, int i, const Image& image, const Color *color, int n = 4);
8 void CtrlsImageLook(Value *look, int i, const Image& image, int n = 4);
9 
10 String DeAmp(const char *s);
11 
12 Size GetSmartTextSize(const char *text, Font font = StdFont(), int cx = INT_MAX);
13 int  GetSmartTextHeight(const char *s, int cx, Font font = StdFont());
14 void DrawSmartText(Draw& w, int x, int y, int cx, const char *text,
15                    Font font = StdFont(), Color ink = SBlack(), int accesskey = 0);
16 
17 int   ExtractAccessKey(const char *s, String& label);
18 bool  CompareAccessKey(int accesskey, dword key);
19 int   ChooseAccessKey(const char *s, dword used);
20 
21 void DrawFocus(Draw& w, int x, int y, int cx, int cy, Color c = SColorText());
22 void DrawFocus(Draw& w, const Rect& r, Color c = SColorText());
23 
24 void DrawHorzDrop(Draw& w, int x, int y, int cx);
25 void DrawVertDrop(Draw& w, int x, int y, int cy);
26 
27 Point GetDragScroll(Ctrl *ctrl, Point p, Size max);
28 Point GetDragScroll(Ctrl *ctrl, Point p, int max = 16);
29 
30 struct DrawLabel {
31 	bool      push;
32 	bool      focus;
33 	bool      disabled;
34 	bool      limg_never_hide;
35 	bool      rimg_never_hide;
36 
37 	PaintRect paintrect;
38 	Image     limg;
39 	Color     lcolor;
40 	int       lspc;
41 	String    text;
42 	Font      font;
43 	Color     ink, disabledink;
44 	Image     rimg;
45 	Color     rcolor;
46 	int       rspc;
47 
48 	int       align, valign;
49 
50 	bool      nowrap;
51 
52 	int       accesskey;
53 	int       accesspos;
54 
55 	Size      GetSize(int txtcx, Size sz1, int lspc, Size sz2, int rspc) const;
56 	Size      GetSize(int txtcx = INT_MAX) const;
57 	Size      Paint(Ctrl *ctrl, Draw& w, const Rect& r, bool visibleaccesskey = true) const;
58 	Size      Paint(Ctrl *ctrl, Draw& w, int x, int y, int cx, int cy, bool visibleaccesskey = true) const;
59 	Size      Paint(Draw& w, const Rect& r, bool visibleaccesskey = true) const;
60 	Size      Paint(Draw& w, int x, int y, int cx, int cy, bool visibleaccesskey = true) const;
61 
62 	DrawLabel();
63 };
64 
65 Image DisabledImage(const Image& img, bool disabled = true);
66 Color GetLabelTextColor(const Ctrl *ctrl);
67 
68 class LabelBase {
69 protected:
70 	virtual void  LabelUpdate();
71 
72 	DrawLabel   lbl;
73 
74 public:
75 	LabelBase&  SetLeftImage(const Image& bmp1, int spc = 0, bool never_hide = false);
76 	LabelBase&  SetPaintRect(const PaintRect& pr);
77 	LabelBase&  SetText(const char *text);
78 	LabelBase&  SetFont(Font font);
79 	LabelBase&  SetInk(Color color, Color disabledink);
SetInk(Color color)80 	LabelBase&  SetInk(Color color)                          { return SetInk(color, color); }
81 	LabelBase&  SetRightImage(const Image& bmp2, int spc = 0, bool never_hide = false);
82 	LabelBase&  SetAlign(int align);
AlignLeft()83 	LabelBase&  AlignLeft()                                  { return SetAlign(ALIGN_CENTER); }
AlignCenter()84 	LabelBase&  AlignCenter()                                { return SetAlign(ALIGN_CENTER); }
AlignRight()85 	LabelBase&  AlignRight()                                 { return SetAlign(ALIGN_RIGHT); }
86 	LabelBase&  SetVAlign(int align);
AlignTop()87 	LabelBase&  AlignTop()                                   { return SetVAlign(ALIGN_TOP); }
AlignVCenter()88 	LabelBase&  AlignVCenter()                               { return SetVAlign(ALIGN_CENTER); }
AlignBottom()89 	LabelBase&  AlignBottom()                                { return SetVAlign(ALIGN_BOTTOM); }
90 	LabelBase&  SetImage(const Image& bmp, int spc = 0, bool never_hide = false)
91 	{ SetLeftImage(bmp, spc, never_hide); return *this; }
92 	LabelBase&  NoWrap(bool b = true);
93 
GetAlign()94 	int         GetAlign() const                             { return lbl.align; }
GetVAlign()95 	int         GetVAlign() const                            { return lbl.valign; }
GetPaintRect()96 	PaintRect   GetPaintRect() const                         { return lbl.paintrect; }
GetText()97 	String      GetText() const                              { return lbl.text; }
GetFont()98 	Font        GetFont() const                              { return lbl.font; }
GetInk()99 	Color       GetInk() const                               { return lbl.ink; }
100 
101 	Size        PaintLabel(Ctrl *ctrl, Draw& w, const Rect& r,
102 	                       bool disabled = false, bool push = false, bool focus = false, bool vak = true);
103 	Size        PaintLabel(Ctrl *ctrl, Draw& w, int x, int y, int cx, int cy,
104 	                       bool disabled = false, bool push = false, bool focus = false, bool vak = true);
105 	Size        PaintLabel(Draw& w, const Rect& r,
106 	                       bool disabled = false, bool push = false, bool focus = false, bool vak = true);
107 	Size        PaintLabel(Draw& w, int x, int y, int cx, int cy,
108 	                       bool disabled = false, bool push = false, bool focus = false, bool vak = true);
109 	Size        GetLabelSize() const;
110 
111 	virtual ~LabelBase();
112 };
113 
114 Rect LookMargins(const Rect& r, const Value& ch);
115 
116 class ActiveEdgeFrame : public CtrlFrame {
117 public:
118 	virtual void FrameLayout(Rect& r);
119 	virtual void FramePaint(Draw& w, const Rect& r);
120 	virtual void FrameAddSize(Size& sz);
121 
122 private:
123 	const Value *edge;
124 	const Ctrl  *ctrl;
125 	Value coloredge;
126 	Color color;
127 	bool  mousein = false;
128 	bool  push = false;
129 	bool  button = false;
130 
131 public:
132 	void Set(const Ctrl *ctrl, const Value *edge, bool active);
Mouse(bool in)133 	void Mouse(bool in)                     { mousein = in; }
Push(bool b)134 	void Push(bool b)                       { button = true; push = b; }
SetColor(const Value & ce,Color c)135 	void SetColor(const Value& ce, Color c) { coloredge = ce; color = c; }
136 
ActiveEdgeFrame()137 	ActiveEdgeFrame() { edge = NULL; mousein = false; }
138 };
139