00001
00009
00010
00011 #ifndef __GUI_H
00012 #define __GUI_H
00013
00014 #if defined BEOS
00015 #include <string.h>
00016 #endif
00017
00018 #include "GSemaphore.h"
00019 #include "GLibrary.h"
00020 #include "LgiOsClasses.h"
00021 #include "GArray.h"
00022 #include "LgiCommon.h"
00023 #include "GXmlTree.h"
00024
00025 #ifndef WIN32
00026 #include "GDragAndDrop.h"
00027 #endif
00028
00030
00031 extern long MouseWatcher(void *Ptr);
00032 extern bool _lgi_check_file(char *Path);
00033 LgiFunc bool LgiPostEvent(OsView Wnd, int Event, int a = 0, int b = 0);
00034 LgiFunc GViewI *GetNextTabStop(GViewI *v, bool Back);
00035 #if defined(MAC)
00036 LgiFunc void DumpHnd(HIViewRef v, int depth = 0);
00037 #endif
00038
00040 class LgiClass GTarget
00041 {
00042 public:
00043 virtual int OnEvent(GMessage *Msg) { return 0; }
00044 };
00045
00047 class LgiClass GViewFill
00048 {
00049 public:
00050 enum FillType
00051 {
00052 None,
00053 Solid,
00054 RefBitmap,
00055 OwnBitmap,
00056 };
00057
00058 protected:
00059 FillType Type;
00060 COLOUR c32;
00061 GSurface *pDC;
00062
00063 #ifdef WIN32
00064 HBRUSH hBrush;
00065 #endif
00066
00067 public:
00068 GViewFill(COLOUR c, int Bits = -1);
00069 GViewFill(GSurface *dc, bool Copy = true);
00070 GViewFill(const GViewFill &f);
00071 virtual ~GViewFill();
00072
00073 void Empty();
00074
00075 GViewFill &operator =(COLOUR col32)
00076 {
00077 Empty();
00078 Type = Solid;
00079 c32 = col32;
00080 return *this;
00081 }
00082
00083 void SetRgba32(int r, int g, int b, int a = 0xff)
00084 {
00085 Empty();
00086 Type = Solid;
00087 c32 = Rgba32(r, g, b, a);
00088 }
00089
00090 COLOUR GetC32()
00091 {
00092 return c32;
00093 }
00094
00095 bool IsTransparent()
00096 {
00097 return Type == Solid && A32(c32) == 0;
00098 }
00099
00100 void Fill(GSurface *pDC, GRect *r = 0, GdcPt2 *Origin = 0);
00101 #ifdef WIN32
00102 HBRUSH GetBrush();
00103 #endif
00104 };
00105
00107 #if WIN32NATIVE
00108 typedef DWORD OsProcessId;
00109 #else
00110 typedef int OsProcessId;
00111 #endif
00112
00114 #define LgiProcessId() (LgiApp->GetProcessId())
00115
00120 #define LgiApp (GApp::ObjInstance())
00121
00126 #define SysFont (LgiApp->SystemNormal)
00127
00132 #define SysBold (LgiApp->SystemBold)
00133
00137 LgiFunc void LgiExitApp();
00138
00142 #define LgiCloseApp() LgiApp->Exit(false)
00143
00145 struct GAppArguments
00146 {
00148 bool NoSkin;
00149 };
00150
00157 class LgiClass GApp : virtual public GAppI, public OsApplication
00158 {
00159 friend class GView;
00160
00161 protected:
00162
00163 class GAppPrivate *d;
00164
00165 #if defined WIN32
00166
00167 CRITICAL_SECTION StackTraceSync;
00168 friend LONG __stdcall _ExceptionFilter_Redir(LPEXCEPTION_POINTERS e);
00169 LONG __stdcall _ExceptionFilter(LPEXCEPTION_POINTERS e, char *ProductId);
00170 friend class GWin32Class;
00171 List<GWin32Class> *GetClasses();
00172
00173 #elif defined ATHEOS
00174
00175 char *_AppFile;
00176
00177 #elif defined BEOS
00178
00179 void RefsReceived(BMessage *Msg);
00180
00181 #elif defined LINUX
00182
00183 friend class GClipBoard;
00184
00185 virtual void OnEvents();
00186 void DeleteMeLater(GViewI *v);
00187 void SetClipBoardContent(OsView Hnd, GVariant &v);
00188 bool GetClipBoardContent(OsView Hnd, GVariant &v, GArray<char*> &Types);
00189
00190 #endif
00191
00192 friend class GMouseHook;
00193 static GMouseHook *MouseHook;
00194
00195 public:
00196
00197
00199 static GApp *ObjInstance();
00200 static class GSkinEngine *SkinEngine;
00201
00202
00203
00205 GFont *SystemNormal;
00206
00208 GFont *SystemBold;
00209
00211 GWindow *AppWnd;
00212
00214 bool IsOk();
00215
00217 OsProcessId GetProcessId();
00218
00220 OsThreadId GetGuiThread();
00221
00223 GApp
00224 (
00227 char *MimeType,
00229 OsAppArguments &AppArgs,
00231 GAppArguments *ObjArgs = 0
00232 );
00233
00235 virtual ~GApp();
00236
00239 char *GetName();
00240
00243 void SetName(char *Name);
00244
00246 char *GetLgiVersion() { return LGI_VER; }
00247
00249 void SetAppArgs(OsAppArguments &AppArgs);
00250
00252 OsAppArguments *GetAppArgs();
00253
00255 char *GetArgumentAt(int n);
00256
00258 bool Run
00259 (
00262 bool Loop = true,
00264 OnIdleProc IdleCallback = NULL,
00266 void *IdleParam = NULL
00267 );
00268
00270 void OnCommandLine();
00271
00273 void OnReceiveFiles(GArray<char*> &Files);
00274
00276 void Exit
00277 (
00279 int Code = 0
00280 );
00281
00284 bool GetOption
00285 (
00287 char *Option,
00289 GArray<char> &Buf
00290 );
00291
00294 bool GetOption
00295 (
00297 char *Option,
00299 char *Dst = 0,
00301 int DstSize = 0
00302 );
00303
00305 GXmlTag *GetConfig(char *Tag);
00306
00308 void SetConfig(GXmlTag *Tag);
00309
00311 GViewI *GetFocus();
00312
00315 GAutoString GetFileMimeType
00316 (
00318 char *File
00319 );
00320
00322 bool GetAppsForMimeType(char *Mime, GArray<GAppInfo*> &Apps);
00323
00325 int32 GetMetric
00326 (
00328 int Metric
00329 );
00330
00332 GMouseHook *GetMouseHook();
00333
00335 class GSymLookup *GetSymLookup();
00336
00337
00338 #if defined WIN32
00339
00340 static bool IsWin9x;
00341 HINSTANCE GetInstance();
00342 int GetShow();
00343
00346 bool IsWine();
00347
00348 #endif
00349
00350 #ifdef LINUX
00351 class GLibrary *GetWindowManagerLib();
00352 void RegisterHandle(GView *v);
00353 void UnregisterHandle(GView *v);
00354 #endif
00355 };
00356
00367 class LgiClass GView : virtual public GViewI, virtual public GBase
00368 {
00369 friend class GWindow;
00370 friend class GLayout;
00371 friend class GControl;
00372 friend class GMenu;
00373 friend class GSubMenu;
00374 friend class GWnd;
00375 friend class GScrollBar;
00376 friend class GFileTarget;
00377 friend class GDialog;
00378 friend class GDragDropTarget;
00379 friend class GPopup;
00380
00381 friend bool SysOnKey(GView *w, GMessage *m);
00382
00383
00384 #if defined WIN32
00385
00386 friend class GWin32Class;
00387 friend LRESULT CALLBACK DlgRedir(OsView hWnd, UINT m, WPARAM a, LPARAM b);
00388 static void CALLBACK TimerProc(OsView hwnd, UINT uMsg, UINT idEvent, uint32 dwTime);
00389
00390 #elif defined MAC
00391
00392 friend OSStatus LgiWindowProc(EventHandlerCallRef, EventRef, void *);
00393 friend OSStatus LgiRootCtrlProc(EventHandlerCallRef, EventRef, void *);
00394 friend OSStatus CarbonControlProc(EventHandlerCallRef, EventRef, void *);
00395 friend OSStatus GViewProc(EventHandlerCallRef, EventRef, void *);
00396
00397 #elif defined BEOS
00398
00399 friend class GButtonRedir;
00400 friend class _OsEditFrame;
00401 friend class BViewRedir;
00402 friend long _lgi_pulse_thread(void *ptr);
00403
00404 #endif
00405
00406 GRect Pos;
00407 int _InLock;
00408
00409 protected:
00410 class GViewPrivate *d;
00411
00412 class GDragDropTarget *&DropTargetPtr();
00413
00414 OsView _View;
00415 GView *_Window;
00416 GSemaphore *_Lock;
00417 uint16 _BorderSize;
00418 uint16 _IsToolBar;
00419 int WndFlags;
00420
00421 static GViewI *_Capturing;
00422 static GViewI *_Over;
00423
00424 #if defined __GTK_H__
00425
00426 friend Gtk::gboolean lgi_widget_expose(Gtk::GtkWidget *widget, Gtk::GdkEventExpose *e);
00427 friend Gtk::gboolean lgi_widget_click(Gtk::GtkWidget *widget, Gtk::GdkEventButton *ev);
00428 friend Gtk::gboolean lgi_widget_motion(Gtk::GtkWidget *widget, Gtk::GdkEventMotion *ev);
00429 friend Gtk::gboolean GViewCallback(Gtk::GtkWidget *widget, Gtk::GdkEvent *event, GView *view);
00430 friend Gtk::gboolean GWindowCallback(Gtk::GtkWidget *widget, Gtk::GdkEvent *event, GWindow *wnd);
00431
00432 public:
00433 enum MappingState
00434 {
00435 Unmapped,
00436 Mapping,
00437 Mapped,
00438 Unmapping,
00439 };
00440
00441 MappingState GetMapState();
00442 virtual void OnMap(bool m);
00443
00444 char *GetMapStateName()
00445 {
00446 switch (GetMapState())
00447 {
00448 case Unmapped: return "Unmapped";
00449 case Mapping: return "Mapping";
00450 case Mapped: return "Mapped";
00451 case Unmapping: return "Unmapping";
00452 }
00453 return "Error";
00454 }
00455
00456 void SetIgnoreInput(bool ignore);
00457
00458 protected:
00459 #elif defined WIN32
00460
00461 uint32 GetStyle();
00462 void SetStyle(uint32 i);
00463 uint32 GetExStyle();
00464 void SetExStyle(uint32 i);
00465 uint32 GetDlgCode();
00466 void SetDlgCode(uint32 i);
00467
00469 char *GetClassW32();
00471 void SetClassW32(char *s);
00475 GWin32Class *CreateClassW32(char *Class = 0, HICON Icon = 0, int AddStyles = 0);
00476
00477 virtual int SysOnNotify(int Code) { return 0; }
00478
00479 #elif defined BEOS
00480
00481 struct OsMouseInfo;
00482 friend long _lgi_mouse_thread(OsMouseInfo *Info);
00483
00484 OsMouseInfo *_MouseInfo;
00485 OsThread _CaptureThread;
00486 OsThread _PulseThread;
00487 int _PulseRate;
00488 BWindow *_QuitMe;
00489
00490 void Sys_KeyDown(const char *bytes, int32 numBytes);
00491 void Sys_KeyUp(const char *bytes, int32 numBytes);
00492 void Sys_MouseDown(BPoint point);
00493 void Sys_MouseMoved(BPoint point, uint32 transit, const BMessage *message);
00494 void Sys_FrameMoved(BPoint p);
00495 virtual bool QuitRequested() {}
00496
00497 #elif defined MAC
00498
00499 OsView _CreateCustomView();
00500 bool _Attach(GViewI *parent);
00501 virtual bool _OnGetInfo(HISize &size, HISize &line, HIRect &bounds, HIPoint &origin) { return false; }
00502 virtual void _OnScroll(HIPoint &origin) {}
00503
00504 #endif
00505
00506
00507
00508
00510 GRect *FindLargest(GRegion &r);
00511
00513 GRect *FindSmallestFit(GRegion &r, int Sx, int Sy);
00514
00516 GRect *FindLargestEdge
00517 (
00519 GRegion &r,
00522 int Edge
00523 );
00524
00525 void _Delete();
00526 GViewI *FindReal(GdcPt2 *Offset = 0);
00527 bool HandleCapture(GView *Wnd, bool c);
00528
00529 virtual void _Paint(GSurface *pDC = 0, int Ox = 0, int Oy = 0);
00530
00531 #if !WIN32NATIVE
00532
00533 GView *&PopupChild();
00534 virtual bool _Mouse(GMouse &m, bool Move);
00535
00536 #endif
00537
00538 virtual bool OnViewMouse(GView *v, GMouse &m) { return true; }
00539 virtual bool OnViewKey(GView *v, GKey &k) { return false; }
00540 virtual void OnNcPaint(GSurface *pDC, GRect &r);
00541
00543 friend class GViewIter;
00544 List<GViewI> Children;
00545
00546 public:
00548 GEventsI *Script;
00549 bool OnScriptEvent(GViewI *Ctrl) { return false; }
00550
00558 GView
00559 (
00561 OsView wnd = 0
00562 );
00563
00565 virtual ~GView();
00566
00568 OsView Handle() { return _View; }
00569
00571 GView *GetGView() { return this; }
00572
00574 virtual OsWindow WindowHandle();
00575
00576
00577 bool AddView(GViewI *v, int Where = -1);
00578 bool DelView(GViewI *v);
00579 bool HasView(GViewI *v);
00580 GViewIterator *IterateViews();
00581
00593 virtual bool Attach
00594 (
00596 GViewI *p
00597 );
00598
00600 virtual bool AttachChildren();
00601
00603 virtual bool Detach();
00604
00606 virtual bool IsAttached();
00607
00609 virtual void Quit(bool DontDelete = false);
00610
00611
00612
00614 GWindow *GetWindow();
00615
00617 GViewI *GetParent();
00618
00622 virtual void SetParent(GViewI *p);
00623
00625 void SendNotify(int Data = 0);
00626
00628 GViewI *GetNotify();
00629
00634 virtual void SetNotify(GViewI *n);
00635
00638 bool Lock
00639 (
00641 char *file,
00643 int line,
00645 int TimeOut = -1
00646 );
00647
00649 void Unlock();
00650
00652 int OnEvent(GMessage *Msg);
00653
00655 bool Enabled();
00656
00658 void Enabled(bool e);
00659
00661 bool Visible();
00662
00664 void Visible
00665 (
00667 bool v
00668 );
00669
00671 bool Focus();
00672
00674 void Focus(bool f);
00675
00677 bool DropTarget();
00678
00680 bool DropTarget(bool t);
00681
00687 bool Sunken();
00688
00690 void Sunken(bool i);
00691
00693 bool Flat();
00694
00696 void Flat(bool i);
00697
00703 bool Raised();
00704
00706 void Raised(bool i);
00707
00709 GViewFill *GetForegroundFill();
00710
00714 bool SetForegroundFill(GViewFill *Fill);
00715
00717 GViewFill *GetBackgroundFill();
00718
00722 bool SetBackgroundFill(GViewFill *Fill);
00723
00730 bool InThread();
00731
00736 bool PostEvent
00737 (
00740 int Cmd,
00742 int a = 0,
00744 int b = 0
00745 );
00746
00753 bool Name(char *n);
00754
00756 char *Name();
00757
00759 virtual bool NameW(char16 *n);
00760
00765 virtual char16 *NameW();
00766
00770 virtual GFont *GetFont();
00771
00776 virtual void SetFont(GFont *Fnt, bool OwnIt = false);
00777
00778
00783 bool SetCursor
00784 (
00787 int Cursor
00788 );
00789
00791 virtual GRect &GetPos() { return Pos; }
00793 virtual GRect &GetClient(bool InClientSpace = true);
00795 virtual bool SetPos(GRect &p, bool Repaint = false);
00797 int X() { return Pos.X(); }
00799 int Y() { return Pos.Y(); }
00801 GdcPt2 GetMinimumSize();
00805 void SetMinimumSize(GdcPt2 Size);
00806
00808 void MoveOnScreen();
00810 void MoveToCenter();
00812 void MoveToMouse();
00813
00820 char *GetClass() { return "GView"; }
00821
00826 bool Capture(bool c);
00828 bool IsCapturing();
00831 bool GetMouse
00832 (
00834 GMouse &m,
00836 bool ScreenCoords = false
00837 );
00838
00843 int GetId();
00845 void SetId(int i);
00847 bool GetTabStop();
00852 void SetTabStop(bool b);
00854 virtual int64 Value() { return 0; }
00856 virtual void Value(int64 i) {}
00858 virtual GViewI *FindControl(OsView hnd);
00860 virtual GViewI *FindControl
00861 (
00862
00863 int Id
00864 );
00865
00867 int64 GetCtrlValue(int Id);
00869 void SetCtrlValue(int Id, int64 i);
00871 char *GetCtrlName(int Id);
00873 void SetCtrlName(int Id, char *s);
00875 bool GetCtrlEnabled(int Id);
00877 void SetCtrlEnabled(int Id, bool Enabled);
00879 bool GetCtrlVisible(int Id);
00881 void SetCtrlVisible(int Id, bool Visible);
00882
00884 bool Invalidate
00885 (
00887 GRect *r = NULL,
00889 bool Repaint = false,
00891 bool NonClient = false
00892 );
00893
00895 bool Invalidate
00896 (
00898 GRegion *r,
00900 bool Repaint = false,
00902 bool NonClient = false
00903 );
00904
00906 bool IsOver(GMouse &m);
00908 GViewI *WindowFromPoint(int x, int y);
00910 void SetPulse
00911 (
00913 int Ms = -1
00914 );
00916 void PointToScreen(GdcPt2 &p);
00918 void PointToView(GdcPt2 &p);
00920 bool WindowVirtualOffset(GdcPt2 *Offset);
00922 GdcPt2 &GetWindowBorderSize();
00924 virtual bool Pour
00925 (
00927 GRegion &r
00928 ) { return false; }
00929
00931 void OnMouseClick
00932 (
00934 GMouse &m
00935 );
00937 void OnMouseEnter
00938 (
00940 GMouse &m
00941 );
00943 void OnMouseExit
00944 (
00946 GMouse &m
00947 );
00949 void OnMouseMove
00950 (
00952 GMouse &m
00953 );
00955 void OnMouseWheel
00956 (
00958 double Lines
00959 );
00961 bool OnKey(GKey &k);
00963 void OnCreate();
00965 void OnDestroy();
00967 void OnFocus
00968 (
00970 bool f
00971 );
00974 void OnPulse();
00976 void OnPosChange();
00978 bool OnRequestClose
00979 (
00981 bool OsShuttingDown
00982 );
00985 int OnHitTest
00986 (
00988 int x,
00990 int y
00991 );
00993 void OnChildrenChanged(GViewI *Wnd, bool Attaching);
00995 void OnPaint(GSurface *pDC);
01001 int OnNotify(GViewI *Ctrl, int Flags);
01003 int OnCommand(int Cmd, int Event, OsView Wnd);
01005 void OnAttach();
01007 bool OnLayout(GViewLayoutInfo &Inf) { return false; }
01008
01009 #if defined(_DEBUG)
01010 bool _Debug;
01011 void Debug();
01012 void _Dump(int Depth = 0);
01013 #endif
01014 };
01015
01017
01018
01021 #define GV_EDGE_TOP 0x0001
01024 #define GV_EDGE_RIGHT 0x0002
01027 #define GV_EDGE_BOTTOM 0x0004
01030 #define GV_EDGE_LEFT 0x0008
01031
01033 #define IDC_VSCROLL 14000
01035 #define IDC_HSCROLL 14001
01036
01037 #ifdef MAC
01038 #define XPLATFORM_GLAYOUT 1
01039 #else
01040 #define XPLATFORM_GLAYOUT 0
01041 #endif
01042
01051 class LgiClass GLayout : public GView
01052 {
01053 friend class GScroll;
01054 friend class GView;
01055
01056
01057 bool _SettingScrollBars;
01058 bool _PourLargest;
01059
01060 protected:
01062 GScrollBar *VScroll;
01063
01065 GScrollBar *HScroll;
01066
01068 virtual bool SetScrollBars
01069 (
01071 bool x,
01073 bool y
01074 );
01075
01076 #ifndef WIN32
01077 void AttachScrollBars();
01078 #endif
01079 #if defined(MAC) && !XPLATFORM_GLAYOUT
01080 friend class GLayoutScrollBar;
01081 HISize Line;
01082
01083 OsView RealWnd;
01084 bool _OnGetInfo(HISize &size, HISize &line, HIRect &bounds, HIPoint &origin);
01085 void _OnScroll(HIPoint &origin);
01086 void OnScrollConfigure();
01087 #endif
01088
01089 public:
01090 GLayout();
01091 ~GLayout();
01092
01093 char *GetClass() { return "GLayout"; }
01094
01096 virtual void GetScrollPos(int &x, int &y);
01098 virtual void SetScrollPos(int x, int y);
01099
01101 bool GetPourLargest();
01108 void SetPourLargest(bool i);
01109
01111 int OnEvent(GMessage *Msg);
01112
01115 bool Pour(GRegion &r);
01116
01117
01118 #if !defined WIN32
01119
01120 bool Attach(GViewI *p);
01121 bool Detach();
01122 GRect &GetClient(bool InClientSpace = true);
01123
01124 #if defined(MAC) && !XPLATFORM_GLAYOUT
01125
01126 bool Invalidate(GRect *r = NULL, bool Repaint = false, bool NonClient = false);
01127 bool Focus();
01128 void Focus(bool f);
01129 bool SetPos(GRect &p, bool Repaint = false);
01130
01131 #else
01132
01133 void OnPosChange();
01134 int OnNotify(GViewI *c, int f);
01135 void OnNcPaint(GSurface *pDC, GRect &r);
01136
01137 #endif
01138 #endif
01139 };
01140
01142 #define GIC_OWNER_DRAW 0x01
01144 #define GIC_ASK_TEXT 0x02
01146 #define GIC_ASK_IMAGE 0x04
01148 #define GIC_OWN_LIST 0x08
01150 #define GIC_IN_DRAG_OP 0x10
01151
01152 class LgiClass GItemContainer
01153 {
01154 protected:
01155 int Flags;
01156 GImageList *ImageList;
01157
01158 public:
01159 GItemContainer();
01160 virtual ~GItemContainer();
01161
01162
01163 bool OwnerDraw() { return TestFlag(Flags, GIC_OWNER_DRAW); }
01164 void OwnerDraw(bool b) { if (b) SetFlag(Flags, GIC_OWNER_DRAW); else ClearFlag(Flags, GIC_OWNER_DRAW); }
01165 bool AskText() { return TestFlag(Flags, GIC_ASK_TEXT); }
01166 void AskText(bool b) { if (b) SetFlag(Flags, GIC_ASK_TEXT); else ClearFlag(Flags, GIC_ASK_TEXT); }
01167 bool AskImage() { return TestFlag(Flags, GIC_ASK_IMAGE); }
01168 void AskImage(bool b) { if (b) SetFlag(Flags, GIC_ASK_IMAGE); else ClearFlag(Flags, GIC_ASK_IMAGE); }
01169 bool InsideDragOp() { return TestFlag(Flags, GIC_IN_DRAG_OP); }
01170 void InsideDragOp(bool b) { if (b) SetFlag(Flags, GIC_IN_DRAG_OP); else ClearFlag(Flags, GIC_IN_DRAG_OP); }
01171
01172
01173 GImageList *GetImageList() { return ImageList; }
01174 bool SetImageList(GImageList *List, bool Own = true);
01175 bool LoadImageList(char *File, int x, int y);
01176 bool OwnList() { return TestFlag(Flags, GIC_OWN_LIST); }
01177 void OwnList(bool b) { if (b) SetFlag(Flags, GIC_OWN_LIST); else ClearFlag(Flags, GIC_OWN_LIST); }
01178 };
01179
01181
01182 #include "GMenu.h"
01183
01185
01187 enum GWindowZoom
01188 {
01190 GZoomMin,
01192 GZoomNormal,
01194 GZoomMax
01195 };
01196
01198 #define GMouseEvents 0x01
01200 #define GKeyEvents 0x02
01201
01203 class LgiClass GWindow :
01204 public GView
01205 #ifndef WIN32
01206 , public GDragDropTarget
01207 #endif
01208 {
01209 friend class BViewRedir;
01210 friend class GView;
01211 friend class GButton;
01212 friend class XWindow;
01213 friend class GDialog;
01214 #ifdef MAC
01215 friend pascal OSStatus LgiWindowProc(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData);
01216 #endif
01217
01218 bool _QuitOnClose;
01219
01220 protected:
01221 #if WIN32NATIVE
01222
01223 GRect OldPos;
01224 HWND LastFocus;
01225
01226 #else
01227
01228 OsWindow Wnd;
01229 void _OnViewDelete();
01230 void _SetDynamic(bool i);
01231
01232 #endif
01233
01234 #if defined BEOS
01235
01236 friend class GMenu;
01237 friend class GView;
01238
01239 #elif defined __GTK_H__
01240
01241 Gtk::GtkWidget *Root;
01242 void _Paint(GSurface *pDC = 0, int Ox = 0, int Oy = 0);
01243
01244 #endif
01245
01247 GViewI *_Default;
01248
01250 GMenu *Menu;
01251
01253 int VirtualFocusId;
01254
01255 class GWindowPrivate *d;
01256
01257 void SetChildDialog(GDialog *Dlg);
01258 void SetDragHandlers(bool On);
01259
01260 public:
01261 #ifdef __GTK_H__
01262 GWindow(Gtk::GtkWidget *w = 0);
01263 #else
01264 GWindow();
01265 #endif
01266 ~GWindow();
01267
01268 char *GetClass() { return "GWindow"; }
01269
01271 virtual void Pour();
01272
01274 GMenu *GetMenu() { return Menu; }
01275
01277 void SetMenu(GMenu *m) { Menu = m; }
01278
01280 bool GetQuitOnClose() { return _QuitOnClose; }
01281
01288 void SetQuitOnClose(bool i) { _QuitOnClose = i; }
01289
01290 bool GetSnapToEdge();
01291 void SetSnapToEdge(bool b);
01292
01294 GWindowZoom GetZoom();
01295
01297 void SetZoom(GWindowZoom i);
01298
01300 void Raise();
01301
01302 void OnPosChange();
01303 int OnEvent(GMessage *Msg);
01304 void OnPaint(GSurface *pDC);
01305 bool HandleViewMouse(GView *v, GMouse &m);
01306 bool HandleViewKey(GView *v, GKey &k);
01307 bool OnRequestClose(bool OsShuttingDown);
01308 bool Visible();
01309 void Visible(bool i);
01310 GRect &GetPos();
01311
01314 bool RegisterHook
01315 (
01317 GView *Target,
01319 int EventType,
01321 int Priority = 0
01322 );
01323
01325 bool UnregisterHook(GView *Target);
01326
01328 virtual void OnZoom(GWindowZoom Action) {}
01329
01331 virtual void OnTrayClick(GMouse &m) {}
01332
01334 virtual void OnReceiveFiles(GArray<char*> &Files) {}
01335
01336 #if !WIN32NATIVE
01337
01338 bool Attach(GViewI *p);
01339
01340
01341 OsWindow WindowHandle() { return Wnd; }
01342 bool Name(char *n);
01343 char *Name();
01344 bool SetPos(GRect &p, bool Repaint = false);
01345 GRect &GetClient(bool InClientSpace = true);
01346
01347
01348 int WillAccept(List<char> &Formats, GdcPt2 Pt, int KeyState);
01349 int OnDrop(char *Format, GVariant *Data, GdcPt2 Pt, int KeyState);
01350
01351
01352 void OnChildrenChanged(GViewI *Wnd, bool Attaching);
01353 void OnCreate();
01354
01355 #endif
01356
01357 #if defined MAC
01358
01359 bool PostEvent(int Cmd, int a = 0, int b = 0);
01360 void Quit(bool DontDelete = false);
01361 OSErr HandlerCallback(DragTrackingMessage *tracking, DragRef theDrag);
01362 int OnCommand(int Cmd, int Event, OsView Wnd);
01363 virtual void OnFrontSwitch(bool b);
01364
01365 #elif defined __GTK_H__
01366
01367 void SetFirstFocus(OsView Hnd);
01368 void OnMap(bool m);
01369
01370 #endif
01371
01373 GViewI *GetDefault();
01375 void SetDefault(GViewI *v);
01376
01378 bool SerializeState
01379 (
01381 GDom *Store,
01383 char *FieldName,
01385 bool Load
01386 );
01387 };
01388
01390
01392 class LgiClass GToolTip : public GView
01393 {
01394 class GToolTipPrivate *d;
01395
01396 public:
01397 GToolTip();
01398 ~GToolTip();
01399
01401 int NewTip
01402 (
01404 char *Name,
01406 GRect &Pos
01407 );
01408
01410 void DeleteTip(int Id);
01411
01412 bool Attach(GViewI *p);
01413 };
01414
01416
01417 #include "LgiWidgets.h"
01418
01420
01421 #include "Progress.h"
01422 #include "GProgress.h"
01423
01425 #include "GFileSelect.h"
01426 #include "GFindReplaceDlg.h"
01427 #include "GToolBar.h"
01428 #include "GThread.h"
01429
01431
01433 class LgiClass GSplitter : public GLayout
01434 {
01435 class GSplitterPrivate *d;
01436
01437 void CalcRegions(bool Follow = false);
01438 bool OverSplit(int x, int y);
01439
01440 public:
01441 GSplitter();
01442 ~GSplitter();
01443
01444 char *GetClass() { return "GSplitter"; }
01445
01447 int64 Value();
01448
01450 void Value(int64 i);
01451
01453 bool IsVertical();
01454
01456 void IsVertical(bool v);
01457
01459 bool DoesSplitFollow();
01460
01462 void DoesSplitFollow(bool i);
01463
01465 GView *GetViewA();
01466
01468 void DetachViewA();
01469
01471 void SetViewA(GView *a, bool Border = true);
01472
01474 GView *GetViewB();
01475
01477 void DetachViewB();
01478
01480 void SetViewB(GView *b, bool Border = true);
01481
01483 int BarSize();
01484
01486 void BarSize(int i);
01487
01488 bool Border();
01489 void Border(bool i);
01490 GViewI *FindControl(OsView hCtrl);
01491
01492 bool Attach(GViewI *p);
01493 bool Pour(GRegion &r);
01494 void OnPaint(GSurface *pDC);
01495 void OnPosChange();
01496 void OnMouseClick(GMouse &m);
01497 void OnMouseMove(GMouse &m);
01498 void OnMouseExit(GMouse &m);
01499 int OnHitTest(int x, int y);
01500 void OnChildrenChanged(GViewI *Wnd, bool Attaching);
01501 };
01502
01504 #define STATUSBAR_SEPARATOR 4
01505 #define GSP_SUNKEN 0x0001
01506
01507 class LgiClass GStatusBar : public GLayout
01508 {
01509 friend class GStatusPane;
01510
01511 protected:
01512 void RePour();
01513
01514 public:
01515 GStatusBar();
01516 ~GStatusBar();
01517
01518 char *GetClass() { return "GStatusBar"; }
01519 bool Pour(GRegion &r);
01520 void OnPaint(GSurface *pDC);
01521
01522 GStatusPane *AppendPane(char *Text, int Width);
01523 bool AppendPane(GStatusPane *Pane);
01524 };
01525
01526 class LgiClass GStatusPane :
01527 public GView
01528 {
01529 friend class GStatusBar;
01530
01531 protected:
01532 int Flags;
01533 int Width;
01534 GSurface *pDC;
01535
01536 public:
01537 GStatusPane();
01538 ~GStatusPane();
01539
01540 char *GetClass() { return "GStatusPane"; }
01541 char *Name() { return GBase::Name(); }
01542 bool Name(char *n);
01543 void OnPaint(GSurface *pDC);
01544
01545 int GetWidth();
01546 void SetWidth(int x);
01547 bool Sunken();
01548 void Sunken(bool i);
01549 GSurface *Bitmap();
01550 void Bitmap(GSurface *pdc);
01551 };
01552
01554 class LgiClass GCommand : public GBase
01555 {
01556 int Flags;
01557 bool PrevValue;
01558
01559 public:
01560 int Id;
01561 GToolButton *ToolButton;
01562 GMenuItem *MenuItem;
01563 GKey *Accelerator;
01564 char *TipHelp;
01565
01566 GCommand();
01567 ~GCommand();
01568
01569 bool Enabled();
01570 void Enabled(bool e);
01571 bool Value();
01572 void Value(bool v);
01573 };
01574
01576 #include "GClipBoard.h"
01577
01579
01581 class LgiClass GTrayIcon :
01582 public GBase
01583
01584 {
01585 friend class GTrayWnd;
01586 class GTrayIconPrivate *d;
01587
01588 public:
01590 GTrayIcon
01591 (
01593 GWindow *p
01594 );
01595
01596 ~GTrayIcon();
01597
01599 bool Load(TCHAR *Str);
01600
01602 bool Visible();
01603
01605 void Visible(bool v);
01606
01608 int64 Value();
01609
01611 void Value(int64 v);
01612
01614 virtual int OnEvent(GMessage *Msg);
01615 };
01616
01618 #include "GInput.h"
01619 #include "GPrinter.h"
01620
01622
01632 class LgiClass GAlert : public GDialog
01633 {
01634 public:
01636 GAlert
01637 (
01639 GViewI *parent,
01641 char *Title,
01643 char *Text,
01645 char *Btn1,
01647 char *Btn2 = 0,
01649 char *Btn3 = 0
01650 );
01651
01652 int OnNotify(GViewI *Ctrl, int Flags);
01653 };
01654
01656 class LgiClass DoEvery
01657 {
01658 int64 LastTime;
01659 int64 Period;
01660
01661 public:
01663 DoEvery
01664 (
01666 int p = 1000
01667 );
01668
01670 void Init
01671 (
01673 int p = -1
01674 );
01675
01677 bool DoNow();
01678 };
01679
01684 class LgiClass GViewFactory
01685 {
01686 static List<GViewFactory> *Factories;
01687
01697 virtual GView *NewView
01698 (
01700 char *Class,
01702 GRect *Pos,
01704 char *Text
01705 ) = 0;
01706
01707 public:
01708 GViewFactory();
01709 virtual ~GViewFactory();
01710
01712 static GView *Create(char *Class, GRect *Pos = 0, char *Text = 0);
01713 };
01714
01716
01717
01718 LgiFunc void LgiInitColours();
01719 LgiFunc COLOUR LgiColour(int Colour);
01720
01721
01722 LgiFunc void LgiDrawBox(GSurface *pDC, GRect &r, bool Sunken, bool Fill);
01723 LgiFunc void LgiWideBorder(GSurface *pDC, GRect &r, int Type);
01724 LgiFunc void LgiThinBorder(GSurface *pDC, GRect &r, int Type);
01725 LgiFunc void LgiFlatBorder(GSurface *pDC, GRect &r, int Width = -1);
01726
01727
01728
01729 #ifdef LINUX
01731 LgiFunc void LgiFinishXWindowsStartup(class GViewI *Wnd);
01732 #endif
01733
01736 LgiFunc int LgiMsg
01737 (
01739 GViewI *Parent,
01741 char *Msg,
01743 char *Title = 0,
01746 int Type = MB_OK,
01747 ...
01748 );
01749
01752 struct GDisplayInfo
01753 {
01757 GRect r;
01759 int BitDepth;
01761 int Refresh;
01763 char *Device;
01765 char *Name;
01767 char *Monitor;
01768
01769 GDisplayInfo()
01770 {
01771 r.ZOff(-1, -1);
01772 BitDepth = 0;
01773 Refresh = 0;
01774 Device = 0;
01775 Name = 0;
01776 Monitor = 0;
01777 }
01778
01779 ~GDisplayInfo()
01780 {
01781 DeleteArray(Device);
01782 DeleteArray(Name);
01783 DeleteArray(Monitor);
01784 }
01785 };
01786
01789 bool LgiGetDisplays
01790 (
01793 GArray<GDisplayInfo*> &Displays,
01796 GRect *AllDisplays = 0
01797 );
01798
01799 #endif
01800
01801