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