home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 Mobile / Chip_Mobile_2001.iso / palm / business / printcar / printcar.exe / src / UI / List.cc < prev    next >
C/C++ Source or Header  |  2000-06-09  |  1KB  |  67 lines

  1. //
  2. //  $Id: List.cc,v 1.3 2000/06/08 21:14:56 sergey Exp $
  3. //
  4.  
  5. #include <Pilot.h>
  6. #include <KeyMgr.h>
  7. #include "List.h"
  8. #include "Form.h"
  9.  
  10.  
  11. namespace UI
  12. {
  13.     List::List(Form& parent, Word listID):
  14.         ConcreteFormObject<ListPtr, frmListObj>(parent, listID)
  15.     {}
  16.  
  17.     List::~List()
  18.     {}
  19.  
  20.     // operations
  21.  
  22.     void List::setSelection(int index)
  23.     {
  24.         LstSetSelection(objectPtr(), index);
  25.         LstMakeItemVisible(objectPtr(), index);
  26.     }
  27.  
  28.     // attributes
  29.  
  30.     void List::setChoices(const ListChoices& choices)
  31.     {
  32.         _choices = choices;
  33.         LstSetListChoices(objectPtr(), (char**)_choices.textItems(), _choices.count());
  34.     }
  35.  
  36.     // event handling
  37.  
  38.     bool List::handleKeyDownEvent(EventType* event)
  39.     {
  40.         if (event->eType == keyDownEvent)
  41.             return processPageKeys();
  42.  
  43.         return false;
  44.     }
  45.  
  46.     // implementation
  47.  
  48.     bool List::processPageKeys()
  49.     {
  50.         DWord state = KeyCurrentState();
  51.  
  52.         if ((state & keyBitPageUp) != 0)
  53.         {
  54.             LstScrollList(objectPtr(), up, LstGetVisibleItems(objectPtr())-1);
  55.             return true;
  56.         }
  57.         else if ((state & keyBitPageDown) != 0)
  58.         {
  59.             LstScrollList(objectPtr(), down, LstGetVisibleItems(objectPtr())-1);
  60.             return true;
  61.         }
  62.  
  63.         return false;
  64.     }
  65. }
  66. // namespace UI
  67.