home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / OWLINC.PAK / FRAMEWIN.H < prev    next >
C/C++ Source or Header  |  1995-08-29  |  5KB  |  169 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // (C) Copyright 1992, 1994 by Borland International, All Rights Reserved
  4. //
  5. //   Declaration of class TFrameWindow.
  6. //----------------------------------------------------------------------------
  7. #if !defined(OWL_FRAMEWIN_H)
  8. #define OWL_FRAMEWIN_H
  9.  
  10. #if !defined(OWL_WINDOW_H)
  11. # include <owl/window.h>
  12. #endif
  13. #if !defined(OWL_MENU_H)
  14. # include <owl/menu.h>
  15. #endif
  16.  
  17. // MDI window IDs
  18. //
  19. const int IDW_MDICLIENT     = 32000;  // ID of MDI client window 
  20. const int IDW_FIRSTMDICHILD = 32001;  // child window IDs, 32 max to 32032
  21.  
  22. //
  23. //  class TMenuItemEnabler
  24. //  ----- ----------------
  25. //
  26. // command enabler for menu items
  27. //
  28. class _OWLCLASS TMenuItemEnabler : public TCommandEnabler {
  29.   public:
  30.     TMenuItemEnabler(HMENU hMenu, uint id, HWND hWndReceiver, int position)
  31.     : TCommandEnabler(id, hWndReceiver)
  32.     {
  33.       HMenu = hMenu;
  34.       Position = position;
  35.       if (::GetMenuItemID(HMenu, Position) == uint(-1))
  36.         Handled = NonSender;
  37.     }
  38.  
  39.     // Override member functions of TCommandEnabler
  40.     //
  41.     void  Enable(bool);
  42.     void  SetText(const char far*);
  43.     void  SetCheck(int);
  44.  
  45.     // Menu specific menber functions
  46.     //
  47.     HMENU GetMenu() {return HMenu;}
  48.     int   GetPosition() {return Position;}
  49.  
  50.   protected:
  51.     HMENU  HMenu;
  52.     int    Position;
  53. };
  54.  
  55.  
  56. //
  57. //  class TFrameWindow
  58. //  ----- ------------
  59. //
  60. //  adds the notion of a client window, keyboard navigation, and special
  61. //  processing for commands (see member function EvCommand)
  62. //
  63. class _OWLCLASS TFrameWindow : virtual public TWindow {
  64.   public:
  65.     bool         KeyboardHandling;
  66.  
  67.     TFrameWindow(TWindow*        parent,
  68.                  const char far* title = 0,
  69.                  TWindow*        clientWnd = 0,
  70.                  bool            shrinkToClient = false,
  71.                  TModule*        module = 0);
  72.  
  73.     TFrameWindow(HWND hWnd, TModule* module = 0);
  74.    ~TFrameWindow();
  75.  
  76.     //
  77.     // Menubar manipulating functions
  78.     //
  79.     virtual bool      AssignMenu(TResId menuResId);
  80.     virtual bool      SetMenu(HMENU newMenu);
  81.     void              SetMenuDescr(const TMenuDescr& menuDescr);
  82.     const TMenuDescr* GetMenuDescr() const {return MenuDescr;}
  83.     bool              MergeMenu(const TMenuDescr& childMenuDescr);
  84.     bool              RestoreMenu();
  85.  
  86.     bool              SetIcon(TModule* iconModule, TResId iconResId);
  87.  
  88.     virtual TWindow*  GetClientWindow();
  89.     virtual TWindow*  SetClientWindow(TWindow* clientWnd);
  90.     void              RemoveChild(TWindow* child);
  91.     virtual HWND      GetCommandTarget();
  92.  
  93.     //
  94.     // sets flag indicating that the receiver has requested "keyboard
  95.     // handling" (translation of keyboard input into control selections)
  96.     //
  97.     void              EnableKBHandler() {KeyboardHandling = true;}
  98.  
  99.     //
  100.     // override virtual functions defined by TWindow
  101.     //
  102.     bool              PreProcessMsg(MSG& msg);
  103.     bool              IdleAction(long idleCount);
  104.     bool              HoldFocusHWnd(HWND hWndLose, HWND hWndGain);
  105.     bool              SetDocTitle(const char far* docname, int index);
  106.  
  107.   protected:
  108.     HWND         HWndRestoreFocus;
  109.     TWindow*     ClientWnd;
  110.     int          DocTitleIndex;
  111.     TModule*     MergeModule;
  112.  
  113.     //
  114.     // Constructor & subsequent initializer for use with virtual derivations
  115.     // Immediate derivitives must call Init() before constructions are done.
  116.     //
  117.     TFrameWindow();
  118.     void              Init(TWindow* clientWnd, bool shrinkToClient);
  119.     
  120.     //
  121.     // extra processing for commands: starts with the focus window and gives
  122.     // it and its parent windows an opportunity to handle the command
  123.     //
  124.     LRESULT           EvCommand(uint id, HWND hWndCtl, uint notifyCode);
  125.     void              EvCommandEnable(TCommandEnabler& ce);
  126.  
  127.     //
  128.     // message response functions
  129.     //
  130.     void              EvInitMenuPopup(HMENU hPopupMenu,
  131.                                       uint  index,
  132.                                       bool  sysMenu);
  133.     void              EvPaint();
  134.     bool              EvEraseBkgnd(HDC);
  135.     HANDLE            EvQueryDragIcon();
  136.     void              EvSetFocus(HWND hWndLostFocus);
  137.     void              EvSize(uint sizeType, TSize& size);
  138.     void              EvParentNotify(uint event,
  139.                                      uint childHandleOrX,
  140.                                      uint childIDOrY);
  141.     void              EvEnterIdle(uint source, HWND hWndDlg);
  142.  
  143.     //
  144.     // override virtual function defined by TWindow
  145.     //
  146.     void              SetupWindow();
  147.  
  148.   private:
  149.     TMenuDescr*  MenuDescr;
  150.     TModule*     IconModule;
  151.     TResId       IconResId;
  152.     TPoint       MinimizedPos;
  153.  
  154.     void              Init(TWindow* clientWnd);
  155.     bool              ResizeClientWindow(bool redraw = true);
  156.     TWindow*          FirstChildWithTab();
  157.  
  158.     //
  159.     // hidden to prevent accidental copying or assignment
  160.     //
  161.     TFrameWindow(const TFrameWindow&);
  162.     TFrameWindow& operator =(const TFrameWindow&);
  163.  
  164.   DECLARE_RESPONSE_TABLE(TFrameWindow);
  165.   DECLARE_STREAMABLE(_OWLCLASS, TFrameWindow, 1);
  166. };
  167.  
  168. #endif  // OWL_FRAMEWIN_H
  169.