Fl_File_Browser.H 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. //
  2. // "$Id: Fl_File_Browser.H 8864 2011-07-19 04:49:30Z greg.ercolano $"
  3. //
  4. // FileBrowser definitions.
  5. //
  6. // Copyright 1999-2010 by Michael Sweet.
  7. //
  8. // This library is free software. Distribution and use rights are outlined in
  9. // the file "COPYING" which should have been included with this file. If this
  10. // file is missing or damaged, see the license at:
  11. //
  12. // http://www.fltk.org/COPYING.php
  13. //
  14. // Please report all bugs and problems on the following page:
  15. //
  16. // http://www.fltk.org/str.php
  17. //
  18. /* \file
  19. Fl_File_Browser widget . */
  20. //
  21. // Include necessary header files...
  22. //
  23. #ifndef _Fl_File_Browser_H_
  24. # define _Fl_File_Browser_H_
  25. # include "Fl_Browser.H"
  26. # include "Fl_File_Icon.H"
  27. # include "filename.H"
  28. //
  29. // Fl_File_Browser class...
  30. //
  31. /** The Fl_File_Browser widget displays a list of filenames, optionally with file-specific icons. */
  32. class FL_EXPORT Fl_File_Browser : public Fl_Browser {
  33. int filetype_;
  34. const char *directory_;
  35. uchar iconsize_;
  36. const char *pattern_;
  37. int full_height() const;
  38. int item_height(void *) const;
  39. int item_width(void *) const;
  40. void item_draw(void *, int, int, int, int) const;
  41. int incr_height() const { return (item_height(0)); }
  42. public:
  43. enum { FILES, DIRECTORIES };
  44. /**
  45. The constructor creates the Fl_File_Browser widget at the specified position and size.
  46. The destructor destroys the widget and frees all memory that has been allocated.
  47. */
  48. Fl_File_Browser(int, int, int, int, const char * = 0);
  49. /** Sets or gets the size of the icons. The default size is 20 pixels. */
  50. uchar iconsize() const { return (iconsize_); };
  51. /** Sets or gets the size of the icons. The default size is 20 pixels. */
  52. void iconsize(uchar s) { iconsize_ = s; redraw(); };
  53. /**
  54. Sets or gets the filename filter. The pattern matching uses
  55. the fl_filename_match()
  56. function in FLTK.
  57. */
  58. void filter(const char *pattern);
  59. /**
  60. Sets or gets the filename filter. The pattern matching uses
  61. the fl_filename_match()
  62. function in FLTK.
  63. */
  64. const char *filter() const { return (pattern_); };
  65. /**
  66. Loads the specified directory into the browser. If icons have been
  67. loaded then the correct icon is associated with each file in the list.
  68. <P>The sort argument specifies a sort function to be used with
  69. fl_filename_list().
  70. */
  71. int load(const char *directory, Fl_File_Sort_F *sort = fl_numericsort);
  72. Fl_Fontsize textsize() const { return Fl_Browser::textsize(); };
  73. void textsize(Fl_Fontsize s) { Fl_Browser::textsize(s); iconsize_ = (uchar)(3 * s / 2); };
  74. /**
  75. Sets or gets the file browser type, FILES or
  76. DIRECTORIES. When set to FILES, both
  77. files and directories are shown. Otherwise only directories are
  78. shown.
  79. */
  80. int filetype() const { return (filetype_); };
  81. /**
  82. Sets or gets the file browser type, FILES or
  83. DIRECTORIES. When set to FILES, both
  84. files and directories are shown. Otherwise only directories are
  85. shown.
  86. */
  87. void filetype(int t) { filetype_ = t; };
  88. DECLARE_CLASS_CHEAP_RTTI_2(Fl_File_Browser, Fl_Browser)
  89. };
  90. #endif // !_Fl_File_Browser_H_
  91. //
  92. // End of "$Id: Fl_File_Browser.H 8864 2011-07-19 04:49:30Z greg.ercolano $".
  93. //