1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
2 | // Module PI : Peida Interactive PIWdgX
|
---|
3 | // Reza 10/95
|
---|
4 | // LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA
|
---|
5 |
|
---|
6 | #ifndef PIWDG_X_SEEN
|
---|
7 | #define PIWDG_X_SEEN
|
---|
8 |
|
---|
9 | #include <X11/Xlib.h>
|
---|
10 | #include <X11/Intrinsic.h>
|
---|
11 |
|
---|
12 | #include "piwdggen.h"
|
---|
13 |
|
---|
14 | typedef Widget SysDWdg;
|
---|
15 | typedef WidgetClass SysDWdgClass;
|
---|
16 |
|
---|
17 |
|
---|
18 | class PIWdgX : public PIWdgGen
|
---|
19 | {
|
---|
20 | public:
|
---|
21 | // Les methodes ...
|
---|
22 | PIWdgX(int narg=0, char *arg[]=NULL);
|
---|
23 | PIWdgX(PIContainerGen *par, char *nom,
|
---|
24 | int sx=10, int sy=10, int px=0, int py=0);
|
---|
25 |
|
---|
26 | virtual ~PIWdgX();
|
---|
27 |
|
---|
28 | virtual void FinishCreate(); // apres avoir installe les sous-vues
|
---|
29 |
|
---|
30 | virtual void SetSize(int sx, int sy);
|
---|
31 | virtual void SetPos(int px, int py);
|
---|
32 | virtual void SetLabel(string const & lab);
|
---|
33 |
|
---|
34 |
|
---|
35 | virtual void SetBinding(PIBindingKind left, PIBindingKind top,
|
---|
36 | PIBindingKind right, PIBindingKind bottom);
|
---|
37 | virtual bool GetBinding(PIBindingKind& left, PIBindingKind& top,
|
---|
38 | PIBindingKind& right, PIBindingKind& bottom);
|
---|
39 |
|
---|
40 | virtual int XSize();
|
---|
41 | virtual int YSize();
|
---|
42 | virtual int XPos();
|
---|
43 | virtual int YPos();
|
---|
44 |
|
---|
45 | virtual string Nom();
|
---|
46 | virtual void GetScreenPos(int & spx, int & spy);
|
---|
47 |
|
---|
48 | virtual void Manage();
|
---|
49 | virtual void UnManage();
|
---|
50 | virtual bool IfManaged();
|
---|
51 | virtual bool IsVisible();
|
---|
52 |
|
---|
53 | // Fonction qui doit etre appelee pour rafraichir la fenetre
|
---|
54 | virtual void Refresh();
|
---|
55 |
|
---|
56 | // Pour rendre un composant graphique (PIWdg) sensible/insensible
|
---|
57 | virtual void SetSensitive();
|
---|
58 | virtual void SetUnSensitive();
|
---|
59 | virtual bool IfSensitive();
|
---|
60 |
|
---|
61 | // Gestion de copier-coller
|
---|
62 | virtual bool ClaimSelection(unsigned int typ=PICP_string);
|
---|
63 | virtual void SelectionLost();
|
---|
64 | virtual unsigned int RequestSelection(unsigned int typ=PICP_string);
|
---|
65 | virtual void* ProvideSelection(unsigned int& typ, unsigned int& len);
|
---|
66 | virtual void SelectionTransferEnd();
|
---|
67 | virtual void PasteSelection(unsigned int typ, void *, unsigned int l);
|
---|
68 |
|
---|
69 | // Copie depuis un PIWdgGen
|
---|
70 | virtual void CopyFrom(PIWdgGen* wdg, int ox, int oy, int dx, int dy, int x, int y);
|
---|
71 |
|
---|
72 | // Gestion des EventHandler
|
---|
73 | virtual void AddDrawHandler(PIEventHandler* drwh, bool ad=false);
|
---|
74 | virtual void RemoveDrawHandler(PIEventHandler* drwh);
|
---|
75 | virtual void AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad=false);
|
---|
76 | virtual void RemoveEventHandler(PIEventHandler* evh);
|
---|
77 |
|
---|
78 | // En public, pour permettre l'acces depuis call-back Xt
|
---|
79 | virtual void CallDrawHandlers(int x0, int y0, int dx, int dy);
|
---|
80 | virtual void CallEventHandlers(unsigned long evt, int px, int py,
|
---|
81 | int k, int km, unsigned long tm);
|
---|
82 |
|
---|
83 | // Usage limite a a la version X11
|
---|
84 | inline SysDWdg XtWdg() const {return(sdw); };
|
---|
85 | inline SysDWdg& XtWdg() {return(sdw); };
|
---|
86 | int CreateXtWdg(char *nom, SysDWdgClass wdgcl=NULL, SysDWdg pwdg=NULL,
|
---|
87 | int sx=10, int sy=10, int px=0, int py=0, Arg* oarg=NULL, int na=0);
|
---|
88 | int BorderWidth();
|
---|
89 | void SetBorderWidth(int bw);
|
---|
90 |
|
---|
91 | protected:
|
---|
92 | // Definit le type de Widget, en particulier pour la gestion des feneteres de haut niveau
|
---|
93 | // k_wmi_cascade : Widget cree en cascade d'un autre (Exemple pour PIWIndowX)
|
---|
94 | enum WmIntState { k_wmi_unknown=0,
|
---|
95 | k_wmi_normal=1, k_wmi_toplevel=2,
|
---|
96 | k_wmi_transient=3, k_wmi_override=4,
|
---|
97 | k_wmi_appshell=5, k_wmi_cascade=6 };
|
---|
98 |
|
---|
99 | int InitXt(int narg=0, char *arg[]=NULL);
|
---|
100 |
|
---|
101 | SysDWdg sdw;
|
---|
102 | WmIntState wmis;
|
---|
103 | bool stmng;
|
---|
104 | PIBindingKind mBKleft, mBKright, mBKtop, mBKbottom;
|
---|
105 | };
|
---|
106 |
|
---|
107 | typedef PIWdgX PIWdg;
|
---|
108 |
|
---|
109 | // -------- La classe PIScreenBuffer ----------
|
---|
110 | class PIScreenBuffer {
|
---|
111 | public :
|
---|
112 | PIScreenBuffer(int sx, int sy);
|
---|
113 | virtual ~PIScreenBuffer();
|
---|
114 |
|
---|
115 | virtual int XSize();
|
---|
116 | virtual int YSize();
|
---|
117 | virtual void CopyFromWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y);
|
---|
118 | virtual void CopyToWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y);
|
---|
119 | virtual void CopyFrom(PIScreenBuffer* grb, int ox, int oy, int dx, int dy, int x, int y);
|
---|
120 |
|
---|
121 | // Acces au Drawable X
|
---|
122 | inline Pixmap XScrBuffer() { return(xScrbuff); }
|
---|
123 | protected :
|
---|
124 | Pixmap xScrbuff;
|
---|
125 | int mSx, mSy;
|
---|
126 | };
|
---|
127 |
|
---|
128 |
|
---|
129 | // Utile pour avoir acces au Display et Screen X ...
|
---|
130 | SysDWdg PIXtTopWdg();
|
---|
131 | XtAppContext* PIXtAppCtx(int& szx, int& szy, int& szf);
|
---|
132 | Display * PIXDisplay();
|
---|
133 | #define PIXScreen() DefaultScreen(PIXDisplay())
|
---|
134 | Time PIXGetLastEventTime();
|
---|
135 | unsigned long PIXGetLastEventSerial();
|
---|
136 | void PIXSetLastEventTimeSerial(Time t, unsigned long ser);
|
---|
137 | void PIXGetLastEventInfo(unsigned int& st, Time& t);
|
---|
138 |
|
---|
139 |
|
---|
140 | #endif/* PIWDGX_SEEN */
|
---|
141 |
|
---|
142 |
|
---|
143 |
|
---|