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

  1. //========================================================================
  2. //
  3. // LTKList.h
  4. //
  5. // Copyright 1997 Derek B. Noonburg
  6. //
  7. //========================================================================
  8.  
  9. #ifndef LTKLIST_H
  10. #define LTKLIST_H
  11.  
  12. #ifdef __GNUC__
  13. #pragma interface
  14. #endif
  15.  
  16. #include <stddef.h>
  17. #include <X11/Xlib.h>
  18. #include "GString.h"
  19. #include "LTKWidget.h"
  20.  
  21. //------------------------------------------------------------------------
  22. // LTKList
  23. //------------------------------------------------------------------------
  24.  
  25. class LTKList: public LTKWidget {
  26. public:
  27.  
  28.   //---------- constructor and destructor ----------
  29.  
  30.   LTKList(char *name1, int widgetNum1,
  31.       int minWidth1, int minLines1,
  32.       GBool allowSelection1, char *fontName1);
  33.  
  34.   virtual ~LTKList();
  35.  
  36.   //---------- access ----------
  37.  
  38.   virtual long getEventMask();
  39.  
  40.   //---------- special access ----------
  41.  
  42.   void addLine(char *s) { insertLine(numLines, s); }
  43.   void insertLine(int line, char *s);
  44.   void replaceLine(int line, char *s);
  45.   void deleteLine(int line);
  46.   void deleteAll();
  47.   int getSelection() { return selection; }
  48.   void setSelection(int line);
  49.   void clearSelection() { setSelection(-1); }
  50.   GString *getLine(int line) { return text[line]; }
  51.   int getNumLines() { return numLines; }
  52.   int getTopLine() { return topLine; }
  53.   int getDisplayedLines();
  54.   int getMaxWidth() { return maxWidth; }
  55.   int getHorizOffset() { return horizOffset; }
  56.   void scrollTo(int line, int horiz);
  57.   void makeVisible(int line);
  58.   void setClickCbk(LTKIntValCbk cbk) { clickCbk = cbk; }
  59.   void setDblClickCbk(LTKIntValCbk cbk) { dblClickCbk = cbk; }
  60.  
  61.   //---------- layout ----------
  62.  
  63.   virtual void layout1();
  64.   virtual void layout3();
  65.  
  66.   //---------- drawing ----------
  67.  
  68.   virtual void redraw();
  69.  
  70.   //---------- callbacks and event handlers ----------
  71.  
  72.   virtual void buttonPress(int mx, int my, int button, GBool dblClick);
  73.  
  74. protected:
  75.  
  76.   void xorSelection();
  77.   void redrawLine(int line);
  78.   void redrawBelow(int line);
  79.  
  80.   int minWidth, minLines;    // minimum widget size
  81.   GBool allowSelection;        // click selects item?
  82.   LTKIntValCbk clickCbk;    // called when user clicks on item
  83.   LTKIntValCbk dblClickCbk;    // called when user double-clicks on item
  84.   GString **text;        // array of lines
  85.   int numLines;            // number of lines
  86.   int textSize;            // size of text array
  87.   int topLine;            // current top line
  88.   int horizOffset;        // horizontal scroll offset
  89.   int selection;        // currently selected line (-1 for none)
  90.   int maxWidth;            // max line width
  91.   int textBase;            // baseline offset
  92.   int textHeight;        // height of text
  93.  
  94.   char *fontName;        // non-NULL if using a custom font
  95.   XFontStruct *fontStruct;    // font info
  96.   GC textGC;            // GC with text font
  97. };
  98.  
  99. #endif
  100.