plugins/consoles/rcons/server/win32/Window.h
changeset 0 7f656887cf89
equal deleted inserted replaced
-1:000000000000 0:7f656887cf89
       
     1 // Window.h
       
     2 // 
       
     3 // Copyright (c) 2010 Accenture. All rights reserved.
       
     4 // This component and the accompanying materials are made available
       
     5 // under the terms of the "Eclipse Public License v1.0"
       
     6 // which accompanies this distribution, and is available
       
     7 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 // 
       
     9 // Initial Contributors:
       
    10 // Accenture - Initial contribution
       
    11 //
       
    12 
       
    13 #if !defined(AFX_WINDOW_H__079A244F_DED8_49A3_AB8E_EEE262119929__INCLUDED_)
       
    14 #define AFX_WINDOW_H__079A244F_DED8_49A3_AB8E_EEE262119929__INCLUDED_
       
    15 
       
    16 #if _MSC_VER > 1000
       
    17 #pragma once
       
    18 #endif // _MSC_VER > 1000
       
    19 
       
    20 
       
    21 #include "Base.h"
       
    22 
       
    23 const unsigned int KSocketMessage = WM_USER;
       
    24 
       
    25 
       
    26 class CWindow;
       
    27 
       
    28 
       
    29 class MWindowMessageHandler
       
    30 	{
       
    31 public:
       
    32 	MWindowMessageHandler();
       
    33 	virtual LRESULT HandleWindowMessage(UINT aMessage, WPARAM aWParam, LPARAM aLParam) = 0;
       
    34 private:
       
    35 	friend class CWindow;
       
    36 	MWindowMessageHandler* iNext;
       
    37 	MWindowMessageHandler* iPrevious;
       
    38 	};
       
    39 
       
    40 
       
    41 class MWindowObserver
       
    42 	{
       
    43 public:
       
    44 	virtual void HandleWindowClosure(CWindow& aWindow) = 0;
       
    45 	virtual LRESULT HandleWindowCommand(UINT aMessage, WPARAM aWParam, LPARAM aLParam) = 0;
       
    46 	};
       
    47 
       
    48 
       
    49 class CWindow : public CBase
       
    50 	{
       
    51 public:
       
    52 	virtual ~CWindow();
       
    53 	void AddMessageHandler(MWindowMessageHandler& aHandler);
       
    54 	void RemoveMessageHandler(MWindowMessageHandler& aHandler);
       
    55 	HWND Handle() const;
       
    56 	void SetTitle(LPCTSTR aTitle);
       
    57 	void GetTitle(LPTSTR aTitle, int aMaxLength) const;
       
    58 	void Redraw();
       
    59 protected:
       
    60 	CWindow();
       
    61 	void Construct(HINSTANCE aAppHandle, LPCTSTR aWindowClass, LPCTSTR aTitle, int aPoxX, int aPosY, int aWidth, int aHeight, MWindowObserver* aObserver);
       
    62 private:
       
    63 	virtual void Draw() const;
       
    64 	virtual LRESULT HandleChar(TCHAR aChar, UINT aModifiers);
       
    65 	virtual LRESULT HandleCommand(UINT aMessage, WPARAM aWParam, LPARAM aLParam);
       
    66 	virtual LRESULT HandleFocusChange(bool aFocused);
       
    67 	virtual void HandleScrollEvent(UINT aMessage, WPARAM aWParam);
       
    68 	virtual void HandleSizeChanged(int aWidth, int aHeight);
       
    69 	virtual void HandleMouseEvent(UINT aMessage, WPARAM aWParam, LPARAM aLParam);
       
    70 	virtual void HandleMenuPopUp(HMENU aMenu);
       
    71 public:
       
    72 	static LRESULT CALLBACK HandleMessage(HWND aHandle, UINT aMessage, WPARAM aWParam, LPARAM aLParam);
       
    73 	static CWindow* Instance(HWND aHandle);
       
    74 private:
       
    75 	static CWindow* sFirst;
       
    76 	static CWindow* sLast;
       
    77 	static MWindowMessageHandler* sFirstMessageHandler;
       
    78 	static MWindowMessageHandler* sLastMessageHandler;
       
    79 	CWindow* iNext;
       
    80 	CWindow* iPrevious;
       
    81 	HINSTANCE iAppHandle;
       
    82 	HWND iHandle;
       
    83 	MWindowObserver* iObserver;
       
    84 	};
       
    85 
       
    86 #endif // !defined(AFX_WINDOW_H__079A244F_DED8_49A3_AB8E_EEE262119929__INCLUDED_)