home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 110 / EnigmaAmiga110CD.iso / indispensabili / utility / apdf / xpdf-0.80 / ltk / ltkbutton.h < prev    next >
C/C++ Source or Header  |  1998-11-27  |  2KB  |  90 lines

  1. //========================================================================
  2. //
  3. // LTKButton.h
  4. //
  5. // Copyright 1996 Derek B. Noonburg
  6. //
  7. //========================================================================
  8.  
  9. #ifndef LTKBUTTON_H
  10. #define LTKBUTTON_H
  11.  
  12. #ifdef __GNUC__
  13. #pragma interface
  14. #endif
  15.  
  16. #include <stddef.h>
  17. #include <X11/Xlib.h>
  18. #include "gtypes.h"
  19. #include "GString.h"
  20. #include "LTKWidget.h"
  21.  
  22. //------------------------------------------------------------------------
  23. // button action type
  24. //------------------------------------------------------------------------
  25.  
  26. enum LTKButtonAction {
  27.   ltkButtonClick,        // momentarily on
  28.   ltkButtonSticky,        // stays on until setState() is called
  29.   ltkButtonToggle        // press on, press off
  30. };
  31.  
  32. //------------------------------------------------------------------------
  33. // LTKButton
  34. //------------------------------------------------------------------------
  35.  
  36. class LTKButton: public LTKWidget {
  37. public:
  38.  
  39.   //---------- constructors and destructor ----------
  40.  
  41.   LTKButton(char *name1, int widgetNum1, char *label1,
  42.         LTKButtonAction action1, LTKBoolValCbk pressCbk1);
  43.  
  44.   LTKButton(char *name1, int widgetNum1,
  45.         unsigned char *iconData1,
  46.         int iconWidth1, int iconHeight1,
  47.         LTKButtonAction action1, LTKBoolValCbk pressCbk1);
  48.  
  49.   virtual ~LTKButton();
  50.  
  51.   //---------- access ----------
  52.  
  53.   virtual long getEventMask();
  54.  
  55.   //---------- special access ----------
  56.  
  57.   void setState(GBool on1);
  58.  
  59.   //---------- layout ----------
  60.  
  61.   virtual void layout1();
  62.   virtual void layout3();
  63.  
  64.   //---------- drawing ----------
  65.  
  66.   virtual void redraw();
  67.  
  68.   //---------- callbacks and event handlers ----------
  69.  
  70.   virtual void buttonPress(int bx, int by, int button, GBool dblClick);
  71.   virtual void buttonRelease(int bx, int by, int button, GBool click);
  72.   virtual void activateDefault();
  73.  
  74. protected:
  75.  
  76.   GString *label;        // label (button has either label or icon)
  77.   Pixmap icon;            // icon
  78.   unsigned char *iconData;    // the icon data (bitmap format)
  79.   int iconWidth, iconHeight;    // the icon size
  80.   LTKButtonAction action;    // action kind
  81.   GBool on;            // current state
  82.   GBool oldOn;            // saved state
  83.   int textWidth, textHeight;    // size of text
  84.   int textBase;            // baseline offset
  85.  
  86.   LTKBoolValCbk pressCbk;    // button-press callback
  87. };
  88.  
  89. #endif
  90.