|
Rapicorn - Experimental UI Toolkit - Source Code 10.08.1
|
00001 /* Rapicorn 00002 * Copyright (C) 2006 Tim Janik 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * A copy of the GNU Lesser General Public License should ship along 00015 * with this library; if not, see http://www.gnu.org/copyleft/. 00016 */ 00017 #ifndef __RAPICORN_VIEWP0RT_HH__ 00018 #define __RAPICORN_VIEWP0RT_HH__ 00019 00020 #include <ui/events.hh> 00021 00022 namespace Rapicorn { 00023 00024 class Viewp0rt : public virtual Deletable, protected NonCopyable { 00025 protected: 00026 explicit Viewp0rt () {} 00027 public: 00028 /* viewp0rt info (constant during runtime) */ 00029 struct Info { 00030 WindowType window_type; 00031 }; 00032 /* viewp0rt state */ 00033 typedef enum { 00034 STATE_STICKY = 0x0004, 00035 STATE_WITHDRAWN = 0x0008, 00036 STATE_HMAXIMIZED = 0x0010, 00037 STATE_VMAXIMIZED = 0x0020, 00038 STATE_FULLSCREEN = 0x0040, 00039 STATE_ICONIFIED = 0x0080, 00040 STATE_ABOVE = 0x0100, 00041 STATE_BELOW = 0x0200, 00042 } WindowState; 00043 struct State { 00044 bool local_blitting; /* blitting via shared memory */ 00045 bool is_active; 00046 bool has_toplevel_focus; /* for embedded windows, this may be false allthough is_active==true */ 00047 WindowState window_state; 00048 double width, height; 00049 }; 00050 /* viewp0rt configuration */ 00051 typedef enum { 00052 HINT_DECORATED = 0x0001, 00053 HINT_URGENT = 0x0002, 00054 HINT_STICKY = 0x0004, 00055 HINT_SHADED = 0x0008, 00056 HINT_HMAXIMIZED = 0x0010, 00057 HINT_VMAXIMIZED = 0x0020, 00058 HINT_FULLSCREEN = 0x0040, /* no decoration, for presentation */ 00059 HINT_ICONIFY = 0x0080, /* minimize */ 00060 HINT_ABOVE_ALL = 0x0100, 00061 HINT_BELOW_ALL = 0x0200, 00062 HINT_SKIP_TASKBAR = 0x0400, 00063 HINT_SKIP_PAGER = 0x0800, 00064 HINT_ACCEPT_FOCUS = 0x1000, 00065 HINT_UNFOCUSED = 0x2000, /* no focus at start up */ 00066 HINT_DELETABLE = 0x4000, /* has [X] delete button */ 00067 } WindowHint; 00068 struct Config { 00069 bool modal; 00070 WindowHint window_hint; 00071 String title; 00072 String session_role; 00073 double root_x, root_y; 00074 double request_width, request_height; 00075 double min_width, min_height; 00076 double initial_width, initial_height; 00077 double max_width, max_height; 00078 double base_width, base_height; 00079 double width_inc, height_inc; 00080 double min_aspect, max_aspect; /* horizontal / vertical */ 00081 Color average_background; 00082 explicit Config() : 00083 modal (false), 00084 window_hint (WindowHint (HINT_DECORATED | HINT_ACCEPT_FOCUS | HINT_DELETABLE)), 00085 root_x (NAN), root_y (NAN), 00086 request_width (33), request_height (33), 00087 min_width (0), min_height (0), 00088 initial_width (0), initial_height (0), 00089 max_width (0), max_height (0), 00090 base_width (0), base_height (0), 00091 width_inc (0), height_inc (0), 00092 min_aspect (0), max_aspect (0), 00093 average_background (0xff808080) 00094 {} 00095 }; 00096 /* --- frontend API --- */ 00097 struct EventReceiver { 00098 virtual ~EventReceiver () {} 00099 virtual void enqueue_async (Event *event) = 0; 00100 }; 00101 /* --- public API --- */ 00102 virtual Info get_info () = 0; 00103 virtual State get_state () = 0; 00104 virtual void set_config (const Config &config, 00105 bool force_resize_draw = false) = 0; 00106 virtual void beep (void) = 0; 00107 /* creation */ 00108 static Viewp0rt* create_viewp0rt (const String &backend_name, 00109 WindowType viewp0rt_type, 00110 EventReceiver &receiver); 00111 /* actions */ 00112 virtual void present_viewp0rt () = 0; 00113 virtual void trigger_hint_action (WindowHint hint) = 0; 00114 virtual void start_user_move (uint button, 00115 double root_x, 00116 double root_y) = 0; 00117 virtual void start_user_resize (uint button, 00118 double root_x, 00119 double root_y, 00120 AnchorType edge) = 0; 00121 virtual void show (void) = 0; 00122 virtual bool visible (void) = 0; 00123 virtual bool viewable (void) = 0; 00124 virtual void hide (void) = 0; 00125 virtual uint last_draw_stamp () = 0; 00126 virtual void enqueue_win_draws (void) = 0; 00127 virtual void blit_display (Display &plane) = 0; 00128 virtual void create_display_backing (Rapicorn::Display &display) = 0; 00129 virtual void copy_area (double src_x, 00130 double src_y, 00131 double width, 00132 double height, 00133 double dest_x, 00134 double dest_y) = 0; 00135 /* --- backend API --- */ 00136 class FactoryBase : protected NonCopyable { 00137 friend class Viewp0rt; 00138 protected: 00139 virtual ~FactoryBase (); 00140 const String m_name; 00141 explicit FactoryBase (const String &name) : m_name (name) {} 00142 static void register_backend (FactoryBase &factory); 00143 virtual Viewp0rt* create_viewp0rt (WindowType viewp0rt_type, 00144 EventReceiver &receiver) = 0; 00145 }; 00146 template<class Backend> 00147 class Factory : public virtual FactoryBase { 00148 public: 00149 explicit Factory (const String &name) : FactoryBase (name) { register_backend (*this); } 00150 virtual Viewp0rt* create_viewp0rt (WindowType viewp0rt_type, 00151 EventReceiver &receiver) { return new Backend (m_name, viewp0rt_type, receiver); } 00152 }; 00153 }; 00154 00155 /* internal */ 00156 void rapicorn_gtk_threads_enter (); 00157 void rapicorn_gtk_threads_leave (); 00158 00159 } // Rapicorn 00160 00161 #endif /* __RAPICORN_VIEWP0RT_HH__ */
1.7.4