00001
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _MGUI_MINIGUI_H
00031 #define _MGUI_MINIGUI_H
00032
00033 #include <stdio.h>
00034
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif
00038
00053 #ifdef WIN32
00054 extern MG_EXPORT HWND __mg_ime_wnd;
00055 #endif
00056
00057 extern MG_EXPORT RECT g_rcScr;
00058
00059 #if defined(_LITE_VERSION) && !defined(_STAND_ALONE)
00060
00071 extern MG_EXPORT RECT g_rcDesktop;
00072
00073 #else
00074 #define g_rcDesktop g_rcScr
00075 #endif
00076
00084 #if defined(_LITE_VERSION) && !defined(_STAND_ALONE)
00085
00086 #include <sys/types.h>
00087
00095 extern MG_EXPORT BOOL mgIsServer;
00096
00106 extern MG_EXPORT void* mgSharedRes;
00107
00116 extern MG_EXPORT size_t mgSizeRes;
00117
00122 #define LEN_LAYER_NAME 14
00123
00128 #define LEN_CLIENT_NAME 14
00129
00134 #define INV_LAYER_HANDLE 0
00135
00136 struct _MG_Layer;
00137
00139 typedef struct _MG_Client
00140 {
00142 char name [LEN_CLIENT_NAME + 1];
00143
00145 pid_t pid;
00147 uid_t uid;
00149 int fd;
00150
00152 RECT rc;
00154 DWORD last_live_time;
00156 DWORD dwAddData;
00157
00159 struct _MG_Client* next;
00161 struct _MG_Client* prev;
00162
00164 struct _MG_Layer* layer;
00165
00167 struct GlobalRes* global_res;
00168 } MG_Client;
00169
00170 struct _CLIPRGN;
00171
00173 typedef struct _MG_Layer
00174 {
00176 char name [LEN_LAYER_NAME + 1];
00177
00179 MG_Client* cli_head;
00181 MG_Client* cli_active;
00183 DWORD dwAddData;
00184
00186 struct _MG_Layer* next;
00188 struct _MG_Layer* prev;
00189
00191 struct _CLIPRGN* spare_rects;
00192 } MG_Layer;
00193
00200 extern MG_EXPORT int mgClientSize;
00201
00212 extern MG_EXPORT MG_Client* mgClients;
00213
00220 extern MG_EXPORT MG_Layer* mgTopmostLayer;
00221
00228 extern MG_EXPORT MG_Layer* mgLayers;
00229
00230 #endif
00231
00244 MG_EXPORT int GUIAPI InitGUI (int, const char **);
00245
00253 MG_EXPORT void GUIAPI TerminateGUI (int rcByGUI);
00254
00264 MG_EXPORT void GUIAPI MiniGUIPanic (int exitcode);
00265
00281 #ifdef _LITE_VERSION
00282
00305 #define MAX_NR_LISTEN_FD 5
00306
00333 MG_EXPORT BOOL GUIAPI RegisterListenFD (int fd, int type,
00334 HWND hwnd, void* context);
00335
00350 MG_EXPORT BOOL GUIAPI UnregisterListenFD (int fd);
00351
00354 #ifdef _STAND_ALONE
00355
00356 #define SetDesktopRect(lx, ty, rx, by) {}
00357
00358 #else
00359
00377 #define NAME_SELF_LAYER ""
00378
00383 #define NAME_TOPMOST_LAYER ""
00384
00389 #define NAME_DEF_LAYER "mginit"
00390
00429 MG_EXPORT GHANDLE GUIAPI JoinLayer (const char* layer_name,
00430 const char* client_name, int lx, int ty, int rx, int by);
00431
00432 #define SetDesktopRect(lx, ty, rx, by) \
00433 JoinLayer ("", "", lx, ty, rx, by)
00434
00453 MG_EXPORT void GUIAPI GetDesktopRect (int* lx, int* ty, int* rx, int* by);
00454
00455 #define NAME_SELF_LAYER ""
00456
00480 MG_EXPORT GHANDLE GUIAPI GetLayerInfo (const char* layer_name, RECT* max_rect,
00481 int* nr_clients, BOOL* is_topmost, int* cli_active);
00482
00494 MG_EXPORT BOOL GUIAPI BringLayer2Topmost (GHANDLE handle);
00495
00508 MG_EXPORT BOOL GUIAPI SetActiveClient (int active);
00509
00530 #define LCO_NEW_CLIENT 1
00531
00536 #define LCO_DEL_CLIENT 2
00537
00544 typedef void (* ON_NEW_DEL_CLIENT) (int op, int cli);
00545
00551 #define LCO_NEW_LAYER 1
00552
00557 #define LCO_DEL_LAYER 2
00558
00563 #define LCO_JOIN_CLIENT 3
00564
00569 #define LCO_REMOVE_CLIENT 4
00570
00575 #define LCO_TOPMOST_CHANGED 5
00576
00581 #define LCO_ACTIVE_CHANGED 6
00582
00590 typedef void (* ON_CHANGE_LAYER) (int op, MG_Layer* layer,
00591 MG_Client* client);
00592
00616 extern MG_EXPORT ON_NEW_DEL_CLIENT OnNewDelClient;
00617
00647 extern MG_EXPORT ON_CHANGE_LAYER OnChangeLayer;
00648
00671 static inline BOOL SetClientScreen (int lx, int ty, int rx, int by)
00672 {
00673 return TRUE;
00674 }
00675
00694 MG_EXPORT BOOL GUIAPI OnlyMeCanDraw (void);
00695
00709 MG_EXPORT BOOL GUIAPI ClientCanDrawNowEx (BOOL bRepaint, const RECT* invrc);
00710
00724 #define ClientCanDrawNow() ClientCanDrawNowEx (TRUE, NULL)
00725
00736 MG_EXPORT void GUIAPI UpdateTopmostLayer (const RECT* dirty_rc);
00737
00752 MG_EXPORT BOOL GUIAPI SetTopMostClient (int cli);
00753
00767 MG_EXPORT BOOL GUIAPI SetTopMostLayer (MG_Layer* layer);
00768
00781 MG_EXPORT int GUIAPI GetClientByPID (int pid);
00782
00820 #define MAX_SYS_REQID 0x0011
00821
00828 #define MAX_REQID 0x0018
00829
00831 typedef struct _REQUEST {
00833 int id;
00835 const void* data;
00837 size_t len_data;
00838 } REQUEST;
00840 typedef REQUEST* PREQUEST;
00841
00860 int ClientRequest (PREQUEST request, void* result, int len_rslt);
00861
00873 int get_sock_fd2srv (void);
00874
00892 int GUIAPI ServerSendReply (int clifd, const void* reply, int len);
00893
00900 typedef int (* REQ_HANDLER)(int cli, int clifd, void* buff, size_t len);
00901
00920 MG_EXPORT BOOL GUIAPI RegisterRequestHandler (int req_id,
00921 REQ_HANDLER your_handler);
00922
00937 MG_EXPORT REQ_HANDLER GUIAPI GetRequestHandler (int req_id);
00938
00973 int serv_listen (const char* name);
00974
00995 int serv_accept (int listenfd, pid_t *pidptr, uid_t *uidptr);
00996
01017 int cli_conn (const char* name, char project);
01018
01019 #define SOCKERR_IO -1
01020 #define SOCKERR_CLOSED -2
01021 #define SOCKERR_INVARG -3
01022 #define SOCKERR_TIMEOUT -4
01023 #define SOCKERR_OK 0
01024
01053 int sock_write_t (int fd, const void* buff,
01054 int count, unsigned int timeout);
01055
01083 int sock_read_t (int fd, void* buff, int count, unsigned int timeout);
01084
01091 #define sock_write(fd, buff, count) sock_write_t(fd, buff, count, 0)
01092
01099 #define sock_read(fd, buff, count) sock_read_t(fd, buff, count, 0)
01100
01105 #endif
01106 #endif
01107
01141 MG_EXPORT BOOL GUIAPI ReinitDesktopEx (BOOL init_sys_text);
01142
01154 #define ReinitDesktop() ReinitDesktopEx (TRUE)
01155
01156
01157
01158
01159
01160
01161
01162
01177 MG_EXPORT void GUIAPI ExitGUISafely (int exitcode);
01178
01179 #ifdef _USE_MINIGUIENTRY
01180 #define main_entry minigui_entry
01181 int minigui_entry (int args, const char* arg[]);
01182 #else
01183 #define main_entry main
01184 #endif
01185
01203 #define MiniGUIMain \
01204 MiniGUIAppMain (int args, const char* argv[]); \
01205 int main_entry (int args, const char* argv[]) \
01206 { \
01207 int iRet = 0; \
01208 if (InitGUI (args, argv) != 0) { \
01209 return 1; \
01210 } \
01211 iRet = MiniGUIAppMain (args, argv); \
01212 TerminateGUI (iRet); \
01213 return iRet; \
01214 } \
01215 int MiniGUIAppMain
01216
01223 #define IDM_DTI_FIRST (300)
01224
01225 #ifndef _LITE_VERSION
01226
01227
01228
01229
01245 MG_EXPORT typedef void GUIAPI (*CustomizeDesktopMenuFunc)(HMENU hDesktopMenu,
01246 int iPos);
01247
01260 MG_EXPORT typedef int GUIAPI (*CustomDesktopCommandFunc)(int id);
01261
01267 extern MG_EXPORT CustomizeDesktopMenuFunc CustomizeDesktopMenu;
01268
01274 extern MG_EXPORT CustomDesktopCommandFunc CustomDesktopCommand;
01275 #endif
01276
01284 #ifdef _MISC_MOUSECALIBRATE
01285
01311 MG_EXPORT BOOL GUIAPI SetMouseCalibrationParameters (const POINT* src_pts,
01312 const POINT* dst_pts);
01313
01314 #endif
01315
01322 #ifdef _MISC_ABOUTDLG
01323 #ifndef _LITE_VERSION
01324 MG_EXPORT void GUIAPI OpenAboutDialog (void);
01325 #else
01326
01344 MG_EXPORT HWND GUIAPI OpenAboutDialog (HWND hHosting);
01345 #endif
01346 #endif
01347
01397 #define ETC_MAXLINE 1024
01398
01403 #define ETC_FILENOTFOUND -1
01404
01408 #define ETC_SECTIONNOTFOUND -2
01409
01413 #define ETC_KEYNOTFOUND -3
01414
01418 #define ETC_TMPFILEFAILED -4
01419
01423 #define ETC_FILEIOFAILED -5
01424
01428 #define ETC_INTCONV -6
01429
01433 #define ETC_INVALIDOBJ -7
01434
01438 #define ETC_READONLYOBJ -8
01439
01443 #define ETC_OK 0
01444
01446 typedef struct _ETCSECTION
01447 {
01449 int key_nr_alloc;
01451 int key_nr;
01453 char *name;
01455 char** keys;
01457 char** values;
01458 } ETCSECTION;
01460 typedef ETCSECTION* PETCSECTION;
01461
01463 typedef struct _ETC_S
01464 {
01466 int sect_nr_alloc;
01468 int section_nr;
01470 PETCSECTION sections;
01471 } ETC_S;
01472
01473 #ifndef _INCORE_RES
01474
01490 extern MG_EXPORT char ETCFILEPATH [];
01491
01492 #endif
01493
01524 MG_EXPORT int GUIAPI GetValueFromEtcFile (const char* pEtcFile,
01525 const char* pSection, const char* pKey, char* pValue, int iLen);
01526
01564 MG_EXPORT int GUIAPI GetIntValueFromEtcFile (const char* pEtcFile,
01565 const char* pSection, const char* pKey, int* value);
01566
01592 MG_EXPORT int GUIAPI SetValueToEtcFile (const char* pEtcFile,
01593 const char* pSection, const char* pKey, char* pValue);
01594
01619 MG_EXPORT int GUIAPI SaveSectionToEtcFile (const char* pEtcFile,
01620 PETCSECTION psect);
01621
01642 MG_EXPORT int GUIAPI RemoveSectionInEtcFile (const char* pEtcFile,
01643 const char* pSection);
01644
01659 MG_EXPORT GHANDLE GUIAPI LoadEtcFile (const char * pEtcFile);
01660
01678 MG_EXPORT int GUIAPI SaveEtcToFile (GHANDLE hEtc, const char* file_name);
01679
01693 MG_EXPORT int GUIAPI UnloadEtcFile (GHANDLE hEtc);
01694
01723 MG_EXPORT int GUIAPI GetValueFromEtc (GHANDLE hEtc, const char* pSection,
01724 const char* pKey, char* pValue, int iLen);
01725
01733 MG_EXPORT int GUIAPI GetIntValueFromEtc (GHANDLE hEtc, const char* pSection,
01734 const char* pKey, int* pValue);
01735
01746 #define SetValueToEtc(hEtc, pSection, pKey, pValue) \
01747 GetValueFromEtc(hEtc, pSection, pKey, pValue, -1)
01748
01766 MG_EXPORT GHANDLE GUIAPI FindSectionInEtc (GHANDLE hEtc,
01767 const char* pSection, BOOL bCreateNew);
01768
01794 MG_EXPORT int GUIAPI GetValueFromEtcSec (GHANDLE hSect,
01795 const char* pKey, char* pValue, int iLen);
01796
01820 MG_EXPORT int GUIAPI GetIntValueFromEtcSec (GHANDLE hSect,
01821 const char* pKey, int* pValue);
01822
01833 MG_EXPORT int GUIAPI SetValueToEtcSec (GHANDLE hSect,
01834 const char* pKey, char* pValue);
01835
01856 MG_EXPORT int GUIAPI RemoveSectionInEtc (GHANDLE hEtc, const char* pSection);
01857
01858
01859 extern MG_EXPORT GHANDLE hMgEtc;
01860
01870 static inline int GetMgEtcValue(const char* pSection,
01871 const char *pKey, char *pValue, int iLen)
01872 {
01873 #ifndef _INCORE_RES
01874 if (!hMgEtc)
01875 return GetValueFromEtcFile (ETCFILEPATH, pSection, pKey, pValue, iLen);
01876 #endif
01877
01878 return GetValueFromEtc (hMgEtc, pSection, pKey, pValue, iLen);
01879 }
01880
01890 static inline int GetMgEtcIntValue (const char *pSection,
01891 const char* pKey, int *value)
01892 {
01893 #ifndef _INCORE_RES
01894 if (!hMgEtc)
01895 return GetIntValueFromEtcFile (ETCFILEPATH, pSection, pKey, value);
01896 #endif
01897
01898 return GetIntValueFromEtc (hMgEtc, pSection, pKey, value);
01899 }
01900
01903 #ifdef _CLIPBOARD_SUPPORT
01904
01914 #define LEN_CLIPBOARD_NAME 15
01915
01919 #define NR_CLIPBOARDS 4
01920
01925 #define CBNAME_TEXT ("text")
01926
01932 #define CBERR_OK 0
01933
01938 #define CBERR_BADNAME 1
01939
01944 #define CBERR_NOMEM 2
01945
01950 #define CBOP_NORMAL 0
01951
01955 #define CBOP_APPEND 1
01956
01974 MG_EXPORT int GUIAPI CreateClipBoard (const char* cb_name, size_t size);
01975
01989 MG_EXPORT int GUIAPI DestroyClipBoard (const char* cb_name);
01990
02014 MG_EXPORT int GUIAPI SetClipBoardData (const char* cb_name,
02015 void* data, size_t n, int cbop);
02016
02029 MG_EXPORT size_t GUIAPI GetClipBoardDataLen (const char* cb_name);
02030
02046 MG_EXPORT size_t GUIAPI GetClipBoardData (const char* cb_name,
02047 void* data, size_t n);
02048
02066 MG_EXPORT int GUIAPI GetClipBoardByte (const char* cb_name,
02067 int index, unsigned char* byte);
02068
02071 #endif
02072
02083 MG_EXPORT void GUIAPI Ping (void);
02084
02090 #define Beep Ping
02091
02106 MG_EXPORT void GUIAPI Tone (int frequency_hz, int duration_ms);
02107
02115 MG_EXPORT void* GUIAPI GetOriginalTermIO (void);
02116
02150 MG_EXPORT char* GUIAPI FixStrAlloc (int len);
02151
02169 MG_EXPORT char* GUIAPI FixStrDup (const char* str);
02170
02183 MG_EXPORT void GUIAPI FreeFixStr (char* str);
02184
02192 #ifndef _CURSOR_SUPPORT
02193 static inline void do_nothing (void) { return; }
02194 #endif
02195
02196 #ifdef _CURSOR_SUPPORT
02197
02214 HCURSOR GUIAPI LoadCursorFromFile (const char* filename);
02215
02232 HCURSOR GUIAPI LoadCursorFromMem (const void* area);
02233
02259 HCURSOR GUIAPI CreateCursor (int xhotspot, int yhotspot, int w, int h,
02260 const BYTE* pANDBits, const BYTE* pXORBits, int colornum);
02261
02272 BOOL GUIAPI DestroyCursor (HCURSOR hcsr);
02273
02332 MG_EXPORT HCURSOR GUIAPI GetSystemCursor (int csrid);
02333
02342 MG_EXPORT HCURSOR GUIAPI GetCurrentCursor (void);
02343 #else
02344 #define LoadCursorFromFile(filename) (do_nothing(), 0)
02345 #define CreateCursor(x, y, w, h, ANDbs, XORbs, cr) (do_nothing(), 0)
02346 #define DestroyCursor(hcsr) (do_nothing(), 0)
02347 #define GetSystemCursor(csrid) (do_nothing(), 0)
02348 #define GetCurrentCursor() (do_nothing(), 0)
02349 #endif
02350
02351 #define MAX_SYSCURSORINDEX 22
02352
02353
02355 #define IDC_ARROW 0
02356
02357 #define IDC_IBEAM 1
02358
02359 #define IDC_PENCIL 2
02360
02361 #define IDC_CROSS 3
02362
02363 #define IDC_MOVE 4
02364
02365 #define IDC_SIZENWSE 5
02366
02367 #define IDC_SIZENESW 6
02368
02369 #define IDC_SIZEWE 7
02370
02371 #define IDC_SIZENS 8
02372
02373 #define IDC_UPARROW 9
02374
02375 #define IDC_NONE 10
02376
02377 #define IDC_HELP 11
02378
02379 #define IDC_BUSY 12
02380
02381 #define IDC_WAIT 13
02382
02383 #define IDC_RARROW 14
02384
02385 #define IDC_COLOMN 15
02386
02387 #define IDC_ROW 16
02388
02389 #define IDC_DRAG 17
02390
02391 #define IDC_NODROP 18
02392
02393 #define IDC_HAND_POINT 19
02394
02395 #define IDC_HAND_SELECT 20
02396
02397 #define IDC_SPLIT_HORZ 21
02398
02399 #define IDC_SPLIT_VERT 22
02400
02412 MG_EXPORT void GUIAPI ClipCursor (const RECT* prc);
02413
02424 MG_EXPORT void GUIAPI GetClipCursor (RECT* prc);
02425
02438 MG_EXPORT void GUIAPI GetCursorPos (POINT* ppt);
02439
02453 MG_EXPORT void GUIAPI SetCursorPos (int x, int y);
02454
02455 #ifdef _CURSOR_SUPPORT
02456
02474 MG_EXPORT HCURSOR GUIAPI SetCursorEx (HCURSOR hcsr, BOOL set_def);
02475
02490 #define SetCursor(hcsr) SetCursorEx (hcsr, FALSE)
02491
02507 #define SetDefaultCursor(hcsr) SetCursorEx (hcsr, TRUE)
02508
02519 MG_EXPORT HCURSOR GUIAPI GetDefaultCursor (void);
02520
02521 #else
02522 #define SetCursorEx(hcsr, set_def) (do_nothing(), 0)
02523 #define SetCursor(hcsr) (do_nothing(), 0)
02524 #define SetDefaultCursor(hcsr) (do_nothing(), 0)
02525 #define GetDefaultCursor() (do_nothing(), 0)
02526 #endif
02527
02528 #ifdef _CURSOR_SUPPORT
02529
02544 MG_EXPORT int GUIAPI ShowCursor (BOOL fShow);
02545 #else
02546 #define ShowCursor(fShow) (do_nothing(), 0)
02547 #endif
02548
02581 MG_EXPORT BOOL GUIAPI GetKeyStatus (UINT uKey);
02582
02623 MG_EXPORT DWORD GUIAPI GetShiftKeyStatus (void);
02624
02651 MG_EXPORT const char* GetSysText (const char* text);
02652
02691 extern MG_EXPORT const char* SysText [];
02692
02704 extern MG_EXPORT const char** local_SysText;
02705
02706
02727 MG_EXPORT char* strnchr (const char* s, size_t n, int c);
02728
02745 MG_EXPORT int substrlen (const char* text, int len, char delimiter,
02746 int* nr_delim);
02747
02760 MG_EXPORT char * strtrimall (char* src);
02761
02762
02769 #ifdef __cplusplus
02770 }
02771 #endif
02772
02773 #endif
02774