summaryrefslogtreecommitdiff
path: root/ldmicro/lib/linuxUI/linuxUI.h
blob: ed2a9615b04626a2c46193ed5b27b83b0cb343fe (plain)
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
#ifndef __LINUX_UI__
#define __LINUX_UI__

/// includes
#include <gtk/gtk.h>
#include <QApplication>
#include <QWidget>
#include <QMenu>
#include <QMenuBar>
#include <QVBoxLayout>
#include <QLabel>
#include <QPainter>
#include <QGroupBox>
#include <QSignalMapper>
#include <QKeyEvent>
#include <QScrollArea>
#include <QScrollBar>
#include <QMessageBox>
#include <QFileDialog>
#include <QStandardPaths>
#include <QPlainTextEdit>
// #include <QtGui>
// #include <QSize>
// #include "freezeLD.h"
// #include "linuxLD.h"
#include <linux/limits.h>
#include <stdio.h>
#include <inttypes.h>
#include <string.h>
#include <stdlib.h>
#include "linuxLD.h"

// 4000 ICON "ldmicro.ico"

/// version control
#define LDMicro_VERSION_MAJOR 1
#define LDMicro_VERSION_MINOR 0

// Timer IDs associated with the main window.
#define TIMER_BLINK_CURSOR      1
#define TIMER_SIMULATE          2

/// Flags
/// message box
#define MB_OK              QMessageBox::Ok
#define MB_OKCANCEL        QMessageBox::Ok | QMessageBox::Cancel
#define MB_YESNO           QMessageBox::Yes | QMessageBox::No
#define MB_YESNOCANCEL     QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel

#define IDOK      QMessageBox::Ok
#define IDCANCEL  QMessageBox::Cancel
#define IDYES     QMessageBox::Yes
#define IDNO      QMessageBox::No

#define MB_ICONERROR        QMessageBox::Critical
#define MB_ICONQUESTION     QMessageBox::Question
#define MB_ICONWARNING      QMessageBox::Warning
#define MB_ICONINFORMATION  QMessageBox::Information

/// Scroll
#define SB_LINEUP        0x00000001
#define SB_PAGEUP        0x00000002
#define SB_LINEDOWN      0x00000004
#define SB_PAGEDOWN      0x00000008
#define SB_TOP           0x00000010
#define SB_BOTTOM        0x00000020
#define SB_THUMBTRACK    0x00000040 
#define SB_THUMBPOSITION 0x00000080 

/// UART terminal flags
#define WM_GETTEXT     0x00000001
#define WM_SETTEXT     0x00000002
#define WM_SETTEXT_END 0x00000004

/// List view flags
#define LVN_ITEMACTIVATE 0x00000001
#define LVN_GETDISPINFO  0x00000002

/// Open/save file
#define OFN_PATHMUSTEXIST     0x00000001L
#define OFN_HIDEREADONLY      0x00000002L
#define OFN_OVERWRITEPROMPT   0x00000004L

/// PatBlt paint flags
#define PATINVERT 0x00000100L

/// Key masks
#define VK_TAB Qt::Key_Tab

#define VK_DOWN  Qt::Key_Down
#define VK_UP    Qt::Key_Up
#define VK_LEFT  Qt::Key_Left
#define VK_RIGHT Qt::Key_Right

#define VK_NP_DOWN  Qt::Key_Down
#define VK_NP_UP    Qt::Key_Up
#define VK_NP_LEFT  Qt::Key_Left
#define VK_NP_RIGHT Qt::Key_Right

#define VK_RETURN  Qt::Key_Return
#define VK_ESCAPE  Qt::Key_Escape
#define VK_F5 Qt::Key_F5
#define VK_F1 Qt::Key_F1

#define VK_OEM_PLUS Qt::Key_Plus
#define VK_OEM_MINUS Qt::Key_Minus
#define VK_OEM_PERIOD Qt::Key_Period
#define VK_OEM_COMMA Qt::Key_Comma

#define VK_DELETE Qt::Key_Delete 
#define VK_NP_DELETE Qt::Key_Delete

#define VK_OEM_1 Qt::Key_Colon     // GDK_KEY_semicolon
#define VK_OEM_2 Qt::Key_Question  // GDK_KEY_slash
#define VK_OEM_5 Qt::Key_Backslash // GDK_KEY_bar

/// Window brushes
#define BS_SOLID       0x00000001L
#define BS_HOLLOW      0x00000002L
#define BLACK_BRUSH    0x00000004L
#define WHITE_BRUSH    0x00000008L 
#define GRAY_BRUSH     0x00000010L
#define LTGRAY_BRUSH   0x00000020L
#define DKGRAY_BRUSH   0x00000040L

extern const COLORREF BLACK_BR;
extern const COLORREF WHITE_BR;
extern const COLORREF GRAY_BR;
extern const COLORREF LTGRAY_BR;
extern const COLORREF DKGRAY_BR;

/// Font flags
#define FW_REGULAR   0x00000001L
#define FW_BOLD      0x00000002L

/// EnableMenuItem variables
extern const UINT MF_ENABLED;
extern const UINT MF_GRAYED;
extern const UINT MF_CHECKED;
extern const UINT MF_UNCHECKED;

/// Accelerators (keyboard shortcuts)
extern GtkAccelGroup* AccelGroup;
extern GClosure* closure;
extern QGroupBox*       CursorObject;

/// ListStore
extern HWID view;
extern HTVC column;

// Timer IDs associated with the main window.
extern int CursorTimer;
extern int SimulateTimer;

/// Structures
typedef struct OpenFileInfoData {
    DWORD         lStructSize;
    HWID          parentWindow;
    LPTSTR        lpstrFile;
    LPCTSTR       lpstrFilter;
    DWORD         nMaxFile;
    LPCTSTR       lpstrTitle;
    DWORD         Flags;
    LPCTSTR       lpstrDefExt;
} OPENFILENAME;

typedef struct TimerRecordTag {
    BOOL (*pfun)(BOOL);
    UINT  ufID;
    UINT  utID;
} TimerRecord;

/******************************************************************
Class to create slots for signals

*******************************************************************/
class ProgramSlots : public QObject
{
    Q_OBJECT
    public:
    signals:
    public slots:
    void LD_WM_Command_call(int CommandCode);
};

/// Variables
extern COLORREF HdcCurrentTextColor;
extern std::vector<TimerRecord> timerRecords;
extern int GLOBAL_mouse_last_clicked_x;
extern int GLOBAL_mouse_last_clicked_y;
extern ProgramSlots MenuHandle;
/// functions
BOOL GetFocus(HWID window);

COLORREF RGB(
    int red, 
    int green, 
    int blue);

int MessageBox(
    HWID  pWindow, 
    char* message, 
    char* title, 
    UINT  mFlags,
    UINT  iFlags);

BOOL GetSaveFileName(OPENFILENAME *ofn);

BOOL GetOpenFileName(OPENFILENAME *ofn);

void EnableMenuItem(
    HMENU MenuName, 
    QAction* MenuItem, 
    UINT  CheckEnabledItem);

void EnableMenuItem(
    HMENU MenuName, 
    HMENU MenuItem, 
    UINT  CheckEnabledItem);

void CheckMenuItem(
    HMENU MenuName, 
    QAction* MenuItem, 
    UINT  Check);

HANDLE GetStockObject(int fnObject);

void SelectObject(
    HCRDC hcr, 
    HFONT hfont);

HBRUSH CreateBrushIndirect(PLOGBRUSH plb);

HFONT CreateFont(
    int     nHeight,
    int     nWidth,
    int     nOrientation,
    int     fnWeight,
    DWORD   fdwItalic,
    LPCTSTR lpszFace);

void SetBkColor(
    HWID     widget, 
    HCRDC    hcr,
    COLORREF bkCol);

void SetTextColor(
    HCRDC    hcr, 
    COLORREF color);

void TextOut(
    HWID    hWid,
    HCRDC   hcr,
    int     nXStart,
    int     nYStart,
    LPCTSTR lpString,
    int     cchString);

COLORREF GetTextColor(HCRDC Hdc);

BOOL InvalidateRect(
    HWID hWId,
    const RECT *lpRect,
    BOOL bErase);

int FillRect(
    HCRDC        hDC,
    const QRect   *lprc,
    HBRUSH       hbr);

BOOL PatBlt(
    HWID   hdc,
    int    nXLeft,
    int    nYLeft,
    int    nWidth,
    int    nHeight,
    DWORD  dwRop,
    HBRUSH hbr);

BOOL GetClientRect(
    HWID   hWid,
    PRECT lpRect);

BOOL MoveWindow(
    HWID hWid,
    int  X,
    int  Y,
    int  nWidth,
    int  nHeight,
    BOOL bRepaint);

BOOL GetWindowRect(
    HWID   hWid,
    PRECT  pRect);

UINT SetTimer(
    HWID  hWid,
    UINT  nIDEvent,
    UINT  uElapse,
    UINT TimerID);

BOOL KillTimer(
    HWID hWid,
    UINT uIDEvent);

void DestroyWindow (HWID widget);

class PaintWidget : public QWidget
{
    Q_OBJECT
public:
 //  MyWidget();
    // PaintWidget(QWidget* parent): QWidget(parent)
    // {}
 
protected:
    void paintEvent(QPaintEvent *event);
    void timerEvent(QTimerEvent *event);
signals:
 
public slots:
};

#endif