win32.H 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. //
  2. // "$Id: win32.H 10189 2014-06-11 09:10:53Z ossman $"
  3. //
  4. // WIN32 header file for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-2012 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. // Do not directly include this file, instead use <FL/x.H>. It will
  19. // include this file if WIN32 is defined. This is to encourage
  20. // portability of even the system-specific code...
  21. #ifndef FL_DOXYGEN
  22. #ifndef Fl_X_H
  23. # error "Never use <FL/win32.H> directly; include <FL/x.H> instead."
  24. #endif // !Fl_X_H
  25. #include <windows.h>
  26. typedef HRGN Fl_Region;
  27. typedef HWND Window;
  28. typedef POINT XPoint;
  29. #include <FL/Fl_Window.H>
  30. // this part is included only when compiling the FLTK library or if requested explicitly
  31. #if defined(FL_LIBRARY) || defined(FL_INTERNALS)
  32. // In some of the distributions, the gcc header files are missing some stuff:
  33. #ifndef LPMINMAXINFO
  34. #define LPMINMAXINFO MINMAXINFO*
  35. #endif
  36. #ifndef VK_LWIN
  37. #define VK_LWIN 0x5B
  38. #define VK_RWIN 0x5C
  39. #define VK_APPS 0x5D
  40. #endif
  41. // some random X equivalents
  42. struct XRectangle {int x, y, width, height;};
  43. extern Fl_Region XRectangleRegion(int x, int y, int w, int h);
  44. inline void XDestroyRegion(Fl_Region r) {DeleteObject(r);}
  45. inline void XClipBox(Fl_Region r,XRectangle* rect) {
  46. RECT win_rect; GetRgnBox(r,&win_rect);
  47. rect->x=win_rect.left;
  48. rect->y=win_rect.top;
  49. rect->width=win_rect.right-win_rect.left;
  50. rect->height=win_rect.bottom-win_rect.top;
  51. }
  52. #define XDestroyWindow(a,b) DestroyWindow(b)
  53. #define XMapWindow(a,b) ShowWindow(b, SW_RESTORE)
  54. #define XUnmapWindow(a,b) ShowWindow(b, SW_HIDE)
  55. // this object contains all win32-specific stuff about a window:
  56. // Warning: this object is highly subject to change!
  57. class FL_EXPORT Fl_X {
  58. public:
  59. // member variables - add new variables only at the end of this block
  60. Window xid;
  61. HBITMAP other_xid; // for double-buffered windows
  62. Fl_Window* w;
  63. Fl_Region region;
  64. Fl_X *next;
  65. int wait_for_expose;
  66. HDC private_dc; // used for OpenGL
  67. HCURSOR cursor;
  68. HDC saved_hdc; // saves the handle of the DC currently loaded
  69. // static variables, static functions and member functions
  70. static Fl_X* first;
  71. static Fl_X* i(const Fl_Window* w) {return w->i;}
  72. static int fake_X_wm(const Fl_Window* w,int &X, int &Y,
  73. int &bt,int &bx,int &by);
  74. void make_fullscreen(int X, int Y, int W, int H);
  75. void setwindow(Fl_Window* wi) {w=wi; wi->i=this;}
  76. void flush() {w->flush();}
  77. void set_minmax(LPMINMAXINFO minmax);
  78. void mapraise();
  79. static Fl_X* make(Fl_Window*);
  80. };
  81. extern FL_EXPORT HCURSOR fl_default_cursor;
  82. extern FL_EXPORT UINT fl_wake_msg;
  83. extern FL_EXPORT char fl_override_redirect; // hack into Fl_Window::make_xid()
  84. extern FL_EXPORT int fl_background_pixel; // hack into Fl_Window::make_xid()
  85. extern FL_EXPORT HPALETTE fl_palette; // non-zero only on 8-bit displays!
  86. extern FL_EXPORT void fl_release_dc(HWND w, HDC dc);
  87. extern FL_EXPORT void fl_save_dc( HWND w, HDC dc);
  88. inline Window fl_xid(const Fl_Window* w) { Fl_X *temp = Fl_X::i(w); return temp ? temp->xid : 0; }
  89. #else
  90. FL_EXPORT Window fl_xid_(const Fl_Window* w);
  91. #define fl_xid(w) fl_xid_(w)
  92. #endif // FL_LIBRARY || FL_INTERNALS
  93. FL_EXPORT Fl_Window* fl_find(Window xid);
  94. void fl_clip_region(Fl_Region);
  95. // most recent fl_color() or fl_rgbcolor() points at one of these:
  96. extern FL_EXPORT struct Fl_XMap {
  97. COLORREF rgb; // this should be the type the RGB() macro returns
  98. HPEN pen; // pen, 0 if none created yet
  99. int brush; // ref to solid brush, 0 if none created yet
  100. } *fl_current_xmap;
  101. inline COLORREF fl_RGB() {return fl_current_xmap->rgb;}
  102. inline HPEN fl_pen() {return fl_current_xmap->pen;}
  103. FL_EXPORT HBRUSH fl_brush(); // allocates a brush if necessary
  104. FL_EXPORT HBRUSH fl_brush_action(int); // now does the real work
  105. extern FL_EXPORT HINSTANCE fl_display;
  106. extern FL_EXPORT Window fl_window;
  107. extern FL_EXPORT HDC fl_gc;
  108. extern FL_EXPORT MSG fl_msg;
  109. extern FL_EXPORT HDC fl_GetDC(Window);
  110. extern FL_EXPORT HDC fl_makeDC(HBITMAP);
  111. // off-screen pixmaps: create, destroy, draw into, copy to window
  112. typedef HBITMAP Fl_Offscreen;
  113. #define fl_create_offscreen(w, h) \
  114. CreateCompatibleBitmap( (fl_gc ? fl_gc : fl_GetDC(0) ) , w, h)
  115. # define fl_begin_offscreen(b) \
  116. HDC _sgc=fl_gc; Window _sw=fl_window; \
  117. Fl_Surface_Device *_ss = Fl_Surface_Device::surface(); Fl_Display_Device::display_device()->set_current(); \
  118. fl_gc=fl_makeDC(b); int _savedc = SaveDC(fl_gc); fl_window=(HWND)b; fl_push_no_clip()
  119. # define fl_end_offscreen() \
  120. fl_pop_clip(); RestoreDC(fl_gc, _savedc); DeleteDC(fl_gc); _ss->set_current(); fl_window=_sw; fl_gc = _sgc
  121. FL_EXPORT void fl_copy_offscreen(int x,int y,int w,int h,HBITMAP pixmap,int srcx,int srcy);
  122. #define fl_delete_offscreen(bitmap) DeleteObject(bitmap)
  123. // Bitmap masks
  124. typedef HBITMAP Fl_Bitmask;
  125. extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
  126. extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
  127. extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm);
  128. // Dummy function to register a function for opening files via the window manager...
  129. inline void fl_open_callback(void (*)(const char *)) {}
  130. extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
  131. #endif // FL_DOXYGEN
  132. //
  133. // End of "$Id: win32.H 10189 2014-06-11 09:10:53Z ossman $".
  134. //