neoWidgets
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Pages
Classes | Public Member Functions | Static Public Member Functions | List of all members
neo::WindowBase Class Reference

The big window class that every other class descends from. More...

#include <WindowBase.h>

Inheritance diagram for neo::WindowBase:
Inheritance graph
[legend]

Public Member Functions

 WindowBase (const WindowBase &rhs)
 
void Attach (HWND handle, NEO_WINDOW_MODE mode)
 
template<typename MESSAGE >
void Bind (UINT message, void(*function)(MESSAGE &))
 
template<typename MESSAGE , typename FUNCTOR >
void Bind (UINT message, FUNCTOR function)
 
template<typename CLASS , typename MESSAGE , typename HANDLER >
void Bind (UINT message, void(CLASS::*function)(MESSAGE &), HANDLER *handler)
 
template<typename MESSAGE >
void Bind (const MessageId &message, void(*function)(MESSAGE &))
 
template<typename MESSAGE , typename FUNCTOR >
void Bind (const MessageId &message, FUNCTOR function)
 
template<typename CLASS , typename MESSAGE , typename HANDLER >
void Bind (const MessageId &message, void(CLASS::*function)(MESSAGE &), HANDLER *handler)
 
void Clear ()
 
void Create (DWORD exStyle, const tstring &cls, const tstring &text, DWORD style, const Rect &r, HWND parent, HMENU menu, NEO_WINDOW_MODE mode)
 
LRESULT DefaultWndProc (HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
 
void Destroy ()
 
void DragAcceptFiles (bool accept=true)
 
void Enable (bool enable)
 
LRESULT GenerateMessage (UINT message, WPARAM wp, LPARAM lp) const
 
Rect GetClientRect () const
 
DWORD GetExStyle () const
 
HFONT GetFont () const
 
HWND GetHandle () const
 
HICON GetIcon (bool bigIcon) const
 
DWORD GetID () const
 
HMENU GetMenu () const
 
HWND GetParentHandle () const
 
Rect GetRectOnParent () const
 
DWORD GetStyle () const
 
tstring GetText () const
 
Rect GetWindowRect () const
 
void Hide ()
 
bool Invalidate (const RECT *rect=0, bool eraseBkgnd=true)
 
bool IsEnabled () const
 
bool IsMessageHandlerBound (UINT message) const
 
bool IsVisible () const
 
void KillTimer (int timerID)
 
void ModifyStyle (DWORD add, DWORD remove)
 
void Move (int x, int y, bool redraw=true)
 
void Move (const POINT &p, bool redraw=true)
 
void Move (int x, int y, int width, int height, bool redraw=true)
 
void Move (const POINT &p, const SIZE &s, bool redraw=true)
 
void Move (const RECT &r, bool redraw=true)
 
 operator HWND () const
 
WindowBaseoperator= (const WindowBase &rhs)
 
bool Redraw (const RECT *rect=0, HRGN region=0, UINT flags=RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE)
 
void SetClientSize (int width, int height)
 
HWND SetFocus ()
 
void SetFont (HFONT font, bool redraw=true)
 
HICON SetIcon (HICON icon, bool bigIcon)
 
void SetMenu (HMENU menu)
 
void SetRedraw (bool allowRedraw)
 
void SetText (const tstring &text)
 
UINT_PTR SetTimer (int timerID, UINT interval, TIMERPROC proc=0)
 
void Show (bool show=true)
 
void UnBind (UINT message)
 
void UnBind (const MessageId &message)
 
virtual LRESULT WndProc (HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
 Can be overridden for old school message handling. More...
 

Static Public Member Functions

static HCURSOR GetDefaultCursor ()
 
static HFONT GetDefaultFont ()
 
static HICON GetDefaultIcon ()
 
static WindowBaseGetWindowFromHWND (HWND _handle)
 
static void SetDefaultCursor (HCURSOR cursor)
 
static void SetDefaultFont (HFONT font)
 
static void SetDefaultIcon (HICON icon)
 
static LRESULT CALLBACK StaticWndProc (HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
 

Detailed Description

The big window class that every other class descends from.

It provides functions that are common across all types of windows, like sizing, visible state, redrawing, etc. Normally you wont use this class directly, because the subclasses Window and Control are nicer to use.

The class has different functionality depending on the NEO_WINDOW_MODE used in its creation.

NEO_MODE_FULLSCALE:
Bind() is supported
Cannot be copied
Destroys its HWND upon destruction

NEO_MODE_LIGHTWEIGHT:
Bind() has no effect
Can be copied
Does not destroy its HWND upon destruction

Member Function Documentation

template<typename MESSAGE >
void neo::WindowBase::Bind ( UINT  message,
void(*)(MESSAGE &)  function 
)
inline

Bind a global function to a message.

template<typename MESSAGE , typename FUNCTOR >
void neo::WindowBase::Bind ( UINT  message,
FUNCTOR  function 
)
inline

Bind a functor to a message.

template<typename CLASS , typename MESSAGE , typename HANDLER >
void neo::WindowBase::Bind ( UINT  message,
void(CLASS::*)(MESSAGE &)  function,
HANDLER *  handler 
)
inline

Bind a class member function to a message.

template<typename MESSAGE >
void neo::WindowBase::Bind ( const MessageId message,
void(*)(MESSAGE &)  function 
)
inline

Specialization to bind WM_COMMAND and WM_NOTIFY. Because these are generated by controls and further distinguished by a notifyCode, we must be able to specify these parameters during the binding.

void neo::WindowBase::DragAcceptFiles ( bool  accept = true)
inline

Enable the window to accept files from Windows Explorer.

Rect neo::WindowBase::GetClientRect ( ) const
inline
Returns
Client coordinates of the window. The topleft corner is always 0,0.
See Also
WindowRect(), RectOnParent()
DWORD neo::WindowBase::GetExStyle ( ) const
inline
Returns
Extended style of the window.
HICON neo::WindowBase::GetIcon ( bool  bigIcon) const
inline
Parameters
bigIconWhether the big or small icon of the window should be retrieved.
DWORD neo::WindowBase::GetID ( ) const
inline
Returns
Identifier of the window.
HWND neo::WindowBase::GetParentHandle ( ) const
inline
Returns
Handle of the parent window or 0.
Rect neo::WindowBase::GetRectOnParent ( ) const
inline
Returns
Coordinates of the window relative to its parent window.
See Also
ClientRect(), WindowRect()
DWORD neo::WindowBase::GetStyle ( ) const
inline
Returns
Style of the window.
tstring neo::WindowBase::GetText ( ) const
inline
Returns
Title of the window.
Rect neo::WindowBase::GetWindowRect ( ) const
inline
Returns
Screen coordinates of the window.
See Also
ClientRect(), RectOnParent()
bool neo::WindowBase::IsMessageHandlerBound ( UINT  message) const
inline
Returns
True if Bind() has been called for this message.
void neo::WindowBase::KillTimer ( int  timerID)
inline

Stop a timer.

void neo::WindowBase::ModifyStyle ( DWORD  add,
DWORD  remove 
)
inline

Add or remove window styles.

Note
Not all styles can be modified after window creation. You can't remove WS_CHILD from a button, for example.
HWND neo::WindowBase::SetFocus ( )
inline
Returns
Previously focused window.
HICON neo::WindowBase::SetIcon ( HICON  icon,
bool  bigIcon 
)
inline
Parameters
iconThe new icon.
bigIconWhether the big or small icon of the window should be set.
Returns
Handle of the previous icon.
void neo::WindowBase::SetRedraw ( bool  allowRedraw)
inline

This function can be used to disable redrawing, e.g. while adding many items to a listbox.

void neo::WindowBase::SetText ( const tstring &  text)
inline

Set title of the window.

UINT_PTR neo::WindowBase::SetTimer ( int  timerID,
UINT  interval,
TIMERPROC  proc = 0 
)
inline

Start a timer. If proc is 0, the window will receive WM_TIMER messages. Otherwise proc will be called.

void neo::WindowBase::UnBind ( UINT  message)
inline

Unbind message handler with normal id.

void neo::WindowBase::UnBind ( const MessageId message)
inline

Unbind message handler with extended id.

LRESULT neo::WindowBase::WndProc ( HWND  hwnd,
UINT  message,
WPARAM  wp,
LPARAM  lp 
)
inlinevirtual

Can be overridden for old school message handling.

Returns
Depends on the message parameter

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