FLTK 1.3.9: win32.H Source File

FLTK 1.3.9

Loading...
Searching...
No Matches
win32.H
1//
2// "$Id$"
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
19// Do not directly include this file, instead use <FL/x.H>. It will
20// include this file if WIN32 is defined. This is to encourage
21// portability of even the system-specific code...
22
23#ifndef FL_DOXYGEN
24#ifndef Fl_X_H
25# error "Never use <FL/win32.H> directly; include <FL/x.H> instead."
26#endif // !Fl_X_H
27
28#include <windows.h>
29typedef HRGN Fl_Region;
30typedef HWND Window;
31typedef POINT XPoint;
32
33#include <FL/Fl_Window.H>
34
35// this part is included only when compiling the FLTK library or if requested explicitly
36#if defined(FL_LIBRARY) || defined(FL_INTERNALS)
37
38// In some of the distributions, the gcc header files are missing some stuff:
39#ifndef LPMINMAXINFO
40#define LPMINMAXINFO MINMAXINFO*
41#endif
42#ifndef VK_LWIN
43#define VK_LWIN 0x5B
44#define VK_RWIN 0x5C
45#define VK_APPS 0x5D
46#endif
47
48// some random X equivalents
49struct XRectangle {int x, y, width, height;};
50extern Fl_Region XRectangleRegion(int x, int y, int w, int h);
51inline void XDestroyRegion(Fl_Region r) {DeleteObject(r);}
52inline void XClipBox(Fl_Region r,XRectangle* rect) {
53 RECT win_rect; GetRgnBox(r,&win_rect);
54 rect->x=win_rect.left;
55 rect->y=win_rect.top;
56 rect->width=win_rect.right-win_rect.left;
57 rect->height=win_rect.bottom-win_rect.top;
58}
59#define XDestroyWindow(a,b) DestroyWindow(b)
60#define XMapWindow(a,b) ShowWindow(b, SW_RESTORE)
61#define XUnmapWindow(a,b) ShowWindow(b, SW_HIDE)
62
63// this object contains all win32-specific stuff about a window:
64// Warning: this object is highly subject to change!
65class FL_EXPORT Fl_X {
66public:
67 // member variables - add new variables only at the end of this block
68 Window xid;
69 HBITMAP other_xid; // for double-buffered windows
70 Fl_Window* w;
71 Fl_Region region;
72 Fl_X *next;
73 int wait_for_expose;
74 HDC private_dc; // used for OpenGL
75 HCURSOR cursor;
76 int custom_cursor;
77 HDC saved_hdc; // saves the handle of the DC currently loaded
78 // static variables, static functions and member functions
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 make_fullscreen(int X, int Y, int W, int H);
84 void setwindow(Fl_Window* wi) {w=wi; wi->i=this;}
85 void flush() {w->flush();}
86 void set_minmax(LPMINMAXINFO minmax);
87 void mapraise();
88 static void set_default_icons(const Fl_RGB_Image*[], int);
89 static void set_default_icons(HICON, HICON);
90 void set_icons();
91 int set_cursor(Fl_Cursor);
92 int set_cursor(const Fl_RGB_Image*, int, int);
93 static Fl_X* make(Fl_Window*);
94};
95extern FL_EXPORT UINT fl_wake_msg;
96extern FL_EXPORT char fl_override_redirect; // hack into Fl_Window::make_xid()
97extern FL_EXPORT int fl_background_pixel; // hack into Fl_Window::make_xid()
98extern FL_EXPORT HPALETTE fl_palette; // non-zero only on 8-bit displays!
99extern FL_EXPORT void fl_release_dc(HWND w, HDC dc);
100extern FL_EXPORT void fl_save_dc( HWND w, HDC dc);
101
102inline Window fl_xid(const Fl_Window* w) { Fl_X *temp = Fl_X::i(w); return temp ? temp->xid : 0; }
103
104extern FL_EXPORT void fl_open_display();
105
106#else
107FL_EXPORT Window fl_xid_(const Fl_Window* w);
108#define fl_xid(w) fl_xid_(w)
109#endif // FL_LIBRARY || FL_INTERNALS
110
111FL_EXPORT Fl_Window* fl_find(Window xid);
112void fl_clip_region(Fl_Region);
113
114// most recent fl_color() or fl_rgbcolor() points at one of these:
115extern FL_EXPORT struct Fl_XMap {
116 COLORREF rgb; // this should be the type the RGB() macro returns
117 HPEN pen; // pen, 0 if none created yet
118 int brush; // ref to solid brush, 0 if none created yet
119} *fl_current_xmap;
120inline COLORREF fl_RGB() {return fl_current_xmap->rgb;}
121inline HPEN fl_pen() {return fl_current_xmap->pen;}
122FL_EXPORT HBRUSH fl_brush(); // allocates a brush if necessary
123FL_EXPORT HBRUSH fl_brush_action(int); // now does the real work
124
125extern FL_EXPORT HINSTANCE fl_display;
126extern FL_EXPORT Window fl_window;
127extern FL_EXPORT HDC fl_gc;
128extern FL_EXPORT MSG fl_msg;
129extern FL_EXPORT HDC fl_GetDC(Window);
130extern FL_EXPORT HDC fl_makeDC(HBITMAP);
131
132// off-screen pixmaps: create, destroy, draw into, copy to window
133typedef HBITMAP Fl_Offscreen;
134#define fl_create_offscreen(w, h) \
135 CreateCompatibleBitmap( (fl_gc ? fl_gc : fl_GetDC(0) ) , w, h)
136
137# define fl_begin_offscreen(b) \
138 HDC _sgc=fl_gc; Window _sw=fl_window; \
139 Fl_Surface_Device *_ss = Fl_Surface_Device::surface(); Fl_Display_Device::display_device()->set_current(); \
140 fl_gc=fl_makeDC(b); int _savedc = SaveDC(fl_gc); fl_window=(HWND)b; fl_push_no_clip()
141
142# define fl_end_offscreen() \
143 fl_pop_clip(); RestoreDC(fl_gc, _savedc); DeleteDC(fl_gc); _ss->set_current(); fl_window=_sw; fl_gc = _sgc
144
145
146FL_EXPORT void fl_copy_offscreen(int x,int y,int w,int h,HBITMAP pixmap,int srcx,int srcy);
147#define fl_delete_offscreen(bitmap) DeleteObject(bitmap)
148
149// Bitmap masks
150typedef HBITMAP Fl_Bitmask;
151
152extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
153extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
154extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm);
155
156// Dummy function to register a function for opening files via the window manager...
157inline void fl_open_callback(void (*)(const char *)) {}
158
159extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
160#endif // FL_DOXYGEN
161//
162// End of "$Id$".
163//
Fl_Cursor
Fl_Cursor
The following constants define the mouse cursors that are available in FLTK.
Definition: Enumerations.H:1046
Fl_Window.H
Fl_Window widget .
Fl_RGB_Image
The Fl_RGB_Image class supports caching and drawing of full-color images with 1 to 4 channels of colo...
Definition: Fl_Image.H:202
Fl_Window
This widget produces an actual window.
Definition: Fl_Window.H:57
uchar
unsigned char uchar
unsigned char
Definition: fl_types.h:30
fl_clip_region
Fl_Region fl_clip_region()
Returns the current clipping region.
Definition: fl_draw.H:140
fl_copy_offscreen
void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy)
Copy a rectangular area of the given offscreen buffer into the current drawing destination.
Definition: Fl_Double_Window.cxx:94
fl_open_callback
void fl_open_callback(void(*cb)(const char *))
Register a function called for each file dropped onto an application icon.