child_frame.hpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:7k
源码类别:

生物技术

开发平台:

C/C++

  1. /*
  2.  * ===========================================================================
  3.  * PRODUCTION $Log: child_frame.hpp,v $
  4.  * PRODUCTION Revision 1000.0  2003/10/31 22:36:59  gouriano
  5.  * PRODUCTION PRODUCTION: IMPORTED [ORIGINAL] Dev-tree R1.5
  6.  * PRODUCTION
  7.  * ===========================================================================
  8.  */
  9. #ifndef GUI_WIDGETS_TOPLEVEL___CHILD_FRAME__HPP
  10. #define GUI_WIDGETS_TOPLEVEL___CHILD_FRAME__HPP
  11. /*  $Id: child_frame.hpp,v 1000.0 2003/10/31 22:36:59 gouriano Exp $
  12.  * ===========================================================================
  13.  *
  14.  *                            PUBLIC DOMAIN NOTICE
  15.  *               National Center for Biotechnology Information
  16.  *
  17.  *  This software/database is a "United States Government Work" under the
  18.  *  terms of the United States Copyright Act.  It was written as part of
  19.  *  the author's official duties as a United States Government employee and
  20.  *  thus cannot be copyrighted.  This software/database is freely available
  21.  *  to the public for use. The National Library of Medicine and the U.S.
  22.  *  Government have not placed any restriction on its use or reproduction.
  23.  *
  24.  *  Although all reasonable efforts have been taken to ensure the accuracy
  25.  *  and reliability of the software and data, the NLM and the U.S.
  26.  *  Government do not and cannot warrant the performance or results that
  27.  *  may be obtained by using this software or data. The NLM and the U.S.
  28.  *  Government disclaim all warranties, express or implied, including
  29.  *  warranties of performance, merchantability or fitness for any particular
  30.  *  purpose.
  31.  *
  32.  *  Please cite the author in any work or product based on this material.
  33.  *
  34.  * ===========================================================================
  35.  *
  36.  * Authors:  Mike DiCuccio
  37.  *
  38.  * File Description:
  39.  *    CChildFrame -- internal widget class that represents the frame
  40.  *                   surrounding a given MDI child
  41.  */
  42. #include <gui/widgets/toplevel/child.hpp>
  43. #include <FL/Fl.H>
  44. #include <FL/Fl_Group.H>
  45. #include <FL/Fl_Window.H>
  46. BEGIN_NCBI_SCOPE
  47. // private internal class for managing child frames
  48. class CChildFrame : public Fl_Window
  49. {
  50.     friend class CTopLevel;
  51. public:
  52.     // enumerated list of possible child window states
  53.     enum EState {
  54.         eNormal,
  55.         eMaximized,
  56.         eMinimized,
  57.     };
  58.     CChildFrame(int x, int y, int w, int h, const char* label = NULL);
  59.     ~CChildFrame();
  60.     // get the current frame window state
  61.     EState GetState    (void) const    { return m_State; }
  62.     bool   GetMaximized(void) const    { return (m_State == eMaximized); }
  63.     bool   GetMinimized(void) const    { return (m_State == eMinimized); }
  64.     // attach / detach this frame to/from a child
  65.     void Attach(CChild* child);
  66.     void Detach(void);
  67.     // FLTK overload: event handler
  68.     int handle(int event);
  69.     // FLTK overload: label
  70.     void label(const char* text);
  71.     const char* label(void) const;
  72.     // accessors
  73.     Fl_Group*   GetSysButtons(void)     { return m_SysButtons; }
  74.     Fl_Group*   GetTitle     (void)     { return m_Title; }
  75.     Fl_Group*   GetTitleBar  (void)     { return m_TitleBar; }
  76.     // static accessors
  77.     static Fl_Color     GetSelectedColor (void);
  78.     static Fl_Boxtype   GetSysButtonBox  (void);
  79.     static Fl_Color     GetSysButtonColor(void);
  80.     static int          GetTitleAlign    (void);
  81.     static int          GetTitleBarHeight(void);
  82.     static Fl_Color     GetTitleColor    (void);
  83.     static Fl_Font      GetTitleFont     (void);
  84.     static int          GetTitleSize     (void);
  85.     static void         SetSelectedColor (Fl_Color color);
  86.     static void         SetSysButtonBox  (Fl_Boxtype box);
  87.     static void         SetSysButtonColor(Fl_Color color);
  88.     static void         SetTitleAlign    (int align);
  89.     static void         SetTitleBarHeight(int h);
  90.     static void         SetTitleColor    (Fl_Color color);
  91.     static void         SetTitleFont     (Fl_Font font);
  92.     static void         SetTitleSize     (int h);
  93. private:
  94.     // group for the title bar
  95.     Fl_Group* m_TitleBar;
  96.     // group for the title itself
  97.     Fl_Group* m_Title;
  98.     // group for the system buttons
  99.     Fl_Group* m_SysButtons;
  100.     // the child we wrap
  101.     CChild*   m_Child;
  102.     // state for this frame
  103.     EState    m_State;
  104.     // saved position of the window, for restore from minimization /
  105.     // maximization
  106.     int m_SavedPos[4];
  107.     // enumerated values of our current mouse state
  108.     // this controls how we interact with the child frame
  109.     enum EDragState {
  110.         eIdle,
  111.         eMoving,
  112.         eResizing,
  113.     };
  114.     // flags that determine which edges of the window we're dragging
  115.     enum FBorderDrag {
  116.         fLeftBorderDrag   = 0x01,
  117.         fRightBorderDrag  = 0x02,
  118.         fTopBorderDrag    = 0x04,
  119.         fBottomBorderDrag = 0x08,
  120.     };
  121.     typedef int TBorderDrag;    // bitmask of FBorderDrag
  122.     // the state of our mouse-window interaction
  123.     EDragState  m_DragState;
  124.     // flags that determine which edges of the window we're dragging
  125.     TBorderDrag m_BorderDrag;
  126.     // stored offsets of our window size for delayed drag / move
  127.     // this is used to draw an overlay box
  128.     int         m_DragSize[4];
  129.     // last mouse position of our event
  130.     pair<int, int> m_LastMousePos;
  131.     // statics for global look-and-feel
  132.     static Fl_Boxtype   sm_SysButtonBox;
  133.     static Fl_Color     sm_SysButtonColor;
  134.     static Fl_Color     sm_SelectedColor;
  135.     static Fl_Color     sm_UnselectedColor;
  136.     static Fl_Font      sm_TitleFont;
  137.     static int          sm_TitleSize;
  138.     static int          sm_TitleAlign;
  139.     static Fl_Color     sm_TitleColor;
  140.     static int          sm_TitleBarHeight;
  141. };
  142. END_NCBI_SCOPE
  143. /*
  144.  * ===========================================================================
  145.  * $Log: child_frame.hpp,v $
  146.  * Revision 1000.0  2003/10/31 22:36:59  gouriano
  147.  * PRODUCTION: IMPORTED [ORIGINAL] Dev-tree R1.5
  148.  *
  149.  * Revision 1.5  2003/09/29 15:52:06  dicuccio
  150.  * Deprecated gui/scope.hpp.  Merged gui/core/types.hpp into gui/types.hpp
  151.  *
  152.  * Revision 1.4  2003/03/17 14:55:41  dicuccio
  153.  * Lots of clean-up.  Fixed memory leaks in test program; added more explicit
  154.  * destruction pathway to support integration into Genome Workbench.  Added
  155.  * explicit calls to cascade / tile widgets in a toplevel workspace.
  156.  *
  157.  * Revision 1.3  2003/03/07 18:14:58  dicuccio
  158.  * Code clean-up.  Added missing accessors for look-n-feel statics; aligned
  159.  * accessors in code
  160.  *
  161.  * Revision 1.2  2003/03/07 17:49:25  dicuccio
  162.  * Small clean-ups.  Added description for each class.
  163.  *
  164.  * Revision 1.1  2003/03/07 17:36:08  dicuccio
  165.  * Initial revision
  166.  *
  167.  * ===========================================================================
  168.  */
  169. #endif  // GUI_WIDGETS_TOPLEVEL___CHILD_FRAME__HPP