Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

win32.h

00001 /*
00002  * $Id: win32.h,v 1.14 2003/04/24 13:59:24 laza2000 Exp $
00003  *
00004  * Extended Fast Light Toolkit (EFLTK)
00005  * Copyright (C) 2002-2003 by EDE-Team
00006  * WWW: http://www.sourceforge.net/projects/ede
00007  *
00008  * Fast Light Toolkit (FLTK)
00009  * Copyright (C) 1998-2003 by Bill Spitzak and others.
00010  * WWW: http://www.fltk.org
00011  *
00012  * This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00013  * version 2. See COPYING for details.
00014  *
00015  * Author : Mikko Lahteenmaki
00016  * Email  : mikko@fltk.net
00017  *
00018  * Please report all bugs and problems to "efltk-bugs@fltk.net"
00019  *
00020  */
00021 
00022 // Do not directly include this file, instead use <fltk/x.h>.  It will
00023 // include this file if _WIN32 is defined.  This is to encourage
00024 // portability of even the system-specific code...
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 // 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 
00049 // Emulate X somewhat:
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 // constant information about the display:
00076 
00077 extern FL_API void  fl_open_display();
00078 extern FL_API HINSTANCE fl_display;
00079 extern FL_API HPALETTE  fl_palette; // non-zero only on 8-bit displays!
00080 
00082 // event handling:
00083 
00084 extern FL_API MSG fl_msg;
00085 
00087 // drawing functions:
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 // This class is an offscreen image that you plan to draw to repeatedly.
00105 // It contains "context" information that may be expensive or impossible
00106 // to recreate each time for drawing. On some systems this is a base
00107 // class for Fl_X, which describes a window. Because
00108 // of differences in how these things are created & destroyed, and
00109 // the desire to have the id have a longer lifetime than this object,
00110 // intelligent constructors and destructors are not implemented.
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 // This is an offscreen image that is designed to be drawn into
00139 // exactly once and then repeatedly used as a source for copy. The
00140 // object is expected to fit into a void* space in the Fl_Image
00141 // structure. Drawing into them is surrounded by macros that save
00142 // the current graphics state in local variables and create a
00143 // temporary drawing context.
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 // Binary images, created from in-memory data:
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 // When fltk tells X about a window, one of these objects is created.
00172 // Warning: this object is highly subject to change!  It's definition
00173 // is only here so that fl_xid can be declared inline:
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 // convert xid <-> Fl_Window:
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

Generated on Thu Jul 31 15:33:46 2003 for eFLTK by doxygen1.2.15