Welcome to the NetCologne GmbH open source mirroring service!

This machine mirrors various open-source projects. 20 Gbit/s uplink.

If there are any issues or you want another project mirrored, please contact mirror-service -=AT=- netcologne DOT de !

x11_display.hxx Source File
Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

x11_display.hxx

Go to the documentation of this file.
00001 //  $Id: x11_display.hxx,v 1.19 2003/01/09 22:10:24 grumbel Exp $
00002 // 
00003 //  Construo - A wire-frame construction game
00004 //  Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 // 
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #ifndef HEADER_X11_DISPLAY_HXX
00021 #define HEADER_X11_DISPLAY_HXX
00022 
00023 #include <X11/Xlib.h>
00024 #include <X11/Xutil.h>
00025 
00026 #ifdef HAVE_LIBXXF86VM
00027 #  include <X11/extensions/xf86vmode.h>
00028 #endif
00029 
00030 #include "math.hxx"
00031 #include "graphic_context.hxx"
00032 #include "input_context.hxx"
00033 
00034 #define X11_FULLSCREEN_MODE true
00035 #define X11_WINDOW_MODE     false
00036 
00037 struct FlipRect
00038 {
00039   int x1;
00040   int y1;
00041   int x2;
00042   int y2;
00043 };
00044 
00046 class X11Display : public GraphicContext,
00047                    public InputContext
00048 {
00049 private:
00050   bool doublebuffer;
00051 #ifdef HAVE_LIBXXF86VM
00052   XF86VidModeModeLine orig_modeline;
00053 #endif
00054   int orig_viewport_x;
00055   int orig_viewport_y;
00056   int orig_dotclock;
00057 
00058   int       width;
00059   int       height;
00060   Display*  display;
00061   Window    window;
00062   Colormap  colormap;
00063   Drawable  drawable;
00064   GC        gc;
00065 
00066   bool shift_pressed;
00067   int  mouse_x;
00068   int  mouse_y;
00069 
00071   bool fullscreen;
00072 
00073   std::vector<FlipRect> flip_rects;
00074   std::vector<FlipRect> last_flip_rects;
00075 public:
00076   X11Display (int w, int h, bool fullscreen_);
00077   virtual ~X11Display ();
00078 
00079   // Graphic Context stuff
00080   void draw_lines (std::vector<Line>& lines, Color color, int wide = 0);
00081   void draw_line(float x1, float y1, float x2, float y2, Color color, int wide = 0);
00082   void draw_rect(float x1, float y1, float x2, float y2, Color color);
00083   void draw_fill_rect(float x1, float y1, float x2, float y2, Color color);
00084   void draw_circle(float x, float y, float r, Color color);
00085   void draw_circles(std::vector<Circle>& circles, Color color);
00086 
00087   void draw_fill_circle(float x, float y, float r, Color color);
00088   void draw_string(float x, float y, const std::string& str, Color color);
00089   void draw_string_centered(float x, float y, const std::string& str, Color color);
00090 
00091   int get_width () { return width; }
00092   int get_height () { return height; }
00093 
00094   void set_fullscreen (bool fullscreen);
00095   void restore_mode ();
00096 
00097   void clear ();
00098   
00100   void flip ();
00101 
00103   void real_flip ();
00104 
00105   void flip (int x1, int y1, int x2, int y2);
00106 
00107   // Input Context stuff
00108   int get_mouse_x ();
00109   int get_mouse_y ();
00110 
00111   bool get_key (int key);
00112 
00114   void wait_for_events_blocking ();
00115 
00116   void wait_for_events ();
00117 
00118   void run();
00119 
00120   void set_clip_rect (int x1_, int y1_, int x2_, int y2_);
00121 
00122   unsigned int get_color_value(Color& color);
00123 private:
00124   bool read_event ();
00125   void send_button_press (int i);
00126   void send_button_release (int i);
00127   void send_load_or_save(int n);
00128 
00129   X11Display (const X11Display&);
00130   X11Display& operator= (const X11Display&);
00131 };
00132 
00133 #endif
00134 
00135 /* EOF */

Generated on Thu Jul 24 10:24:32 2003 for Construo by doxygen1.3-rc3