00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _unatdisp_hpp_
00022 #define _unatdisp_hpp_
00023
00024 #include <ubit/unatgraph.hpp>
00025 #include <ubit/unatwin.hpp>
00026 #include <ubit/uappli.hpp>
00027 namespace ubit {
00028
00029 class UColorImpl;
00030 class UNatFont;
00031
00032
00035 class UNatDisp {
00036 public:
00037 struct {
00038 USysAtom _PRIMARY_SELECTION, _SECONDARY_SELECTION,
00039 _WM_PROTOCOLS, _WM_DELETE_WINDOW, _WM_TAKE_FOCUS, _UMS_WINDOW, _UMS_MESSAGE;
00040 } atoms;
00047 UNatDisp(UDisp&);
00048 virtual ~UNatDisp();
00049
00050 bool isOpened() const {return is_opened;}
00052
00053 UDisp& getDisp() const {return disp;}
00055
00056 int getID() const {return disp.id;}
00058
00059 void realize();
00061
00062 bool isRealized() const;
00064
00065 USysDisp getSysDisp() const {return sys_disp;}
00066 USysScreen getSysScreen() const {return sys_screen;}
00067 USysVisual getSysVisual() const {return sys_visual;}
00068 USysWin getSysRoot() const;
00069 USysWin getSysFrame() const {return mainframe.sys_win;}
00070 UNatWin& getNatFrame() {return mainframe;}
00071 USysColormap getSysColormap() const {return sys_cmap;}
00072 USysPixel getBlackPixel() const;
00073 USysPixel getWhitePixel() const;
00074
00075 int getDepth() const {return depth;}
00077
00078 int getScreenWidth() const;
00079 int getScreenHeight() const;
00081
00082 int getScreenNumber() const;
00084
00085 int getScreenCount() const;
00087
00088 unsigned long getRedMask() const {return red_mask;}
00089 unsigned long getGreenMask() const {return green_mask;}
00090 unsigned long getBlueMask() const {return blue_mask;}
00091 int getRedShift() const {return red_shift;}
00092 int getGreenShift() const {return green_shift;}
00093 int getBlueShift() const {return blue_shift;}
00094 int getRedBits() const {return red_bits;}
00095 int getGreenBits() const {return green_bits;}
00096 int getBlueBits() const {return blue_bits;}
00098
00099 int getShiftMask() const {return shift_mask;}
00100 int getControlMask() const {return control_mask;}
00101 int getMetaMask() const {return meta_mask;}
00102 int getAltMask() const {return alt_mask;}
00103 int getAltGraphMask() const {return alt_graph_mask;}
00104
00105
00106
00107
00108 USysPixel getColorPixel(const UColor& c);
00109 USysPixel getColorPixel(UColorImpl&);
00114 bool realizeColor(const UColor& c);
00115 bool realizeColor(UColorImpl&);
00121
00122
00123
00124 USysCursor getCursor(const UCursor&);
00129 bool setCursor(UNatWin&, const UCursor*);
00134 bool realizeCursor(const UCursor&);
00139
00140
00141
00142 UNatFont* getFont(const UFontDesc&);
00147 UNatFont* realizeFont(const UFont&);
00148 UNatFont* realizeFont(const UFontDesc&);
00149 void realizeFontFamily(const UFontFamily&);
00154
00155 #ifdef HAVE_GL
00156
00157 bool setGLVisual(int bpp = 0);
00163 bool setGLVisual(XVisualInfo*);
00165
00166 XVisualInfo* getGLVisual() {return glvisual;}
00168
00169 GLXContext createNewGLContext();
00171
00172 bool setMainGLContext(GLXContext);
00174
00175 GLXContext getMainGLContext() {return glcontext;}
00177
00178 #endif
00179
00180 void resizeGLViewport(int w, int h);
00182
00183
00184
00185
00186 #ifndef WITH_GDK
00187 int setVisual(int visual_class, int depth_hint, bool linear_gamma,
00188 USysColormap = None);
00204 int setVisual(const XVisualInfo&, USysColormap = None);
00211 int chooseVisual(XVisualInfo&, int visual_class, int depth_hint, bool linear_gamma);
00225 bool findExactVisual(XVisualInfo&, int visual_class, int depth,
00226 bool linear_gamma);
00227 #endif
00228
00229
00230
00231
00232 bool setSelectionOwner(UEvent&);
00237 void copySelectionCallback(USysEvent);
00243 void pasteSelectionRequest(UEvent&);
00250 void pasteSelectionCallback(USysEvent);
00256
00257
00258
00259 void dispatchEvent(USysEvent);
00261
00262 UEventFlow* obtainFlow(unsigned int ev_state, unsigned long channel);
00264
00265 void on_selection(UWin*, UView*, USysEvent);
00266 void on_expose(UWin*, UView*, USysEvent);
00267 void on_mpress(UWin*, UView*, USysEvent);
00268 void on_mrelease(UWin*, UView*, USysEvent);
00269 void on_mmove(UWin*, UView*, USysEvent);
00270 void on_kpress(UWin*, UView*, USysEvent);
00271 void on_krelease(UWin*, UView*, USysEvent);
00272 void on_enter(UWin*, UView*, USysEvent);
00273 void on_leave(UWin*, UView*, USysEvent);
00274 void on_focus(UWin*, UView*, USysEvent);
00275 void on_configure(UWin*, UView*, USysEvent);
00276 void on_winstate(UWin*, UView*, USysEvent);
00277 void on_property(UWin*, UView*, USysEvent);
00278 void on_clientmsg(UWin*, UView*, USysEvent);
00279 void on_misc(UWin*, UView*, USysEvent);
00280
00281
00282
00283
00284 USysPix getDefaultPixmap() const {return default_pixmap;}
00286
00287 UNatGraph* getNatGraph() const {return natgraph;}
00289
00290 void initModifiers();
00292
00293
00294 private:
00295 friend class UAppliImpl;
00296 friend class UNatAppli;
00297 friend class UNatWin;
00298 friend class UGraph;
00299 friend class UGraphElem;
00300 friend class UNatGraph;
00301 friend class UFontFamily;
00302 friend class UDisp;
00303
00304 UDisp& disp;
00305 bool is_opened;
00306 USysDisp sys_disp;
00307 USysScreen sys_screen;
00308 USysVisual sys_visual;
00309 USysColormap sys_cmap;
00310 UNatWin mainframe;
00311 USysPix default_pixmap;
00312 int depth;
00313 int xconnection;
00314 unsigned long red_mask, green_mask, blue_mask;
00315 int red_shift, green_shift, blue_shift;
00316 int red_bits, green_bits, blue_bits;
00317 int shift_mask, control_mask, meta_mask, alt_mask, alt_graph_mask;
00318 UNatGraph* natgraph;
00319 std::vector<UNatFont**> font_map;
00320 UTime app_motion_time, nat_motion_time;
00321 #ifdef HAVE_GL
00322 XVisualInfo* glvisual;
00323 GLXContext glcontext;
00324 #endif
00325 };
00326
00327 }
00328 #endif
00329
00330