Go to the documentation of this file.00001
00002 #ifndef vgui_win32_adaptor_h_
00003 #define vgui_win32_adaptor_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <windows.h>
00017
00018 #include <vgui/vgui_adaptor.h>
00019 #include <vgui/internals/vgui_adaptor_mixin.h>
00020 #include <vgui/impl/win32/vgui_win32_cmdtarget.h>
00021 #include <vcl_map.h>
00022
00023 class vgui_win32_window;
00024 class vgui_win32_internal_timer;
00025
00026 class vgui_win32_adaptor : public vgui_adaptor, public vgui_adaptor_mixin,
00027 public vgui_win32_cmdtarget
00028 {
00029 public:
00030 typedef vgui_adaptor_mixin mixin;
00031
00032 vgui_win32_adaptor(HWND hwnd, vgui_window *win = 0);
00033 ~vgui_win32_adaptor();
00034
00035
00036
00037 void set_width(unsigned w) { width = w; }
00038 void set_height(unsigned h) { height = h; }
00039
00040
00041 virtual unsigned get_width() const { return width; }
00042
00043
00044 virtual unsigned get_height() const { return height; }
00045
00046
00047
00048
00049
00050 virtual void post_timer(float tm, int id);
00051
00052 virtual void post_redraw();
00053
00054 virtual void post_overlay_redraw();
00055 virtual void post_idle_request();
00056
00057 virtual void post_destroy();
00058
00059
00060 virtual void kill_timer(int timer);
00061
00062
00063 virtual void bind_popups(vgui_modifier m, vgui_button b)
00064 { mixin::popup_modifier = m; mixin::popup_button = b; }
00065
00066
00067 virtual void get_popup_bindings(vgui_modifier &m, vgui_button &b) const
00068 { m = mixin::popup_modifier; b = mixin::popup_button; }
00069
00070
00071
00072 virtual vgui_window *get_window() const { return win_; }
00073
00074
00075 virtual void swap_buffers() { SwapBuffers(hdc_); }
00076 virtual void make_current() { wglMakeCurrent(hdc_, hglrc_); }
00077
00078
00079 virtual BOOL OnCmdMsg(UINT message, WPARAM wParam, LPARAM lParam);
00080
00081 void menu_dispatcher(int menuId);
00082
00083
00084 void OnCreate();
00085
00086 void OnSize(WPARAM wParam, LPARAM lParam);
00087 void OnPaint();
00088 void OnTimer(WPARAM wParam, LPARAM lParam);
00089 void OnHScroll(UINT message, WPARAM wParam, LPARAM lParam);
00090 void OnVScroll(UINT message, WPARAM wParam, LPARAM lParam);
00091 void OnKeyDown(WPARAM wParam, LPARAM lParam);
00092 void OnKeyUp(WPARAM wParam, LPARAM lParam);
00093
00094 void OnLButtonDown(WPARAM wParam, LPARAM lParam);
00095 void OnLButtonUp(WPARAM wParam, LPARAM lParam);
00096 void OnMButtonDown(WPARAM wParam, LPARAM lParam);
00097 void OnMButtonUp(WPARAM wParam, LPARAM lParam);
00098 void OnRButtonDown(WPARAM wParam, LPARAM lParam);
00099 void OnRButtonUp(WPARAM wParam, LPARAM lParam);
00100 void OnMouseMove(WPARAM wParam, LPARAM lParam);
00101 void OnMouseWheel(WPARAM wParam, LPARAM lParam);
00102
00103 protected:
00104
00105 vgui_event translate_message(WPARAM wParam, LPARAM lParam,
00106 vgui_event_type evtype = vgui_EVENT_NULL);
00107
00108 void translate_key(UINT nChar, UINT nFlags, int *key, int *ascii_char);
00109
00110 void domouse(vgui_event_type t, vgui_button b, UINT nFlags, int x, int y);
00111
00112 HWND hwnd_;
00113 HGLRC hglrc_;
00114 HDC hdc_;
00115 int tid_;
00116
00117 vgui_window *win_;
00118
00119
00120 vcl_map<unsigned int, vgui_win32_internal_timer> timers_;
00121
00122 static vgui_menu last_popup;
00123 vcl_vector<vgui_command_sptr> popup_callbacks;
00124
00125 private:
00126 HGLRC setup_for_gl(HDC);
00127
00128
00129 bool redraw_posted_;
00130
00131
00132 bool overlay_redraw_posted_;
00133
00134
00135 bool idle_request_posted_;
00136
00137 DECLARE_MESSAGE_MAP()
00138 };
00139
00140 class vgui_win32_internal_timer
00141 {
00142 public:
00143 vgui_win32_internal_timer() : timer_id(0), callback_ptr(0) {}
00144 vgui_win32_internal_timer(unsigned int id, void *p)
00145 : timer_id(id), callback_ptr(p) {}
00146
00147 unsigned int timer_id;
00148 void* callback_ptr;
00149 };
00150
00151 #endif // vgui_win32_adaptor_h_