Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes
vgui_mfc_adaptor Class Reference

MFC implementation of vgui_adaptor. More...

#include <vgui_mfc_adaptor.h>

Inheritance diagram for vgui_mfc_adaptor:
Inheritance graph
[legend]

List of all members.

Public Types

typedef vgui_adaptor_mixin mixin

Public Member Functions

 vgui_mfc_adaptor ()
 Constructor used by dynamic creation.
unsigned int get_width () const
 MFC implementation from vgui_adaptor - returns width of rendering area.
unsigned int get_height () const
 MFC implementation from vgui_adaptor - returns height of rendering area.
void post_redraw ()
 MFC implementation from vgui_adaptor - redraws rendering area.
void post_overlay_redraw ()
 MFC implementation from vgui_adaptor - redraws overlay buffer.
void swap_buffers ()
 MFC impl. from vgui_adaptor - swap buffers if using double buffering.
void make_current ()
 MFC impl. from vgui_adaptor - make this the current GL rendering context.
void draw ()
 MFC implementation from vgui_adaptor - redraw everything now.
bool do_idle ()
void service_redraws ()
 Redraws the OpenGL area.
void set_default_popup (vgui_menu)
 Change the default popup menu to the given one (not yet implemented).
void post_timer (float, int)
 Sets timer to dispatch WM_TIMER event to a mainframe every time milliseconds.
void kill_timer (int id)
 Stop timer.
void post_idle_request ()
 Flags than a child requests idle processing.
vgui_menu get_popup ()
 Return the default popup menu (not yet implemented).
void bind_popups (vgui_modifier m, vgui_button b)
 MFC impl. from vgui_adaptor - set button & modifier to display popup.
void get_popup_bindings (vgui_modifier &m, vgui_button &b) const
 MFC impl. from vgui_adaptor - get button & modifier which display popup.
virtual vgui_windowget_window () const
void set_window (vgui_window *win)
void setup_adaptor (CWnd *this_cwnd, HDC OldDC, HGLRC oldContext)
 If your adaptor is not in the main window of the application call this function.
virtual ~vgui_mfc_adaptor ()
 Destructor.
vgui_tableau_sptr get_tableau () const
 Get the vgui_tableau associated with this vgui_adaptor.
void set_tableau (vgui_tableau_sptr const &t)
 Set the vgui_tableau associated with this vgui_adaptor.
void set_double_buffering (bool b)
 True to use double buffering, false to not use it.
vgui_menu get_total_popup (vgui_popup_params &) const
 Return the concatenation of the adaptor's menu with the tableau's menu.
void config_dialog ()
 Pop up a dialog for changing the popup modifier and button bindings.
void set_popup (vgui_menu const &m)
 Set the popup menu for this adaptor.
void include_in_popup (vgui_menu const &m)
 Add the given menu to the popup menu for this adaptor.
bool dispatch_to_tableau (vgui_event const &)
 Dispatches the given event to the tableau.
int post_timer (float)
virtual void post_message (char const *, void const *)
virtual void post_destroy ()

Public Attributes

CDC * m_pDC
 Device context for this adaptor.
HBITMAP m_pDC_default_bitmap
unsigned width
 Cached width of adaptor render area.
unsigned height
 Cached height of adaptor render area.
vgui_button popup_button
 Mouse button (used with popup_modifier) which causes the popup menu to appear.
vgui_modifier popup_modifier
 Modifier (used with popup_button) which causes the popup menu to appear.

Static Public Attributes

static vgui_DLLDATA vgui_adaptorcurrent = 0
 This static datum points to the adaptor that last received a mouse event.

Protected Member Functions

virtual void OnDraw (CDC *pDC)
 Called by MFC when a draw event is required - overridden to draw this view.
virtual BOOL PreCreateWindow (CREATESTRUCT &cs)
 Called by MFC before the creation of the window attached to this object.
void domouse (vgui_event_type e, UINT nFlags, CPoint point, vgui_button b)
 Handles mouse press/release events.
afx_msg int OnCreate (LPCREATESTRUCT lpCreateStruct)
 Called by MFC when the application requests the creation of a window.
afx_msg void OnDestroy ()
 Called by MFC when the main window has been destroyed.
afx_msg void OnPaint ()
 Called by MFC when the application requests part of the window is redrawn.
afx_msg BOOL OnEraseBkgnd (CDC *pDC)
 Called by MFC when the background needs erasing.
afx_msg void OnSize (UINT nType, int cx, int cy)
 Called by MFC when the application is resized.
vgui_event generate_vgui_event (UINT nChar, UINT nRepCnt, UINT nFlags, vgui_event_type evttype)
 Create the corresponding vgui_event from an MFC event.
afx_msg void OnKeyDown (UINT nChar, UINT nRepCnt, UINT nFlags)
 Called by MFC when a key is pressed inside the application.
afx_msg void OnKeyUp (UINT nChar, UINT nRepCnt, UINT nFlags)
 Called by MFC when a key is released inside the application.
afx_msg void OnLButtonDown (UINT nFlags, CPoint point)
 Called by MFC when the left mouse button is pressed inside the application.
afx_msg void OnLButtonUp (UINT nFlags, CPoint point)
 Called by MFC when left mouse button is released inside the application.
afx_msg void OnMouseMove (UINT nFlags, CPoint point)
 Called by MFC when the mouse is moved inside the application.
afx_msg void OnRButtonDown (UINT nFlags, CPoint point)
 Called by MFC when right mouse button is pressed inside the application.
afx_msg void OnRButtonUp (UINT nFlags, CPoint point)
 Called by MFC when right mouse button is released inside the application.
afx_msg BOOL OnMouseWheel (UINT nFlags, short zDelta, CPoint pt)
 Called by MFC when a user rotates a mouse wheel.
afx_msg void OnMButtonDown (UINT nFlags, CPoint point)
 Called by MFC when middle mouse button is pressed inside the application.
afx_msg void OnMButtonUp (UINT nFlags, CPoint point)
 Called by MFC when middle mouse button is released inside the application.

Protected Attributes

CWnd * m_pCWnd
 The window associated with this adaptor if it is not the main window.
HDC hOldDC
 The previous device context to this one.
HGLRC hOldRC
 The previous rendering context to this one.
HGLRC m_hRC
 The Win-OpenGL resource context.
int m_width
 Width of rendering area.
int m_height
 Height of rendering area.
vgui_windowwin_
bool nested_popups
 Parameters controlling the popup menu style.
bool default_items
bool use_double_buffering
 Whether or not to use double buffering.

Static Protected Attributes

static vgui_menu last_popup

Private Member Functions

void create_bitmap (int cx, int cy, CDC *&out_pDC, HBITMAP &defaultBitmapForDC)
HGLRC setup_for_gl (CDC *pDC, DWORD dwFlags)

Private Attributes

CDC * m_pDC_aux
 Device context for the auxiliary buffer used for simulating overlays.
bool aux_dc_valid_
 True if the aux buffer is a copy of the main GL buffer.
HBITMAP m_pDC_aux_default_bitmap
bool redraw_posted_
 True while a redraw event has been requested but not implemented.
bool overlay_redraw_posted_
 True while an overlay redraw event has been requested but not implemented.
bool idle_request_posted_
 True while an idle time has been requested but not implemented.

Detailed Description

MFC implementation of vgui_adaptor.

The adaptor allows you to draw an OpenGL area in your MFC application.

If this adaptor is not being used inside the main window of the application then you will need to call setup_adaptor(). See vgui_mfc_dialog_impl where this is done, when an OpenGL area is used in a dialog box.

Definition at line 52 of file vgui_mfc_adaptor.h.


Member Typedef Documentation

Definition at line 66 of file vgui_mfc_adaptor.h.


Constructor & Destructor Documentation

vgui_mfc_adaptor::vgui_mfc_adaptor ( )

Constructor used by dynamic creation.

Constructor.

kym - this used to be protected, but I changed it to public so I can add adaptors to dialog boxes.

Definition at line 36 of file vgui_mfc_adaptor.cxx.

vgui_mfc_adaptor::~vgui_mfc_adaptor ( ) [virtual]

Destructor.

kym - moved stuff here from OnDestroy because OnDestroy seems to only be called when the main window is deleted.

Definition at line 58 of file vgui_mfc_adaptor.cxx.


Member Function Documentation

void vgui_mfc_adaptor::bind_popups ( vgui_modifier  m,
vgui_button  b 
) [inline, virtual]

MFC impl. from vgui_adaptor - set button & modifier to display popup.

Reimplemented from vgui_adaptor.

Definition at line 116 of file vgui_mfc_adaptor.h.

void vgui_adaptor::config_dialog ( ) [inherited]

Pop up a dialog for changing the popup modifier and button bindings.

Pops up a dialog for changing the popup modifier and button bindings.

Definition at line 102 of file vgui_adaptor.cxx.

void vgui_mfc_adaptor::create_bitmap ( int  cx,
int  cy,
CDC *&  out_pDC,
HBITMAP &  defaultBitmapForDC 
) [private]

Definition at line 308 of file vgui_mfc_adaptor.cxx.

bool vgui_adaptor::dispatch_to_tableau ( vgui_event const &  e) [inherited]

Dispatches the given event to the tableau.

This method performs various checks which can be performed generically for all tableaux. It is not the responsibility of this method to take care of overlay handling - the derived class must sort that out.

This method performs various checks which can be performed generically for all tableaux. It is not the responsibility of this method to take care of overlay handling - the derived class must sort that out. The derived class must also ensure that the correct draw buffer is set.

Reimplemented in vgui_qt_adaptor, and vgui_qt_adaptor.

Definition at line 182 of file vgui_adaptor.cxx.

bool vgui_mfc_adaptor::do_idle ( )

Definition at line 482 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::domouse ( vgui_event_type  e,
UINT  nFlags,
CPoint  point,
vgui_button  b 
) [protected]

Handles mouse press/release events.

Deals with right popup menu.

'point' is window coordinates whereas TrackPopup menu requires screen coordinates. So translate them into screen coordinates

Definition at line 635 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::draw ( )

MFC implementation from vgui_adaptor - redraw everything now.

MFC implementation of vgui_adaptor function - redraw everything now!.

Definition at line 476 of file vgui_mfc_adaptor.cxx.

vgui_event vgui_mfc_adaptor::generate_vgui_event ( UINT  nChar,
UINT  nRepCnt,
UINT  nFlags,
vgui_event_type  evttype 
) [protected]

Create the corresponding vgui_event from an MFC event.

Definition at line 593 of file vgui_mfc_adaptor.cxx.

unsigned int vgui_mfc_adaptor::get_height ( ) const [inline, virtual]

MFC implementation from vgui_adaptor - returns height of rendering area.

Implements vgui_adaptor.

Definition at line 74 of file vgui_mfc_adaptor.h.

vgui_menu vgui_mfc_adaptor::get_popup ( )

Return the default popup menu (not yet implemented).

Reimplemented from vgui_adaptor.

Definition at line 178 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::get_popup_bindings ( vgui_modifier m,
vgui_button b 
) const [inline, virtual]

MFC impl. from vgui_adaptor - get button & modifier which display popup.

Reimplemented from vgui_adaptor.

Definition at line 122 of file vgui_mfc_adaptor.h.

vgui_tableau_sptr vgui_adaptor::get_tableau ( ) const [inherited]

Get the vgui_tableau associated with this vgui_adaptor.

Get the vgui_tableau associated with this adaptor.

Definition at line 64 of file vgui_adaptor.cxx.

vgui_menu vgui_adaptor::get_total_popup ( vgui_popup_params params) const [inherited]

Return the concatenation of the adaptor's menu with the tableau's menu.

Returns concatenation of the adaptor's menu with the tableau's menu.

Definition at line 78 of file vgui_adaptor.cxx.

unsigned int vgui_mfc_adaptor::get_width ( ) const [inline, virtual]

MFC implementation from vgui_adaptor - returns width of rendering area.

Implements vgui_adaptor.

Definition at line 71 of file vgui_mfc_adaptor.h.

virtual vgui_window* vgui_mfc_adaptor::get_window ( ) const [inline, virtual]

Reimplemented from vgui_adaptor.

Definition at line 127 of file vgui_mfc_adaptor.h.

void vgui_adaptor::include_in_popup ( vgui_menu const &  m) [inline, inherited]

Add the given menu to the popup menu for this adaptor.

Definition at line 81 of file vgui_adaptor.h.

void vgui_mfc_adaptor::kill_timer ( int  id) [virtual]

Stop timer.

Stop timer to dispatch WM_TIME event.

Reimplemented from vgui_adaptor.

Definition at line 454 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::make_current ( ) [virtual]

MFC impl. from vgui_adaptor - make this the current GL rendering context.

MFC implementation of vgui_adaptor function - make this the current GL rendering context.

Reimplemented from vgui_adaptor.

Definition at line 159 of file vgui_mfc_adaptor.cxx.

int vgui_mfc_adaptor::OnCreate ( LPCREATESTRUCT  lpCreateStruct) [protected]

Called by MFC when the application requests the creation of a window.

This function must return 0 to continue the creation of the CWind object, returning -1 destroys the window.

Reimplemented in vgui_mfc_view.

Definition at line 222 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::OnDestroy ( ) [protected]

Called by MFC when the main window has been destroyed.

Note, this function is not called when your adaptor is destroyed inside a non-main window (eg. a dialog box).

Definition at line 358 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::OnDraw ( CDC *  pDC) [protected, virtual]

Called by MFC when a draw event is required - overridden to draw this view.

Reimplemented in vgui_mfc_view.

Definition at line 465 of file vgui_mfc_adaptor.cxx.

BOOL vgui_mfc_adaptor::OnEraseBkgnd ( CDC *  pDC) [protected]

Called by MFC when the background needs erasing.

For example this would be called if the window was resized.

Definition at line 366 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::OnKeyDown ( UINT  nChar,
UINT  nRepCnt,
UINT  nFlags 
) [protected]

Called by MFC when a key is pressed inside the application.

Definition at line 613 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::OnKeyUp ( UINT  nChar,
UINT  nRepCnt,
UINT  nFlags 
) [protected]

Called by MFC when a key is released inside the application.

Definition at line 624 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::OnLButtonDown ( UINT  nFlags,
CPoint  point 
) [protected]

Called by MFC when the left mouse button is pressed inside the application.

Definition at line 700 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::OnLButtonUp ( UINT  nFlags,
CPoint  point 
) [protected]

Called by MFC when left mouse button is released inside the application.

Called by MFC when the left mouse button is released inside the application.

Definition at line 706 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::OnMButtonDown ( UINT  nFlags,
CPoint  point 
) [protected]

Called by MFC when middle mouse button is pressed inside the application.

Called by MFC when the middle mouse button is pressed inside the application.

Definition at line 712 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::OnMButtonUp ( UINT  nFlags,
CPoint  point 
) [protected]

Called by MFC when middle mouse button is released inside the application.

Called by MFC when the middle mouse button is released inside the application.

Definition at line 718 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::OnMouseMove ( UINT  nFlags,
CPoint  point 
) [protected]

Called by MFC when the mouse is moved inside the application.

Definition at line 736 of file vgui_mfc_adaptor.cxx.

BOOL vgui_mfc_adaptor::OnMouseWheel ( UINT  nFlags,
short  zDelta,
CPoint  pt 
) [protected]

Called by MFC when a user rotates a mouse wheel.

Definition at line 742 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::OnPaint ( ) [protected]

Called by MFC when the application requests part of the window is redrawn.

Definition at line 491 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::OnRButtonDown ( UINT  nFlags,
CPoint  point 
) [protected]

Called by MFC when right mouse button is pressed inside the application.

Called by MFC when the right mouse button is pressed inside the application.

Definition at line 724 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::OnRButtonUp ( UINT  nFlags,
CPoint  point 
) [protected]

Called by MFC when right mouse button is released inside the application.

Called by MFC when the right mouse button is released inside the application.

Definition at line 730 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::OnSize ( UINT  nType,
int  cx,
int  cy 
) [protected]

Called by MFC when the application is resized.

Definition at line 497 of file vgui_mfc_adaptor.cxx.

void vgui_adaptor::post_destroy ( void  ) [virtual, inherited]
void vgui_mfc_adaptor::post_idle_request ( void  ) [inline, virtual]

Flags than a child requests idle processing.

Reimplemented from vgui_adaptor.

Definition at line 110 of file vgui_mfc_adaptor.h.

void vgui_adaptor::post_message ( char const *  ,
void const *   
) [virtual, inherited]

Reimplemented in vgui_wx_adaptor.

Definition at line 242 of file vgui_adaptor.cxx.

void vgui_mfc_adaptor::post_overlay_redraw ( void  ) [virtual]

MFC implementation from vgui_adaptor - redraws overlay buffer.

MFC implementation of vgui_adaptor function - redraws overlay buffer.

Implements vgui_adaptor.

Definition at line 126 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::post_redraw ( void  ) [virtual]

MFC implementation from vgui_adaptor - redraws rendering area.

MFC implementation of vgui_adaptor function - redraws rendering area.

Implements vgui_adaptor.

Definition at line 142 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::post_timer ( float  tm,
int  id 
) [virtual]

Sets timer to dispatch WM_TIMER event to a mainframe every time milliseconds.

Reimplemented from vgui_adaptor.

Definition at line 443 of file vgui_mfc_adaptor.cxx.

int vgui_adaptor::post_timer ( float  t) [inherited]

Definition at line 266 of file vgui_adaptor.cxx.

BOOL vgui_mfc_adaptor::PreCreateWindow ( CREATESTRUCT &  cs) [protected, virtual]

Called by MFC before the creation of the window attached to this object.

Reimplemented in vgui_mfc_view.

Definition at line 207 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::service_redraws ( )

Redraws the OpenGL area.

Definition at line 373 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::set_default_popup ( vgui_menu  )

Change the default popup menu to the given one (not yet implemented).

Definition at line 172 of file vgui_mfc_adaptor.cxx.

void vgui_adaptor::set_double_buffering ( bool  b) [inline, inherited]

True to use double buffering, false to not use it.

Definition at line 66 of file vgui_adaptor.h.

void vgui_adaptor::set_popup ( vgui_menu const &  m) [inline, inherited]

Set the popup menu for this adaptor.

Definition at line 78 of file vgui_adaptor.h.

void vgui_adaptor::set_tableau ( vgui_tableau_sptr const &  t) [inherited]

Set the vgui_tableau associated with this vgui_adaptor.

Set the vgui_tableau associated with this adaptor.

Definition at line 71 of file vgui_adaptor.cxx.

void vgui_mfc_adaptor::set_window ( vgui_window win) [inline]

Definition at line 128 of file vgui_mfc_adaptor.h.

void vgui_mfc_adaptor::setup_adaptor ( CWnd *  this_cwnd,
HDC  oldDC,
HGLRC  oldContext 
)

If your adaptor is not in the main window of the application call this function.

The first parameter tells it which window this adaptor is associated with, the other parameters are so we can go back to our old rendering context when this adaptor is deleted.

The first parameter tells it which window this adaptor is associated with, the other parameters are so we can go back to our old rendering context.

Definition at line 187 of file vgui_mfc_adaptor.cxx.

HGLRC vgui_mfc_adaptor::setup_for_gl ( CDC *  pDC,
DWORD  dwFlags 
) [private]

Definition at line 256 of file vgui_mfc_adaptor.cxx.

void vgui_mfc_adaptor::swap_buffers ( ) [virtual]

MFC impl. from vgui_adaptor - swap buffers if using double buffering.

MFC implementation of vgui_adaptor function - swap buffers if using double buffering.

Reimplemented from vgui_adaptor.

Definition at line 165 of file vgui_mfc_adaptor.cxx.


Member Data Documentation

True if the aux buffer is a copy of the main GL buffer.

Definition at line 150 of file vgui_mfc_adaptor.h.

vgui_adaptor * vgui_adaptor::current = 0 [static, inherited]

This static datum points to the adaptor that last received a mouse event.

It is set to zero if its pointer receives a LEAVE event. It will often point to the adaptor which was current when a popup menu was triggered, which is often what one wants it for.

Definition at line 93 of file vgui_adaptor.h.

bool vgui_adaptor::default_items [protected, inherited]

Definition at line 143 of file vgui_adaptor.h.

unsigned vgui_adaptor_mixin::height [inherited]

Cached height of adaptor render area.

Definition at line 29 of file vgui_adaptor_mixin.h.

HDC vgui_mfc_adaptor::hOldDC [protected]

The previous device context to this one.

Definition at line 168 of file vgui_mfc_adaptor.h.

HGLRC vgui_mfc_adaptor::hOldRC [protected]

The previous rendering context to this one.

Definition at line 171 of file vgui_mfc_adaptor.h.

True while an idle time has been requested but not implemented.

Definition at line 161 of file vgui_mfc_adaptor.h.

Definition at line 207 of file vgui_mfc_adaptor.h.

int vgui_mfc_adaptor::m_height [protected]

Height of rendering area.

Definition at line 203 of file vgui_mfc_adaptor.h.

HGLRC vgui_mfc_adaptor::m_hRC [protected]

The Win-OpenGL resource context.

Definition at line 197 of file vgui_mfc_adaptor.h.

CWnd* vgui_mfc_adaptor::m_pCWnd [protected]

The window associated with this adaptor if it is not the main window.

Definition at line 165 of file vgui_mfc_adaptor.h.

Device context for this adaptor.

Definition at line 62 of file vgui_mfc_adaptor.h.

Device context for the auxiliary buffer used for simulating overlays.

Definition at line 148 of file vgui_mfc_adaptor.h.

Definition at line 152 of file vgui_mfc_adaptor.h.

Definition at line 64 of file vgui_mfc_adaptor.h.

int vgui_mfc_adaptor::m_width [protected]

Width of rendering area.

Definition at line 200 of file vgui_mfc_adaptor.h.

bool vgui_adaptor::nested_popups [protected, inherited]

Parameters controlling the popup menu style.

These are put onto a popup_params object and passed to tableau::get_popup()

Definition at line 142 of file vgui_adaptor.h.

True while an overlay redraw event has been requested but not implemented.

Definition at line 158 of file vgui_mfc_adaptor.h.

Mouse button (used with popup_modifier) which causes the popup menu to appear.

Definition at line 34 of file vgui_adaptor_mixin.h.

Modifier (used with popup_button) which causes the popup menu to appear.

Definition at line 36 of file vgui_adaptor_mixin.h.

True while a redraw event has been requested but not implemented.

Definition at line 155 of file vgui_mfc_adaptor.h.

bool vgui_adaptor::use_double_buffering [protected, inherited]

Whether or not to use double buffering.

Definition at line 146 of file vgui_adaptor.h.

unsigned vgui_adaptor_mixin::width [inherited]

Cached width of adaptor render area.

Definition at line 27 of file vgui_adaptor_mixin.h.

Definition at line 205 of file vgui_mfc_adaptor.h.


The documentation for this class was generated from the following files: