home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / oclsrc15.zip / OCL / Include / OButtonBar.hpp < prev    next >
C/C++ Source or Header  |  1996-08-12  |  6KB  |  187 lines

  1. // OCL - OS/2 Class Library
  2. // (c) Cubus 1995
  3. // All Rights Reserved
  4. // OButtonBar.hpp
  5.  
  6.  
  7. /*
  8.  * Redistribution and use in source and binary forms, with or without
  9.  * modification, are permitted provided that the following conditions
  10.  * are met:
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  * 2. Neither the name Cubus nor the name Team OCL may be used to
  14.  *    endorse or promote products derived from this software
  15.  *    without specific prior written permission.
  16.  * 3. See OCL.INF for a detailed copyright notice.
  17.  *
  18.  *              THIS SOFTWARE IS PROVIDED ``AS IS'' AND
  19.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  22.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  24.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  25.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  26.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  27.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28.  * SUCH DAMAGE.
  29.  */
  30.  
  31.  
  32. // $Header: W:/Projects/OCL/INCLUDE/rcs/OButtonBar.hpp 1.1 1996/08/12 00:01:11 B.STEIN Release $
  33.  
  34. #ifndef OBUTTONBAR_INCLUDED
  35.   #define OBUTTONBAR_INCLUDED
  36.  
  37.  
  38. #ifndef OGRBTN_INCLUDED
  39.   #include <OGraphicsButton.hpp>
  40. #endif
  41.  
  42. #ifndef OFBTN_INCLUDED
  43.   #include <OFillButton.hpp>
  44. #endif
  45.  
  46. #ifndef OHPOPUP_INCLUDED
  47.   #include <OHelpPopup.hpp>
  48. #endif
  49.  
  50. /* 
  51.   The OButtonBar sends a WM_CONTROL-Message to the parent window
  52.   if the mouse pointer is moved over one of the buttons
  53.   this message looks like
  54.    
  55.   WinSendMsg(parent, WM_CONTROL,
  56.              MPFROM2SHORT(OBUTTONBAR_MOVEOVER, buttonID), MPARAM(helptext));
  57.  
  58.   Process this message if you want to display the helptext somewhere.
  59.   When buttonID is set to 0 the mouse pointer has left the toolbar client area.
  60. */
  61.  
  62. /*
  63.   The OButtonBar sends a WM_CONTROL-Message to the parent window
  64.   if a mouse button is depressed on one of the buttons
  65.   this message looks like
  66.  
  67.   WinSendMsg(parent, WM_CONTROL,
  68.              MPFROM2SHORT(OBUTTONBAR_BUTTONxDOWN, buttonID), NULL);
  69.  
  70.   x means the depressed button. Process this message if you want to poupup a menu for example.
  71. */
  72.  
  73.  
  74. #define OBUTTONBAR_BUTTON1DOWN  WM_BUTTON1DOWN
  75. #define OBUTTONBAR_BUTTON2DOWN  WM_BUTTON2DOWN
  76. #define OBUTTONBAR_BUTTON3DOWN  WM_BUTTON3DOWN
  77.  
  78.  
  79. typedef class OButtonBar *pOButtonBar;
  80.  
  81.  
  82. typedef OList<OGraphicsButton> buttonList;
  83. typedef buttonList *pbuttonList;
  84.  
  85.  
  86. class __CPP_EXPORT__ OButtonBar
  87.   : public OFrame
  88. {
  89.  protected:
  90.     BOOL                  bubbleHelper;
  91.     OFillButton           fillBTN;
  92.  
  93.     class _enable : public OIterator<OGraphicsButton>
  94.     {
  95.      public: void applyToElement (OGraphicsButton* elem);
  96.     };
  97.  
  98.     class _disable : public OIterator<OGraphicsButton>
  99.     {
  100.      public: void applyToElement (OGraphicsButton* elem);
  101.     };
  102.  
  103.     class _destroy : public OIterator<OGraphicsButton>
  104.     {
  105.      public: void applyToElement (OGraphicsButton* elem);
  106.     };
  107.  
  108.     OButtonBar&
  109.       initButtonBarDefaults ();
  110.  
  111.  private:
  112.     ULONG                    orientation,
  113.                              bHeight,
  114.                              bWidth,
  115.                              picSize,
  116.                              drawStyle,
  117.                              currentButton;
  118.  
  119.     _enable                  btn_enable;
  120.     _disable                 btn_disable;
  121.     _destroy                 btn_destroy;
  122.     
  123.  public:
  124.     OHelpPopup               bubbleHelpWin;
  125.     buttonList               buttons; // linked list of buttoninfo
  126.  
  127.  
  128.     enum
  129.       {
  130.        up2down = 1,       // default
  131.        left2right, 
  132.        fillButton         // paint button imitation into the free space
  133.       };
  134.  
  135.  
  136.     OButtonBar               (const ULONG id,
  137.                               const HWND  parentWindow, 
  138.                               const BOOL  bubbleHelp   = TRUE);
  139.  
  140.     OButtonBar               (const ULONG   id,
  141.                               const OFrame& parentWindow, 
  142.                               const BOOL    bubbleHelp = TRUE);
  143.  
  144.     OButtonBar               (const ULONG   id,
  145.                               const pOFrame parentWindow, 
  146.                               const BOOL    bubbleHelp = TRUE);
  147.  
  148.     virtual
  149.        ~OButtonBar           ();
  150.  
  151.     virtual
  152.        PSZ isOfType          () const;
  153.  
  154.     OButtonBar
  155.        &createButtonBar      (),
  156.  
  157.        &setButtonDimensions  (const ULONG height = 32,
  158.                               const ULONG width  = 32),
  159.        &setOrientation       (const ULONG type),
  160.        &setPicSize           (const ULONG length),
  161.        &setDrawStyle         (const ULONG Style), 
  162.  
  163.        &setupButtons         (),
  164.        &destroyButtons       (),
  165.        &enableButtons        (),
  166.        &disableButtons       ();
  167.  
  168.     PSZ
  169.        requestHelpText       (const ULONG id, 
  170.                               const BOOL isHandle),
  171.        requestHelpText       ();
  172.  
  173.     inline ULONG
  174.        getHeight             () const { return(bHeight); }
  175.  
  176.     inline ULONG
  177.        getWidth              () const { return(bWidth);  }
  178.  
  179.     virtual
  180.        BOOL OCommand         (ULONG msg, MPARAM mp1, MPARAM mp2);
  181. };
  182.  
  183.  
  184. #endif // OBUTTONBAR_INCLUDED
  185.  
  186. // end of source
  187.