sprint 1-alpha
sprint/gtl/VWindow.h
Go to the documentation of this file.
00001 /******************************************************************************
00002  *  GTL: GUI Template Library 
00003  *    A Cross Platform C++ Wrapper for Win32 users
00004  *  Copyright (C) 2007-2011 Paolo Medici (www.pmx.it)
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Lesser General Public
00008  *  License as published by the Free Software Foundation; either
00009  *  version 2.1 of the License, or (at your option) any later version.
00010  *
00011  *  This library is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  Lesser General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Lesser General Public
00017  *  License along with this library; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019  *
00020  *******************************************************************************/
00021  
00022 #ifndef _SPRINT_VIRTUAL_WINDOW_H
00023 #define _SPRINT_VIRTUAL_WINDOW_H
00024 
00028 #include <sprint/gtl/Window.h>
00029 #include <sprint/gtl/dialog.h>
00030 #include <sprint/gtl/instance.h>
00031 
00033 #define DEFAULT_CLASS_NAME      "proxy_class32"
00034 
00035 namespace sprint {
00036         namespace gtl {
00037 
00044 class VWindow: public CWindow {
00046   int m_ref_count;
00047   protected:
00048   // preliminary handle scrolling
00049   int vscroll;
00050   int hscroll;
00051 
00052   private:  
00053   template<int T>
00054   bool OnScroll(int nCmd, short int pos, HWND hwndCtl);
00055 
00057     static LRESULT CALLBACK Proc (HWND, UINT, WPARAM, LPARAM);    
00058 
00060     static inline VWindow *Get(HWND hwnd)
00061         {
00062           return reinterpret_cast<VWindow *> (::GetWindowLong(hwnd, 0) );
00063         }
00065     inline void Bind(HWND hwnd)
00066       {
00067         m_hwnd = hwnd;
00068         ::SetWindowLong(m_hwnd, 0, (LONG) this);
00069       }
00070 
00071   public:
00072     VWindow() : m_ref_count(1) {}
00073 
00076 #if 0
00077 
00082     VWindow(LPCTSTR lpWindowName, 
00083                     DWORD dwStyle = WS_OVERLAPPEDWINDOW, 
00084                     int x = CW_USEDEFAULT, 
00085                     int y = CW_USEDEFAULT, 
00086                     int nWidth = CW_USEDEFAULT, 
00087                     int nHeight = CW_USEDEFAULT,
00088                     HWND hWndParent = NULL, 
00089                     HMENU hMenu = NULL, 
00090                     HINSTANCE hInstance = sprint::ThisInstance() ) : m_ref_count(1)
00091                      {
00092                          Create(lpWindowName, dwStyle, x,y,nWidth, nHeight, hWndParent, hMenu, hInstance);
00093                      }
00094 #endif
00095 
00096     virtual ~VWindow();
00097 
00099     virtual LPCTSTR getClassName() const;
00100     
00112     virtual void GetClass(HINSTANCE hInstance, WNDCLASSEX & wc) const;
00113     
00115     bool Register() const;
00116     
00119     HWND Create(LPCTSTR lpWindowName, 
00120                     DWORD dwStyle = WS_OVERLAPPEDWINDOW, 
00121                     int x = CW_USEDEFAULT, 
00122                     int y = CW_USEDEFAULT, 
00123                     int nWidth = CW_USEDEFAULT, 
00124                     int nHeight = CW_USEDEFAULT,
00125                     HWND hWndParent = NULL, 
00126                     HMENU hMenu = NULL, 
00127                                         HINSTANCE hInstance = sprint::gtl::ThisInstance());
00128 
00129     HWND CreateEx(LPCTSTR lpWindowName, DWORD dwExStyle,
00130         DWORD dwStyle,
00131         int x,
00132         int y,
00133         int nWidth,
00134         int nHeight,
00135         HWND hWndParent,
00136         HMENU hMenu,    
00137         HINSTANCE hInstance);
00138         
00139         
00141 
00143 HWND ModelessDialog(      
00144     LPCTSTR lpTemplate,
00145     DLGPROC lpDialogFunc
00146 )
00147 {
00148 return ::CreateDialog( ThisInstance(), lpTemplate, m_hwnd, lpDialogFunc);    
00149 }
00150 
00151 template<class T>
00152 HWND ModelessTDialog(LPCTSTR lpTemplate, T & inst)
00153 {
00154 return ::CreateDialogParam(ThisInstance(), lpTemplate, m_hwnd, &DlgProc<T>, reinterpret_cast<LPARAM>(&inst) );         
00155 }
00156 
00158 INT_PTR ModalDialog(      
00159     LPCTSTR lpTemplate,
00160     DLGPROC lpDialogFunc
00161 )
00162 {
00163 return ::DialogBox(ThisInstance(), lpTemplate, m_hwnd, lpDialogFunc);    
00164 }
00165 
00166 template<class T>
00167 INT_PTR ModalTDialog(      
00168     LPCTSTR lpTemplate, 
00169     T & inst)
00170 {
00171 return ::DialogBoxParam(ThisInstance(), lpTemplate, m_hwnd, &DlgProc<T>, reinterpret_cast<LPARAM>(&inst) );    
00172 }
00173     
00174 template<class T>
00175 INT_PTR ModalTDialog(      
00176     LPCTSTR lpTemplate)
00177 {
00178 T *inst = new T;    
00179 INT_PTR ret = ::DialogBoxParam(ThisInstance(), lpTemplate, m_hwnd, &DlgProc<T>, reinterpret_cast<LPARAM>(inst) );    
00180 delete inst;
00181 return ret;
00182 }
00183         
00184             
00187     
00188     virtual bool OnCreate();
00189     virtual bool OnPaint() { return false; }
00190     virtual bool OnDestroy();
00191     
00192     virtual bool OnCommand(WORD wNotifyCode, WORD wId) { return false; }
00193     virtual bool OnNotify(HWND hwnd, int idCtrl, LPNMHDR pnmh) { return false; }
00194     virtual bool OnSize(WPARAM fwSizeType, WORD nWidth, WORD nHeight) { return false; }
00195     virtual bool OnButtonDown(int button_no, WPARAM fwKeys, WORD xPos, WORD yPos) { return false; }
00196     virtual bool OnButtonUp(int button_no, WPARAM fwKeys, WORD xPos, WORD yPos) { return false; }    
00197     virtual bool OnMouseMove(WPARAM fwKeys, WORD xPos, WORD yPos) { return false; }    
00198     virtual bool OnMouseWheel(WPARAM fwKeys, int dir, int xPos, int yPos) { return false; }
00199     
00200     virtual bool OnDropFile(const char *filename) { return false; }
00201     virtual bool OnTimer(int id)       { return false; }
00202     virtual bool OnSize(unsigned int w, unsigned int h) { return false; }
00203     virtual bool OnChar(WPARAM key) { return false; }
00204     virtual bool OnKeyDown(WPARAM key) { return false; }
00206 };
00207 
00208 
00215 bool MainLoop();
00216 
00217 }
00218 
00219 }
00220 
00221 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines