home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lstbx3.zip / xlisthdr.cpp < prev    next >
Text File  |  1994-08-12  |  10KB  |  233 lines

  1. /*******************************************************************************
  2. * FILE NAME: xlisthdr.cpp                                                      *
  3. *                                                                              *
  4. * DESCRIPTION:                                                                 *
  5. *   This file contains the implementation of classes/functions declared        *
  6. *   in xlisthdr.hpp.                                                           *
  7. *                                                                              *
  8. *******************************************************************************/
  9. extern "C"
  10. {
  11.   #define INCL_WINLISTBOXES
  12.   #define INCL_WINWINDOWMGR
  13.   #include <os2.h>
  14.   #include "listbox.h"
  15. }
  16.  
  17. #ifndef _IWINDOW_
  18.   #include <iwindow.hpp>
  19. #endif
  20. #ifndef _ISTRING_
  21.   #include <istring.hpp>
  22. #endif
  23. #ifndef _IEXCEPT_
  24.   #include <iexcept.hpp>
  25. #endif
  26.  
  27. #ifndef _XLISTHDR_
  28.   #include "xlisthdr.hpp"
  29. #endif
  30. #ifndef _XLISTBOX_
  31.   #include "xlistbox.hpp"
  32. #endif
  33.  
  34.  
  35. /*------------------------------------------------------------------------------
  36. | ListBox32Handler::ListBox32Handler                                           |
  37. |                                                                              |
  38. | Construct from a pointer to a ListBox32 object.  This ctor will attach the   |
  39. | handler to the object if the object is provided.                             |
  40. ------------------------------------------------------------------------------*/
  41. ListBox32Handler::ListBox32Handler( ListBox32 *pLB ) : IHandler( )
  42. {
  43.   if (pLB)
  44.     handleEventsFor( pLB );
  45. }
  46.  
  47. /*------------------------------------------------------------------------------
  48. | ListBox32Handler::~ListBox32Handler                                          |
  49. |                                                                              |
  50. | Default destructor                                                           |
  51. ------------------------------------------------------------------------------*/
  52. ListBox32Handler::~ListBox32Handler()
  53. {
  54. }
  55.  
  56. /*------------------------------------------------------------------------------
  57. | ListBox32Handler::handleEventsFor                                            |
  58. |                                                                              |
  59. | Attaches this handler to the ListBox32 object.                               |
  60. ------------------------------------------------------------------------------*/
  61. ListBox32Handler& ListBox32Handler::handleEventsFor( ListBox32 *pLB )
  62. {
  63.   Inherited::handleEventsFor( pLB );
  64.   return( *this );
  65. };
  66.  
  67. /*------------------------------------------------------------------------------
  68. | ListBox32Handler::dispatchHandlerEvent                                       |
  69. |                                                                              |
  70. | Process control events destined for our "ListBoxWindow" window class.        |
  71. | True is returned if event was processed.  Otherwise, false is returned       |
  72. | to give the next handler in the chain (if any) an opportunity to process.    |
  73. | If no handlers process the event, then default PM processing will occur.     |
  74. ------------------------------------------------------------------------------*/
  75. Boolean ListBox32Handler::dispatchHandlerEvent( IEvent &evt )
  76. {
  77.   Boolean bRC = false;
  78.  
  79.   /***************************************************************/
  80.   /* Only process control events ....                            */
  81.   /***************************************************************/
  82.   if (evt.eventId() == WM_CONTROL)
  83.   {
  84.     IControlEvent ctlevt(evt);
  85.     unsigned long ulMsg = ctlevt.parameter1().number2();
  86.     IWindow* pwndControl = ctlevt.controlWindow();
  87.  
  88.     /*************************************************************/
  89.     /* This handler is either attached to the control generating */
  90.     /* the WM_CONTROL message or to its owner.  If               */
  91.     /* IControlEvent::controlWindow returns 0, this must mean we */
  92.     /* have a non-wrappered control with a wrappered owner       */
  93.     /* window and that the handler is attached to the owner      */
  94.     /* window.  This case is supported only if the owner of the  */
  95.     /* control is also the control's parent (this is in order    */
  96.     /* for handleWithId to work).                                */
  97.     /*************************************************************/
  98.     IWindowHandle hwndControl;
  99.     if (pwndControl)
  100.     {
  101.        hwndControl = pwndControl->handle();
  102.     }
  103.     else
  104.     {
  105.        hwndControl = IWindow::handleWithId( ctlevt.controlId(),
  106.                                             ctlevt.handle() );
  107.     }
  108.  
  109.     if (hwndControl)
  110.     {
  111.       IString className = IString( 0, 16 );
  112.       WinQueryClassName( hwndControl, className.length()+1, className );
  113.  
  114.       /***********************************************************/
  115.       /* ... for the 32-Bit list box.                            */
  116.       /***********************************************************/
  117.       if (className == "ListBoxWindow")
  118.       {
  119.         if (ulMsg == LN_SELECT)
  120.         {
  121.           bRC = selected( ctlevt );
  122.         }
  123.         else if (ulMsg == LN_ENTER)
  124.         {
  125.           bRC = enter( ctlevt );
  126.         }
  127.         else if (ulMsg == LN_SETFOCUS)
  128.         {
  129.           bRC = gotFocus( ctlevt );
  130.         }
  131.         else if (ulMsg == LN_KILLFOCUS)
  132.         {
  133.           bRC = lostFocus( ctlevt );
  134.         }
  135.         else if (ulMsg == LN_SCROLL)
  136.         {
  137.           bRC = scroll( ctlevt );
  138.         }
  139.         else if (ulMsg == LNX_CHECKED)
  140.         {
  141.           bRC = checked( ctlevt );
  142.         }
  143.       }
  144.  
  145.       /***********************************************************/
  146.       /* Processing complete ... Set result if event was         */
  147.       /* processed.                                              */
  148.       /***********************************************************/
  149.       if (bRC)
  150.          evt.setResult(ctlevt.result());
  151.     }
  152.   } /* endif WM_CONTROL */
  153.  
  154.   return( bRC );
  155. }
  156.  
  157. /*------------------------------------------------------------------------------
  158. | ListBox32Handler::enter                                                      |
  159. |                                                                              |
  160. | Dummy virtual handler function.  Derived classes override to process the     |
  161. | enter event.                                                                 |
  162. ------------------------------------------------------------------------------*/
  163. Boolean ListBox32Handler::enter ( const ListBox32Event &evt )
  164. {
  165.   return( false );
  166. }
  167.  
  168. /*------------------------------------------------------------------------------
  169. | ListBox32Handler::selected                                                   |
  170. |                                                                              |
  171. | Dummy virtual handler function.  Derived classes override to process the     |
  172. | selection event.                                                             |
  173. ------------------------------------------------------------------------------*/
  174. Boolean ListBox32Handler::selected ( const ListBox32Event &evt )
  175. {
  176.   return( false );
  177. }
  178.  
  179. /*------------------------------------------------------------------------------
  180. | ListBox32Handler::gotFocus                                                   |
  181. |                                                                              |
  182. | Dummy virtual handler function.  Derived classes override to process the     |
  183. | focus gain event.                                                            |
  184. ------------------------------------------------------------------------------*/
  185. Boolean ListBox32Handler::gotFocus ( const ListBox32Event &evt )
  186. {
  187.   return( false );
  188. }
  189.  
  190. /*------------------------------------------------------------------------------
  191. | ListBox32Handler::lostFocus                                                  |
  192. |                                                                              |
  193. | Dummy virtual handler function.  Derived classes override to process the     |
  194. | focus loss event.                                                            |
  195. ------------------------------------------------------------------------------*/
  196. Boolean ListBox32Handler::lostFocus ( const ListBox32Event &evt )
  197. {
  198.   return( false );
  199. }
  200.  
  201. /*------------------------------------------------------------------------------
  202. | ListBox32Handler::scroll                                                     |
  203. |                                                                              |
  204. | Dummy virtual handler function.  Derived classes override to process the     |
  205. | scroll event.                                                               |
  206. ------------------------------------------------------------------------------*/
  207. Boolean ListBox32Handler::scroll ( const ListBox32Event &evt )
  208. {
  209.   return( false );
  210. }
  211.  
  212. /*------------------------------------------------------------------------------
  213. | ListBox32Handler::checked                                                    |
  214. |                                                                              |
  215. | Dummy virtual handler function.  Derived classes override to process the     |
  216. | checked event.                                                               |
  217. ------------------------------------------------------------------------------*/
  218. Boolean ListBox32Handler::checked ( const ListBox32Event &evt )
  219. {
  220.   return( false );
  221. }
  222.  
  223. /*------------------------------------------------------------------------------
  224. | ListBox32Handler::handleEventsFor                                (private)   |
  225. |                                                                              |
  226. | Defined to prevent accidental usage.  Function defined to accept ListBox32 * |
  227. | is the handleEventsFor that only should be used.                             |
  228. ------------------------------------------------------------------------------*/
  229. ListBox32Handler& ListBox32Handler::handleEventsFor( IWindow * )
  230. {
  231.   return( *this );
  232. };
  233.