home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / toolba.zip / ATOOLBAR.CPP < prev    next >
Text File  |  1994-09-08  |  3KB  |  101 lines

  1. /*********************************************
  2. * AToolBar.cpp - toolbar implementation file *
  3. *********************************************/
  4.  
  5. #include <igraphbt.hpp>
  6. #include <istattxt.hpp>
  7.  
  8. #define INCL_WINMESSAGEMGR
  9. #include <os2.h>
  10.  
  11. #include "atoolbar.hpp"
  12.  
  13. AToolBar::AToolBar( unsigned long windowId, IWindow *owner ) :
  14.    ISetCanvas( windowId, owner, owner, 
  15.       IRectangle(IPoint(), ISize( 1, 1 )),
  16.       ISetCanvas::defaultStyle() )
  17. {
  18.    setMargin( ISize() );
  19.    setPad( ISize() );
  20.    setAutoDeleteObject();
  21.    messageId = 0;
  22. }  /* end AToolBar::AToolBar( ... ) */
  23.  
  24. AToolBar::AToolBar( unsigned long windowId, IWindow *owner, 
  25.    const Style style ) :
  26.    ISetCanvas( windowId, owner, owner,
  27.       IRectangle(IPoint(), ISize( 1, 1 )), style )
  28. {
  29.    setMargin( ISize() );
  30.    setPad( ISize() );
  31.    setAutoDeleteObject();
  32.    messageId = 0;
  33. }  /* end AToolBar::AToolBar( ... ) */
  34.  
  35.  
  36. /* ----------------------------------
  37.    allow control parameters to be set
  38.    ---------------------------------- */
  39.  
  40. void AToolBar::setMessageId( unsigned long id )
  41. {
  42.    messageId = id;
  43. }  /* end AToolBar::setMessageId( ... ) */
  44.  
  45.  
  46. /* ---------------------------------------------------
  47.    provide for the addition of controls to the toolbar
  48.    --------------------------------------------------- */
  49.  
  50. Boolean AToolBar::addButton( unsigned long id )
  51. {
  52.    IGraphicPushButton *button;
  53.  
  54.    button = new IGraphicPushButton( id, this, this, id,
  55.       IRectangle(), IGraphicPushButton::defaultStyle() | 
  56.       IButton::noPointerFocus | IGraphicPushButton::sizeToGraphic );
  57.    button->setMinimumSize( ISize(20, 20) );
  58.    button->setAutoDeleteObject();
  59.    AMouseMoveHandler::handleEventsFor( button );
  60.    return true;
  61. }  /* end AToolBar::addButton( ... ) */
  62.  
  63. Boolean AToolBar::addButtons( unsigned long ids[], unsigned long count )
  64. {
  65.    unsigned long i;
  66.  
  67.    for( i = 0; i < count; i++ ) {
  68.       addButton( ids[i] );
  69.    } /* endfor */
  70.    return true;
  71. }
  72.  
  73. Boolean AToolBar::addSpace( unsigned long size )
  74. {
  75.    IStaticText *staticText;
  76.  
  77.    staticText = new IStaticText( TOOLBAR_TEXT, this, this );
  78.    if ( deckOrientation() == ISetCanvas::horizontal ) {
  79.       staticText->setMinimumSize( ISize(size, 20) );
  80.    } else {
  81.       staticText->setMinimumSize( ISize(20, size) );
  82.    } /* endif */
  83.    staticText->setAutoDeleteObject();
  84.    return true;
  85. }  /* end AToolBar::addSpace( ... ) */
  86.  
  87.  
  88. /* -------------------------------------------------------------------
  89.    capture mouse movement messages in order to send microhelp requests
  90.    ------------------------------------------------------------------- */
  91.  
  92. Boolean AToolBar::motion( IEvent &evt )
  93. {
  94.    if ( messageId > 0 ) {
  95.       owner()->postEvent( WM_USER + messageId, 
  96.          evt.window()->id(), (unsigned long)evt.window() );
  97.    } /* endif */
  98.    return false;  /* allow standard processing */
  99. }  /* end AToolBar::motion( ... ) */
  100.  
  101.