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 GColour Col;
00061 GSurface *pDC;
00062
00063 #ifdef WIN32
00064 HBRUSH hBrush;
00065 #endif
00066
00067 public:
00068 GViewFill(GColour c);
00069 GViewFill(COLOUR c, int Bits = -1);
00070 GViewFill(GSurface *dc, bool Copy = true);
00071 GViewFill(const GViewFill &f);
00072 virtual ~GViewFill();
00073
00074 void Empty();
00075
00076 GViewFill &operator =(GColour col)
00077 {
00078 Empty();
00079 Type = Solid;
00080 Col = col;
00081 return *this;
00082 }
00083
00084 void SetRgba32(int r, int g, int b, int a = 0xff)
00085 {
00086 Empty();
00087 Type = Solid;
00088 Col.Rgb(r, g, b, a);
00089 }
00090
00091 GColour GetFlat() const
00092 {
00093 return Col;
00094 }
00095
00096 bool IsTransparent()
00097 {
00098 return Type == Solid && Col.a() == 0;
00099 }
00100
00101 void Fill(GSurface *pDC, GRect *r = 0, GdcPt2 *Origin = 0);
00102 #ifdef WIN32
00103 HBRUSH GetBrush();
00104 #endif
00105 };
00106
00108 #if WIN32NATIVE
00109 typedef DWORD OsProcessId;
00110 #else
00111 typedef int OsProcessId;
00112 #endif
00113
00115 #define LgiProcessId() (LgiApp->GetProcessId())
00116
00121 #define LgiApp (GApp::ObjInstance())
00122
00127 #define SysFont (LgiApp->SystemNormal)
00128
00133 #define SysBold (LgiApp->SystemBold)
00134
00138 LgiFunc void LgiExitApp();
00139
00143 #define LgiCloseApp() LgiApp->Exit(false)
00144
00146 struct GAppArguments
00147 {
00149 bool NoSkin;
00150 };
00151
00158 class LgiClass GApp : virtual public GAppI, public OsApplication
00159 {
00160 friend class GView;
00161
00162 protected:
00163
00164 class GAppPrivate *d;
00165
00166 #if defined WIN32
00167
00168 CRITICAL_SECTION StackTraceSync;
00169 friend LONG __stdcall _ExceptionFilter_Redir(LPEXCEPTION_POINTERS e);
00170 LONG __stdcall _ExceptionFilter(LPEXCEPTION_POINTERS e, char *ProductId);
00171 friend class GWin32Class;
00172 List<GWin32Class> *GetClasses();
00173
00174 #elif defined ATHEOS
00175
00176 char *_AppFile;
00177
00178 #elif defined BEOS
00179
00180 void RefsReceived(BMessage *Msg);
00181
00182 #elif defined LINUX
00183
00184 friend class GClipBoard;
00185
00186 virtual void OnEvents();
00187 void DeleteMeLater(GViewI *v);
00188 void SetClipBoardContent(OsView Hnd, GVariant &v);
00189 bool GetClipBoardContent(OsView Hnd, GVariant &v, GArray<char*> &Types);
00190
00191 #endif
00192
00193 friend class GMouseHook;
00194 static GMouseHook *MouseHook;
00195
00196 public:
00197
00198
00200 static GApp *ObjInstance();
00201 static class GSkinEngine *SkinEngine;
00202
00203
00204
00206 GFont *SystemNormal;
00207
00209 GFont *SystemBold;
00210
00212 GWindow *AppWnd;
00213
00215 bool IsOk();
00216
00218 OsProcessId GetProcessId();
00219
00221 OsThreadId GetGuiThread();
00222
00224 GApp
00225 (
00228 const char *MimeType,
00230 OsAppArguments &AppArgs,
00232 GAppArguments *ObjArgs = 0
00233 );
00234
00236 virtual ~GApp();
00237
00240 char *GetName();
00241
00244 void SetName(const char *Name);
00245
00247 const char *GetLgiVersion() { return LGI_VER; }
00248
00250 void SetAppArgs(OsAppArguments &AppArgs);
00251
00253 OsAppArguments *GetAppArgs();
00254
00256 char *GetArgumentAt(int n);
00257
00259 bool Run
00260 (
00263 bool Loop = true,
00265 OnIdleProc IdleCallback = NULL,
00267 void *IdleParam = NULL
00268 );
00269
00271 void OnCommandLine();
00272
00274 void OnReceiveFiles(GArray<char*> &Files);
00275
00277 void Exit
00278 (
00280 int Code = 0
00281 );
00282
00285 bool GetOption
00286 (
00288 const char *Option,
00290 GAutoString &Buf
00291 );
00292
00295 bool GetOption
00296 (
00298 const char *Option,
00300 char *Dst = 0,
00302 int DstSize = 0
00303 );
00304
00306 GXmlTag *GetConfig(const char *Tag);
00307
00309 void SetConfig(GXmlTag *Tag);
00310
00312 GViewI *GetFocus();
00313
00316 GAutoString GetFileMimeType
00317 (
00319 const char *File
00320 );
00321
00323 bool GetAppsForMimeType(char *Mime, GArray<GAppInfo*> &Apps);
00324
00326 int32 GetMetric
00327 (
00329 int Metric
00330 );
00331
00333 GMouseHook *GetMouseHook();
00334
00336 class GSymLookup *GetSymLookup();
00337
00338
00339 #if defined WIN32
00340
00341 static bool IsWin9x;
00342 HINSTANCE GetInstance();
00343 int GetShow();
00344
00347 bool IsWine();
00348
00349 #endif
00350
00351 #ifdef LINUX
00352 class GLibrary *GetWindowManagerLib();
00353 void RegisterHandle(GView *v);
00354 void UnregisterHandle(GView *v);
00355 #endif
00356 };
00357
00368 class LgiClass GView : virtual public GViewI, virtual public GBase
00369 {
00370 friend class GWindow;
00371 friend class GLayout;
00372 friend class GControl;
00373 friend class GMenu;
00374 friend class GSubMenu;
00375 friend class GWnd;
00376 friend class GScrollBar;
00377 friend class GFileTarget;
00378 friend class GDialog;
00379 friend class GDragDropTarget;
00380 friend class GPopup;
00381
00382 friend bool SysOnKey(GView *w, GMessage *m);
00383
00384
00385 #if defined WIN32
00386
00387 friend class GWin32Class;
00388 friend LRESULT CALLBACK DlgRedir(OsView hWnd, UINT m, WPARAM a, LPARAM b);
00389 static void CALLBACK TimerProc(OsView hwnd, UINT uMsg, UINT idEvent, uint32 dwTime);
00390
00391 #elif defined MAC
00392
00393 friend OSStatus LgiWindowProc(EventHandlerCallRef, EventRef, void *);
00394 friend OSStatus LgiRootCtrlProc(EventHandlerCallRef, EventRef, void *);
00395 friend OSStatus CarbonControlProc(EventHandlerCallRef, EventRef, void *);
00396 friend OSStatus GViewProc(EventHandlerCallRef, EventRef, void *);
00397
00398 #elif defined BEOS
00399
00400 friend class GButtonRedir;
00401 friend class _OsEditFrame;
00402 friend class BViewRedir;
00403 friend long _lgi_pulse_thread(void *ptr);
00404
00405 #endif
00406
00407 GRect Pos;
00408 int _InLock;
00409
00410 protected:
00411 class GViewPrivate *d;
00412
00413 class GDragDropTarget *&DropTargetPtr();
00414
00415 OsView _View;
00416 GView *_Window;
00417 GSemaphore *_Lock;
00418 uint16 _BorderSize;
00419 uint16 _IsToolBar;
00420 int WndFlags;
00421
00422 static GViewI *_Capturing;
00423 static GViewI *_Over;
00424
00425 #if defined __GTK_H__
00426
00427 friend Gtk::gboolean lgi_widget_expose(Gtk::GtkWidget *widget, Gtk::GdkEventExpose *e);
00428 friend Gtk::gboolean lgi_widget_click(Gtk::GtkWidget *widget, Gtk::GdkEventButton *ev);
00429 friend Gtk::gboolean lgi_widget_motion(Gtk::GtkWidget *widget, Gtk::GdkEventMotion *ev);
00430 friend Gtk::gboolean GViewCallback(Gtk::GtkWidget *widget, Gtk::GdkEvent *event, GView *view);
00431 friend Gtk::gboolean GWindowCallback(Gtk::GtkWidget *widget, Gtk::GdkEvent *event, GWindow *wnd);
00432
00433 public:
00434 enum MappingState
00435 {
00436 Unmapped,
00437 Mapping,
00438 Mapped,
00439 Unmapping,
00440 };
00441
00442 MappingState GetMapState();
00443 virtual void OnMap(bool m);
00444
00445 char *GetMapStateName()
00446 {
00447 switch (GetMapState())
00448 {
00449 case Unmapped: return "Unmapped";
00450 case Mapping: return "Mapping";
00451 case Mapped: return "Mapped";
00452 case Unmapping: return "Unmapping";
00453 }
00454 return "Error";
00455 }
00456
00457 void SetIgnoreInput(bool ignore);
00458
00459 protected:
00460 #elif defined WIN32
00461
00462 uint32 GetStyle();
00463 void SetStyle(uint32 i);
00464 uint32 GetExStyle();
00465 void SetExStyle(uint32 i);
00466 uint32 GetDlgCode();
00467 void SetDlgCode(uint32 i);
00468
00470 const char *GetClassW32();
00472 void SetClassW32(const char *s);
00476 GWin32Class *CreateClassW32(const char *Class = 0, HICON Icon = 0, int AddStyles = 0);
00477
00478 virtual int SysOnNotify(int Code) { return 0; }
00479
00480 #elif defined BEOS
00481
00482 struct OsMouseInfo;
00483 friend long _lgi_mouse_thread(OsMouseInfo *Info);
00484
00485 OsMouseInfo *_MouseInfo;
00486 OsThread _CaptureThread;
00487 OsThread _PulseThread;
00488 int _PulseRate;
00489 BWindow *_QuitMe;
00490
00491 void Sys_KeyDown(const char *bytes, int32 numBytes);
00492 void Sys_KeyUp(const char *bytes, int32 numBytes);
00493 void Sys_MouseDown(BPoint point);
00494 void Sys_MouseMoved(BPoint point, uint32 transit, const BMessage *message);
00495 void Sys_FrameMoved(BPoint p);
00496 virtual bool QuitRequested() {}
00497
00498 #elif defined MAC
00499
00500 OsView _CreateCustomView();
00501 bool _Attach(GViewI *parent);
00502 virtual bool _OnGetInfo(HISize &size, HISize &line, HIRect &bounds, HIPoint &origin) { return false; }
00503 virtual void _OnScroll(HIPoint &origin) {}
00504
00505 #endif
00506
00507
00508
00509
00511 GRect *FindLargest(GRegion &r);
00512
00514 GRect *FindSmallestFit(GRegion &r, int Sx, int Sy);
00515
00517 GRect *FindLargestEdge
00518 (
00520 GRegion &r,
00523 int Edge
00524 );
00525
00526 void _Delete();
00527 GViewI *FindReal(GdcPt2 *Offset = 0);
00528 bool HandleCapture(GView *Wnd, bool c);
00529
00530 virtual void _Paint(GSurface *pDC = 0, int Ox = 0, int Oy = 0);
00531
00532 #if !WIN32NATIVE
00533
00534 GView *&PopupChild();
00535 virtual bool _Mouse(GMouse &m, bool Move);
00536
00537 #endif
00538
00539 virtual bool OnViewMouse(GView *v, GMouse &m) { return true; }
00540 virtual bool OnViewKey(GView *v, GKey &k) { return false; }
00541 virtual void OnNcPaint(GSurface *pDC, GRect &r);
00542
00544 friend class GViewIter;
00545 List<GViewI> Children;
00546
00547 public:
00549 GEventsI *Script;
00550 bool OnScriptEvent(GViewI *Ctrl) { return false; }
00551
00559 GView
00560 (
00562 OsView wnd = 0
00563 );
00564
00566 virtual ~GView();
00567
00569 OsView Handle() { return _View; }
00570
00572 GView *GetGView() { return this; }
00573
00575 virtual OsWindow WindowHandle();
00576
00577
00578 bool AddView(GViewI *v, int Where = -1);
00579 bool DelView(GViewI *v);
00580 bool HasView(GViewI *v);
00581 GViewIterator *IterateViews();
00582
00594 virtual bool Attach
00595 (
00597 GViewI *p
00598 );
00599
00601 virtual bool AttachChildren();
00602
00604 virtual bool Detach();
00605
00607 virtual bool IsAttached();
00608
00610 virtual void Quit(bool DontDelete = false);
00611
00612
00613
00615 GWindow *GetWindow();
00616
00618 GViewI *GetParent();
00619
00623 virtual void SetParent(GViewI *p);
00624
00626 void SendNotify(int Data = 0);
00627
00629 GViewI *GetNotify();
00630
00635 virtual void SetNotify(GViewI *n);
00636
00639 bool Lock
00640 (
00642 const char *file,
00644 int line,
00646 int TimeOut = -1
00647 );
00648
00650 void Unlock();
00651
00653 int OnEvent(GMessage *Msg);
00654
00656 bool Enabled();
00657
00659 void Enabled(bool e);
00660
00662 bool Visible();
00663
00665 void Visible
00666 (
00668 bool v
00669 );
00670
00672 bool Focus();
00673
00675 void Focus(bool f);
00676
00678 bool DropTarget();
00679
00681 bool DropTarget(bool t);
00682
00688 bool Sunken();
00689
00691 void Sunken(bool i);
00692
00694 bool Flat();
00695
00697 void Flat(bool i);
00698
00704 bool Raised();
00705
00707 void Raised(bool i);
00708
00710 GViewFill *GetForegroundFill();
00711
00715 bool SetForegroundFill(GViewFill *Fill);
00716
00718 GViewFill *GetBackgroundFill();
00719
00723 bool SetBackgroundFill(GViewFill *Fill);
00724
00731 bool InThread();
00732
00737 bool PostEvent
00738 (
00741 int Cmd,
00743 int a = 0,
00745 int b = 0
00746 );
00747
00754 bool Name(const char *n);
00755
00757 char *Name();
00758
00760 virtual bool NameW(const char16 *n);
00761
00766 virtual char16 *NameW();
00767
00771 virtual GFont *GetFont();
00772
00777 virtual void SetFont(GFont *Fnt, bool OwnIt = false);
00778
00779
00784 bool SetCursor
00785 (
00788 int Cursor
00789 );
00790
00792 virtual GRect &GetPos() { return Pos; }
00794 virtual GRect &GetClient(bool InClientSpace = true);
00796 virtual bool SetPos(GRect &p, bool Repaint = false);
00798 int X() { return Pos.X(); }
00800 int Y() { return Pos.Y(); }
00802 GdcPt2 GetMinimumSize();
00806 void SetMinimumSize(GdcPt2 Size);
00807
00809 void MoveOnScreen();
00811 void MoveToCenter();
00813 void MoveToMouse();
00814
00821 const char *GetClass() { return "GView"; }
00822
00827 bool Capture(bool c);
00829 bool IsCapturing();
00832 bool GetMouse
00833 (
00835 GMouse &m,
00837 bool ScreenCoords = false
00838 );
00839
00844 int GetId();
00846 void SetId(int i);
00848 bool GetTabStop();
00853 void SetTabStop(bool b);
00855 virtual int64 Value() { return 0; }
00857 virtual void Value(int64 i) {}
00859 virtual GViewI *FindControl(OsView hnd);
00861 virtual GViewI *FindControl
00862 (
00863
00864 int Id
00865 );
00866
00868 int64 GetCtrlValue(int Id);
00870 void SetCtrlValue(int Id, int64 i);
00872 char *GetCtrlName(int Id);
00874 void SetCtrlName(int Id, const char *s);
00876 bool GetCtrlEnabled(int Id);
00878 void SetCtrlEnabled(int Id, bool Enabled);
00880 bool GetCtrlVisible(int Id);
00882 void SetCtrlVisible(int Id, bool Visible);
00883
00885 bool Invalidate
00886 (
00888 GRect *r = NULL,
00890 bool Repaint = false,
00892 bool NonClient = false
00893 );
00894
00896 bool Invalidate
00897 (
00899 GRegion *r,
00901 bool Repaint = false,
00903 bool NonClient = false
00904 );
00905
00907 bool IsOver(GMouse &m);
00909 GViewI *WindowFromPoint(int x, int y, bool Debug = false);
00911 void SetPulse
00912 (
00914 int Ms = -1
00915 );
00917 void PointToScreen(GdcPt2 &p);
00919 void PointToView(GdcPt2 &p);
00921 bool WindowVirtualOffset(GdcPt2 *Offset);
00923 GdcPt2 &GetWindowBorderSize();
00925 virtual bool Pour
00926 (
00928 GRegion &r
00929 ) { return false; }
00930
00932 void OnMouseClick
00933 (
00935 GMouse &m
00936 );
00938 void OnMouseEnter
00939 (
00941 GMouse &m
00942 );
00944 void OnMouseExit
00945 (
00947 GMouse &m
00948 );
00950 void OnMouseMove
00951 (
00953 GMouse &m
00954 );
00956 void OnMouseWheel
00957 (
00959 double Lines
00960 );
00962 bool OnKey(GKey &k);
00964 void OnCreate();
00966 void OnDestroy();
00968 void OnFocus
00969 (
00971 bool f
00972 );
00975 void OnPulse();
00977 void OnPosChange();
00979 bool OnRequestClose
00980 (
00982 bool OsShuttingDown
00983 );
00986 int OnHitTest
00987 (
00989 int x,
00991 int y
00992 );
00994 void OnChildrenChanged(GViewI *Wnd, bool Attaching);
00996 void OnPaint(GSurface *pDC);
01002 int OnNotify(GViewI *Ctrl, int Flags);
01004 int OnCommand(int Cmd, int Event, OsView Wnd);
01006 void OnAttach();
01008 bool OnLayout(GViewLayoutInfo &Inf) { return false; }
01009
01010 #if defined(_DEBUG)
01011 bool _Debug;
01012 void Debug();
01013 void _Dump(int Depth = 0);
01014 #endif
01015 };
01016
01018
01019
01022 #define GV_EDGE_TOP 0x0001
01025 #define GV_EDGE_RIGHT 0x0002
01028 #define GV_EDGE_BOTTOM 0x0004
01031 #define GV_EDGE_LEFT 0x0008
01032
01034 #define IDC_VSCROLL 14000
01036 #define IDC_HSCROLL 14001
01037
01038 #ifdef MAC
01039 #define XPLATFORM_GLAYOUT 1
01040 #else
01041 #define XPLATFORM_GLAYOUT 0
01042 #endif
01043
01052 class LgiClass GLayout : public GView
01053 {
01054 friend class GScroll;
01055 friend class GView;
01056
01057
01058 bool _SettingScrollBars;
01059 bool _PourLargest;
01060
01061 protected:
01063 GScrollBar *VScroll;
01064
01066 GScrollBar *HScroll;
01067
01069 virtual bool SetScrollBars
01070 (
01072 bool x,
01074 bool y
01075 );
01076
01077 #ifndef WIN32
01078 void AttachScrollBars();
01079 #endif
01080 #if defined(MAC) && !XPLATFORM_GLAYOUT
01081 friend class GLayoutScrollBar;
01082 HISize Line;
01083
01084 OsView RealWnd;
01085 bool _OnGetInfo(HISize &size, HISize &line, HIRect &bounds, HIPoint &origin);
01086 void _OnScroll(HIPoint &origin);
01087 void OnScrollConfigure();
01088 #endif
01089
01090 public:
01091 GLayout();
01092 ~GLayout();
01093
01094 const char *GetClass() { return "GLayout"; }
01095
01097 virtual void GetScrollPos(int &x, int &y);
01099 virtual void SetScrollPos(int x, int y);
01100
01102 bool GetPourLargest();
01109 void SetPourLargest(bool i);
01110
01112 int OnEvent(GMessage *Msg);
01113
01116 bool Pour(GRegion &r);
01117
01118
01119 #if !defined WIN32
01120
01121 bool Attach(GViewI *p);
01122 bool Detach();
01123 GRect &GetClient(bool InClientSpace = true);
01124
01125 #if defined(MAC) && !XPLATFORM_GLAYOUT
01126
01127 bool Invalidate(GRect *r = NULL, bool Repaint = false, bool NonClient = false);
01128 bool Focus();
01129 void Focus(bool f);
01130 bool SetPos(GRect &p, bool Repaint = false);
01131
01132 #else
01133
01134 void OnPosChange();
01135 int OnNotify(GViewI *c, int f);
01136 void OnNcPaint(GSurface *pDC, GRect &r);
01137
01138 #endif
01139 #endif
01140 };
01141
01143 #define GIC_OWNER_DRAW 0x01
01145 #define GIC_ASK_TEXT 0x02
01147 #define GIC_ASK_IMAGE 0x04
01149 #define GIC_OWN_LIST 0x08
01151 #define GIC_IN_DRAG_OP 0x10
01152
01153 class LgiClass GItemContainer
01154 {
01155 protected:
01156 int Flags;
01157 GImageList *ImageList;
01158
01159 public:
01160 GItemContainer();
01161 virtual ~GItemContainer();
01162
01163
01164 bool OwnerDraw() { return TestFlag(Flags, GIC_OWNER_DRAW); }
01165 void OwnerDraw(bool b) { if (b) SetFlag(Flags, GIC_OWNER_DRAW); else ClearFlag(Flags, GIC_OWNER_DRAW); }
01166 bool AskText() { return TestFlag(Flags, GIC_ASK_TEXT); }
01167 void AskText(bool b) { if (b) SetFlag(Flags, GIC_ASK_TEXT); else ClearFlag(Flags, GIC_ASK_TEXT); }
01168 bool AskImage() { return TestFlag(Flags, GIC_ASK_IMAGE); }
01169 void AskImage(bool b) { if (b) SetFlag(Flags, GIC_ASK_IMAGE); else ClearFlag(Flags, GIC_ASK_IMAGE); }
01170 bool InsideDragOp() { return TestFlag(Flags, GIC_IN_DRAG_OP); }
01171 void InsideDragOp(bool b) { if (b) SetFlag(Flags, GIC_IN_DRAG_OP); else ClearFlag(Flags, GIC_IN_DRAG_OP); }
01172
01173
01174 GImageList *GetImageList() { return ImageList; }
01175 bool SetImageList(GImageList *List, bool Own = true);
01176 bool LoadImageList(char *File, int x, int y);
01177 bool OwnList() { return TestFlag(Flags, GIC_OWN_LIST); }
01178 void OwnList(bool b) { if (b) SetFlag(Flags, GIC_OWN_LIST); else ClearFlag(Flags, GIC_OWN_LIST); }
01179 };
01180
01182
01183 #include "GMenu.h"
01184
01186
01188 enum GWindowZoom
01189 {
01191 GZoomMin,
01193 GZoomNormal,
01195 GZoomMax
01196 };
01197
01199 #define GMouseEvents 0x01
01201 #define GKeyEvents 0x02
01202
01204 class LgiClass GWindow :
01205 public GView
01206 #ifndef WIN32
01207 , public GDragDropTarget
01208 #endif
01209 {
01210 friend class BViewRedir;
01211 friend class GView;
01212 friend class GButton;
01213 friend class XWindow;
01214 friend class GDialog;
01215 #ifdef MAC
01216 friend pascal OSStatus LgiWindowProc(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData);
01217 #endif
01218
01219 bool _QuitOnClose;
01220
01221 protected:
01222 #if WIN32NATIVE
01223
01224 GRect OldPos;
01225 HWND LastFocus;
01226
01227 #else
01228
01229 OsWindow Wnd;
01230 void _OnViewDelete();
01231 void _SetDynamic(bool i);
01232
01233 #endif
01234
01235 #if defined BEOS
01236
01237 friend class GMenu;
01238 friend class GView;
01239
01240 #elif defined __GTK_H__
01241
01242 Gtk::GtkWidget *Root;
01243 void _Paint(GSurface *pDC = 0, int Ox = 0, int Oy = 0);
01244
01245 #endif
01246
01248 GViewI *_Default;
01249
01251 GMenu *Menu;
01252
01254 int VirtualFocusId;
01255
01256 class GWindowPrivate *d;
01257
01258 void SetChildDialog(GDialog *Dlg);
01259 void SetDragHandlers(bool On);
01260
01261 public:
01262 #ifdef __GTK_H__
01263 GWindow(Gtk::GtkWidget *w = 0);
01264 #else
01265 GWindow();
01266 #endif
01267 ~GWindow();
01268
01269 const char *GetClass() { return "GWindow"; }
01270
01272 virtual void Pour();
01273
01275 GMenu *GetMenu() { return Menu; }
01276
01278 void SetMenu(GMenu *m) { Menu = m; }
01279
01281 bool GetQuitOnClose() { return _QuitOnClose; }
01282
01289 void SetQuitOnClose(bool i) { _QuitOnClose = i; }
01290
01291 bool GetSnapToEdge();
01292 void SetSnapToEdge(bool b);
01293
01295 GWindowZoom GetZoom();
01296
01298 void SetZoom(GWindowZoom i);
01299
01301 void Raise();
01302
01303 void OnPosChange();
01304 int OnEvent(GMessage *Msg);
01305 void OnPaint(GSurface *pDC);
01306 bool HandleViewMouse(GView *v, GMouse &m);
01307 bool HandleViewKey(GView *v, GKey &k);
01308 bool OnRequestClose(bool OsShuttingDown);
01309 bool Visible();
01310 void Visible(bool i);
01311 GRect &GetPos();
01312
01315 bool RegisterHook
01316 (
01318 GView *Target,
01320 int EventType,
01322 int Priority = 0
01323 );
01324
01326 bool UnregisterHook(GView *Target);
01327
01329 virtual void OnZoom(GWindowZoom Action) {}
01330
01332 virtual void OnTrayClick(GMouse &m) {}
01333
01335 virtual void OnReceiveFiles(GArray<char*> &Files) {}
01336
01337 #if !WIN32NATIVE
01338
01339 bool Attach(GViewI *p);
01340
01341
01342 OsWindow WindowHandle() { return Wnd; }
01343 bool Name(const char *n);
01344 char *Name();
01345 bool SetPos(GRect &p, bool Repaint = false);
01346 GRect &GetClient(bool InClientSpace = true);
01347
01348
01349 int WillAccept(List<char> &Formats, GdcPt2 Pt, int KeyState);
01350 int OnDrop(char *Format, GVariant *Data, GdcPt2 Pt, int KeyState);
01351
01352
01353 void OnChildrenChanged(GViewI *Wnd, bool Attaching);
01354 void OnCreate();
01355
01356 #endif
01357
01358 #if defined MAC
01359
01360 bool PostEvent(int Cmd, int a = 0, int b = 0);
01361 void Quit(bool DontDelete = false);
01362 OSErr HandlerCallback(DragTrackingMessage *tracking, DragRef theDrag);
01363 int OnCommand(int Cmd, int Event, OsView Wnd);
01364 virtual void OnFrontSwitch(bool b);
01365
01366 #elif defined __GTK_H__
01367
01368 void SetFirstFocus(OsView Hnd);
01369 void OnMap(bool m);
01370
01371 #endif
01372
01374 GViewI *GetDefault();
01376 void SetDefault(GViewI *v);
01377
01379 bool SerializeState
01380 (
01382 GDom *Store,
01384 const char *FieldName,
01386 bool Load
01387 );
01388 };
01389
01391
01393 class LgiClass GToolTip : public GView
01394 {
01395 class GToolTipPrivate *d;
01396
01397 public:
01398 GToolTip();
01399 ~GToolTip();
01400
01402 int NewTip
01403 (
01405 char *Name,
01407 GRect &Pos
01408 );
01409
01411 void DeleteTip(int Id);
01412
01413 bool Attach(GViewI *p);
01414 };
01415
01417
01418 #include "LgiWidgets.h"
01419
01421
01422 #include "Progress.h"
01423 #include "GProgress.h"
01424
01426 #include "GFileSelect.h"
01427 #include "GFindReplaceDlg.h"
01428 #include "GToolBar.h"
01429 #include "GThread.h"
01430
01432
01434 class LgiClass GSplitter : public GLayout
01435 {
01436 class GSplitterPrivate *d;
01437
01438 void CalcRegions(bool Follow = false);
01439 bool OverSplit(int x, int y);
01440
01441 public:
01442 GSplitter();
01443 ~GSplitter();
01444
01445 const char *GetClass() { return "GSplitter"; }
01446
01448 int64 Value();
01449
01451 void Value(int64 i);
01452
01454 bool IsVertical();
01455
01457 void IsVertical(bool v);
01458
01460 bool DoesSplitFollow();
01461
01463 void DoesSplitFollow(bool i);
01464
01466 GView *GetViewA();
01467
01469 void DetachViewA();
01470
01472 void SetViewA(GView *a, bool Border = true);
01473
01475 GView *GetViewB();
01476
01478 void DetachViewB();
01479
01481 void SetViewB(GView *b, bool Border = true);
01482
01484 int BarSize();
01485
01487 void BarSize(int i);
01488
01489 bool Border();
01490 void Border(bool i);
01491 GViewI *FindControl(OsView hCtrl);
01492
01493 bool Attach(GViewI *p);
01494 bool Pour(GRegion &r);
01495 void OnPaint(GSurface *pDC);
01496 void OnPosChange();
01497 void OnMouseClick(GMouse &m);
01498 void OnMouseMove(GMouse &m);
01499 void OnMouseExit(GMouse &m);
01500 int OnHitTest(int x, int y);
01501 void OnChildrenChanged(GViewI *Wnd, bool Attaching);
01502 };
01503
01505 #define STATUSBAR_SEPARATOR 4
01506 #define GSP_SUNKEN 0x0001
01507
01508 class LgiClass GStatusBar : public GLayout
01509 {
01510 friend class GStatusPane;
01511
01512 protected:
01513 void RePour();
01514
01515 public:
01516 GStatusBar();
01517 ~GStatusBar();
01518
01519 const char *GetClass() { return "GStatusBar"; }
01520 bool Pour(GRegion &r);
01521 void OnPaint(GSurface *pDC);
01522
01523 GStatusPane *AppendPane(char *Text, int Width);
01524 bool AppendPane(GStatusPane *Pane);
01525 };
01526
01527 class LgiClass GStatusPane :
01528 public GView
01529 {
01530 friend class GStatusBar;
01531
01532 protected:
01533 int Flags;
01534 int Width;
01535 GSurface *pDC;
01536
01537 public:
01538 GStatusPane();
01539 ~GStatusPane();
01540
01541 const char *GetClass() { return "GStatusPane"; }
01542 char *Name() { return GBase::Name(); }
01543 bool Name(const char *n);
01544 void OnPaint(GSurface *pDC);
01545
01546 int GetWidth();
01547 void SetWidth(int x);
01548 bool Sunken();
01549 void Sunken(bool i);
01550 GSurface *Bitmap();
01551 void Bitmap(GSurface *pdc);
01552 };
01553
01555 class LgiClass GCommand : public GBase
01556 {
01557 int Flags;
01558 bool PrevValue;
01559
01560 public:
01561 int Id;
01562 GToolButton *ToolButton;
01563 GMenuItem *MenuItem;
01564 GKey *Accelerator;
01565 char *TipHelp;
01566
01567 GCommand();
01568 ~GCommand();
01569
01570 bool Enabled();
01571 void Enabled(bool e);
01572 bool Value();
01573 void Value(bool v);
01574 };
01575
01578 class LgiClass GTrayIcon :
01579 public GBase
01580
01581 {
01582 friend class GTrayWnd;
01583 class GTrayIconPrivate *d;
01584
01585 public:
01587 GTrayIcon
01588 (
01590 GWindow *p
01591 );
01592
01593 ~GTrayIcon();
01594
01596 bool Load(const TCHAR *Str);
01597
01599 bool Visible();
01600
01602 void Visible(bool v);
01603
01605 int64 Value();
01606
01608 void Value(int64 v);
01609
01611 virtual int OnEvent(GMessage *Msg);
01612 };
01613
01615 #include "GInput.h"
01616 #include "GPrinter.h"
01617
01619
01629 class LgiClass GAlert : public GDialog
01630 {
01631 public:
01633 GAlert
01634 (
01636 GViewI *parent,
01638 const char *Title,
01640 const char *Text,
01642 const char *Btn1,
01644 const char *Btn2 = 0,
01646 const char *Btn3 = 0
01647 );
01648
01649 int OnNotify(GViewI *Ctrl, int Flags);
01650 };
01651
01653 class LgiClass DoEvery
01654 {
01655 int64 LastTime;
01656 int64 Period;
01657
01658 public:
01660 DoEvery
01661 (
01663 int p = 1000
01664 );
01665
01667 void Init
01668 (
01670 int p = -1
01671 );
01672
01674 bool DoNow();
01675 };
01676
01681 class LgiClass GViewFactory
01682 {
01683 static List<GViewFactory> *Factories;
01684
01694 virtual GView *NewView
01695 (
01697 const char *Class,
01699 GRect *Pos,
01701 const char *Text
01702 ) = 0;
01703
01704 public:
01705 GViewFactory();
01706 virtual ~GViewFactory();
01707
01709 static GView *Create(const char *Class, GRect *Pos = 0, const char *Text = 0);
01710 };
01711
01713
01714
01715 LgiFunc void LgiInitColours();
01716 LgiFunc COLOUR LgiColour(int Colour);
01717
01718
01719 LgiFunc void LgiDrawBox(GSurface *pDC, GRect &r, bool Sunken, bool Fill);
01720 LgiFunc void LgiWideBorder(GSurface *pDC, GRect &r, int Type);
01721 LgiFunc void LgiThinBorder(GSurface *pDC, GRect &r, int Type);
01722 LgiFunc void LgiFlatBorder(GSurface *pDC, GRect &r, int Width = -1);
01723
01724
01725
01726 #ifdef LINUX
01728 LgiFunc void LgiFinishXWindowsStartup(class GViewI *Wnd);
01729 #endif
01730
01733 LgiFunc int LgiMsg
01734 (
01736 GViewI *Parent,
01738 const char *Msg,
01740 const char *Title = 0,
01743 int Type = MB_OK,
01744 ...
01745 );
01746
01749 struct GDisplayInfo
01750 {
01754 GRect r;
01756 int BitDepth;
01758 int Refresh;
01760 char *Device;
01762 char *Name;
01764 char *Monitor;
01765
01766 GDisplayInfo()
01767 {
01768 r.ZOff(-1, -1);
01769 BitDepth = 0;
01770 Refresh = 0;
01771 Device = 0;
01772 Name = 0;
01773 Monitor = 0;
01774 }
01775
01776 ~GDisplayInfo()
01777 {
01778 DeleteArray(Device);
01779 DeleteArray(Name);
01780 DeleteArray(Monitor);
01781 }
01782 };
01783
01786 bool LgiGetDisplays
01787 (
01790 GArray<GDisplayInfo*> &Displays,
01793 GRect *AllDisplays = 0
01794 );
01795
01796 #endif
01797
01798