Hiding the Fl_X class under WIN32 (STR #2522).

Applied Manolo's patch, modified to use FL_INTERNALS for
explicit request in user code to expose class Fl_X.
Also changed X11 and Mac OS to use FL_INTERNALS.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8289 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Albrecht Schlosser 2011-01-17 23:52:32 +00:00
parent b841d90d3c
commit 96c410dceb
5 changed files with 34 additions and 25 deletions

View File

@ -3,7 +3,7 @@
//
// Mac header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2010 by Bill Spitzak and others.
// Copyright 1998-2011 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
@ -53,7 +53,7 @@ typedef void* Fl_Bitmask; // this is really a CGImageRef
#define MAC_OS_X_VERSION_10_6 1060
#endif
#ifndef FL_LIBRARY // this part is used when compiling an application program
#if !(defined(FL_LIBRARY) || defined(FL_INTERNALS)) // this part is used when compiling an application program
typedef void* Fl_Region;
typedef void* Fl_CGContextRef;
@ -163,7 +163,7 @@ extern struct Fl_XMap {
} *fl_current_xmap;
extern FL_EXPORT Window fl_window;
#endif // FL_LIBRARY
#endif // FL_LIBRARY || FL_INTERNALS
extern FL_EXPORT Fl_CGContextRef fl_gc;
extern FL_EXPORT class Fl_Sys_Menu_Bar *fl_sys_menu_bar;

View File

@ -3,7 +3,7 @@
//
// WIN32 header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2010 by Bill Spitzak and others.
// Copyright 1998-2011 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
@ -35,6 +35,12 @@
#endif // !Fl_X_H
#include <windows.h>
typedef HRGN Fl_Region;
typedef HWND Window;
// this part is included only when compiling the FLTK library or if requested explicitly
#if defined(FL_LIBRARY) || defined(FL_INTERNALS)
// In some of the distributions, the gcc header files are missing some stuff:
#ifndef LPMINMAXINFO
#define LPMINMAXINFO MINMAXINFO*
@ -45,14 +51,9 @@
#define VK_APPS 0x5D
#endif
#include <FL/Fl_Device.H>
// some random X equivalents
typedef HWND Window;
typedef POINT XPoint;
struct XRectangle {int x, y, width, height;};
typedef HRGN Fl_Region;
FL_EXPORT void fl_clip_region(Fl_Region);
extern Fl_Region XRectangleRegion(int x, int y, int w, int h);
inline void XDestroyRegion(Fl_Region r) {DeleteObject(r);}
inline void XClipBox(Fl_Region r,XRectangle* rect) {
@ -66,7 +67,7 @@ inline void XClipBox(Fl_Region r,XRectangle* rect) {
#define XMapWindow(a,b) ShowWindow(b, SW_RESTORE)
#define XUnmapWindow(a,b) ShowWindow(b, SW_HIDE)
#include "Fl_Window.H"
#include <FL/Fl_Window.H>
// this object contains all win32-specific stuff about a window:
// Warning: this object is highly subject to change!
class FL_EXPORT Fl_X {
@ -94,10 +95,17 @@ public:
};
extern FL_EXPORT HCURSOR fl_default_cursor;
extern FL_EXPORT UINT fl_wake_msg;
inline Window fl_xid(const Fl_Window*w) {Fl_X *temp = Fl_X::i(w); return temp ? temp->xid : 0;}
FL_EXPORT Fl_Window* fl_find(Window xid);
extern FL_EXPORT char fl_override_redirect; // hack into Fl_Window::make_xid()
extern FL_EXPORT int fl_background_pixel; // hack into Fl_Window::make_xid()
extern FL_EXPORT HPALETTE fl_palette; // non-zero only on 8-bit displays!
extern FL_EXPORT void fl_release_dc(HWND w, HDC dc);
extern FL_EXPORT void fl_save_dc( HWND w, HDC dc);
#endif // FL_LIBRARY || FL_INTERNALS
extern FL_EXPORT Window fl_xid(const Fl_Window*w);
FL_EXPORT Fl_Window* fl_find(Window xid);
FL_EXPORT void fl_clip_region(Fl_Region);
// most recent fl_color() or fl_rgbcolor() points at one of these:
extern FL_EXPORT struct Fl_XMap {
@ -113,19 +121,15 @@ FL_EXPORT HBRUSH fl_brush_action(int); // now does the real work
extern FL_EXPORT HINSTANCE fl_display;
extern FL_EXPORT Window fl_window;
extern FL_EXPORT HDC fl_gc;
extern FL_EXPORT HPALETTE fl_palette; // non-zero only on 8-bit displays!
extern FL_EXPORT HDC fl_GetDC(Window);
extern FL_EXPORT MSG fl_msg;
extern FL_EXPORT void fl_release_dc(HWND w, HDC dc);
extern FL_EXPORT void fl_save_dc( HWND w, HDC dc);
extern FL_EXPORT HDC fl_GetDC(Window);
extern FL_EXPORT HDC fl_makeDC(HBITMAP);
// off-screen pixmaps: create, destroy, draw into, copy to window
typedef HBITMAP Fl_Offscreen;
#define fl_create_offscreen(w, h) \
CreateCompatibleBitmap( (fl_gc ? fl_gc : fl_GetDC(0) ) , w, h)
extern FL_EXPORT HDC fl_makeDC(HBITMAP);
# define fl_begin_offscreen(b) \
HDC _sgc=fl_gc; Window _sw=fl_window; \
Fl_Surface_Device *_ss = fl_surface; fl_display_device->set_current(); \
@ -133,11 +137,11 @@ extern FL_EXPORT HDC fl_makeDC(HBITMAP);
# define fl_end_offscreen() \
fl_pop_clip(); RestoreDC(fl_gc, _savedc); DeleteDC(fl_gc); _ss->set_current(); fl_window=_sw; fl_gc = _sgc
FL_EXPORT void fl_copy_offscreen(int x,int y,int w,int h,HBITMAP pixmap,int srcx,int srcy);
FL_EXPORT void fl_copy_offscreen_with_alpha(int x,int y,int w,int h,HBITMAP pixmap,int srcx,int srcy);
#define fl_delete_offscreen(bitmap) DeleteObject(bitmap);
#define fl_delete_offscreen(bitmap) DeleteObject(bitmap)
// Bitmap masks
typedef HBITMAP Fl_Bitmask;

8
FL/x.H
View File

@ -3,7 +3,7 @@
//
// X11 header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2010 by Bill Spitzak and others.
// Copyright 1998-2011 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
@ -105,7 +105,7 @@ extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm);
#ifdef FL_LIBRARY
#if defined(FL_LIBRARY) || defined(FL_INTERNALS)
extern FL_EXPORT Window fl_message_window;
extern FL_EXPORT void *fl_xftfont;
FL_EXPORT Fl_Region XRectangleRegion(int x, int y, int w, int h); // in fl_rect.cxx
@ -138,7 +138,7 @@ extern FL_EXPORT Fl_XFont_On_Demand fl_xfont;
// this object contains all X-specific stuff about a window:
// Warning: this object is highly subject to change!
// FL_LIBRARY must be defined to access this class.
// FL_LIBRARY or FL_INTERNALS must be defined to access this class.
class FL_EXPORT Fl_X {
public:
Window xid;
@ -163,7 +163,7 @@ public:
extern FL_EXPORT char fl_override_redirect; // hack into Fl_X::make_xid()
extern FL_EXPORT int fl_background_pixel; // hack into Fl_X::make_xid()
#endif // FL_LIBRARY
#endif // FL_LIBRARY || FL_INTERNALS
// convert xid <-> Fl_Window:
Window fl_xid(const Fl_Window*w);

View File

@ -368,7 +368,7 @@ MyWindow::~MyWindow() {
}
\endcode
\note Access to the Fl_X hidden class requires to \#define FL_LIBRARY
\note Access to the Fl_X hidden class requires to \#define FL_INTERNALS
before compilation.
\subsection osissues_x_icon Setting the Icon of a Window

View File

@ -1933,6 +1933,11 @@ Fl_Region XRectangleRegion(int x, int y, int w, int h) {
return CreatePolygonRgn(pt, 4, ALTERNATE);
}
Window fl_xid(const Fl_Window *w) {
Fl_X *temp = Fl_X::i(w);
return temp ? temp->xid : 0;
}
#ifdef USE_PRINT_BUTTON
// to test the Fl_Printer class creating a "Print front window" button in a separate window
// contains also preparePrintFront call above