Repository navigation
Expand file tree
/
Copy pathLgiClasses.h
More file actions
198 lines (167 loc) · 5.02 KB
/
Copy pathLgiClasses.h
File metadata and controls
198 lines (167 loc) · 5.02 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/**
\file
\author Matthew Allen
\date 19/12/1997
\brief Gui class definitions
Copyright (C) 1997-2004, <a href="mailto:fret@memecode.com">Matthew Allen</a>
*/
/////////////////////////////////////////////////////////////////////////////////////
// Includes
#ifndef _LGICLASSES_H_
#define _LGICLASSES_H_
#include "lgi/common/Mutex.h"
#include "LgiOsClasses.h"
#include "lgi/common/Mem.h"
#include "lgi/common/Array.h"
#include "lgi/common/DragAndDrop.h"
/////////////////////////////////////////////////////////////////////////////////////
LgiFunc bool LPostEvent(OsView Wnd, int Event, LMessage::Param a = 0, LMessage::Param b = 0);
LgiFunc LViewI *GetNextTabStop(LViewI *v, bool Back);
class LgiClass LCommand : public LBase
{
int Flags = GWF_VISIBLE;
bool PrevValue = false;
public:
int Id = 0;
LToolButton *ToolButton = NULL;
LMenuItem *MenuItem = NULL;
LAutoPtr<LKey> Accelerator;
LString TipHelp;
LCommand();
~LCommand();
bool Enabled();
void Enabled(bool e);
bool Value();
void Value(bool v);
};
#include "lgi/common/Input.h"
#ifndef LGI_STATIC
/// \brief A BeOS style alert window, kinda like a Win32 MessageBox
///
/// The best thing about this class is you can name the buttons very specifically.
/// It's always non-intuitive to word a question to the user in such a way so thats
/// it's obvious to answer with "Ok" or "Cancel". But if the user gets a question
/// with customized "actions" as buttons they'll love you.
///
/// The button pressed is returned as a index from the DoModal() function. Starting
/// at '1'. i.e. Btn2 -> returns 2.
class LgiClass LAlert : public LDialog
{
LArray<std::function<void(int)>> Callbacks;
public:
/// Constructor
LAlert
(
/// The parent view
LViewI *parent,
/// The dialog title
const char *Title,
/// The body of the message
const char *Text,
/// The first button text
const char *Btn1,
/// The [optional] 2nd buttons text
const char *Btn2 = nullptr,
/// The [optional] 3rd buttons text
const char *Btn3 = nullptr
);
const char *GetClass() override { return "LAlert"; }
void SetAppModal();
int OnNotify(LViewI *Ctrl, const LNotification &n) override;
void SetButtonCallback(int ButtonIdx, std::function<void(int)> Callback);
void DisableBtn(int idx);
};
#endif
/// Timer class to help do something every so often
class LgiClass DoEvery
{
int64 LastTime;
int64 Period;
public:
/// Constructor
DoEvery
(
/// Timeout in ms
int p = 1000
);
/// Reset the timer
void Init
(
/// Timeout in ms
int p = -1
);
/// Returns true when the time has expired. Resets automatically.
bool DoNow();
};
//////////////////////////////////////////////////////////
// Graphics
LgiFunc void LDrawBox(LSurface *pDC, LRect &r, bool Sunken, bool Fill);
LgiFunc void LWideBorder(LSurface *pDC, LRect &r, LEdge Type);
LgiFunc void LThinBorder(LSurface *pDC, LRect &r, LEdge Type);
LgiFunc void LFlatBorder(LSurface *pDC, LRect &r, int Width = -1);
// Helpers
#ifdef __GTK_H__
extern Gtk::gboolean GtkViewCallback(Gtk::GtkWidget *widget, Gtk::GdkEvent *event, LView *This);
#endif
#ifdef LINUX
/// Ends a x windows startup session
LgiFunc void LFinishXWindowsStartup(class LViewI *Wnd);
#endif
/// \brief Displays a message box
/// \returns The button clicked. The return value is one of #IDOK, #IDCANCEL, #IDYES or #IDNO.
LgiFunc int LgiMsg
(
/// The parent view or NULL if none available
LViewI *Parent,
/// The message's text. This is a printf format string that you can pass arguments to
const char *Msg,
/// The title of the message box window
const char *Title = 0,
/// The type of buttons below the message. Can be one of:
/// #MB_OK, #MB_OKCANCEL, #MB_YESNO or #MB_YESNOCANCEL.
int Type = MB_OK,
...
);
/// This is like LgiMsg but displays the text in a scrollable view.
LgiFunc void LDialogTextMsg(LViewI *Parent, const char *Title, LString Txt);
/// Contains all the information about a display/monitor attached to the system.
/// \sa LGetDisplays
struct LDisplayInfo
{
/// The position and dimensions of the display. On windows the left/upper
/// most display will be positioned at 0,0 and each further display will have
/// co-ordinates that join to one edge of that initial rectangle.
LRect r;
/// The number of bits per pixel
int BitDepth;
/// The refresh rate
int Refresh;
/// The device's path, system specific
LString Device;
/// A descriptive name of the device, usually the video card
LString Name;
/// The name of any attached monitor
LString Monitor;
/// The dots per inch of the display
LPoint Dpi;
LDisplayInfo()
{
r.ZOff(-1, -1);
BitDepth = 0;
Refresh = 0;
}
LPointF Scale();
};
/// Returns infomation about the displays attached to the system.
/// \returns non-zero on success.
LgiFunc bool LGetDisplays
(
/// [out] The array of display info structures. The caller should free these
/// objects using Displays.DeleteObjects().
LArray<LDisplayInfo*> &Displays,
/// [out] Optional bounding rectangle of all displays. Can be NULL if your don't
/// need that information.
LRect *AllDisplays = 0
);
#include "lgi/common/Profile.h"
#endif