home *** CD-ROM | disk | FTP | other *** search
- #ifndef _CUSTWIND_H_
- #define _CUSTWIND_H_
-
- #ifndef __OWL_H
- #include <owl.h>
- #endif
-
- #ifndef _CUSTSTRC_H_
- #include "custstrc.h"
- #endif
-
- #ifndef _CUSTID_H_
- #include "custid.h"
- #endif
-
- #ifndef _NCBUTTON_H_
- #include "ncbutton.h"
- #endif
-
- #define HTNCBUTTON 50
- #define MAX_NCBUTTONS 20
-
- #define WM_CUSTOMUPDATEWINDOW WM_USER + 50
-
- #define WTYPE_WINDOW 0
- #define WTYPE_DIALOG 1
-
- HINSTANCE _EXPORT GetCustWindInstance(void);
- PTModule _EXPORT GetCustWindModule(void);
-
- _CLASSDEF(TUnderlying)
- class _EXPORT TUnderlying
- {
- HICON ClassIcon;
- HCURSOR OldCursor;
-
- char NoCenter; //Do not center during setup
-
- PTNCButton NCButtons[MAX_NCBUTTONS];
- char ButtonCapt,LastIn;
-
- void HandleButtonMove(RTMessage Msg);
- public:
- HWND MyHWindow;
- PTWindowsObject MyParent;
- PTWindowsObject Me;
- BYTE Type;
- //The following declarations are so that this
- //class can reference these functions that will
- //when derived reference the REAL functions of
- //these.
- void SetThis(PTWindowsObject This)
- { MyHWindow = This->HWindow;
- MyParent = This->Parent;
- Me = This; };
-
- //Default Constructor, so that only one of the
- //derived classes to have TUnderlying in its
- //initializer list.
- TUnderlying() { };
- TUnderlying(PCustColors Colors);
- TUnderlying(PCustColors, PCustCursors);
- virtual ~TUnderlying();
-
- void SetNoCustom(void)
- { Chars.CustomLevel = 0;
- InvalidateRect(MyHWindow, NULL, TRUE); };
- void SetLightCustom(void)
- { Chars.CustomLevel = 1;
- InvalidateRect(MyHWindow, NULL, TRUE);};
- void SetHeavyCustom(void)
- { Chars.CustomLevel = 2;
- InvalidateRect(MyHWindow, NULL, TRUE); };
- void DontCenter(void)
- { NoCenter = TRUE; };
-
- void DrawNCButton(int Button);
- //User Definable
- //The three are used to allow shorter functions,
- //thus more readibility, and also to allow derived
- //classes to not have to draw all of the parts
- virtual void UserFrame(HDC DrawDC);
- virtual void UserTitle(HDC DrawDC);
- virtual void DrawSysMenu(HDC DrawDC);
- virtual void DrawMinMax(HDC DrawDC);
-
- virtual void USetupWindow();
- virtual void UCtlColor(RTMessage Msg);
- virtual void UPaint(RTMessage Msg);
- virtual void UNCPaint(RTMessage Msg);
- virtual void UActivate(RTMessage Msg);
- virtual void USetText(RTMessage Msg);
- virtual void UNCActivate(RTMessage Msg);
- virtual void UUpdateEntireWindow(RTMessage)
- { InvalidateRect(MyHWindow, NULL, TRUE); };
- virtual void UClose(RTMessage Msg);
- virtual void USize(RTMessage Msg);
- virtual void UDestroy(RTMessage Msg)
- { Chars.Closing = TRUE; };
- virtual void UEraseBkGnd(RTMessage Msg);
- virtual void UNCMouseMove(RTMessage Msg);
- virtual void UMouseMove(RTMessage Msg);
- virtual void USetCursor(RTMessage Msg);
- virtual void UNCLButtonDown(RTMessage Msg);
- virtual void UNCLButtonUp(RTMessage Msg);
- virtual BOOL ULButtonDown(RTMessage Msg);
- virtual void ULButtonUp(RTMessage Msg);
- virtual void UNCHitTest(RTMessage Msg);
-
- BOOL AddNCButton(PTNCButton AButton);
- BOOL RemoveNCButton(PTNCButton AButton);
- BOOL RemoveNCButton(int Id);
- PTNCButton GetNCButton(int Id);
-
- void AddExtendedButtons(HINSTANCE Inst, int StartRight);
- void DeleteExtendedButtons(void);
- //Inline functions of NCButton positioning
- void PosFromTopLeft(RECT& ARect, int APos)
- { AreaFromTopLeft(ARect, APos); };
- void PosFromTopRight(RECT& ARect, int APos)
- { AreaFromTopRight(ARect, APos); };
- //There are times when an inline funciton is required
- //instead of a define
-
- protected:
- virtual void CalcRegions(void);
- virtual void Construct(PCustColors Colors, PCustCursors);
- virtual void DrawFrame(void);
-
- //These variables are protected so derived classes
- //have access to them
- HBRUSH Background;
- struct {
- unsigned int IsActive : 1;
- unsigned int Closing : 1;
- unsigned int SysMenu : 1;
- unsigned int MinBox : 1;
- unsigned int MaxBox : 1;
- unsigned int Caption : 1;
- unsigned int CustomLevel: 2;
- unsigned int IsChild : 1;
- } Chars;
- RECT WindowRect, TitleRect, ClientRect;
- POINT SysMenu, MaxButton, MinButton;
- int BorderSize, BitWidth, BitHeight, TitleHeight;
- CustColors DrawColors;
- CustCursors MouseCursors;
-
- virtual void GetWindowClass(WNDCLASS _FAR & AWndClass);
- virtual void ChangeCursor(int HitTest);
- };
-
- _CLASSDEF(TCustomDialog)
- class _EXPORT TCustomDialog : public TDialog,
- virtual public TUnderlying
- {
- public:
- TCustomDialog(PTWindowsObject AParent, LPSTR AName,
- PCustColors Colors, PTModule AModule = NULL);
- TCustomDialog(PTWindowsObject AParent, int ResourceId,
- PCustColors Colors, PTModule AModule = NULL);
- TCustomDialog(PTWindowsObject AParent, LPSTR AName,
- PCustColors Colors, PCustCursors Cursors,
- PTModule AModule = NULL);
- TCustomDialog(PTWindowsObject AParent, int ResourceId,
- PCustColors Colors, PCustCursors Cursors,
- PTModule AModule = NULL);
-
- virtual void SetupWindow()
- { SetThis(this);
- USetupWindow();
- TDialog::SetupWindow(); };
- virtual void WMCtlColor(RTMessage Msg) = [WM_FIRST + WM_CTLCOLOR]
- { UCtlColor(Msg); };
- virtual void WMPaint(RTMessage Msg) = [WM_FIRST + WM_PAINT]
- { UPaint(Msg); };
- virtual void WMNCPaint(RTMessage Msg) = [WM_FIRST + WM_NCPAINT]
- { UNCPaint(Msg); };
- virtual void WMActivate(RTMessage Msg) = [WM_FIRST + WM_ACTIVATE]
- { UActivate(Msg);
- TDialog::WMActivate(Msg); };
- virtual void WMSetText(RTMessage Msg) = [WM_FIRST + WM_SETTEXT]
- { USetText(Msg); };
- virtual void WMNCActivate(RTMessage Msg) = [WM_FIRST + WM_NCACTIVATE]
- { UNCActivate(Msg); };
- virtual void WMUpdateEntireWindow(RTMessage Msg) = [WM_FIRST + WM_CUSTOMUPDATEWINDOW]
- { UUpdateEntireWindow(Msg); };
- virtual void WMClose(RTMessage Msg) = [WM_FIRST + WM_CLOSE]
- { UClose(Msg);
- TDialog::WMClose(Msg); };
- virtual void WMSize(RTMessage Msg) = [WM_FIRST + WM_SIZE]
- { USize(Msg); };
- virtual void WMDestroy(RTMessage Msg) = [WM_FIRST + WM_DESTROY]
- { UDestroy(Msg);
- TDialog::WMDestroy(Msg); };
- virtual void WMEraseBkGnd(RTMessage Msg) = [WM_FIRST + WM_ERASEBKGND]
- { UEraseBkGnd(Msg); };
- virtual void WMNCMouseMove(RTMessage Msg) = [WM_FIRST + WM_NCMOUSEMOVE]
- { UNCMouseMove(Msg); };
- virtual void WMMouseMove(RTMessage Msg) = [WM_FIRST + WM_MOUSEMOVE]
- { UMouseMove(Msg); };
- virtual void WMSetCursor(RTMessage Msg) = [WM_FIRST + WM_SETCURSOR]
- { USetCursor(Msg); };
- virtual void WMNCLButtonDown(RTMessage Msg) = [WM_FIRST + WM_NCLBUTTONDOWN]
- { UNCLButtonDown(Msg); };
- virtual void WMNCLButtonUp(RTMessage Msg) = [WM_FIRST + WM_NCLBUTTONUP]
- { UNCLButtonUp(Msg); };
- virtual void WMLButtonDown(RTMessage Msg) = [WM_FIRST + WM_LBUTTONDOWN]
- { ULButtonDown(Msg); };
- virtual void WMLButtonUp(RTMessage Msg) = [WM_FIRST + WM_LBUTTONUP]
- { ULButtonUp(Msg); };
- virtual void WMNCHitTest(RTMessage Msg) = [WM_FIRST + WM_NCHITTEST]
- { UNCHitTest(Msg); };
- virtual void Cancel(RTMessage Msg) = [ID_FIRST + IDCANCEL]
- { Chars.Closing = 1;
- TDialog::Cancel(Msg); };
- protected:
- virtual LPSTR GetClassName();
- virtual void GetWindowClass(WNDCLASS _FAR & AWndClass);
- };
-
- _CLASSDEF(TCustomWindow)
- class _EXPORT TCustomWindow : public TWindow,
- virtual public TUnderlying
- {
- public:
- TCustomWindow(PTWindowsObject AParent, LPSTR ATitle,
- PCustColors Colors, PTModule AModule = NULL);
- TCustomWindow(PTWindowsObject AParent, LPSTR ATitle,
- PCustColors Colors, PCustCursors Cursors,
- PTModule AModule = NULL);
-
- virtual void SetupWindow()
- { SetThis(this);
- USetupWindow();
- TWindow::SetupWindow(); };
- virtual void WMCtlColor(RTMessage Msg) = [WM_FIRST + WM_CTLCOLOR]
- { UCtlColor(Msg); };
- virtual void WMPaint(RTMessage Msg) = [WM_FIRST + WM_PAINT]
- { TWindow::WMPaint(Msg);
- UPaint(Msg); };
- virtual void WMNCPaint(RTMessage Msg) = [WM_FIRST + WM_NCPAINT]
- { UNCPaint(Msg); };
- virtual void WMActivate(RTMessage Msg) = [WM_FIRST + WM_ACTIVATE]
- { UActivate(Msg);
- TWindow::WMActivate(Msg); };
- virtual void WMSetText(RTMessage Msg) = [WM_FIRST + WM_SETTEXT]
- { USetText(Msg); };
- virtual void WMNCActivate(RTMessage Msg) = [WM_FIRST + WM_NCACTIVATE]
- { UNCActivate(Msg); };
- virtual void WMUpdateEntireWindow(RTMessage Msg) = [WM_FIRST + WM_CUSTOMUPDATEWINDOW]
- { UUpdateEntireWindow(Msg); };
- virtual void WMClose(RTMessage Msg) = [WM_FIRST + WM_CLOSE]
- { UClose(Msg);
- TWindow::WMClose(Msg); };
- virtual void WMSize(RTMessage Msg) = [WM_FIRST + WM_SIZE]
- { USize(Msg); };
- virtual void WMDestroy(RTMessage Msg) = [WM_FIRST + WM_DESTROY]
- { UDestroy(Msg);
- TWindow::WMDestroy(Msg); };
- virtual void WMEraseBkGnd(RTMessage Msg) = [WM_FIRST + WM_ERASEBKGND]
- { UEraseBkGnd(Msg); };
- virtual void WMNCMouseMove(RTMessage Msg) = [WM_FIRST + WM_NCMOUSEMOVE]
- { UNCMouseMove(Msg); };
- virtual void WMMouseMove(RTMessage Msg) = [WM_FIRST + WM_MOUSEMOVE]
- { UMouseMove(Msg); };
- virtual void WMSetCursor(RTMessage Msg) = [WM_FIRST + WM_SETCURSOR]
- { USetCursor(Msg); };
- virtual void WMNCLButtonDown(RTMessage Msg) = [WM_FIRST + WM_NCLBUTTONDOWN]
- { UNCLButtonDown(Msg); };
- virtual void WMNCLButtonUp(RTMessage Msg) = [WM_FIRST + WM_NCLBUTTONUP]
- { UNCLButtonUp(Msg); };
- virtual void WMLButtonDown(RTMessage Msg) = [WM_FIRST + WM_LBUTTONDOWN]
- { if(ULButtonDown(Msg)) TWindow::WMLButtonDown(Msg); };
- virtual void WMLButtonUp(RTMessage Msg) = [WM_FIRST + WM_LBUTTONUP]
- { ULButtonUp(Msg); };
- virtual void WMNCHitTest(RTMessage Msg) = [WM_FIRST + WM_NCHITTEST]
- { UNCHitTest(Msg); };
- protected:
- virtual LPSTR GetClassName();
- virtual void GetWindowClass(WNDCLASS _FAR & AWndClass);
- };
- #endif