1 // $Id: x11_display.hxx,v 1.25 2003/07/28 21:03:22 grumbel Exp $
3 // Construo - A wire-frame construction game
4 // Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef HEADER_X11_DISPLAY_HXX
21 #define HEADER_X11_DISPLAY_HXX
24 #include <X11/Xutil.h>
26 #ifdef HAVE_LIBXXF86VM
27 # include <X11/extensions/xf86vmode.h>
30 #include "cursors.hxx"
32 #include "root_graphic_context.hxx"
33 #include "input_context.hxx"
35 #define X11_FULLSCREEN_MODE true
36 #define X11_WINDOW_MODE false
46 /** X11Display driver */
47 class X11Display
: public RootGraphicContext
,
52 Pixmap cursor_scroll_pix
;
53 Pixmap cursor_scroll_mask
;
56 Pixmap cursor_zoom_pix
;
57 Pixmap cursor_zoom_mask
;
60 Pixmap cursor_insert_pix
;
61 Pixmap cursor_insert_mask
;
64 Pixmap cursor_select_pix
;
65 Pixmap cursor_select_mask
;
67 Cursor cursor_collider
;
68 Pixmap cursor_collider_pix
;
69 Pixmap cursor_collider_mask
;
72 #ifdef HAVE_LIBXXF86VM
73 XF86VidModeModeLine orig_modeline
;
91 /** Color Depth of the Display */
94 /** true if display is in fullscreen mode, false for window mode */
97 std::vector
<FlipRect
> flip_rects
;
98 std::vector
<FlipRect
> last_flip_rects
;
100 /** Save the current visual mode for later restoration after leaving
104 X11Display (int w
, int h
, bool fullscreen_
);
105 virtual ~X11Display ();
107 // Graphic Context stuff
108 void draw_lines (std::vector
<Line
>& lines
, Color color
, int wide
= 0);
109 void draw_line(float x1
, float y1
, float x2
, float y2
, Color color
, int wide
= 0);
110 void draw_rect(float x1
, float y1
, float x2
, float y2
, Color color
);
111 void draw_fill_rect(float x1
, float y1
, float x2
, float y2
, Color color
);
112 void draw_circle(float x
, float y
, float r
, Color color
);
113 void draw_circles(std::vector
<Circle
>& circles
, Color color
);
115 void draw_fill_circle(float x
, float y
, float r
, Color color
);
116 void draw_string(float x
, float y
, const std::string
& str
, Color color
);
117 void draw_string_centered(float x
, float y
, const std::string
& str
, Color color
);
119 int get_width () { return width
; }
120 int get_height () { return height
; }
122 void toggle_fullscreen();
126 /** Flip the double buffered display */
129 void enter_fullscreen();
130 void leave_fullscreen();
132 /** perform the real flip, only flip marked reagions */
135 void flip (int x1
, int y1
, int x2
, int y2
);
137 // Input Context stuff
141 bool get_key (int key
);
143 /** Waits for events to come in, blocks until new events are available */
144 void wait_for_events_blocking ();
146 void wait_for_events ();
150 void set_clip_rect (int x1_
, int y1_
, int x2_
, int y2_
);
152 unsigned int get_color_value(const Color
& color
);
153 XColor
get_xcolor(const Color
& color
);
155 void set_cursor_real(CursorType cursor
);
158 void send_button_press (int i
);
159 void send_button_release (int i
);
160 void send_load_or_save(int n
);
162 X11Display (const X11Display
&);
163 X11Display
& operator= (const X11Display
&);