Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- /// \class TWindow
- // ~~~~~ ~~~~~~~
- /// TWindow, derived from TEventHandler and TStreamableBase, provides
- /// window-specific behavior and encapsulates many functions that control window
- /// behavior and specify window creation and registration attributes.
- ///
- /// TWindow is a generic window that can be resized and moved. You can construct an
- /// instance of TWindow, though normally you use TWindow as a base for your
- /// specialized window classes. In general, to associate and disassociate a TWindow
- /// object with a window element, you need to follow these steps:
- /// - 1. Construct an instance of a TWindow.
- /// - 2. Call Create or Execute, which creates the interface element (HWND) and then
- /// calls SetupWindow, which calls the base SetupWindow for normal processing, which
- /// in turn involves
- /// - Creating the HWindow and any child HWindows.
- /// - Calling TransferData to setup the transfer of data between the
- /// parent and child windows.
- /// - 3. To destroy the interface element, choose one of the following actions,
- /// depending on your application:
- /// - Call Destroy to destroy the interface element unconditionally.
- /// - Call CloseWindow, which calls CanClose to test if it is OK to
- /// destroy the interface element.
- /// - 4. There are two ways to destroy the interface object:
- /// - If the object has been new'd, use delete.
- /// - If the object has not been new'd, the compiler automatically
- /// destructs the object.
- ///
- /// The ObjectWindows destroy process consists of two parts: (1) call Destroy to
- /// destroy the interface element and (2) then delete the C++ object. However, it is
- /// perfectly valid to call Destroy on the interface element without deleting the
- /// C++ object and then to call Create at a later time to re-create the window.
- /// Because it is also valid to construct a C++ window object on the stack or as an
- /// aggregated member, the Destroy function cannot assume it should delete the C++
- /// object.
- ///
- /// The user-generated WM_CLOSE event handler, EvClose, also causes a C++ object to
- /// be deleted by passing the this pointer to the application. The C++ object is
- /// deleted automatically because the EvClose event frequently occurs in response to
- /// a user action, and this is the most convenient place for the deletion to take
- /// place. Later, when it's safe to do so, the application then deletes the window
- /// pointer. Because the stack often contains selectors that refer to the addresses
- /// of objects that may become invalid during the delete process, it is not safe to
- /// delete the this pointer while events are still being processed. If the addresses
- /// become invalid, they could cause trouble when they are reloaded from the stack.
- ///
- /// TWindow is the base class for all window classes, including TFrameWindow,
- /// TControl, TDialog, and TMDIChild. The ObjectWindows hierarchy diagram shows the
- /// many classes that are derived from TWindow.
- //
- class _OWLCLASS TWindow : virtual public TEventHandler,
- virtual public TStreamableBase {
- public:
- // Class scoped types
- //
- typedef HWND THandle; ///< TWindow encapsulates an HWND
- /// \todo Make protected or private
- void TraceWindowPlacement(); //DLN debug
- // Constructors and destructor for TWindow
- //
- TWindow(TWindow* parent, LPCTSTR title = 0, TModule* module = 0);
- TWindow(TWindow* parent, const tstring& title, TModule* module = 0);
- TWindow(HWND handle, TModule* module = 0);
- virtual ~TWindow();
- /// \name Two iterators that take function pointers
- /// @{
- TWindow* FirstThat(TCondFunc test, void* paramList = 0) const;
- void ForEach(TActionFunc action, void* paramList = 0);
- /// @}
- /// \name Two iterators that take pointers to member functions
- /// @{
- TWindow* FirstThat(TCondMemFunc test, void* paramList = 0);
- void ForEach(TActionMemFunc action, void* paramList = 0);
- /// @}
- /// \name Other functions for iteration
- /// @{
- TWindow* Next();
- void SetNext(TWindow* next);
- TWindow* GetFirstChild();
- TWindow* GetLastChild();
- TWindow* Previous();
- uint NumChildren() const; // Number of child windows
- /// @}
- /// \name Query and set the Owl window flags.
- /// Accepts TWindowFlag args, possibly or'd together.
- /// @{
- void SetFlag(uint mask);
- void ClearFlag(uint mask);
- bool IsFlagSet(uint mask);
- /// @}
- /// \name Sets/clears auto-create flag
- /// It indicates that the TWindow should be
- /// created if a create is sent while in the parent's child list
- /// @{
- void EnableAutoCreate();
- void DisableAutoCreate();
- /// @}
- /// \name Retrieves/assigns tooltip of/to window
- /// @{
- virtual TTooltip* GetTooltip() const;
- virtual void EnableTooltip(bool enable=true);
- void SetTooltip(TTooltip* tooltip);
- /// @}
- /// \name Sets/clears transfer flag
- /// It indicates that the TWindow can/will transfer data via the transfer mechanism
- /// @{
- void EnableTransfer();
- void DisableTransfer();
- /// @}
- /// \name Window's default module access functions
- // !CQ SetModule() should be protected!
- /// @{
- TModule* GetModule() const;
- void SetModule(TModule* module);
- /// @}
- /// Convenience functions - forwards the call to the module associated with this window.
- /// @{
- tstring LoadString(uint id) const {PRECONDITION(Module); return Module->LoadString(id);}
- HBITMAP LoadBitmap(TResId id) const {PRECONDITION(Module); return Module->LoadBitmap(id);}
- HACCEL LoadAccelerators(TResId id) const {PRECONDITION(Module); return Module->LoadAccelerators(id);}
- HMENU LoadMenu(TResId id) const {PRECONDITION(Module); return Module->LoadMenu(id);}
- HCURSOR LoadCursor(TResId id) const {PRECONDITION(Module); return Module->LoadCursor(id);}
- HICON LoadIcon(LPCTSTR name) const {PRECONDITION(Module); return Module->LoadIcon(name);}
- /// @}
- TApplication* GetApplication() const;
- virtual bool Register();
- TScroller* GetScroller();
- void SetScroller(TScroller* scroller);
- /// \name Create/destroy an native window to be associated with this window
- /// @{
- virtual bool Create();
- bool CreateChildren();
- virtual void Destroy(int retVal = 0);
- /// @}
- /// \name Create a modal window, and perform actual modal execute call
- /// @{
- virtual int Execute();
- virtual int DoExecute();
- /// @}
- // Request this window to close itself
- //
- virtual void CloseWindow(int retVal = 0);
- /// \name Unconditionally shut down a given window.
- /// Destroy() is called to
- /// destroy the Handle, & then the window is deleted. Non-static version
- /// is safe as long as it is inline and not called on itself
- /// @{
- static void ShutDownWindow(TWindow* win, int retVal = 0);
- void ShutDownWindow(int retVal = 0);
- /// @}
- /// \name Attach or detach a window handle to a TWindow object.
- /// Used when a child re-creates itself.
- /// @{
- void AttachHandle(HWND handle);
- void DetachHandle();
- /// @}
- #if defined(BI_MULTI_THREAD_RTL)
- //Override TEventHandler::Dispatch() to handle multi-thread
- //synchronization
- //
- virtual TResult Dispatch(TEventInfo& info, TParam1 wp, TParam2 lp = 0);
- #endif
- /// \name Message preprocessing
- /// Called from TApplication::ProcessAppMsg() to give the window an
- /// opportunity to perform preprocessing of the Windows message
- /// @{
- virtual bool PreProcessMsg(MSG& msg);
- virtual bool IdleAction(long idleCount);
- virtual bool HoldFocusHWnd(HWND hLose, HWND hGain);
- /// @}
- TWindowAttr& GetWindowAttr();
- const TWindowAttr& GetWindowAttr() const;
- LPCTSTR GetCaption() const;
- /// \name Child and parenting
- /// @{
- int GetId() const;
- TWindow* ChildWithId(int id) const;
- /// @}
- /// \name Get this window's parent.
- /// Either the handle of native window, or a
- /// pointer to the OWL object. May return different objects in some cases.
- /// Use H & O varieties to avoid change across version
- /// @{
- HWND GetParentH() const; // Native handle version
- TWindow* GetParentO() const; // OWL object version
- TWindow* GetParent() const; // New version -- returns object
- /// @}
- virtual void SetParent(TWindow* newParent);
- /// \name Other attributes
- /// @{
- virtual bool SetDocTitle(LPCTSTR docname, int index);
- bool SetDocTitle(const tstring& docname, int index) {return SetDocTitle(docname.c_str(), index);}
- void SetCaption(LPCTSTR title);
- void SetCaption(const tstring& title) {SetCaption(title.c_str());}
- void SetCaption(uint resourceStringId);
- bool SetCursor(TModule* module, TResId resId);
- void SetBkgndColor(const TColor& color);
- void SetAcceleratorTable(TResId resId);
- /// @}
- //Can close virtual tests whether all children and this window are ready
- //and able to close
- //
- virtual bool CanClose();
- /// \name Message forwarding
- /// Forward the current event to "handle" using either PostMessage() or
- /// SendMessage(). Owl window version calls directly to window proc on send.
- /// @{
- TResult ForwardMessage(HWND handle, bool send = true);
- TResult ForwardMessage(bool send = true);
- /// @}
- // Send message to all children
- //
- void ChildBroadcastMessage(uint msg, TParam1 wParam=0, TParam2 lParam=0);
- /// \name Notify a window (parent usually) of a child action.
- /// @{
- void SendNotification(int id, int notifyCode, HWND hCtl,
- uint msg = WM_COMMAND);
- void SendNotification(HWND receiver, int id,
- int notifyCode, HWND hCtl,
- uint msg = WM_COMMAND);
- TResult SendNotification(int id, NMHDR& nmhdr,
- uint msg = WM_NOTIFY);
- TResult SendNotification(HWND receiver, uint id,
- NMHDR& nmhdr, uint msg = WM_NOTIFY);
- /// @}
- #if defined(OWL5_COMPAT)
- // Obsolete. Forwards the call to message handler.
- //
- TResult ReceiveMessage(uint msg, TParam1 p1 = 0, TParam2 p2 = 0)
- {return ReceiveMessage(Handle, msg, p1, p2);}
- #endif
- // Call a Window's window proc to handle a message. Similar to SendMessage
- // but goes directly to the OWL window, bypassing the Windows message queue.
- //
- TResult HandleMessage(uint msg, TParam1 p1 = 0, TParam2 p2 = 0)
- {return ReceiveMessage(Handle, msg, p1, p2);}
- /// \name Windows message handlers
- /// Virtual functions called to handle a message, and to deal with an
- /// unhandled message in a default way.
- /// @{
- virtual TResult WindowProc(uint msg, TParam1 p1, TParam2 p2);
- virtual TResult DefWindowProc(uint msg, TParam1 p1, TParam2 p2);
- /// @}
- // Called by WindowProc() to handle WM_COMMANDs
- //
- virtual TResult EvCommand(uint id, HWND hWndCtl, uint notifyCode);
- // Called by WindowProc() to handle WM_NOTIFYs
- //
- virtual TResult EvNotify(uint id, TNotify & notifyInfo);
- /// \name Called by WindowProc() to handle WM_COMMAND_ENABLE, & helper function
- /// @{
- virtual void EvCommandEnable(TCommandEnabler& ce);
- void RouteCommandEnable(HWND hInitCmdTarget, TCommandEnabler& ce);
- /// @}
- // Default processing, deals with special cases or calls DefWindowProc
- //
- TResult DefaultProcessing();
- // Paint function called by base classes when responding to WM_PAINT
- //
- virtual void Paint(TDC& dc, bool erase, TRect& rect);
- /// \name Transfer buffer functionality
- /// @{
- #if defined(OWL5_COMPAT)
- void SetTransferBuffer(void* transferBuffer);
- #endif
- void SetTransferBuffer(void* transferBuffer, uint size);
- template <class TBuffer>
- void SetTransferBuffer(TBuffer* transferBuffer);
- template <class TElement, uint Count>
- void SetTransferBuffer(TElement (&transferBuffer)[Count]);
- void* GetTransferBuffer() const {return TransferBuffer;}
- uint GetTransferBufferSize() const {return TransferBufferSize;}
- virtual uint Transfer(void* buffer, TTransferDirection direction);
- virtual void TransferData(TTransferDirection direction);
- /// @}
- // Installs the instance window procedure and saves the previous window
- // procedure in "DefaultProc"
- //
- void SubclassWindowFunction();
- //-----------------------------------
- // Encapsulated native HWND functions inline
- //
- /// \name Allow a TWindow& to be used as an HWND in Windows API calls
- /// @{
- HWND GetHandle() const;
- operator HWND() const;
- bool IsWindow() const;
- /// @}
- /// \name Messages
- /// @{
- TResult SendMessage(uint msg, TParam1 p1 = 0, TParam2 p2 = 0) const;
- TResult SendDlgItemMessage(int childId, uint msg, TParam1 p1 = 0,
- TParam2 p2 = 0);
- bool PostMessage(uint msg, TParam1 p1 = 0, TParam2 p2 = 0);
- static HWND GetCapture();
- HWND SetCapture();
- static void ReleaseCapture();
- static HWND GetFocus();
- HWND SetFocus();
- bool IsWindowEnabled() const;
- virtual bool EnableWindow(bool enable);
- void SetRedraw(bool redraw);
- /// @}
- /// \name Window coordinates, dimensions...
- /// @{
- void ScreenToClient(TPoint& point) const;
- void MapWindowPoints(HWND hWndTo, TPoint* pts, int count) const;
- void GetClientRect(TRect& rect) const;
- TRect GetClientRect() const;
- static HWND WindowFromPoint(const TPoint& point);
- HWND ChildWindowFromPoint(const TPoint& point) const;
- void ClientToScreen(TPoint& point) const;
- void GetWindowRect(TRect& rect) const;
- TRect GetWindowRect() const;
- static void AdjustWindowRect(TRect& rect, uint32 style, bool menu);
- static void AdjustWindowRectEx(TRect& rect, uint32 style,
- bool menu, uint32 exStyle);
- /// @}
- /// \name Window and class Words and Longs, window properties
- /// @{
- long GetClassName(LPTSTR className, int maxCount) const;
- long GetClassLong(int index) const;
- long SetClassLong(int index, long newLong);
- uint16 GetClassWord(int index) const;
- uint16 SetClassWord(int index, uint16 newWord);
- LONG_PTR GetWindowLongPtr(int index) const;
- LONG_PTR SetWindowLongPtr(int index, LONG_PTR newLong);
- long GetWindowLong(int index) const;
- long SetWindowLong(int index, long newLong);
- uint16 GetWindowWord(int index) const;
- uint16 SetWindowWord(int index, uint16 newWord);
- WNDPROC GetWindowProc() const;
- WNDPROC SetWindowProc(WNDPROC wndProc);
- int EnumProps(PROPENUMPROC proc);
- HANDLE GetProp(uint16 atom) const;
- HANDLE RemoveProp(uint16 atom) const;
- bool SetProp(uint16 atom, HANDLE data) const;
- HANDLE GetProp(LPCTSTR str) const;
- HANDLE GetProp(const tstring& str) const {return GetProp(str.c_str());}
- HANDLE RemoveProp(LPCTSTR str) const;
- HANDLE RemoveProp(const tstring& str) const {return RemoveProp(str.c_str());}
- bool SetProp(LPCTSTR str, HANDLE data) const;
- bool SetProp(const tstring& str, HANDLE data) const {return SetProp(str.c_str(), data);}
- /// @}
- /// \name Dual mode accessors.
- /// Work with Attr and other members as well as the underlying window information
- /// @{
- uint32 GetStyle() const;
- uint32 SetStyle(uint32 style);
- uint32 GetExStyle() const;
- uint32 SetExStyle(uint32 style);
- bool ModifyStyle(uint32 offBits, uint32 onBits,
- uint swpFlags = 0);
- bool ModifyExStyle(uint32 offBits, uint32 onBits,
- uint swpFlags = 0);
- /// @}
- /// \name Window placement(X,Y) and display
- /// @{
- bool MoveWindow(int x, int y, int w, int h, bool repaint = false);
- bool MoveWindow(const TRect& rect, bool repaint = false);
- virtual bool ShowWindow(int cmdShow);
- void ShowOwnedPopups(bool show);
- bool IsWindowVisible() const;
- bool IsZoomed() const;
- bool IsIconic() const;
- int GetWindowTextLength() const;
- int GetWindowText(LPTSTR str, int maxCount) const;
- tstring GetWindowText() const;
- void SetWindowText(LPCTSTR str);
- void SetWindowText(const tstring& str) {SetWindowText(str.c_str());}
- void SetWindowText(uint resourceStringId);
- bool GetWindowPlacement(WINDOWPLACEMENT* place) const;
- bool SetWindowPlacement(const WINDOWPLACEMENT* place);
- /// @}
- /// \name Window positioning(Z), sibling relationships
- /// @{
- void BringWindowToTop();
- static HWND GetActiveWindow();
- HWND SetActiveWindow();
- static HWND GetDesktopWindow();
- HWND GetLastActivePopup() const;
- HWND GetNextWindow(uint dirFlag) const;
- HWND GetTopWindow() const;
- HWND GetWindow(uint cmd) const;
- bool SetWindowPos(HWND hWndInsertAfter,
- const TRect& rect,
- uint flags);
- bool SetWindowPos(HWND hWndInsertAfter,
- int x, int y, int w, int h,
- uint flags);
- /// @}
- /// \name Window painting: invalidating, validating & updating
- /// @{
- virtual void Invalidate(bool erase = true);
- virtual void InvalidateRect(const TRect& rect, bool erase = true);
- void InvalidateRgn(HRGN hRgn, bool erase = true);
- void Validate();
- void ValidateRect(const TRect& rect);
- void ValidateRgn(HRGN hRgn);
- void UpdateWindow();
- bool FlashWindow(bool invert);
- bool GetUpdateRect(TRect& rect, bool erase = true) const;
- int GetUpdateRgn(TRegion& rgn, bool erase = true) const;
- bool LockWindowUpdate(bool lock=true);
- bool RedrawWindow(TRect* update,
- HRGN hUpdateRgn,
- uint redrawFlags = RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE);
- /// @}
- /// \name Scrolling and scrollbars
- /// @{
- int GetScrollPos(int bar) const;
- int SetScrollPos(int bar, int pos, bool redraw = true);
- void GetScrollRange(int bar, int& minPos, int& maxPos) const;
- void SetScrollRange(int bar,
- int minPos,
- int maxPos,
- bool redraw = true);
- void SetScrollPage(int bar, int page, bool redraw = true);
- int GetScrollPage(int bar) const;
- bool EnableScrollBar(uint sbFlags=SB_BOTH,
- uint arrowFlags=ESB_ENABLE_BOTH);
- void ShowScrollBar(int bar, bool show = true);
- void ScrollWindow(int dx,
- int dy,
- const TRect * scroll = 0,
- const TRect * clip = 0);
- void ScrollWindowEx(int dx,
- int dy,
- const TRect * scroll = 0,
- const TRect * clip = 0,
- HRGN hUpdateRgn = 0,
- TRect * update = 0,
- uint flags = 0);
- void SetScrollInfo(int bar, SCROLLINFO* scrollInfo,
- bool redraw = true);
- void GetScrollInfo(int bar, SCROLLINFO* scrollInfo) const;
- /// @}
- /// \name Parent/child with Ids
- /// @{
- int GetDlgCtrlID() const;
- HWND GetDlgItem(int childId) const;
- uint GetDlgItemInt(int childId,
- bool* translated = 0,
- bool isSigned = true) const;
- void SetDlgItemInt(int childId,
- uint value,
- bool isSigned = true) const;
- int GetDlgItemText(int childId, LPTSTR text, int max) const;
- tstring GetDlgItemText(int childId) const;
- void SetDlgItemText(int childId, LPCTSTR text) const;
- void SetDlgItemText(int childId, const tstring& text) const {SetDlgItemText(childId, text.c_str());}
- void SetDlgItemText(int childId, uint resourceStringId) const {SetDlgItemText(childId, LoadString(resourceStringId));}
- uint IsDlgButtonChecked(int buttonId) const;
- bool IsChild(HWND hWnd) const;
- HWND GetNextDlgGroupItem(HWND hWndCtrl,
- bool previous = false) const;
- HWND GetNextDlgTabItem(HWND hWndCtrl,
- bool previous = false) const;
- void CheckDlgButton(int buttonId, uint check);
- void CheckRadioButton(int firstButtonId,
- int lastButtonId,
- int checkButtonId);
- /// @}
- /// \name Menus and menubar
- /// @{
- HMENU GetMenu() const;
- HMENU GetSystemMenu(bool revert = false) const;
- bool SetMenu(HMENU hMenu);
- bool HiliteMenuItem(HMENU hMenu, uint idItem, uint hilite);
- void DrawMenuBar();
- /// @}
- /// \name Timer
- /// @{
- bool KillTimer(UINT_PTR timerId);
- UINT_PTR SetTimer(UINT_PTR timerId, uint timeout, TIMERPROC proc = 0);
- /// @}
- /// \name Caret, cursor, font
- /// @{
- void CreateCaret(HBITMAP hBitmap);
- void CreateCaret(bool isGray, int width, int height);
- static uint GetCaretBlinkTime();
- static void GetCaretPos(TPoint& point);
- void HideCaret();
- static void SetCaretBlinkTime(uint16 milliSecs);
- static void SetCaretPos(int x, int y);
- static void SetCaretPos(const TPoint& pos);
- void ShowCaret();
- static void DestroyCaret();
- static void GetCursorPos(TPoint& pos);
- void SetWindowFont(HFONT font, bool redraw);
- HFONT GetWindowFont();
- /// @}
- /// \name Hot keys
- /// @{
- bool RegisterHotKey(int idHotKey, uint modifiers, uint virtKey);
- bool UnregisterHotKey(int idHotKey);
- /// @}
- /// \name Misc
- /// @{
- bool WinHelp(LPCTSTR helpFile, uint command, uint32 data);
- bool WinHelp(const tstring& helpFile, uint command, uint32 data) {return WinHelp(helpFile.c_str(), command, data);}
- void AssignContextMenu(TPopupMenu* menu);
- TPopupMenu* GetContextMenu() const;
- int MessageBox(LPCTSTR text, LPCTSTR caption = 0, uint flags = MB_OK);
- int MessageBox(const tstring& text, const tstring& caption = tstring(), uint flags = MB_OK);
- int MessageBox(uint resId, LPCTSTR caption = 0, uint flags = MB_OK);
- int MessageBox(uint resId, const tstring& caption, uint flags = MB_OK);
- int FormatMessageBox(LPCTSTR text, LPCTSTR caption, uint flags, va_list argp);
- int FormatMessageBox(LPCTSTR text, LPCTSTR caption, uint flags, ...);
- int FormatMessageBox(const tstring& text, const tstring& caption, uint flags, va_list argp);
- int FormatMessageBox(const tstring& text, const tstring& caption, uint flags, ...);
- int FormatMessageBox(uint resId, LPCTSTR caption, uint flags, va_list argp);
- int FormatMessageBox(uint resId, LPCTSTR caption = 0, uint flags = MB_OK, ...);
- int FormatMessageBox(uint resId, const tstring& caption, uint flags, va_list argp);
- int FormatMessageBox(uint resId, const tstring& caption, uint flags = MB_OK, ...);
- HTASK GetWindowTask() const;
- void DragAcceptFiles(bool accept);
- TCurrentEvent& GetCurrentEvent();
- void SethAccel(HACCEL);
- /// @}
- protected:
- /// \name These events are processed by TWindow
- /// @{
- void EvClose();
- int EvCreate(CREATESTRUCT & createStruct);
- void EvDestroy();
- TResult EvCompareItem(uint ctrlId, COMPAREITEMSTRUCT & compareInfo);
- void EvDeleteItem(uint ctrlId, DELETEITEMSTRUCT & deleteInfo);
- void EvDrawItem(uint ctrlId, DRAWITEMSTRUCT & drawInfo);
- void EvMeasureItem(uint ctrlId, MEASUREITEMSTRUCT & measureInfo);
- void EvHScroll(uint scrollCode, uint thumbPos, HWND hWndCtl);
- void EvVScroll(uint scrollCode, uint thumbPos, HWND hWndCtl);
- void EvMove(TPoint& clientOrigin);
- void EvNCDestroy();
- bool EvQueryEndSession();
- void EvSize(uint sizeType, TSize& size);
- void EvLButtonDown(uint modKeys, TPoint& point);
- bool EvEraseBkgnd(HDC);
- void EvPaint();
- void EvSysColorChange();
- TResult EvWin32CtlColor(TParam1, TParam2);
- /// @}
- /// \name Input validation message handler
- /// @{
- void EvChildInvalid(HWND hWnd);
- /// @}
- /// \name System messages
- /// @{
- void EvCommNotify(uint commId, uint status);
- void EvCompacting(uint compactRatio);
- void EvDevModeChange(LPTSTR devName);
- void EvEnable(bool enabled);
- void EvEndSession(bool endSession, bool logOff /* used only by Win95 */);
- void EvFontChange();
- int EvPower(uint powerEvent);
- void EvSysCommand(uint cmdType, TPoint& point);
- void EvSystemError(uint error);
- void EvTimeChange();
- void EvTimer(uint timerId);
- void EvWinIniChange(LPTSTR section);
- /// @}
- /// \name Window manager messages
- /// @{
- void EvActivate(uint active,
- bool minimized,
- HWND hWndOther /* may be 0 */);
- void EvActivateApp(bool active, HTASK hTask);
- void EvCancelMode();
- void EvGetMinMaxInfo(MINMAXINFO & minmaxinfo);
- void EvGetText(uint buffSize, LPTSTR buff);
- uint EvGetTextLength();
- void EvIconEraseBkgnd(HDC hDC);
- void EvKillFocus(HWND hWndGetFocus /* may be 0 */);
- uint EvMouseActivate(HWND hTopLevel, uint hitCode, uint msg);
- /// @}
- /// \name The following are called under Win32 only
- /// @{
- void EvInputFocus(bool gainingFocus);
- void EvOtherWindowCreated(HWND hWndOther);
- void EvOtherWindowDestroyed(HWND hWndOther);
- void EvPaintIcon();
- void EvHotKey(int idHotKey);
- TResult EvCopyData(HWND hwnd, COPYDATASTRUCT* dataStruct);
- void EvNextDlgCtl(uint hctlOrDir, uint isHCtl);
- void EvParentNotify(uint event,
- uint childHandleOrX,
- uint childIDOrY);
- HANDLE EvQueryDragIcon();
- bool EvQueryOpen();
- void EvQueueSync();
- bool EvSetCursor(HWND hWndCursor,
- uint hitTest,
- uint mouseMsg);
- void EvSetFocus(HWND hWndLostFocus /* may be 0 */);
- HFONT EvGetFont();
- void EvSetFont(HFONT hFont, bool redraw);
- void EvSetRedraw(bool redraw);
- void EvSetText(LPCTSTR text);
- void EvShowWindow(bool show, uint status);
- void EvWindowPosChanged(WINDOWPOS & windowPos);
- void EvWindowPosChanging(WINDOWPOS & windowPos);
- /// @}
- /// \name Controls
- /// @{
- HBRUSH EvCtlColor(HDC hDC, HWND hWndChild, uint ctlType);
- /// @}
- /// \name Keyboard input
- /// @{
- void EvChar(uint key, uint repeatCount, uint flags);
- void EvDeadChar(uint deadKey, uint repeatCount, uint flags);
- void EvKeyDown(uint key, uint repeatCount, uint flags);
- void EvKeyUp(uint key, uint repeatCount, uint flags);
- void EvSysChar(uint key, uint repeatCount, uint flags);
- void EvSysDeadChar(uint key, uint repeatCount, uint flags);
- void EvSysKeyDown(uint key, uint repeatCount, uint flags);
- void EvSysKeyUp(uint key, uint repeatCount, uint flags);
- /// @}
- /// \name Mouse input
- /// @{
- void EvLButtonDblClk(uint modKeys, TPoint& point);
- void EvLButtonUp(uint modKeys, TPoint& point);
- void EvMButtonDblClk(uint modKeys, TPoint& point);
- void EvMButtonDown(uint modKeys, TPoint& point);
- void EvMButtonUp(uint modKeys, TPoint& point);
- void EvMouseMove(uint modKeys, TPoint& point);
- bool EvMouseWheel(uint modKeys, int zDelta, TPoint& point);
- void EvRButtonDblClk(uint modKeys, TPoint& point);
- void EvRButtonDown(uint modKeys, TPoint& point);
- void EvRButtonUp(uint modKeys, TPoint& point);
- TResult EvRegisteredMouseWheel(TParam1, TParam2);
- /// @}
- /// \name Menu related messages
- /// @{
- void EvInitMenu(HMENU hMenu);
- void EvInitMenuPopup(HMENU hPopupMenu,
- uint index,
- bool sysMenu);
- int32 EvMenuChar(uint nChar, uint menuType, HMENU hMenu);
- void EvMenuSelect(uint menuItemId, uint flags, HMENU hMenu);
- void EvContextMenu(HWND childHwnd, int x, int y);
- /// @}
- /// \name Dialog [Menu] messages
- /// @{
- uint EvGetDlgCode(MSG * msg);
- void EvEnterIdle(uint source, HWND hWndDlg);
- /// @}
- /// \name Print manager messages
- /// @{
- void EvSpoolerStatus(uint jobStatus, uint jobsLeft);
- /// @}
- /// \name Clipboard messages
- /// @{
- void EvAskCBFormatName(uint bufLen, LPTSTR buffer);
- void EvChangeCBChain(HWND hWndRemoved, HWND hWndNext);
- void EvDrawClipboard();
- void EvDestroyClipboard();
- void EvHScrollClipboard(HWND hCBViewer, uint scrollCode, uint pos);
- void EvPaintClipboard(HWND hWnd, HANDLE hPaintStruct);
- void EvRenderAllFormats();
- void EvRenderFormat(uint dataFormat);
- void EvSizeClipboard(HWND hWndViewer, HANDLE hRect);
- void EvVScrollClipboard(HWND hCBViewer, uint scrollCode, uint pos);
- /// @}
- /// \name Palette manager messages
- /// @{
- void EvPaletteChanged(HWND hWndPalChg);
- void EvPaletteIsChanging(HWND hWndPalChg);
- bool EvQueryNewPalette();
- /// @}
- /// \name Drag-n-drop messages
- /// @{
- void EvDropFiles(TDropInfo dropInfo);
- /// @}
- /// \name List box messages
- /// @{
- int EvCharToItem(uint key, HWND hWndListBox, uint caretPos);
- int EvVKeyToItem(uint key, HWND hWndListBox, uint caretPos);
- /// @}
- /// \name Non-client messages
- /// @{
- bool EvNCActivate(bool active);
- uint EvNCCalcSize(bool calcValidRects, NCCALCSIZE_PARAMS & params);
- bool EvNCCreate(CREATESTRUCT & createStruct);
- uint EvNCHitTest(TPoint& point);
- void EvNCLButtonDblClk(uint hitTest, TPoint& point);
- void EvNCLButtonDown(uint hitTest, TPoint& point);
- void EvNCLButtonUp(uint hitTest, TPoint& point);
- void EvNCMButtonDblClk(uint hitTest, TPoint& point);
- void EvNCMButtonDown(uint hitTest, TPoint& point);
- void EvNCMButtonUp(uint hitTest, TPoint& point);
- void EvNCMouseMove(uint hitTest, TPoint& point);
- // WM_NCPAINT now passes an HRGN under Win32.
- //
- void EvNCPaint(HRGN);
- void EvNCRButtonDblClk(uint hitTest, TPoint& point);
- void EvNCRButtonDown(uint hitTest, TPoint& point);
- void EvNCRButtonUp(uint hitTest, TPoint& point);
- /// @}
- /// \name Icon messages
- /// \todo There is no implementation for these functions
- /// @{
- HICON EvGetIcon(bool largeIcon);
- HICON EvSetIcon(bool largeIcon, HICON icon);
- /// @}
- /// \name Callback procs for hooking TWindow to native window
- /// @{
- static TResult CALLBACK InitWndProc(HWND, uint, TParam1, TParam2);
- /// @}
- protected:
- // Constructor & subsequent initializer for use with virtual derivations
- // Immediate derivitives must call Init() before constructions are done.
- //
- TWindow();
- void Init(TWindow* parent, LPCTSTR title, TModule* module);
- void Init(TWindow* parent, const tstring& title, TModule* module) {Init(parent, title.c_str(), module);}
- void Init(HWND hWnd, TModule* module);
- //
- /// For code safety and 64-bit compatibility the old parameter to PerformCreate
- /// has been deprecated. In the strict build mode, the parameter is no longer
- /// used, and the signature of PerformCreate has been changed to force a
- /// compilation error for legacy code. This is achieved by changing the return
- /// type but leaving the old parameter in place, although now unused.
- //
- #if OWL_STRICT
- typedef THandle TPerformCreateReturnType;
- #else
- typedef void TPerformCreateReturnType;
- #endif
- virtual TPerformCreateReturnType PerformCreate(int deprecated_argument = 0);
- void SetHandle(THandle);
- TPerformCreateReturnType SetOrReturnHandle(THandle);
- // Resynching state
- //
- void GetHWndState(bool forceStyleSync = false);
- void GetWindowTextTitle();
- virtual void GetWindowClass(WNDCLASS& wndClass);
- #if defined(OWL5_COMPAT)
- typedef LPTSTR TGetClassNameReturnType;
- #else
- typedef LPCTSTR TGetClassNameReturnType;
- #endif
- virtual TGetClassNameReturnType GetClassName();
- void PerformSetupAndTransfer();
- virtual void SetupWindow();
- virtual void CleanupWindow();
- void DispatchScroll(uint scrollCode, uint thumbPos, HWND hWndCtrl);
- void LoadAcceleratorTable();
- virtual void RemoveChild(TWindow* child);
- TWindow* GetWindowPtr(HWND hWnd) const;
- // Member data // !CQ need to add accessors for many of these
- //
- public_data:
- /// Holds the handle to the associated MS-Windows window, which you'll need to
- /// access if you make calls directly to Windows API functions.
- //
- HWND Handle;
- /// Points to the window's caption. When there is a valid HWindow, Title will yield
- /// the same information as ::GetWindowText if you use TWindow::SetCaption to set
- /// it.
- LPTSTR Title; // Logical title. Usually the same as window text
- /// Points to the interface object that serves as the parent window for this interface object.
- TWindow* Parent; // Owl parent, use GetParentO(), SetParent()
- /// Holds a TWindowAttr structure, which contains the window's creation attributes.
- /// These attributes, which include the window's style, extended style, position,
- /// size, menu ID, child window ID, and menu accelerator table ID, are passed to the
- /// function that creates the window.
- TWindowAttr Attr;
- /// Holds the address of the default window procedure. DefWindowProc calls
- /// DefaultProc to process Windows messages that are not handled by the window.
- WNDPROC DefaultProc;
- /// Points to the scroller object that supports either the horizontal or vertical
- /// scrolling for this window.
- TScroller* Scroller; // Scrolling helper object
- protected_data:
- /// Holds the handle to the current Windows accelerator table associated with this window.
- //
- HACCEL HAccel;
- /// Holds the module ID for the specified cursor. A value of 0 indicates a standard system cursor.
- TModule* CursorModule;
- /// Holds the cursor resource ID for the window's cursor. If the data member
- /// CursorModule is 0, CursorResId can be one of the following IDC_Xxxx constants
- /// that represent different kinds of cursors:
- /// - \c \b IDC_ARROW Customary arrow cursor
- /// - \c \b IDC_CROSS Crosshair cursor
- /// - \c \b IDC_IBEAM I-beam cursor
- /// - \c \b IDC_ICON Unfilled icon cursor
- /// - \c \b IDC_SIZE A smaller square in the right inside corner of a larger square
- /// - \c \b IDC_SIZENESW Dual-pointing cursor with arrows pointing southwest and northeast
- /// - \c \b IDC_SIZENS Dual-pointing cursor with arrows pointing south and north
- /// - \c \b IDC_SIZENWSE Dual-pointing cursor with arrows pointing southeast and northwest
- /// - \c \b IDC_SIZEWE Dual-pointing cursor with arrows pointing east and west
- /// - \c \b IDC_UPARROW Vertical arrow cursor
- /// - \c \b IDC_WAIT Hourglass cursor
- TResId CursorResId;
- /// Holds a handle to the window's cursor. The cursor is retrieved using
- /// CursorModule and CursorResId and set using SetCursor.
- HCURSOR HCursor;
- /// Stores the current background color set by TWindow::SetBkgndColor.
- TColor BkgndColor;
- TPopupMenu* ContextPopupMenu; ///< Popup menu used for right click
- TTooltip* Tooltip; // Tooltip
- #if defined(OWL5_COMPAT)
- protected_data: // TransferBuffer is proteced or maybe even public.
- #else
- private: // TransferBuffer is always private.
- #endif
- /// Points to a buffer to be used in transferring data in and out of the TWindow
- /// object. A TWindow object assumes that the buffer contains data used by the
- /// windows in its child list. If TransferBuffer is 0, no data is to be transferred.
- void* TransferBuffer;
- /// Specifies the size of the transfer buffer pointed to by TransferBuffer.
- uint TransferBufferSize;
- private:
- WNDPROC InstanceProc; ///< The window proc for this window instance
- TApplication* Application; ///< Application that this window belongs to
- TModule* Module; ///< Default module used for getting resources
- uint32 Flags;
- uint16 ZOrder;
- TWindow* ChildList;
- TWindow* SiblingList;
- uint32 UniqueId;
- static uint32 LastUniqueId;
- // Instance window proc interface
- //
- WNDPROC CreateInstanceProc();
- WNDPROC GetInstanceProc() const;
- void InitInstanceProc();
- void FreeInstanceProc();
- // Internal functions
- //
- HMENU MakeMenuOrId();
- void PerformInit(TWindow* parent, TModule* module);
- bool OrderIsI(TWindow* win, void* position);
- void AssignZOrder();
- void AddChild(TWindow* child);
- int IndexOf(TWindow* child) const;
- TWindow* At(int position);
- void SetUniqueId();
- TResult ReceiveMessage(HWND hwnd, uint msg, TParam1 p1 = 0, TParam2 p2 = 0);
- friend void* GetMessageReceiverMemberFunctionAddress();
- // Hidden to prevent accidental copying or assignment
- //
- TWindow(const TWindow&);
- TWindow& operator =(const TWindow&);
- DECLARE_RESPONSE_TABLE(TWindow);
- // DECLARE_STREAMABLE(_OWLCLASS, owl::TWindow, 3);
- DECLARE_STREAMABLE_OWL(owl::TWindow, 3);
- }; // class TWindow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement