CMD Enhancements:
[reactos.git] / rosapps / devutils / vmingw / winui.h
1 /********************************************************************
2 * Module: winui.h. This is part of WinUI.
3 *
4 * License: WinUI is covered by GNU General Public License,
5 * Copyright (C) 2001 Manu B.
6 * See license.htm for more details.
7 *
8 ********************************************************************/
9 #ifndef WINUI_H
10 #define WINUI_H
11
12 /* These are patched headers */
13 #include "commdlg.h"
14 #include "commctrl.h"
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <time.h>
18 // OLE.
19 #include <shlobj.h>
20
21 #include "CList.h"
22
23 #define SPLSTYLE_HORZ 0
24 #define SPLSTYLE_VERT 1
25 #define SPLMODE_1 0
26 #define SPLMODE_2 1
27
28 char *StpCpy(char *dest, const char *src);
29 size_t strcpylen(char *dest, const char *src);
30
31 void SplitFileName(char * dirName, char * fileName);
32 bool ChangeFileExt(char * fileName, char * ext);
33
34 class CMessageBox
35 {
36 public:
37 CMessageBox();
38 ~CMessageBox();
39
40 void SetParent(HWND hwnd);
41 void SetCaption(char * string);
42 void DisplayString(char * string, char * substring = NULL, UINT uType = MB_OK);
43 void DisplayWarning(char * string, char * substring = NULL);
44 void DisplayFatal(char * string, char * substring = NULL);
45 void DisplayLong(long number);
46 void DisplayRect(RECT * rect);
47 int Ask(char * question, bool canCancel);
48 int AskToSave(bool canCancel);
49
50 protected:
51 HWND hParent;
52 char msgBuf[256];
53 char caption[64];
54
55 private:
56 };
57
58 class CPath
59 {
60 public:
61 CPath();
62 ~CPath();
63
64 bool ChangeDirectory(char * dir);
65
66 protected:
67
68 private:
69 char pathBuf[MAX_PATH];
70 };
71
72 class CWindow
73 {
74 public:
75 CWindow();
76 virtual ~CWindow();
77
78 virtual HWND CreateEx(CWindow * pWindow, DWORD dwExStyle,
79 LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y,
80 int nWidth, int nHeight, HMENU hMenu, LPVOID lpParam);
81
82 HWND GetId(void);
83 LONG SetLong(int nIndex, LONG dwNewLong);
84 LONG GetLong(int nIndex);
85 LRESULT SendMessage(UINT msg, WPARAM wParam = 0, LPARAM lParam = 0);
86
87 virtual bool SetPosition(HWND hInsertAfter, int x, int y, int width, int height, UINT uFlags);
88 virtual bool Show(int nCmdShow = SW_SHOWNORMAL);
89 virtual bool Hide(void);
90 HWND SetFocus(void);
91 CWindow * _pParent;
92 HWND _hWnd;
93 HINSTANCE _hInst;
94 LPVOID _lParam;
95
96 protected:
97
98 private:
99 };
100
101 class CWinBase : public CWindow
102 {
103 public:
104 CWinBase();
105 ~CWinBase();
106
107 HINSTANCE hPrevInst;
108 LPSTR lpCmdLine;
109 int nCmdShow;
110
111 char appName[64];
112 char msgBuf[256];
113 bool isWinNT;
114
115 bool Init(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
116 int nCmdShow);
117 bool SetName(char * name, char * version = NULL);
118 void ParseCmdLine(char * outBuff);
119 bool IsWinNT(void);
120
121 bool ChangeDirectory(char * dir);
122
123 protected:
124
125 private:
126 };
127
128 class CSDIBase : public CWinBase
129 {
130 public:
131 CSDIBase();
132 virtual ~CSDIBase();
133
134 virtual int Run(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
135 virtual bool CustomInit(void);
136 virtual bool Release(void);
137 virtual bool CreateUI(void);
138 bool MainRegisterEx(const char * className);
139 virtual LRESULT CALLBACK CMainWndProc(UINT Message, WPARAM wParam, LPARAM lParam);
140
141 protected:
142 WNDCLASSEX wc;
143 HACCEL hAccel;
144 char mainClass[16];
145
146 private:
147 };
148
149 class CMDIChild;
150
151 class CMDIClient : public CWindow
152 {
153 public:
154 CMDIClient();
155 ~CMDIClient();
156
157 void Init(int menuIndex, UINT idFirstChild);
158 HWND CreateEx(CWindow * pWindow, DWORD dwExStyle, DWORD dwStyle = WS_CHILD, UINT resId = 0);
159 LPARAM GetParam(LPARAM lParam);
160
161 bool initialized;
162 char childClass[16];
163 CList childList;
164
165 protected:
166 CLIENTCREATESTRUCT ccs;
167 int nPos;
168
169 private:
170 };
171
172 class UseOle
173 {
174 public:
175 UseOle(){oleError = OleInitialize(NULL);}
176 ~UseOle(){OleUninitialize();}
177 HRESULT GetError(void){return oleError;}
178 protected:
179 HRESULT oleError;
180 private:
181 };
182
183 class CMDIBase : public CSDIBase
184 {
185 public:
186 CMDIBase();
187 virtual ~CMDIBase();
188
189 virtual int Run(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
190 virtual bool CustomInit(void);
191 virtual bool Release(void);
192 virtual bool CreateUI(void);
193 bool ChildRegisterEx(const char * className);
194 virtual LRESULT CALLBACK CMainWndProc(UINT Message, WPARAM wParam, LPARAM lParam);
195 virtual LRESULT CALLBACK CChildWndProc(CWindow * pWnd, UINT Message, WPARAM wParam, LPARAM lParam);
196
197 CMDIClient MdiClient;
198
199 protected:
200 UseOle useOle;
201
202 private:
203 };
204
205 class CMDIChild : public CNode, public CWindow
206 {
207 public:
208 CMDIChild();
209 virtual ~CMDIChild();
210
211 HWND CreateEx(CMDIClient * pMdiClient, DWORD dwExStyle, DWORD dwStyle, char * caption, UINT resId = 0, LPVOID lParam = NULL);
212
213 CMDIBase * _pFrame;
214
215 protected:
216
217 private:
218 };
219
220 class CFileDlgBase : public CWindow
221 {
222 public:
223 CFileDlgBase();
224 ~CFileDlgBase();
225
226 void Reset(void);
227 void SetData(char * filter, char * defExt, DWORD flags);
228 void SetTitle(char * title);
229 void SetFilterIndex(DWORD filterIndex);
230 void SetFilter(char * filter);
231 void SetDefExt(char * defExt);
232 void SetFlags(DWORD flags);
233 void SetInitialDir(char * lpstrInitialDir);
234
235 WORD GetFileOffset(void);
236 WORD GetFileExtension(void);
237 WORD GetNextFileOffset(void);
238
239 bool OpenFileName(CWindow * pWindow, char * pszFileName, DWORD nMaxFile);
240 bool SaveFileName(CWindow * pWindow, char * pszFileName, DWORD nMaxFile);
241 OPENFILENAME ofn;
242
243 protected:
244
245 WORD nNextFileOffset;
246 private:
247 };
248
249 class CDlgBase : public CWindow
250 {
251 public:
252 CDlgBase();
253 virtual ~CDlgBase();
254
255 HWND Create(CWindow * pWindow, WORD wResId, RECT * Pos, LPARAM lParam);
256 int CreateModal(CWindow * pWindow, WORD wResId, LPARAM lParam);
257 HWND CreateParam(CWindow * pWindow, WORD wResId, LPARAM lParam);
258 BOOL EndDlg(int nResult);
259 virtual LRESULT CALLBACK CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam);
260 HWND GetItem(int nIDDlgItem);
261 BOOL SetItemText(HWND hItem, LPCTSTR lpString);
262 UINT GetItemText(HWND hItem, LPTSTR lpString, int nMaxCount);
263 /* BOOL SetItemInt(HWND hItem, UINT uValue, BOOL bSigned);
264 UINT GetItemInt(HWND hItem, BOOL *lpTranslated, BOOL bSigned);
265 */
266 protected:
267
268 private:
269 };
270
271 class CTabbedDlg : public CDlgBase
272 {
273 public:
274 CTabbedDlg();
275 virtual ~CTabbedDlg();
276
277 virtual void OnNotify(int idCtrl, LPNMHDR notify);
278 virtual void OnSelChanging(LPNMHDR notify);
279 virtual void OnSelChange(LPNMHDR notify);
280 virtual bool SetChildPosition(HWND hChild);
281
282 protected:
283 LPARAM GetParam(void);
284 HWND _hWndTab;
285 RECT Pos;
286 TCITEM tcitem;
287
288 private:
289 };
290
291 class CToolBar : public CWindow
292 {
293 public:
294 CToolBar();
295 ~CToolBar();
296
297 HWND CreateEx(CWindow * pWindow, DWORD dwExStyle, DWORD dwStyle = WS_CHILD, UINT resId = 0);
298 LRESULT AddBitmap(UINT resId, int nBmp, HINSTANCE hInstance = 0);
299 BOOL AddButtons(TBBUTTON * tbButtons, UINT numButtons);
300
301 protected:
302
303 private:
304 };
305
306 class CBitmap
307 {
308 public:
309 CBitmap();
310 ~CBitmap();
311
312 HBITMAP Load(CWindow * pWindow, LPCTSTR lpBitmapName);
313 HBITMAP Load(CWindow * pWindow, WORD wResId);
314 BOOL Destroy(void);
315
316 HBITMAP hBitmap;
317
318 protected:
319
320 private:
321 };
322
323 class CImageList
324 {
325 public:
326 CImageList();
327 ~CImageList();
328
329 HIMAGELIST Create(int cx, int cy, UINT flags, int cInitial, int cGrow);
330 int AddMasked(CBitmap * pBitmap, COLORREF crMask);
331 HIMAGELIST GetId(void){return hImgList;};
332
333 protected:
334 HIMAGELIST hImgList;
335
336 private:
337 };
338
339 class CTabCtrl : public CWindow
340 {
341 public:
342 CTabCtrl();
343 ~CTabCtrl();
344
345 HWND CreateEx(CWindow * pWindow, DWORD dwExStyle, DWORD dwStyle = WS_CHILD, UINT resId = 0, LPVOID lParam = NULL);
346 BOOL SetItem_Param(int iItem, LPARAM lParam);
347 LPARAM GetItem_Param(int iItem);
348 int GetCurSel(void);
349 int InsertItem(int iItem, UINT mask, DWORD dwState, DWORD dwStateMask,
350 LPTSTR pszText, int cchTextMax, int iImage, LPARAM lParam);
351
352 protected:
353 TCITEM tcitem;
354
355 private:
356 };
357
358 class CTreeView : public CWindow
359 {
360 public:
361 CTreeView();
362 ~CTreeView();
363
364 TVINSERTSTRUCT tvi;
365 TVITEM _TvItem;
366 HWND CreateEx(CWindow * pWindow, DWORD dwExStyle, DWORD dwStyle = WS_CHILD, UINT resId = 0, LPVOID lParam = NULL);
367 HTREEITEM CreateItem(HTREEITEM hParent, HTREEITEM hInsertAfter, int iImage, LPTSTR pszText, LPARAM lParam);
368 LPARAM GetSelectedItemParam(void);
369
370 protected:
371 private:
372 };
373
374 class CScintilla : public CWindow
375 {
376 public:
377 CScintilla();
378 ~CScintilla();
379
380 HWND CreateEx(CWindow * pWindow, DWORD dwExStyle, DWORD dwStyle = WS_CHILD, UINT resId = 0, LPVOID lParam = NULL);
381
382 protected:
383 private:
384 };
385
386 class CListView : public CWindow
387 {
388 public:
389 CListView();
390 ~CListView();
391
392 HWND CreateEx(CWindow * pWindow, DWORD dwExStyle, DWORD dwStyle = WS_CHILD, UINT resId = 0);
393 void Clear(void);
394
395 protected:
396 DWORD lastRow;
397
398 private:
399 };
400
401 class CStatusBar : public CWindow
402 {
403 public:
404 CStatusBar();
405 ~CStatusBar();
406
407 HWND CreateEx(CWindow * pWindow, DWORD dwExStyle, DWORD dwStyle = WS_CHILD, UINT resId = 0);
408 void SetParts(int nParts, int * aWidths);
409
410 void WriteString(char * string, int part);
411 void WriteLong(long number, int part);
412
413 protected:
414
415 private:
416 int numParts;
417 };
418
419 class CSplitter : public CWindow
420 {
421 public:
422 CSplitter();
423 ~CSplitter();
424
425 void Init(CWindow * pane1, CWindow * pane2, bool vertical,
426 int barPos, int barMode);
427 bool SetPosition(HWND hInsertAfter, int x, int y, int width, int height, UINT uFlags);
428 bool Show(int nCmdShow = SW_SHOWNORMAL);
429 bool Hide(void);
430 bool HaveMouse(HWND hwnd, short xPos, short yPos);
431 void Move(int mouseX, int mouseY);
432 bool OnLButtonDown(HWND hwnd, short xPos, short yPos);
433 void OnMouseMove(HWND hwnd, short xPos, short yPos);
434 void OnLButtonUp(HWND hwnd, short xPos, short yPos);
435 bool OnSetCursor(HWND hwnd, LPARAM lParam);
436
437 protected:
438 void SetVertPosition(void);
439 void SetHorzPosition(void);
440 void DrawXorBar(HDC hdc, int x1, int y1, int width, int height);
441 void ClientToWindow(HWND hwnd, POINT * pt, RECT * rect);
442
443 CWindow * Pane1;
444 CWindow * Pane2;
445 int p;
446 int size;
447 int psize;
448 bool isVertical;
449 int mode;
450 bool isActive;
451 RECT pos;
452 RECT barPos;
453 int deltaPos;
454 POINT initialXorPos;
455
456 POINT initialPos;
457 POINT newPos;
458 private:
459 bool initialized;
460 };
461
462 #define MAX_BLOC_SIZE 16384
463 class CIniFile
464 {
465 public:
466 CIniFile();
467 ~CIniFile();
468
469 bool Load(char * fullPath);
470 void Close(void);
471 bool GetString(char * data, char * key, char * section = NULL);
472 int GetInt(char * key, char * section = NULL);
473
474 protected:
475
476 private:
477
478 char * buffer;
479 char * pcurrent;
480 char * psection;
481
482 bool FindSection(char * pcurrent, char * section);
483 bool FindData(char * s, char * key, char * data);
484 long CopyData(char * data, char * s);
485 char *SkipUnwanted(char *s);
486 };
487
488 class CChrono
489 {
490 public:
491 CChrono();
492 ~CChrono();
493
494 void Start(void);
495 DWORD Stop(void);
496
497 protected:
498 DWORD _time;
499
500 private:
501 };
502
503 class CShellDlg
504 {
505 public:
506 CShellDlg();
507 ~CShellDlg();
508 bool BrowseForFolder(CWindow * pWindow, LPSTR pszDisplayName, LPCSTR lpszTitle,
509 UINT ulFlags, BFFCALLBACK lpfn=0, LPARAM lParam=0, int iImage=0);
510
511 protected:
512 IMalloc* pMalloc;
513 BROWSEINFO bi;
514
515 private:
516 };
517
518 class CCriticalSection
519 {
520 public:
521 CCriticalSection();
522 ~CCriticalSection();
523 void Enter();
524 void Leave();
525 private:
526 CRITICAL_SECTION cs;
527 };
528
529 #endif