x.H 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. //
  2. // "$Id: x.H 12307 2017-07-11 13:22:56Z manolo $"
  3. //
  4. // X11 header file for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-2017 by Bill Spitzak and others.
  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. // These are internal fltk symbols that are necessary or useful for
  19. // calling Xlib. You should include this file if (and ONLY if) you
  20. // need to call Xlib directly. These symbols may not exist on non-X
  21. // systems.
  22. #if !defined(Fl_X_H) && !defined(FL_DOXYGEN)
  23. # define Fl_X_H
  24. # include <FL/Fl_Export.H>
  25. # include <FL/platform_types.h>
  26. # include <FL/fl_types.h> // for uchar
  27. class Fl_Window;
  28. # ifdef WIN32
  29. # include "win32.H"
  30. # elif defined(__APPLE__)
  31. # include "mac.H"
  32. # elif defined(USE_SDL)
  33. # pragma message "FL_PORTING: write a header file based on this file, win32.H, or mac.H to define the FLTK core internals"
  34. # include "porting.H"
  35. # elif defined(FL_PORTING)
  36. # pragma message "FL_PORTING: write a header file based on this file, win32.H, or mac.H to define the FLTK core internals"
  37. # include "porting.H"
  38. # else // X11
  39. # include <FL/fl_types.h>
  40. # include <FL/Enumerations.H>
  41. # if !defined(USE_X11)
  42. # define USE_X11 1
  43. # endif
  44. # if defined(_ABIN32) || defined(_ABI64) // fix for broken SGI Irix X .h files
  45. # pragma set woff 3322
  46. # endif
  47. # include <X11/Xlib.h>
  48. # include <X11/Xutil.h>
  49. # if defined(_ABIN32) || defined(_ABI64)
  50. # pragma reset woff 3322
  51. # endif
  52. # include <X11/Xatom.h>
  53. FL_EXPORT void fl_open_display(Display*);
  54. // constant info about the X server connection:
  55. extern FL_EXPORT Display *fl_display;
  56. extern FL_EXPORT int fl_screen;
  57. extern FL_EXPORT XVisualInfo *fl_visual;
  58. extern FL_EXPORT Colormap fl_colormap;
  59. // drawing functions:
  60. extern FL_EXPORT GC fl_gc;
  61. FL_EXPORT ulong fl_xpixel(Fl_Color i);
  62. FL_EXPORT ulong fl_xpixel(uchar r, uchar g, uchar b);
  63. // feed events into fltk:
  64. FL_EXPORT int fl_handle(const XEvent&);
  65. // you can use these in Fl::add_handler() to look at events:
  66. extern FL_EXPORT const XEvent* fl_xevent;
  67. extern FL_EXPORT ulong fl_event_time;
  68. #if defined(FL_LIBRARY) || defined(FL_INTERNALS)
  69. extern FL_EXPORT Window fl_message_window;
  70. extern FL_EXPORT void *fl_xftfont;
  71. // access to core fonts:
  72. // This class provides a "smart pointer" that returns a pointer to an XFontStruct.
  73. // The global variable fl_xfont can be called wherever a bitmap "core" font is
  74. // needed, e.g. when rendering to a GL context under X11.
  75. // With Xlib / X11 fonts, fl_xfont will return the current selected font.
  76. // With XFT / X11 fonts, fl_xfont will attempt to return the bitmap "core" font most
  77. // similar to (usually the same as) the current XFT font.
  78. class FL_EXPORT Fl_XFont_On_Demand
  79. {
  80. public:
  81. Fl_XFont_On_Demand(XFontStruct* p = NULL) : ptr(p) { }
  82. Fl_XFont_On_Demand& operator=(const Fl_XFont_On_Demand& x)
  83. { ptr = x.ptr; return *this; }
  84. Fl_XFont_On_Demand& operator=(XFontStruct* p)
  85. { ptr = p; return *this; }
  86. XFontStruct* value();
  87. operator XFontStruct*() { return value(); }
  88. XFontStruct& operator*() { return *value(); }
  89. XFontStruct* operator->() { return value(); }
  90. bool operator==(const Fl_XFont_On_Demand& x) { return ptr == x.ptr; }
  91. bool operator!=(const Fl_XFont_On_Demand& x) { return ptr != x.ptr; }
  92. private:
  93. XFontStruct *ptr;
  94. };
  95. extern FL_EXPORT Fl_XFont_On_Demand fl_xfont;
  96. extern FL_EXPORT char fl_override_redirect; // hack into Fl_X::make_xid()
  97. extern FL_EXPORT int fl_background_pixel; // hack into Fl_X::make_xid()
  98. #endif // FL_LIBRARY || FL_INTERNALS
  99. # endif // X11
  100. //
  101. // cross-platform declarations
  102. //
  103. #if defined(FL_LIBRARY) || defined(FL_INTERNALS)
  104. # include <FL/Fl_Window.H>
  105. class FL_EXPORT Fl_X {
  106. public:
  107. Window xid;
  108. Fl_Window* w;
  109. Fl_Region region;
  110. Fl_X *next;
  111. // static variables, static functions and member functions
  112. static Fl_X* first;
  113. static Fl_X* i(const Fl_Window* w) {return (Fl_X*)w->i;}
  114. # if defined(USE_X11) // for backward compatibility
  115. static void make_xid(Fl_Window*, XVisualInfo* =fl_visual, Colormap=fl_colormap);
  116. static Fl_X* set_xid(Fl_Window*, Window);
  117. # endif
  118. };
  119. inline Window fl_xid(const Fl_Window* w) { Fl_X *xTemp = Fl_X::i(w); return xTemp ? xTemp->xid : 0; }
  120. #else
  121. extern FL_EXPORT Window fl_xid_(const Fl_Window* w);
  122. # define fl_xid(w) fl_xid_(w)
  123. #endif // FL_LIBRARY || FL_INTERNALS
  124. extern FL_EXPORT Fl_Window* fl_find(Window xid);
  125. extern FL_EXPORT void fl_open_display();
  126. extern FL_EXPORT void fl_close_display();
  127. extern FL_EXPORT Window fl_window;
  128. extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
  129. extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
  130. extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm);
  131. extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
  132. extern FL_EXPORT void fl_open_callback(void (*)(const char *));
  133. #endif // !Fl_X_H
  134. //
  135. // End of "$Id: x.H 12307 2017-07-11 13:22:56Z manolo $".
  136. //