00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _FL_WIN32_H_
00027 #define _FL_WIN32_H_
00028
00029 #ifdef _WIN32_WCE
00030 # include <wince.h>
00031 #else
00032 # include <windows.h>
00033 #endif
00034
00035 #include <winuser.h>
00036 #include "Fl_Color.h"
00037
00038
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
00049
00050 typedef HDC GC;
00051 typedef HWND Window;
00052 typedef POINT XPoint;
00053 struct FL_API XRectangle {int x, y, width, height;};
00054 typedef HRGN Region;
00055 typedef HBITMAP Pixmap;
00056
00057 inline Region XRectangleRegion(int x, int y, int w, int h) {
00058 return CreateRectRgn(x, y, x+w, y+h);
00059 }
00060 inline void XDestroyRegion(Region r) { DeleteObject(r); }
00061 inline int XOffsetRegion(Region r, int dx, int dy) { return OffsetRgn(r, dx, dy); }
00062 inline int XSubtractRegion(Region a, Region b, Region ret) { return CombineRgn(ret, a, b, RGN_DIFF); }
00063 inline void XClipBox(Region r, XRectangle* rect) {
00064 RECT win_rect; GetRgnBox(r, &win_rect);
00065 rect->x = win_rect.left;
00066 rect->y = win_rect.top;
00067 rect->width = win_rect.right-win_rect.left;
00068 rect->height = win_rect.bottom-win_rect.top;
00069 }
00070 #define XDestroyWindow(a,b) DestroyWindow(b)
00071 #define XMapWindow(a,b) ShowWindow(b, SW_RESTORE)
00072 #define XUnmapWindow(a,b) ShowWindow(b, SW_HIDE)
00073
00075
00076
00077 extern FL_API void fl_open_display();
00078 extern FL_API HINSTANCE fl_display;
00079 extern FL_API HPALETTE fl_palette;
00080
00082
00083
00084 extern FL_API MSG fl_msg;
00085
00087
00088
00089 extern FL_API HDC fl_gc;
00090 inline FL_API HDC fl_getDC() { return fl_gc ? fl_gc : GetDC(0); }
00091 extern FL_API HFONT fl_xfont();
00092 extern FL_API TEXTMETRIC* fl_textmetric();
00093 extern FL_API COLORREF fl_colorref;
00094 extern FL_API COLORREF fl_wincolor(Fl_Color i);
00095
00096 extern FL_API HPEN fl_set_geometric_pen();
00097 extern FL_API HPEN fl_set_cosmetic_pen();
00098 extern FL_API HBRUSH fl_setbrush();
00099
00100 extern FL_API void fl_clip_region(Region);
00101 extern FL_API Region fl_clip_region();
00102
00104
00105
00106
00107
00108
00109
00110
00111
00112 FL_API HDC fl_makeDC(HBITMAP);
00113
00114 class FL_API Fl_Drawable {
00115 public:
00116 HWND xid;
00117 HDC dc;
00118 Fl_Drawable() {}
00119 Fl_Drawable(HBITMAP p) : xid((HWND)p), dc(fl_makeDC(p)) {}
00120 void create(int w, int h) {
00121 HBITMAP bitmap = CreateCompatibleBitmap(fl_gc, w, h);
00122 xid = (HWND)bitmap;
00123 dc = fl_makeDC(bitmap);
00124 }
00125 void copy(int x, int y, int w, int h, int src_x, int src_y) {
00126 BitBlt(fl_gc, x, y, w, h, dc, src_x, src_y, SRCCOPY);
00127 }
00128 void free_gc() {
00129 if (dc) {if (fl_gc == dc) fl_gc = 0; DeleteDC(dc); dc = 0;}
00130 }
00131 void destroy() {
00132 if (xid) {free_gc(); DeleteObject((HBITMAP)xid); xid = 0;}
00133 }
00134 void make_current() { fl_gc = dc; fl_current_dev->load_identity(); }
00135 };
00136
00138
00139
00140
00141
00142
00143
00144
00145 #define fl_create_offscreen(w, h) CreateCompatibleBitmap(fl_gc, w, h)
00146
00147 #define fl_begin_offscreen(id) \
00148 {fl_push_matrix(); \
00149 HDC _sdc = fl_gc; \
00150 Fl_Drawable _nd(id); \
00151 _nd.make_current(); \
00152 fl_push_no_clip()
00153
00154 #define fl_end_offscreen() \
00155 _nd.free_gc(); fl_gc = _sdc; fl_pop_clip(); fl_pop_matrix();}
00156
00157 FL_API void fl_copy_offscreen(int x,int y,int w,int h,HBITMAP id,int srcx,int srcy);
00158
00159 #define fl_delete_offscreen(bitmap) DeleteObject(bitmap);
00160
00162
00163
00164 extern FL_API Pixmap fl_create_bitmap(const uchar* bitmap, int w, int h);
00165
00166 #define fl_delete_bitmap(bitmap) DeleteObject((HBITMAP)(bitmap));
00167
00169 #ifdef _FL_WINDOW_H_ // only include this if <efltk/Fl_Window.h> was included
00170
00171
00172
00173
00174
00175 class FL_API Fl_X : public Fl_Drawable {
00176 public:
00177 Fl_Drawable backbuffer;
00178 Fl_Window* window;
00179 Region region;
00180 void expose(int x, int y, int w, int h);
00181 Fl_X *next;
00182 bool wait_for_expose;
00183 HCURSOR cursor;
00184 static Fl_X* first;
00185 static Fl_X* i(const Fl_Window* window) {return window->i;}
00186 static int borders(const Fl_Window* w, int& dx, int& dy, int& dw, int& dh);
00187 void set_minmax(LPMINMAXINFO minmax);
00188 static void create(Fl_Window*);
00189 };
00190
00191
00192 inline Window fl_xid(const Fl_Window* window) {return Fl_X::i(window)->xid;}
00193 FL_API Fl_Window* fl_find(Window xid);
00194
00195 extern FL_API HCURSOR fl_default_cursor;
00196
00197 #endif //_FL_WINDOW_H_
00198
00200
00201 #endif