Implement Fl_Window::make_current() under the driver model.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11393 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
ec0b695709
commit
9ba3889ae5
@ -73,6 +73,7 @@ public:
|
||||
virtual void draw_begin();
|
||||
virtual void draw_end();
|
||||
void draw();
|
||||
virtual void make_current();
|
||||
|
||||
virtual Fl_X *makeWindow() { /* FIXME: move Fl_X::make(Fl_Window*) here for OSX, MSWin, and X11 */ return 0; }
|
||||
virtual void wait_for_expose() {} // TODO: check
|
||||
|
@ -32,6 +32,8 @@
|
||||
|
||||
char *Fl_Window::default_xclass_ = 0L;
|
||||
|
||||
Fl_Window *Fl_Window::current_;
|
||||
|
||||
void Fl_Window::_Fl_Window() {
|
||||
cursor_default = FL_CURSOR_DEFAULT;
|
||||
type(FL_WINDOW);
|
||||
@ -479,7 +481,11 @@ void Fl_Window::draw()
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
void Fl_Window::make_current()
|
||||
{
|
||||
pWindowDriver->make_current();
|
||||
current_ = this;
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
|
@ -42,6 +42,7 @@ unsigned char Fl_Window_Driver::size_range_set() {return pWindow->size_range_set
|
||||
|
||||
void Fl_Window_Driver::flush_single() { pWindow->Fl_Window::flush(); }
|
||||
void Fl_Window_Driver::draw() { pWindow->draw(); }
|
||||
void Fl_Window_Driver::make_current() { }
|
||||
|
||||
|
||||
void Fl_Window_Driver::take_focus()
|
||||
|
@ -94,7 +94,6 @@ void *fl_capture = 0; // (NSWindow*) we need this to compensate for a missing(
|
||||
bool fl_show_iconic; // true if called from iconize() - shows the next created window in collapsed state
|
||||
//int fl_disable_transient_for; // secret method of removing TRANSIENT_FOR
|
||||
Window fl_window;
|
||||
Fl_Window *Fl_Window::current_;
|
||||
|
||||
// forward declarations of variables in this file
|
||||
static int got_events = 0;
|
||||
@ -3266,14 +3265,14 @@ void Fl_Window::resize(int X,int Y,int W,int H) {
|
||||
Subsequent drawing requests go to this window. CAUTION: it's not possible to call Fl::wait(),
|
||||
Fl::check() nor Fl::ready() while in the draw() function of a widget. Use an idle callback instead.
|
||||
*/
|
||||
void Fl_Window::make_current()
|
||||
void Fl_Cocoa_Window_Driver::make_current()
|
||||
{
|
||||
if (make_current_counts > 1) return;
|
||||
if (make_current_counts) make_current_counts++;
|
||||
Fl_X::q_release_context();
|
||||
Fl_X *i = Fl_X::i(pWindow);
|
||||
fl_window = i->xid;
|
||||
Fl_X::set_high_resolution( i->mapped_to_retina() );
|
||||
current_ = this;
|
||||
|
||||
NSGraphicsContext *nsgc;
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
@ -3299,13 +3298,13 @@ void Fl_Window::make_current()
|
||||
// this is the context with origin at top left of (sub)window
|
||||
CGContextSaveGState(i->gc);
|
||||
#if defined(FLTK_USE_CAIRO)
|
||||
if (Fl::cairo_autolink_context()) Fl::cairo_make_current(this); // capture gc changes automatically to update the cairo context adequately
|
||||
if (Fl::cairo_autolink_context()) Fl::cairo_make_current(pWindow); // capture gc changes automatically to update the cairo context adequately
|
||||
#endif
|
||||
fl_clip_region( 0 );
|
||||
|
||||
#if defined(FLTK_USE_CAIRO)
|
||||
// update the cairo_t context
|
||||
if (Fl::cairo_autolink_context()) Fl::cairo_make_current(this);
|
||||
if (Fl::cairo_autolink_context()) Fl::cairo_make_current(pWindow);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -4274,11 +4273,6 @@ CGImageRef Fl_X::CGImage_from_window_rect(Fl_Window *win, int x, int y, int w, i
|
||||
return img;
|
||||
}
|
||||
|
||||
WindowRef Fl_X::window_ref() // useless with cocoa GL windows
|
||||
{
|
||||
return (WindowRef)[xid windowRef];
|
||||
}
|
||||
|
||||
// so a CGRect matches exactly what is denoted x,y,w,h for clipping purposes
|
||||
CGRect fl_cgrectmake_cocoa(int x, int y, int w, int h) {
|
||||
return CGRectMake(x - 0.5, y - 0.5, w, h);
|
||||
|
@ -2361,7 +2361,6 @@ void Fl_Window::show() {
|
||||
#endif
|
||||
}
|
||||
|
||||
Fl_Window *Fl_Window::current_;
|
||||
// the current context
|
||||
// the current window handle, initially set to -1 so we can correctly
|
||||
// allocate fl_GetDC(0)
|
||||
@ -2385,24 +2384,6 @@ HDC fl_GetDC(HWND w) {
|
||||
return gc;
|
||||
}
|
||||
|
||||
// make X drawing go into this window (called by subclass flush() impl.)
|
||||
void Fl_Window::make_current() {
|
||||
fl_GetDC(fl_xid(this));
|
||||
|
||||
#if USE_COLORMAP
|
||||
// Windows maintains a hardware and software color palette; the
|
||||
// SelectPalette() call updates the current soft->hard mapping
|
||||
// for all drawing calls, so we must select it here before any
|
||||
// code does any drawing...
|
||||
|
||||
fl_select_palette();
|
||||
#endif // USE_COLORMAP
|
||||
|
||||
current_ = this;
|
||||
fl_clip_region(0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* Make sure that all allocated fonts are released. This works only if
|
||||
Fl::run() is allowed to exit by closing all windows. Calling 'exit(int)'
|
||||
|
18
src/Fl_x.cxx
18
src/Fl_x.cxx
@ -2927,24 +2927,6 @@ preparePrintFront();
|
||||
#endif
|
||||
}
|
||||
|
||||
Window fl_window;
|
||||
Fl_Window *Fl_Window::current_;
|
||||
|
||||
// make X drawing go into this window (called by subclass flush() impl.)
|
||||
void Fl_Window::make_current() {
|
||||
if (!shown()) {
|
||||
fl_alert("Fl_Window::make_current(), but window is not shown().");
|
||||
Fl::fatal("Fl_Window::make_current(), but window is not shown().");
|
||||
}
|
||||
fl_window = i->xid;
|
||||
current_ = this;
|
||||
fl_clip_region(0);
|
||||
|
||||
#ifdef FLTK_USE_CAIRO
|
||||
// update the cairo_t context
|
||||
if (Fl::cairo_autolink_context()) Fl::cairo_make_current(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
FL_EXPORT Window fl_xid_(const Fl_Window *w) {
|
||||
Fl_X *temp = Fl_X::i(w);
|
||||
|
@ -73,6 +73,7 @@ public:
|
||||
virtual void flush_overlay();
|
||||
virtual void draw_begin();
|
||||
virtual void draw_end();
|
||||
virtual void make_current();
|
||||
|
||||
virtual void shape(const Fl_Image* img);
|
||||
// that one is implemented in Fl_Cocoa.mm because it uses Objective-c
|
||||
|
@ -76,6 +76,7 @@ public:
|
||||
virtual void flush_double();
|
||||
virtual void flush_overlay();
|
||||
virtual void draw_begin();
|
||||
virtual void make_current();
|
||||
|
||||
virtual void shape(const Fl_Image* img);
|
||||
virtual void icons(const Fl_RGB_Image *icons[], int count);
|
||||
|
@ -29,6 +29,11 @@
|
||||
#include "Fl_WinAPI_Window_Driver.H"
|
||||
#include <windows.h>
|
||||
|
||||
#if USE_COLORMAP
|
||||
extern HPALETTE fl_select_palette(void); // in fl_color_win32.cxx
|
||||
#endif
|
||||
|
||||
|
||||
Fl_Window_Driver *Fl_Window_Driver::newWindowDriver(Fl_Window *w)
|
||||
{
|
||||
return new Fl_WinAPI_Window_Driver(w);
|
||||
@ -374,6 +379,21 @@ void Fl_WinAPI_Window_Driver::wait_for_expose() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Fl_WinAPI_Window_Driver::make_current() {
|
||||
fl_GetDC(fl_xid(pWindow));
|
||||
|
||||
#if USE_COLORMAP
|
||||
// Windows maintains a hardware and software color palette; the
|
||||
// SelectPalette() call updates the current soft->hard mapping
|
||||
// for all drawing calls, so we must select it here before any
|
||||
// code does any drawing...
|
||||
fl_select_palette();
|
||||
#endif // USE_COLORMAP
|
||||
|
||||
fl_graphics_driver->clip_region(0);
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
@ -81,6 +81,7 @@ public:
|
||||
virtual void flush_double();
|
||||
virtual void flush_overlay();
|
||||
virtual void draw_begin();
|
||||
virtual void make_current();
|
||||
|
||||
virtual void shape(const Fl_Image* img);
|
||||
virtual void icons(const Fl_RGB_Image *icons[], int count);
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <FL/Fl_Shared_Image.H>
|
||||
#include <FL/Fl_Overlay_Window.H>
|
||||
#include <FL/fl_draw.H>
|
||||
#include <FL/fl_ask.H>
|
||||
#include <FL/Fl.H>
|
||||
#include <string.h>
|
||||
#if HAVE_DLFCN_H
|
||||
@ -31,6 +32,9 @@
|
||||
#define ShapeBounding 0
|
||||
#define ShapeSet 0
|
||||
|
||||
Window fl_window;
|
||||
|
||||
|
||||
#if USE_XDBE
|
||||
#include <X11/extensions/Xdbe.h>
|
||||
|
||||
@ -422,6 +426,23 @@ void Fl_X11_Window_Driver::wait_for_expose() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// make X drawing go into this window (called by subclass flush() impl.)
|
||||
void Fl_X11_Window_Driver::make_current() {
|
||||
if (!pWindow->shown()) {
|
||||
fl_alert("Fl_Window::make_current(), but window is not shown().");
|
||||
Fl::fatal("Fl_Window::make_current(), but window is not shown().");
|
||||
}
|
||||
fl_window = fl_xid(pWindow);
|
||||
fl_graphics_driver->clip_region(0);
|
||||
|
||||
#ifdef FLTK_USE_CAIRO
|
||||
// update the cairo_t context
|
||||
if (Fl::cairo_autolink_context()) Fl::cairo_make_current(pWindow);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user