00001
00007 #ifndef __LGI_OS_DEFS_H
00008 #define __LGI_OS_DEFS_H
00009
00010 #include <string.h>
00011 #include "assert.h"
00012 #include "LgiDefs.h"
00013 #include <stdarg.h>
00014 #include <stdlib.h>
00015 #include <stdio.h>
00016 #ifdef WIN32
00017 #define WIN32_LEAN_AND_MEAN
00018 #include "windows.h"
00019 #include "winsock2.h"
00020 #include "ShellAPI.h"
00021 #define WIN32GTK 1
00022 #define WIN32NATIVE 0
00023 #else
00024 #define _MULTI_THREADED
00025 #include <pthread.h>
00026 #define LINUX 1
00027 #define XP_CTRLS 1
00028 #define POSIX 1
00029 #endif
00030
00031 #undef stricmp
00032
00033 #include "LgiInc.h"
00034 namespace Gtk {
00035 #include <gtk/gtk.h>
00036 #ifdef WIN32
00037 #include <gdk/gdkwin32.h>
00038 #endif
00039 }
00040
00041
00042
00043 #undef Status
00044 #undef Success
00045 #undef None
00046 #undef Above
00047 #undef Below
00048
00049 #define XStatus int
00050 #define XSuccess 0
00051 #define XAbove 0
00052 #define XBelow 1
00053 #define XNone 0L
00054
00055 class LgiClass OsAppArguments
00056 {
00057 struct OsAppArgumentsPriv *d;
00058
00059 public:
00060 int Args;
00061 char **Arg;
00062
00063 OsAppArguments(int args, char **arg);
00064 ~OsAppArguments();
00065
00066 void Set(char *CmdLine);
00067 OsAppArguments &operator =(OsAppArguments &a);
00068 };
00069
00070
00071 #ifdef WIN32
00072 typedef HANDLE OsProcess;
00073 #else
00074 typedef int OsProcess;
00075 #endif
00076 typedef int OsProcessId;
00077 typedef Gtk::GtkWidget *OsView;
00078 typedef Gtk::GtkWindow *OsWindow;
00079 typedef char OsChar;
00080 typedef Gtk::GdkGC *OsPainter;
00081 typedef Gtk::PangoFontDescription *OsFont;
00082 typedef void *OsBitmap;
00083
00084 class OsApplication
00085 {
00086 class OsApplicationPriv *d;
00087
00088 protected:
00089 static OsApplication *Inst;
00090
00091 public:
00092 OsApplication(int Args, char **Arg);
00093 ~OsApplication();
00094
00095 static OsApplication *GetInst() { LgiAssert(Inst); return Inst; }
00096 };
00097
00098 #define XcbConn() (OsApplication::GetInst()->GetConn())
00099 #define XcbScreen() (OsApplication::GetInst()->GetScreen())
00100 #define XcbCheck(cookie) (OsApplication::GetInst()->Check(cookie, __FILE__, __LINE__))
00101 #ifdef _DEBUG
00102 #define XcbDebug(cookie) (OsApplication::GetInst()->Check(cookie, __FILE__, __LINE__))
00103 #else
00104 #define XcbDebug(cookie) cookie
00105 #endif
00106
00107 class LgiClass GMessage
00108 {
00109 public:
00110 typedef int Param;
00111 bool OwnEvent;
00112 Gtk::GdkEvent *Event;
00113
00114 GMessage(int m, Param a = 0, Param b = 0);
00115 ~GMessage();
00116
00117 int Type();
00118 Param A();
00119 Param B();
00120 void Set(int m, Param a, Param b);
00121 bool Send(OsView Wnd);
00122 };
00123
00124 #define MsgCode(Msg) Msg->Type()
00125 #define MsgA(Msg) Msg->A()
00126 #define MsgB(Msg) Msg->B()
00127
00128
00129 #ifdef WIN32
00130 typedef HANDLE OsThread;
00131 typedef DWORD OsThreadId;
00132 typedef CRITICAL_SECTION OsSemaphore;
00133 #define LgiGetCurrentThread() GetCurrentThreadId()
00134 #else
00135 typedef pthread_t OsThread;
00136 typedef pthread_t OsThreadId;
00137 typedef pthread_mutex_t OsSemaphore;
00138 #define LgiGetCurrentThread() pthread_self()
00139 #endif
00140
00141
00142 #define ValidSocket(s) ((s)>=0)
00143 #ifndef WIN32
00144 #define INVALID_SOCKET -1
00145 #endif
00146 typedef int OsSocket;
00147
00149 #ifdef WIN32
00150 LgiFunc void LgiSleep(DWORD i);
00151 #else
00152 #define LgiSleep(i) _lgi_sleep(i)
00153 LgiFunc void _lgi_sleep(int i);
00154 #endif
00155
00156 #ifndef WIN32
00157 #define atoi64 atoll
00158 #else
00159 #define atoi64 _atoi64
00160 #endif
00161
00162 #define _snprintf snprintf
00163 #define _vsnprintf vsnprintf
00164
00166 #define LgiYield() LgiApp->Run(false)
00167
00168 #define K_CHAR 0x0
00169
00171 #define LGI_FileDropFormat "text/uri-list"
00172 #define LGI_IllegalFileNameChars "\t\r\n/\\:*?\"<>|"
00173 #define LGI_WideCharset "utf-32"
00174 #define LGI_PrintfInt64 "%Li"
00175
00176 #ifndef SND_ASYNC
00177 #define SND_ASYNC 1
00178 #endif
00179
00180 #define DOUBLE_CLICK_THRESHOLD 5
00181 #define DOUBLE_CLICK_TIME 400
00182
00183
00184 #define GWF_VISIBLE 0x00000001
00185 #define GWF_DISABLED 0x00000002
00186 #define GWF_FOCUS 0x00000004
00187 #define GWF_OVER 0x00000008
00188 #define GWF_DROP_TARGET 0x00000010
00189 #define GWF_SUNKEN 0x00000020
00190 #define GWF_FLAT 0x00000040
00191 #define GWF_RAISED 0x00000080
00192 #define GWF_BORDER 0x00000100
00193 #define GWF_DIALOG 0x00000200
00194 #define GWF_DESTRUCTOR 0x00000400
00195 #define GWF_QUIT_WND 0x00000800
00196
00197
00198 #ifndef WIN32
00199 #define ODS_SELECTED 0x1
00200 #define ODS_DISABLED 0x2
00201 #define ODS_CHECKED 0x4
00202 #endif
00203
00205 #define SUNKEN 1
00207 #define RAISED 2
00209 #define CHISEL 3
00211 #define FLAT 4
00212
00213 #ifdef WIN32
00215 #define DIR_CHAR '\\'
00217 #define DIR_STR "\\"
00219 #define LGI_PATH_SEPARATOR ";"
00221 #define LGI_ALL_FILES "*.*"
00223 #define LGI_LIBRARY_EXT "dll"
00224 #else
00226 #define DIR_CHAR '/'
00228 #define DIR_STR "/"
00230 #define LGI_PATH_SEPARATOR ":"
00232 #define LGI_ALL_FILES "*"
00234 #define LGI_LIBRARY_EXT "so"
00235 #endif
00237 #define EOL_SEQUENCE "\n"
00239 #define IsSlash(c) (((c)=='/')OR((c)=='\\'))
00241 #define IsQuote(c) (((c)=='\"')OR((c)=='\''))
00242
00244 #define M_SYSTEM (1000)
00246 #define M_CLOSE (M_SYSTEM+1)
00248 #define M_X11_INVALIDATE (M_SYSTEM+2)
00250 #define M_X11_REPARENT (M_SYSTEM+4)
00251
00253 #define M_USER (M_SYSTEM+1000)
00254
00259 #define M_MOUSEENTER (M_USER+100)
00260
00265 #define M_MOUSEEXIT (M_USER+101)
00266
00271 #define M_CHANGE (M_USER+102)
00272
00277 #define M_DESCRIBE (M_USER+103)
00278
00279
00280 #define M_WANT_DIALOG_PROC (M_USER+104)
00281
00282 #define M_MENU (M_USER+105)
00283 #define M_COMMAND (M_USER+106)
00284 #define M_DRAG_DROP (M_USER+107)
00285
00286 #define M_TRAY_NOTIFY (M_USER+108)
00287 #define M_CUT (M_USER+109)
00288 #define M_COPY (M_USER+110)
00289 #define M_PASTE (M_USER+111)
00290 #define M_DELETE (M_USER+112)
00291 #define M_GTHREADWORK_COMPELTE (M_USER+113)
00293 #define M_PULSE (M_USER+114)
00294
00297 #define IDOK 1
00300 #define IDCANCEL 2
00303 #define IDYES 6
00306 #define IDNO 7
00307
00308 #ifndef WIN32
00311 #define MB_OK 0
00314 #define MB_OKCANCEL 1
00317 #define MB_YESNOCANCEL 3
00320 #define MB_YESNO 4
00321
00322 #define MB_SYSTEMMODAL 0x1000
00323 #endif
00324
00327 #define LGI_VKEY_CTRL 0x001
00330 #define LGI_VKEY_ALT 0x002
00333 #define LGI_VKEY_SHIFT 0x004
00334
00337 #define LGI_VMOUSE_LEFT 0x008
00340 #define LGI_VMOUSE_MIDDLE 0x010
00343 #define LGI_VMOUSE_RIGHT 0x020
00346 #define LGI_VMOUSE_CTRL 0x040
00349 #define LGI_VMOUSE_ALT 0x080
00352 #define LGI_VMOUSE_SHIFT 0x100
00355 #define LGI_VMOUSE_DOWN 0x200
00358 #define LGI_VMOUSE_DOUBLE 0x400
00359
00360
00361 #define abs(a) ( (a) < 0 ? -(a) : (a) )
00362
00363 #ifndef WIN32
00364 typedef enum {
00365
00366 VK_UNKNOWN = 0,
00367 VK_FIRST = 0,
00368 VK_BACKSPACE = 0xff08,
00369 VK_TAB = 0xff09,
00370 VK_CLEAR = 12,
00371 VK_RETURN = 0xff0d,
00372 VK_PAUSE = 19,
00373 VK_ESCAPE = 0xff1b,
00374 VK_SPACE = 32,
00375 VK_EXCLAIM = 33,
00376 VK_QUOTEDBL = 34,
00377 VK_HASH = 35,
00378 VK_DOLLAR = 36,
00379 VK_AMPERSAND = 38,
00380 VK_QUOTE = 39,
00381 VK_LEFTPAREN = 40,
00382 VK_RIGHTPAREN = 41,
00383 VK_ASTERISK = 42,
00384 VK_PLUS = 43,
00385 VK_COMMA = 44,
00386 VK_MINUS = 45,
00387 VK_PERIOD = 46,
00388 VK_SLASH = 47,
00389 VK_0 = 48,
00390 VK_1 = 49,
00391 VK_2 = 50,
00392 VK_3 = 51,
00393 VK_4 = 52,
00394 VK_5 = 53,
00395 VK_6 = 54,
00396 VK_7 = 55,
00397 VK_8 = 56,
00398 VK_9 = 57,
00399 VK_COLON = 58,
00400 VK_SEMICOLON = 59,
00401 VK_LESS = 60,
00402 VK_EQUALS = 61,
00403 VK_GREATER = 62,
00404 VK_QUESTION = 63,
00405 VK_AT = 64,
00406
00407
00408
00409 VK_LEFTBRACKET = 91,
00410 VK_BACKSLASH = 92,
00411 VK_RIGHTBRACKET = 93,
00412 VK_CARET = 94,
00413 VK_UNDERSCORE = 95,
00414 VK_BACKQUOTE = 96,
00415 VK_a = 97,
00416 VK_b = 98,
00417 VK_c = 99,
00418 VK_d = 100,
00419 VK_e = 101,
00420 VK_f = 102,
00421 VK_g = 103,
00422 VK_h = 104,
00423 VK_i = 105,
00424 VK_j = 106,
00425 VK_k = 107,
00426 VK_l = 108,
00427 VK_m = 109,
00428 VK_n = 110,
00429 VK_o = 111,
00430 VK_p = 112,
00431 VK_q = 113,
00432 VK_r = 114,
00433 VK_s = 115,
00434 VK_t = 116,
00435 VK_u = 117,
00436 VK_v = 118,
00437 VK_w = 119,
00438 VK_x = 120,
00439 VK_y = 121,
00440 VK_z = 122,
00441
00442
00443
00444 VK_KP_ENTER = 0xff8d,
00445 VK_KP7 = 0xff95,
00446 VK_KP4 = 0xff96,
00447 VK_KP8 = 0xff97,
00448 VK_KP6 = 0xff98,
00449 VK_KP2 = 0xff99,
00450 VK_KP9 = 0xff9a,
00451 VK_KP3 = 0xff9b,
00452 VK_KP1 = 0xff9c,
00453 VK_KP5 = 0xff9d,
00454 VK_KP0 = 0xff9e,
00455 VK_KP_PERIOD = 0xff9f,
00456 VK_KP_MULTIPLY = 0xffaa,
00457 VK_KP_PLUS = 0xffab,
00458 VK_KP_MINUS = 0xffad,
00459 VK_KP_DIVIDE = 0xffaf,
00460 VK_KP_EQUALS = 0xffbd,
00461
00462
00463 VK_HOME = 0xff50,
00464 VK_LEFT = 0xff51,
00465 VK_UP = 0xff52,
00466 VK_RIGHT = 0xff53,
00467 VK_DOWN = 0xff54,
00468 VK_PAGEUP = 0xff55,
00469 VK_PAGEDOWN = 0xff56,
00470 VK_END = 0xff57,
00471 VK_INSERT = 0xff63,
00472
00473
00474 VK_F1 = 0xffbe,
00475 VK_F2,
00476 VK_F3,
00477 VK_F4,
00478 VK_F5,
00479 VK_F6,
00480 VK_F7,
00481 VK_F8,
00482 VK_F9,
00483 VK_F10,
00484 VK_F11,
00485 VK_F12,
00486 VK_F13,
00487 VK_F14,
00488 VK_F15,
00489
00490
00491 VK_NUMLOCK = 0xff7f,
00492 VK_CAPSLOCK = 0xffe5,
00493 VK_SCROLLOCK = 0xff14,
00494 VK_LSHIFT = 0xffe1,
00495 VK_RSHIFT,
00496 VK_LCTRL = 0xffe3,
00497 VK_RCTRL,
00498 VK_LALT = 0xffe9,
00499 VK_RALT,
00500 VK_LMETA = 0xffed,
00501 VK_RMETA,
00502 VK_LSUPER = 0xffeb,
00503 VK_RSUPER,
00504
00505
00506 VK_HELP = 0xff6a,
00507 VK_PRINT = 0xff61,
00508 VK_SYSREQ = 0xff15,
00509 VK_BREAK = 0xff6b,
00510 VK_MENU = 0xff67,
00511 VK_UNDO = 0xff65,
00512 VK_REDO,
00513 VK_EURO = 0x20ac,
00514 VK_COMPOSE = 0xff20,
00515 VK_MODE = 0xff7e,
00516 VK_DELETE = 0xffff,
00517 VK_POWER = 0x10000,
00518
00519
00520 VK_LAST
00521 } LgiKey;
00522 #else
00523 #define VK_BACKSPACE VK_BACK
00524 #define VK_PAGEUP VK_PRIOR
00525 #define VK_PAGEDOWN VK_NEXT
00526 #define VK_RALT VK_MENU
00527 #define VK_LALT VK_MENU
00528 #define VK_RCTRL VK_CONTROL
00529 #define VK_LCTRL VK_CONTROL
00530 #endif
00531
00533
00534 #ifndef WIN32 // __CYGWIN__
00535 LgiFunc char *strnistr(char *a, char *b, int n);
00536 LgiFunc int strnicmp(char *a, char *b, int i);
00537 LgiFunc char *strupr(char *a);
00538 LgiFunc char *strlwr(char *a);
00539 LgiFunc int stricmp(char *a, char *b);
00540 LgiFunc int stricmp(char *a, char *b);
00541 #else
00542 LgiFunc class GViewI *GWindowFromHandle(OsView hWnd);
00543 LgiFunc int GetMouseWheelLines();
00544 LgiFunc int WinPointToHeight(int Pt);
00545 LgiFunc int WinHeightToPoint(int Ht);
00546 LgiFunc char *GetWin32Folder(int Id);
00547
00548 typedef BOOL (__stdcall *pSHGetSpecialFolderPathA)(HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate);
00549 typedef BOOL (__stdcall *pSHGetSpecialFolderPathW)(HWND hwndOwner, LPWSTR lpszPath, int nFolder, BOOL fCreate);
00550 typedef int (__stdcall *pSHFileOperationA)(LPSHFILEOPSTRUCTA lpFileOp);
00551 typedef int (__stdcall *pSHFileOperationW)(LPSHFILEOPSTRUCTW lpFileOp);
00552 typedef int (__stdcall *p_vscprintf)(const char *format, va_list argptr);
00553
00554 #if _MSC_VER >= 1400
00555 #define snprintf sprintf_s
00556 #endif
00557
00558 #endif
00559
00561 LgiFunc int FormatToInt(char *s);
00563 LgiFunc char *FormatToStr(int f);
00564
00565
00566 #endif
00567