• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

win32.H

00001 //
00002 // "$Id$"
00003 //
00004 // WIN32 header file for the Fast Light Tool Kit (FLTK).
00005 //
00006 // Copyright 1998-2012 by Bill Spitzak and others.
00007 //
00008 // This library is free software. Distribution and use rights are outlined in
00009 // the file "COPYING" which should have been included with this file.  If this
00010 // file is missing or damaged, see the license at:
00011 //
00012 //     http://www.fltk.org/COPYING.php
00013 //
00014 // Please report all bugs and problems on the following page:
00015 //
00016 //     http://www.fltk.org/str.php
00017 //
00018 
00019 // Do not directly include this file, instead use <FL/x.H>.  It will
00020 // include this file if WIN32 is defined.  This is to encourage
00021 // portability of even the system-specific code...
00022 
00023 #ifndef FL_DOXYGEN
00024 #ifndef Fl_X_H
00025 #  error "Never use <FL/win32.H> directly; include <FL/x.H> instead."
00026 #endif // !Fl_X_H
00027 
00028 #include <windows.h>
00029 typedef HRGN Fl_Region;
00030 typedef HWND Window;
00031 typedef POINT XPoint;
00032 
00033 #include <FL/Fl_Window.H>
00034 
00035 // this part is included only when compiling the FLTK library or if requested explicitly
00036 #if defined(FL_LIBRARY) || defined(FL_INTERNALS) 
00037 
00038 // In some of the distributions, the gcc header files are missing some stuff:
00039 #ifndef LPMINMAXINFO
00040 #define LPMINMAXINFO MINMAXINFO*
00041 #endif
00042 #ifndef VK_LWIN
00043 #define VK_LWIN 0x5B
00044 #define VK_RWIN 0x5C
00045 #define VK_APPS 0x5D
00046 #endif
00047 
00048 // some random X equivalents
00049 struct XRectangle {int x, y, width, height;};
00050 extern Fl_Region XRectangleRegion(int x, int y, int w, int h);
00051 inline void XDestroyRegion(Fl_Region r) {DeleteObject(r);}
00052 inline void XClipBox(Fl_Region r,XRectangle* rect) {
00053     RECT win_rect; GetRgnBox(r,&win_rect);
00054     rect->x=win_rect.left;
00055     rect->y=win_rect.top;
00056     rect->width=win_rect.right-win_rect.left;
00057     rect->height=win_rect.bottom-win_rect.top;
00058 }
00059 #define XDestroyWindow(a,b) DestroyWindow(b)
00060 #define XMapWindow(a,b) ShowWindow(b, SW_RESTORE)
00061 #define XUnmapWindow(a,b) ShowWindow(b, SW_HIDE)
00062 
00063 // this object contains all win32-specific stuff about a window:
00064 // Warning: this object is highly subject to change!
00065 class FL_EXPORT Fl_X {
00066 public:
00067   // member variables - add new variables only at the end of this block
00068   Window xid;
00069   HBITMAP other_xid; // for double-buffered windows
00070   Fl_Window* w;
00071   Fl_Region region;
00072   Fl_X *next;
00073   int wait_for_expose;
00074   HDC private_dc; // used for OpenGL
00075   HCURSOR cursor;
00076   int custom_cursor;
00077   HDC saved_hdc;  // saves the handle of the DC currently loaded
00078   // static variables, static functions and member functions
00079   static Fl_X* first;
00080   static Fl_X* i(const Fl_Window* w) {return w->i;}
00081   static int fake_X_wm(const Fl_Window* w,int &X, int &Y,
00082                                  int &bt,int &bx,int &by);
00083   void make_fullscreen(int X, int Y, int W, int H);
00084   void setwindow(Fl_Window* wi) {w=wi; wi->i=this;}
00085   void flush() {w->flush();}
00086   void set_minmax(LPMINMAXINFO minmax);
00087   void mapraise();
00088   static void set_default_icons(const Fl_RGB_Image*[], int);
00089   static void set_default_icons(HICON, HICON);
00090   void set_icons();
00091   int set_cursor(Fl_Cursor);
00092   int set_cursor(const Fl_RGB_Image*, int, int);
00093   static Fl_X* make(Fl_Window*);
00094 };
00095 extern FL_EXPORT UINT fl_wake_msg;
00096 extern FL_EXPORT char fl_override_redirect; // hack into Fl_Window::make_xid()
00097 extern FL_EXPORT int fl_background_pixel;  // hack into Fl_Window::make_xid()
00098 extern FL_EXPORT HPALETTE fl_palette; // non-zero only on 8-bit displays!
00099 extern FL_EXPORT void fl_release_dc(HWND w, HDC dc);
00100 extern FL_EXPORT void fl_save_dc( HWND w, HDC dc);
00101 
00102 inline Window fl_xid(const Fl_Window* w) { Fl_X *temp = Fl_X::i(w); return temp ? temp->xid : 0; }
00103 
00104 extern FL_EXPORT void fl_open_display();
00105 
00106 #else
00107 FL_EXPORT Window fl_xid_(const Fl_Window* w);
00108 #define fl_xid(w) fl_xid_(w)
00109 #endif // FL_LIBRARY || FL_INTERNALS
00110 
00111 FL_EXPORT Fl_Window* fl_find(Window xid);
00112 void fl_clip_region(Fl_Region);
00113 
00114 // most recent fl_color() or fl_rgbcolor() points at one of these:
00115 extern FL_EXPORT struct Fl_XMap {
00116   COLORREF rgb; // this should be the type the RGB() macro returns
00117   HPEN pen;     // pen, 0 if none created yet
00118   int brush;    // ref to solid brush, 0 if none created yet
00119 } *fl_current_xmap;
00120 inline COLORREF fl_RGB() {return fl_current_xmap->rgb;}
00121 inline HPEN fl_pen() {return fl_current_xmap->pen;}
00122 FL_EXPORT HBRUSH fl_brush(); // allocates a brush if necessary
00123 FL_EXPORT HBRUSH fl_brush_action(int); // now does the real work
00124 
00125 extern FL_EXPORT HINSTANCE fl_display;
00126 extern FL_EXPORT Window fl_window;
00127 extern FL_EXPORT HDC fl_gc;
00128 extern FL_EXPORT MSG fl_msg;
00129 extern FL_EXPORT HDC fl_GetDC(Window);
00130 extern FL_EXPORT HDC fl_makeDC(HBITMAP);
00131 
00132 // off-screen pixmaps: create, destroy, draw into, copy to window
00133 typedef HBITMAP Fl_Offscreen;
00134 #define fl_create_offscreen(w, h) \
00135   CreateCompatibleBitmap( (fl_gc ? fl_gc : fl_GetDC(0) ) , w, h)
00136 
00137 # define fl_begin_offscreen(b) \
00138    HDC _sgc=fl_gc; Window _sw=fl_window; \
00139    Fl_Surface_Device *_ss = Fl_Surface_Device::surface(); Fl_Display_Device::display_device()->set_current(); \
00140    fl_gc=fl_makeDC(b); int _savedc = SaveDC(fl_gc); fl_window=(HWND)b; fl_push_no_clip()
00141 
00142 # define fl_end_offscreen() \
00143    fl_pop_clip(); RestoreDC(fl_gc, _savedc); DeleteDC(fl_gc); _ss->set_current(); fl_window=_sw; fl_gc = _sgc
00144 
00145 
00146 FL_EXPORT void fl_copy_offscreen(int x,int y,int w,int h,HBITMAP pixmap,int srcx,int srcy);
00147 #define fl_delete_offscreen(bitmap) DeleteObject(bitmap)
00148 
00149 // Bitmap masks
00150 typedef HBITMAP Fl_Bitmask;
00151 
00152 extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
00153 extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
00154 extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm);
00155 
00156 // Dummy function to register a function for opening files via the window manager...
00157 inline void fl_open_callback(void (*)(const char *)) {}
00158 
00159 extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
00160 #endif // FL_DOXYGEN
00161 //
00162 // End of "$Id$".
00163 //
  • © 1998-2016 by Bill Spitzak and others.     FLTK

  • © 1998-2016 by Bill Spitzak and others.     FLTK

    Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.