Fl_File_Browser.H 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. //
  2. // "$Id: Fl_File_Browser.H 7903 2010-11-28 21:06:39Z matt $"
  3. //
  4. // FileBrowser definitions.
  5. //
  6. // Copyright 1999-2010 by Michael Sweet.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems on the following page:
  24. //
  25. // http://www.fltk.org/str.php
  26. //
  27. /* \file
  28. Fl_File_Browser widget . */
  29. //
  30. // Include necessary header files...
  31. //
  32. #ifndef _Fl_File_Browser_H_
  33. # define _Fl_File_Browser_H_
  34. # include "Fl_Browser.H"
  35. # include "Fl_File_Icon.H"
  36. # include "filename.H"
  37. //
  38. // Fl_File_Browser class...
  39. //
  40. /** The Fl_File_Browser widget displays a list of filenames, optionally with file-specific icons. */
  41. class FL_EXPORT Fl_File_Browser : public Fl_Browser
  42. {
  43. int filetype_;
  44. const char *directory_;
  45. uchar iconsize_;
  46. const char *pattern_;
  47. int full_height() const;
  48. int item_height(void *) const;
  49. int item_width(void *) const;
  50. void item_draw(void *, int, int, int, int) const;
  51. int incr_height() const { return (item_height(0)); }
  52. public:
  53. enum { FILES, DIRECTORIES };
  54. /**
  55. The constructor creates the Fl_File_Browser widget at the specified position and size.
  56. The destructor destroys the widget and frees all memory that has been allocated.
  57. */
  58. Fl_File_Browser(int, int, int, int, const char * = 0);
  59. /** Sets or gets the size of the icons. The default size is 20 pixels. */
  60. uchar iconsize() const { return (iconsize_); };
  61. /** Sets or gets the size of the icons. The default size is 20 pixels. */
  62. void iconsize(uchar s) { iconsize_ = s; redraw(); };
  63. /**
  64. Sets or gets the filename filter. The pattern matching uses
  65. the fl_filename_match()
  66. function in FLTK.
  67. */
  68. void filter(const char *pattern);
  69. /**
  70. Sets or gets the filename filter. The pattern matching uses
  71. the fl_filename_match()
  72. function in FLTK.
  73. */
  74. const char *filter() const { return (pattern_); };
  75. /**
  76. Loads the specified directory into the browser. If icons have been
  77. loaded then the correct icon is associated with each file in the list.
  78. <P>The sort argument specifies a sort function to be used with
  79. fl_filename_list().
  80. */
  81. int load(const char *directory, Fl_File_Sort_F *sort = fl_numericsort);
  82. Fl_Fontsize textsize() const { return Fl_Browser::textsize(); };
  83. void textsize(Fl_Fontsize s) { Fl_Browser::textsize(s); iconsize_ = (uchar)(3 * s / 2); };
  84. /**
  85. Sets or gets the file browser type, FILES or
  86. DIRECTORIES. When set to FILES, both
  87. files and directories are shown. Otherwise only directories are
  88. shown.
  89. */
  90. int filetype() const { return (filetype_); };
  91. /**
  92. Sets or gets the file browser type, FILES or
  93. DIRECTORIES. When set to FILES, both
  94. files and directories are shown. Otherwise only directories are
  95. shown.
  96. */
  97. void filetype(int t) { filetype_ = t; };
  98. };
  99. #endif // !_Fl_File_Browser_H_
  100. //
  101. // End of "$Id: Fl_File_Browser.H 7903 2010-11-28 21:06:39Z matt $".
  102. //