Move the sources to trunk
[opencv] / otherlibs / _fltk / include / FL / win32.H
1 //
2 // "$Id: win32.H,v 1.2 2002/12/01 15:38:37 neurosurg Exp $"
3 //
4 // WIN32 header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2002 by Bill Spitzak and others.
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // Library General Public License for more details.
17 //
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 // USA.
22 //
23 // Please report all bugs and problems to "fltk-bugs@fltk.org".
24 //
25
26 // Do not directly include this file, instead use <FL/x.H>.  It will
27 // include this file if WIN32 is defined.  This is to encourage
28 // portability of even the system-specific code...
29
30 #ifndef Fl_X_H
31 #  error "Never use <FL/win32.H> directly; include <FL/x.H> instead."
32 #endif // !Fl_X_H
33
34 #include <windows.h>
35 // In some of the distributions, the gcc header files are missing some stuff:
36 #ifndef LPMINMAXINFO
37 #define LPMINMAXINFO MINMAXINFO*
38 #endif
39 #ifndef VK_LWIN
40 #define VK_LWIN 0x5B
41 #define VK_RWIN 0x5C
42 #define VK_APPS 0x5D
43 #endif
44
45 // some random X equivalents
46 typedef HWND Window;
47 typedef POINT XPoint;
48 struct XRectangle {int x, y, width, height;};
49 typedef HRGN Fl_Region;
50 FL_EXPORT void fl_clip_region(Fl_Region);
51 inline Fl_Region XRectangleRegion(int x, int y, int w, int h) {
52     return CreateRectRgn(x,y,x+w,y+h);
53 }
54 inline void XDestroyRegion(Fl_Region r) {DeleteObject(r);}
55 inline void XClipBox(Fl_Region r,XRectangle* rect) {
56     RECT win_rect; GetRgnBox(r,&win_rect);
57     rect->x=win_rect.left;
58     rect->y=win_rect.top;
59     rect->width=win_rect.right-win_rect.left;
60     rect->height=win_rect.bottom-win_rect.top;
61 }
62 #define XDestroyWindow(a,b) DestroyWindow(b)
63 #define XMapWindow(a,b) ShowWindow(b, SW_RESTORE)
64 #define XUnmapWindow(a,b) ShowWindow(b, SW_HIDE)
65
66 #include "Fl_Window.H"
67 // this object contains all win32-specific stuff about a window:
68 // Warning: this object is highly subject to change!
69 class FL_EXPORT Fl_X {
70 public:
71   Window xid;
72   HBITMAP other_xid; // for double-buffered windows
73   Fl_Window* w;
74   Fl_Region region;
75   Fl_X *next;
76   int wait_for_expose;
77   HDC private_dc; // used for OpenGL
78   HCURSOR cursor;
79   static Fl_X* first;
80   static Fl_X* i(const Fl_Window* w) {return w->i;}
81   static int fake_X_wm(const Fl_Window* w,int &X, int &Y,
82                                  int &bt,int &bx,int &by);
83   void setwindow(Fl_Window* wi) {w=wi; wi->i=this;}
84   void flush() {w->flush();}
85   void set_minmax(LPMINMAXINFO minmax);
86   void mapraise();
87   static Fl_X* make(Fl_Window*);
88 };
89 extern FL_EXPORT HCURSOR fl_default_cursor;
90 extern FL_EXPORT UINT fl_wake_msg;
91 inline Window fl_xid(const Fl_Window*w) {return Fl_X::i(w)->xid;}
92 FL_EXPORT Fl_Window* fl_find(Window xid);
93 extern FL_EXPORT char fl_override_redirect; // hack into Fl_Window::make_xid()
94 extern FL_EXPORT int fl_background_pixel;  // hack into Fl_Window::make_xid()
95
96 // most recent fl_color() or fl_rgbcolor() points at one of these:
97 extern FL_EXPORT struct Fl_XMap {
98   COLORREF rgb; // this should be the type the RGB() macro returns
99   HPEN pen;     // pen, 0 if none created yet
100   int brush;    // ref to solid brush, 0 if none created yet
101 } *fl_current_xmap;
102 inline COLORREF fl_RGB() {return fl_current_xmap->rgb;}
103 inline HPEN fl_pen() {return fl_current_xmap->pen;}
104 FL_EXPORT HBRUSH fl_brush(); // allocates a brush if necessary
105
106 extern FL_EXPORT HINSTANCE fl_display;
107 extern FL_EXPORT Window fl_window;
108 extern FL_EXPORT HDC fl_gc;
109 extern FL_EXPORT HPALETTE fl_palette; // non-zero only on 8-bit displays!
110 extern FL_EXPORT HDC fl_GetDC(Window);
111 extern FL_EXPORT MSG fl_msg;
112
113 // off-screen pixmaps: create, destroy, draw into, copy to window
114 typedef HBITMAP Fl_Offscreen;
115 #define fl_create_offscreen(w, h) CreateCompatibleBitmap(fl_gc, w, h)
116
117 extern FL_EXPORT HDC fl_makeDC(HBITMAP);
118 #define fl_begin_offscreen(b) \
119   HDC _sgc=fl_gc; Window _sw=fl_window; \
120   fl_gc=fl_makeDC(b); fl_window=(HWND)b; fl_push_no_clip()
121
122 #define fl_end_offscreen() \
123   fl_pop_clip(); DeleteDC(fl_gc); fl_window=_sw; fl_gc = _sgc
124
125 FL_EXPORT void fl_copy_offscreen(int x,int y,int w,int h,HBITMAP pixmap,int srcx,int srcy);
126 #define fl_delete_offscreen(bitmap) DeleteObject(bitmap);
127
128 // Bitmap masks
129 typedef HBITMAP Fl_Bitmask;
130
131 extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
132 extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
133 extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm);
134
135 extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
136
137 //
138 // End of "$Id: win32.H,v 1.2 2002/12/01 15:38:37 neurosurg Exp $".
139 //