home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 3.ddi / OWLINC.ZIP / WINDOBJ.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  8.1 KB  |  255 lines

  1. // ObjectWindows - (C) Copyright 1992 by Borland International
  2.  
  3. #ifndef __WINDOBJ_H
  4. #define __WINDOBJ_H
  5.  
  6. #ifndef __WINDOWS_H
  7. #undef NULL
  8. #include <windows.h>
  9. #endif
  10.  
  11. #ifndef __OBJECT_H
  12. #include <object.h>
  13. #endif
  14.  
  15. #ifndef __APPLICAT_H
  16. #include <applicat.h>
  17. #endif
  18.  
  19. #ifndef __OWLDEFS_H
  20. #include <owldefs.h>
  21. #endif
  22.  
  23. #ifndef __OBJSTRM_H
  24. #include <objstrm.h>
  25. #endif
  26.  
  27. #pragma option -Vo-
  28. #if     defined(__BCOPT__) && !defined(_ALLOW_po)
  29. #pragma option -po-
  30. #endif
  31.  
  32. //  windows 3.1 name confict with TWindowsObject::GetFirstChild()
  33. #if defined(GetFirstChild)
  34. #undef GetFirstChild(hwnd)
  35. #endif
  36.  
  37. struct TMessage {
  38.   HWND Receiver;
  39.   WORD Message;
  40.   union {
  41.     WORD WParam;
  42.         struct tagWP {
  43.           BYTE Lo;
  44.           BYTE Hi;
  45.         } WP;
  46.   };
  47.   union {
  48.         DWORD LParam;
  49.         struct tagLP {
  50.           WORD Lo;
  51.           WORD Hi;
  52.         } LP;
  53.   };
  54.   long Result;
  55. };
  56.  
  57. _CLASSDEF(TMDIClient)
  58. _CLASSDEF(TApplication)
  59. _CLASSDEF(TModule)
  60. _CLASSDEF(TWindowsObject)
  61.  
  62.  
  63. typedef TMessage _FAR &RTMessage;
  64.  
  65. typedef void ( _FAR *TActionFunc )(Pvoid Child, Pvoid ParamList);
  66. typedef BOOL ( _FAR *TCondFunc )(Pvoid Child, Pvoid ParamList);
  67.  
  68. /* TWindowsObject */
  69. class _EXPORT TWindowsObject : public Object, public TStreamable
  70. {
  71. public:
  72.     int Status;
  73.     HWND HWindow;    // handle to associated MS-Windows window
  74.     LPSTR Title;
  75.     PTWindowsObject Parent;
  76.  
  77.     TWindowsObject(PTWindowsObject AParent, PTModule AModule = NULL);
  78.     virtual ~TWindowsObject();
  79.     void SetFlags(WORD Mask, BOOL OnOff);
  80.  
  81.     /* Determines whether the flag whose mask is passed has been set,
  82.        returning a BOOL indicator --  True = On, False = Off. */
  83.     BOOL IsFlagSet(WORD Mask)
  84.         { return( (Flags & Mask) == Mask); }
  85.  
  86.     PTWindowsObject FirstThat(TCondFunc Test, Pvoid PParamList);
  87.     void ForEach(TActionFunc Action, Pvoid PParamList);
  88.     PTWindowsObject FirstThat(
  89.         BOOL (TWindowsObject::* _FAR Test)(Pvoid, Pvoid), Pvoid PParamList);
  90.     void ForEach(
  91.         void (TWindowsObject::* _FAR Action)(Pvoid, Pvoid), Pvoid PParamList);
  92.  
  93.     PTWindowsObject Next();
  94.     PTWindowsObject GetFirstChild()
  95.         { return ChildList->SiblingList; }
  96.     PTWindowsObject GetLastChild()
  97.         { return ChildList; }
  98.     PTWindowsObject Previous();
  99.     void EnableKBHandler();
  100.     void EnableAutoCreate();
  101.     void DisableAutoCreate();
  102.     void EnableTransfer();
  103.     void DisableTransfer();
  104.  
  105.     PTModule GetModule()
  106.         { return Module; }
  107.     PTApplication GetApplication()
  108.         { return Application; }
  109.     WNDPROC GetInstance()
  110.         { return Instance; }
  111.     virtual BOOL Register();
  112.  
  113. /* Pure virtual function, placeholder for derived classes to redefine to
  114.    create an MS_Windows element to be associated with an OWL window
  115.    object */
  116.     virtual BOOL Create() = 0;
  117.  
  118.     virtual void Destroy();
  119.  
  120.     virtual int GetId();
  121.     PTWindowsObject ChildWithId(int Id);
  122.     virtual PTMDIClient GetClient();
  123.     virtual void SetParent(PTWindowsObject NewParent);
  124.     void Show(int ShowCmd);
  125.     void SetCaption(LPSTR ATitle);
  126.     virtual BOOL CanClose();
  127.     void SetTransferBuffer(Pvoid ATransferBuffer)
  128.         { TransferBuffer = ATransferBuffer; }
  129.     virtual WORD Transfer(Pvoid DataPtr, WORD TransferFlag);
  130.     virtual void TransferData(WORD Direction);
  131.     virtual void DefWndProc(RTMessage Msg);
  132.     virtual void BeforeDispatchHandler() {}
  133.     virtual void AfterDispatchHandler() {}
  134.     virtual void DispatchAMessage(WORD AMsg, RTMessage AMessage,
  135.         void (TWindowsObject::* _FAR)(RTMessage ));
  136.     void CloseWindow();
  137.     void GetChildren(Ripstream is);
  138.     void PutChildren(Ropstream os);
  139.     BOOL CreateChildren();
  140.     virtual void ShutDownWindow();
  141.     virtual void DrawItem(DRAWITEMSTRUCT far & DrawInfo);
  142.     virtual void ActivationResponse(WORD Activated, BOOL IsIconified);
  143.  
  144.     // define pure virtual functions derived from Object class
  145.     virtual classType      isA() const = 0;
  146.     virtual Pchar nameOf() const = 0;
  147.     virtual hashValueType  hashValue() const
  148.         { return hashValueType(HWindow); }
  149.     virtual int              isEqual(RCObject testwin)  const
  150.         { return this ==  &(RTWindowsObject)testwin; }
  151.     virtual void             printOn(Rostream outputStream) const
  152.     { outputStream << nameOf() << "{ HWindow = "
  153.          << (void _FAR *)HWindow << " }\n"; }
  154.  
  155.     static PTStreamable build();
  156.  
  157. protected:
  158.  
  159.     WNDPROC DefaultProc;
  160.     Pvoid TransferBuffer;
  161.     virtual void GetWindowClass(WNDCLASS _FAR & AWndClass);
  162.     virtual LPSTR GetClassName() = 0;
  163.     void RemoveClient()
  164.         { RemoveChild((PTWindowsObject)GetClient()); }
  165.     void GetChildPtr(Ripstream is, RPTWindowsObject P);
  166.     void PutChildPtr(Ropstream os, PTWindowsObject P);
  167.     void GetSiblingPtr(Ripstream is, RPTWindowsObject P);
  168.     void PutSiblingPtr(Ropstream os, PTWindowsObject P);
  169.     virtual void DefCommandProc(RTMessage Msg);
  170.     virtual void DefChildProc(RTMessage Msg);
  171.     virtual void DefNotificationProc(RTMessage Msg);
  172.     virtual void SetupWindow();
  173.     virtual void WMVScroll(RTMessage Msg) =
  174.                  [WM_FIRST + WM_VSCROLL];
  175.     virtual void WMHScroll(RTMessage Msg) =
  176.                  [WM_FIRST + WM_HSCROLL];
  177.     void DispatchScroll(RTMessage Msg);
  178.     virtual void WMCommand(RTMessage Msg) =
  179.                  [WM_FIRST + WM_COMMAND];
  180.     virtual void WMDrawItem(RTMessage Msg) =
  181.                  [WM_FIRST + WM_DRAWITEM];
  182.     virtual void WMClose(RTMessage Msg) =
  183.                  [WM_FIRST + WM_CLOSE];
  184.     virtual void WMDestroy(RTMessage Msg) =
  185.                  [WM_FIRST + WM_DESTROY];
  186.     virtual void WMNCDestroy(RTMessage Msg) =
  187.                  [WM_FIRST + WM_NCDESTROY];
  188.     virtual void WMActivate(RTMessage Msg) =
  189.                  [WM_FIRST + WM_ACTIVATE];
  190.     virtual void WMQueryEndSession(RTMessage Msg) =
  191.                  [WM_FIRST + WM_QUERYENDSESSION];
  192.     virtual void CMExit(RTMessage Msg) =
  193.                  [CM_FIRST + CM_EXIT];
  194.  
  195.     TWindowsObject(StreamableInit) {};
  196.     virtual void write (Ropstream os);
  197.     virtual Pvoid read (Ripstream is);
  198.  
  199. private:
  200.  
  201.     WNDPROC Instance;
  202.     PTApplication Application;
  203.     PTModule Module;
  204.     WORD Flags;
  205.     WORD CreateOrder;
  206.     BOOL OrderIsI(Pvoid P, Pvoid I);
  207.     BOOL CreateZeroChild(Pvoid P, Pvoid I);
  208.     void AssignCreateOrder();
  209.     PTWindowsObject ChildList, SiblingList;
  210.     void AddChild(PTWindowsObject AChild);
  211.     void RemoveChild(PTWindowsObject AChild);
  212.     int IndexOf(PTWindowsObject P);
  213.     PTWindowsObject At(int APosition);
  214.  
  215.     virtual const Pchar streamableName() const
  216.         { return "TWindowsObject"; }
  217.  
  218. };    // end of WindowsObject class
  219.  
  220. /* Returns the Id of the TWindowsObject, used to identify the window
  221.    in a specified parent's ChildList.  Redefined by TControl
  222.    descendants to return their identifier from their attributes
  223.    structure.  0 is returned here as the default identifier. This
  224.    precludes any window with a 0 Id from being easily found. If you
  225.    need to address individual windows, redefine GetId to return
  226.    something other than 0.*/
  227. inline int TWindowsObject::GetId()
  228.         { return 0; }
  229.  
  230. /* Returns a pointer to the TWindowsObject's next sibling (the next
  231.    window in its parent's child window list.  If this was the last child
  232.    added to the list, returns a pointer to the first child added.*/
  233. inline PTWindowsObject TWindowsObject::Next()
  234.         { return SiblingList; }
  235.  
  236. typedef void ( TWindowsObject::* _FAR TActionMemFunc )(Pvoid Child, Pvoid ParamList);
  237. typedef BOOL ( TWindowsObject::* _FAR TCondMemFunc )(Pvoid Child, Pvoid ParamList);
  238.  
  239. inline Ripstream operator >> ( Ripstream is, RTWindowsObject cl )
  240.     { return is >> (RTStreamable)cl; }
  241. inline Ripstream operator >> ( Ripstream is, RPTWindowsObject cl )
  242.     { return is >> (RPvoid)cl; }
  243.  
  244. inline Ropstream operator << ( Ropstream os, RTWindowsObject cl )
  245.     { return os << (RTStreamable )cl; }
  246. inline Ropstream operator << ( Ropstream os, PTWindowsObject cl )
  247.     { return os << (PTStreamable )cl; }
  248.  
  249. #pragma option -Vo.
  250. #if     defined(__BCOPT__) && !defined(_ALLOW_po)
  251. #pragma option -po.
  252. #endif
  253.  
  254. #endif  // ifndef _WINDOBJ_H
  255.