Fl_Window_Driver.H 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. //
  2. // "$Id: Fl_Window_Driver.H 12619 2018-01-04 15:23:18Z manolo $"
  3. //
  4. // A base class for platform specific window handling code
  5. // for the Fast Light Tool Kit (FLTK).
  6. //
  7. // Copyright 2010-2017 by Bill Spitzak and others.
  8. //
  9. // This library is free software. Distribution and use rights are outlined in
  10. // the file "COPYING" which should have been included with this file. If this
  11. // file is missing or damaged, see the license at:
  12. //
  13. // http://www.fltk.org/COPYING.php
  14. //
  15. // Please report all bugs and problems on the following page:
  16. //
  17. // http://www.fltk.org/str.php
  18. //
  19. /** \file Fl_Window_Driver.H
  20. \brief declaration of classe Fl_Window_Driver.
  21. */
  22. #ifndef FL_WINDOW_DRIVER_H
  23. #define FL_WINDOW_DRIVER_H
  24. #include <FL/Fl_Export.H>
  25. #include <FL/Fl_Window.H>
  26. #include <FL/Fl_Overlay_Window.H>
  27. #include <stdlib.h>
  28. class Fl_X;
  29. class Fl_Image;
  30. class Fl_Shared_Image;
  31. class Fl_RGB_Image;
  32. /**
  33. \brief A base class for platform specific window handling code.
  34. This class is only for internal use by the FLTK library.
  35. Each supported platform implements several of the virtual methods of this class.
  36. */
  37. class FL_EXPORT Fl_Window_Driver
  38. {
  39. friend class Fl_Window;
  40. friend class Fl_X;
  41. private:
  42. static bool is_a_rescale_; // true when a top-level window is being rescaled
  43. protected:
  44. Fl_Window *pWindow;
  45. struct shape_data_type;
  46. shape_data_type *shape_data_; ///< non-null means the window has a non-rectangular shape
  47. void flush_Fl_Window(); // accessor to protected Fl_Window::flush()
  48. public:
  49. Fl_Window_Driver(Fl_Window *);
  50. virtual ~Fl_Window_Driver();
  51. static Fl_Window_Driver *newWindowDriver(Fl_Window *);
  52. int wait_for_expose_value;
  53. Fl_Offscreen other_xid; // offscreen bitmap (overlay and double-buffered windows)
  54. virtual int screen_num();
  55. virtual void screen_num(int) {}
  56. static bool is_a_rescale() {return is_a_rescale_;};
  57. // --- frequently used accessors to public window data
  58. /** returns the x coordinate of the window. */
  59. int x() const { return pWindow->x(); }
  60. /** returns the y coordinate of the window. */
  61. int y() const { return pWindow->y(); }
  62. /** returns the width of the window. */
  63. int w() const { return pWindow->w(); }
  64. /** returns the width of the window. */
  65. int h() const { return pWindow->h(); }
  66. /** returns whether the window has a border. */
  67. int border() const { return pWindow->border(); }
  68. /** returns whether the window itself is visible(). */
  69. int visible() const { return pWindow->visible(); }
  70. /** returns whether the window and all its parents is visible(). */
  71. int visible_r() const { return pWindow->visible_r(); }
  72. /** returns whether the window is shown(). */
  73. int shown() const { return pWindow->shown(); }
  74. /** returns the parent of the window. */
  75. Fl_Group *parent() const { return pWindow->parent(); }
  76. // --- accessors to private window data
  77. int minw();
  78. int minh();
  79. int maxw();
  80. int maxh();
  81. int dw();
  82. int dh();
  83. int aspect();
  84. int fullscreen_screen_top();
  85. int fullscreen_screen_bottom();
  86. int fullscreen_screen_left();
  87. int fullscreen_screen_right();
  88. unsigned char size_range_set();
  89. int force_position();
  90. void force_position(int c);
  91. void x(int X);
  92. void y(int Y);
  93. void current(Fl_Window *c);
  94. char show_iconic() { return Fl_Window::show_iconic_; }
  95. void show_iconic(char c) { Fl_Window::show_iconic_ = c; }
  96. void i(Fl_X *x) { pWindow->i = x; }
  97. /** for an Fl_Overlay_Window, returns the value of its overlay_ member variable */
  98. Fl_Window *overlay() {
  99. return pWindow->as_overlay_window() ? pWindow->as_overlay_window()->overlay_ : NULL;
  100. }
  101. /** for an Fl_Overlay_Window, sets the value of its overlay_ member variable */
  102. void overlay(Fl_Window *o) {
  103. if (pWindow->as_overlay_window()) pWindow->as_overlay_window()->overlay_ = o;
  104. }
  105. void resize_after_scale_change(int ns, float old_f, float new_f);
  106. // --- window data
  107. virtual int decorated_w() = 0;
  108. virtual int decorated_h() = 0;
  109. // --- window management
  110. virtual void take_focus();
  111. virtual void flush(); // the default implementation may be enough
  112. virtual void flush_double();
  113. virtual void flush_overlay();
  114. virtual void flush_menu();
  115. virtual void erase_menu() {}
  116. /** Usable for platform-specific code executed before the platform-independent part of Fl_Window::draw() */
  117. virtual void draw_begin();
  118. /** Usable for platform-specific code executed after the platform-independent part of Fl_Window::draw() */
  119. virtual void draw_end();
  120. void draw();
  121. virtual void make_current();
  122. virtual void label(const char *name, const char *mininame);
  123. virtual Fl_X *makeWindow() { return 0; }
  124. virtual void wait_for_expose();
  125. virtual void destroy_double_buffer();
  126. virtual void show();
  127. virtual void show_menu();
  128. virtual void resize(int X,int Y,int W,int H) {}
  129. virtual void hide() {}
  130. int hide_common();
  131. virtual void map() {}
  132. virtual void unmap() {}
  133. virtual void fullscreen_on() {}
  134. virtual void fullscreen_off(int X, int Y, int W, int H) {}
  135. virtual void use_border();
  136. virtual void size_range();
  137. virtual void iconize() {}
  138. virtual void decoration_sizes(int *top, int *left, int *right, int *bottom) {
  139. *top = *left = *right = *bottom = 0; }
  140. virtual void show_with_args_begin() {}
  141. virtual void show_with_args_end(int argc, char **argv) {}
  142. virtual int can_do_overlay();
  143. virtual void redraw_overlay();
  144. // --- window cursor stuff
  145. virtual int set_cursor(Fl_Cursor);
  146. virtual int set_cursor(const Fl_RGB_Image*, int, int);
  147. virtual fl_uintptr_t current_cursor();
  148. // --- window shape stuff
  149. void shape_pixmap_(Fl_Image* pixmap); // platform-independent, support function
  150. virtual void shape(const Fl_Image* img) {}
  151. virtual void shape_alpha_(Fl_Image* img, int offset) {}
  152. // --- window icon stuff
  153. virtual void icons(const Fl_RGB_Image *icons[], int count) {}
  154. virtual const void *icon() const {return NULL;}
  155. virtual void icon(const void * ic) {}
  156. virtual void free_icons() {}
  157. // each platform implements this its own way
  158. static void default_icons(const Fl_RGB_Image *icons[], int count);
  159. // --- window printing/drawing helper
  160. virtual void capture_titlebar_and_borders(Fl_Shared_Image*& top, Fl_Shared_Image*& left,
  161. Fl_Shared_Image*& bottom, Fl_Shared_Image*& right);
  162. #if defined(FL_PORTING)
  163. # pragma message "FL_PORTING: implement scrolling of the screen contents"
  164. #endif
  165. virtual int scroll(int src_x, int src_y, int src_w, int src_h, int dest_x, int dest_y,
  166. void (*draw_area)(void*, int,int,int,int), void* data) { return 0; }
  167. };
  168. #endif // FL_WINDOW_DRIVER_H
  169. //
  170. // End of "$Id: Fl_Window_Driver.H 12619 2018-01-04 15:23:18Z manolo $".
  171. //