📄 display.h
字号:
/* $Id: display.h,v 1.38 2004/01/02 15:42:43 mbn Exp $
**
** ClanLib Game SDK
** Copyright (C) 2003 The ClanLib Team
** For a total list of contributers see the file CREDITS.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
*/
//! clanDisplay="Display 2D"
//! header=display.h
#ifndef header_display
#define header_display
#if _MSC_VER > 1000
#pragma once
#endif
#ifdef _MSC_VER
#pragma warning( disable : 4786)
#endif
#include <string>
#include "color.h"
#include "gradient.h"
#include "../signals.h"
#include "../Core/Math/rect.h"
#include "../Core/Math/size.h"
#include "../Core/Math/point.h"
class CL_DisplayWindow;
class CL_InputEvent;
class CL_PixelBuffer;
class CL_DisplayMode;
//: Top level display class.
//- !group=Display/Display 2D!
//- !header=display.h!
//- <p>The display class provides a static function interface to
//- CL_DisplayWindow and other clanDisplay classes. It uses a selected
//- display window (by default the first created window) to call the
//- equalent functions in CL_DisplayWindow, CL_GraphicContext and such.</p>
//- <p>The entire point of this is to allow applications with only one
//- window to not pass around a pointer to the display window.</p>
class CL_Display
{
//! Attributes:
public:
//: Returns the currently selected window.
static CL_DisplayWindow *get_current_window();
//: Returns the current width of the window.
static int get_width();
//: Returns the current height of the window.
static int get_height();
//: Returns true if window is currently running fullscreen.
static bool is_fullscreen();
//: Returns true if window has focus.
static bool has_focus();
//: Returns the pixel buffer for the specified flipping buffer.
static CL_PixelBuffer *get_buffer(int i);
//: Returns the amount of flipping buffers being used.
static int get_buffer_count();
//: Returns the current flipping buffer being used as the front buffer.
static CL_PixelBuffer &get_front_buffer();
//: Returns the current flipping buffer being used as the back buffer.
static CL_PixelBuffer &get_back_buffer();
//: Returns the current clipping rectangle used on the graphic context.
static const CL_Rect &get_cliprect();
//: Returns the current effective x-axis translation offset.
static int get_translate_x();
//: Returns the current effective y-axis translation offset.
static int get_translate_y();
//! Operations:
public:
//: Sets the currently selected window.
static void set_current_window(CL_DisplayWindow *window);
//: Change window to running fullscreen mode.
static void set_fullscreen(int width, int height, int bpp);
//: Change window to running fullscreen mode.
static void set_fullscreen(const CL_DisplayMode &display_mode);
//: Change window to running windowed mode.
static void set_windowed();
//: Change window title.
static void set_title(const std::string &title);
//: Set window position and size.
static void set_position(const CL_Rect &pos);
static void set_position(int x, int y);
//: Resize window.
static void set_size(int width, int height);
//: Changes the amount of surface buffers used in the flipping system.
//: (2 = double buffer, 3 = triple buffer)
static void set_buffer_count(int flipping_buffers);
//: Copy the specified rectangle area from back buffer to front buffer.
static void update(const CL_Rect &rect);
//: Flip back buffer to front, making changes visible on screen.
static void flip();
//: Flushes current rendering batch.
//- <p>With the OpenGL target, this causes the graphic context to end its current
//- active glBegin()/glEnd() pair, making it possible to call other OpenGL calls.</p>
static void flush();
//: Draw a pixel at (x, y) using the specified color.
static void draw_pixel(int x, int y, const CL_Color &color);
//: Draw a line from (x1, y1) to (x2, y2) using the specified color.
static void draw_line(int x1, int y1, int x2, int y2, const CL_Color &color);
//: Draw a rectangle using the specified color.
static void draw_rect(const CL_Rect &rect, const CL_Color &color);
//: Draw a gradient rectangle using the specified gradient.
static void fill_rect(const CL_Rect &rect, const CL_Gradient &gradient);
//: Draw a filled rectangle using the specified color.
static void fill_rect(const CL_Rect &rect, const CL_Color &color);
//: Clears the whole window using the specified color.
static void clear(const CL_Color &color = CL_Color(0,0,0));
//: Set the current clipping rectangle.
static void set_cliprect(const CL_Rect &rect);
//: Push current clipping rectangle to stack.
//- <p>If a rectangle is passed, it afterwards sets clipping
//- rectangle to the union of the current rectangle and the passed
//- rectangle.</p>
static void push_cliprect(const CL_Rect &rect);
static void push_cliprect();
//: Pop current clipping rectangle from the stack.
static void pop_cliprect();
//: Sets the translate offset.
//- <p> The new offset will disregard any previous offset's, but will not
//- empty the translation stack. The new translation offset will affect
//- any subsequent display operations on the current displaycard, by
//- translating the position of the display operation with the offset. </p>
static void set_translate_offset(int x, int y);
//: Push translation offset onto translation stack.
//- <p> This offset will affect any subsequent display operations on the current
//- displaycard, by translating the position of the display operation with the offset.
//- The offset will be offset by any previous offsets pushed onto the stack,
//- eg. it inherits the previous offset. </p>
static void push_translate_offset(int delta_x, int delta_y);
static void push_translate_offset();
//: Pops the last pushed translation offset from the translation offset stack.
//- <p> If the stack is empty, nothing will happen, and if the last
//- translation offset is popped, the translation offset will be set to 0,0. </p>
static void pop_translate_offset();
//! Signals:
public:
//: Signal emitted when window is resized.
static CL_Signal_v2<int, int> &sig_resize();
//: Signal emitted when an area of the window is invalidated.
static CL_Signal_v1<const CL_Rect &> &sig_paint();
//: Signal emitted when window lost focus.
static CL_Signal_v0 &sig_lost_focus();
//: Signal emitted when window gain focus.
static CL_Signal_v0 &sig_got_focus();
//: Signal emitted when window is closed.
static CL_Signal_v0 &sig_window_close();
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -