Quartz:
- made multiple contexts for windows, popups and menus work - still missing: double buffer handling git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3793 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
93798e2f83
commit
bc704ad62f
10
FL/mac.H
10
FL/mac.H
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: mac.H,v 1.1.2.12 2004/08/26 00:18:41 matthiaswm Exp $"
|
||||
// "$Id: mac.H,v 1.1.2.13 2004/08/27 20:02:43 matthiaswm Exp $"
|
||||
//
|
||||
// Mac header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -65,7 +65,6 @@ class Fl_X
|
||||
public:
|
||||
Window xid; // Mac WindowPtr
|
||||
GWorldPtr other_xid; // pointer for offscreen bitmaps (doublebuffer)
|
||||
CGContextRef gc; // Quartz: graphics context (NULL when using QD)
|
||||
Fl_Window *w; // FLTK window for
|
||||
Fl_Region region;
|
||||
Fl_Region subRegion; // region for this specific subwindow
|
||||
@ -78,6 +77,11 @@ public:
|
||||
static int fake_X_wm(const Fl_Window*,int&,int&,int&,int&,int&);
|
||||
static void make(Fl_Window*);
|
||||
void flush();
|
||||
// Quartz additions:
|
||||
CGContextRef gc; // graphics context (NULL when using QD)
|
||||
static void q_fill_context(); // fill a Quartz context with current FLTK state
|
||||
static void q_clear_clipping(); // remove all clipping from a Quartz context
|
||||
static void q_release_context(Fl_X *x=0); // free all resources associated with fl_gc
|
||||
};
|
||||
|
||||
inline Window fl_xid(const Fl_Window*w)
|
||||
@ -120,6 +124,6 @@ extern void fl_open_callback(void (*cb)(const char *));
|
||||
extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
|
||||
|
||||
//
|
||||
// End of "$Id: mac.H,v 1.1.2.12 2004/08/26 00:18:41 matthiaswm Exp $".
|
||||
// End of "$Id: mac.H,v 1.1.2.13 2004/08/27 20:02:43 matthiaswm Exp $".
|
||||
//
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl.cxx,v 1.24.2.41.2.64 2004/08/26 00:18:42 matthiaswm Exp $"
|
||||
// "$Id: Fl.cxx,v 1.24.2.41.2.65 2004/08/27 20:02:44 matthiaswm Exp $"
|
||||
//
|
||||
// Main event handling code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -798,6 +798,7 @@ void Fl_Window::hide() {
|
||||
fl_window = 0;
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
# warning quartz
|
||||
Fl_X::q_release_context(ip);
|
||||
if ( ip->xid == fl_window )
|
||||
fl_window = 0;
|
||||
#else
|
||||
@ -1027,5 +1028,5 @@ void Fl_Window::flush() {
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl.cxx,v 1.24.2.41.2.64 2004/08/26 00:18:42 matthiaswm Exp $".
|
||||
// End of "$Id: Fl.cxx,v 1.24.2.41.2.65 2004/08/27 20:02:44 matthiaswm Exp $".
|
||||
//
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_mac.cxx,v 1.1.2.60 2004/08/26 22:24:23 matthiaswm Exp $"
|
||||
// "$Id: Fl_mac.cxx,v 1.1.2.61 2004/08/27 20:02:44 matthiaswm Exp $"
|
||||
//
|
||||
// MacOS specific code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -1820,6 +1820,9 @@ void Fl_Window::resize(int X,int Y,int W,int H) {
|
||||
*/
|
||||
void Fl_Window::make_current()
|
||||
{
|
||||
#ifdef __APPLE_QUARTZ__
|
||||
Fl_X::q_release_context();
|
||||
#endif
|
||||
if ( !fl_window_region )
|
||||
fl_window_region = NewRgn();
|
||||
fl_window = i->xid;
|
||||
@ -1857,14 +1860,13 @@ void Fl_Window::make_current()
|
||||
#ifdef __APPLE_QUARTZ__
|
||||
#warning : bracket all the QD stuff above with ifdefs!
|
||||
#warning : verbose copy of patch; please check code
|
||||
#if 0
|
||||
Rect portRect;
|
||||
GetPortBounds(GetWindowPort(i->xid), &portRect);
|
||||
short port_height = portRect.bottom - portRect.top;
|
||||
if (!i->gc) {
|
||||
//CreateCGContextForPort(GetWindowPort(i->xid), &i->gc);
|
||||
QDBeginCGContext(GetWindowPort(i->xid), &i->gc);
|
||||
#warning : line capping should not be set. Check AA settings to make this work
|
||||
CGContextSetLineCap(i->gc, kCGLineCapSquare);
|
||||
// save the unclipped state for later
|
||||
CGContextSaveGState(i->gc);
|
||||
// translate coordinate system to coorespond with fltk's.
|
||||
@ -1874,10 +1876,55 @@ void Fl_Window::make_current()
|
||||
CGContextSetTextMatrix(i->gc, font_mx);
|
||||
}
|
||||
fl_gc = i->gc;
|
||||
#else
|
||||
QDBeginCGContext(GetWindowPort(i->xid), &i->gc);
|
||||
fl_gc = i->gc;
|
||||
CGContextSaveGState(fl_gc);
|
||||
Fl_X::q_fill_context();
|
||||
#endif
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// helper function to manage the current CGContext fl_gc
|
||||
#ifdef __APPLE_QUARTZ__
|
||||
extern Fl_Color fl_color_;
|
||||
extern class Fl_FontSize *fl_fontsize;
|
||||
extern void fl_font(class Fl_FontSize*);
|
||||
|
||||
// FLTK has only on global graphics state. This function copies the FLTK state into the
|
||||
// current Quartz context
|
||||
void Fl_X::q_fill_context() {
|
||||
if (!fl_gc) return;
|
||||
Rect portRect;
|
||||
GetPortBounds(GetWindowPort( fl_window ), &portRect);
|
||||
CGContextTranslateCTM(fl_gc, 0.5, portRect.bottom-portRect.top-0.5f);
|
||||
CGContextScaleCTM(fl_gc, 1.0f, -1.0f);
|
||||
static CGAffineTransform font_mx = { 1, 0, 0, -1, 0, 0 };
|
||||
CGContextSetTextMatrix(fl_gc, font_mx);
|
||||
fl_font(fl_fontsize);
|
||||
fl_color(fl_color_);
|
||||
}
|
||||
|
||||
// The only way to reste clipping to its original state is to pop the current graphics
|
||||
// state and restore the global state.
|
||||
void Fl_X::q_clear_clipping() {
|
||||
if (!fl_gc) return;
|
||||
CGContextRestoreGState(fl_gc);
|
||||
CGContextSaveGState(fl_gc);
|
||||
}
|
||||
|
||||
// Give the Quartz context back to the system
|
||||
void Fl_X::q_release_context(Fl_X *x) {
|
||||
if (x && x->gc!=fl_gc) return;
|
||||
if (!fl_gc) return;
|
||||
CGContextRestoreGState(fl_gc);
|
||||
QDEndCGContext(GetWindowPort(fl_window), &fl_gc);
|
||||
fl_gc = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Cut & paste.
|
||||
|
||||
@ -1950,6 +1997,6 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) {
|
||||
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_mac.cxx,v 1.1.2.60 2004/08/26 22:24:23 matthiaswm Exp $".
|
||||
// End of "$Id: Fl_mac.cxx,v 1.1.2.61 2004/08/27 20:02:44 matthiaswm Exp $".
|
||||
//
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: fl_color_mac.cxx,v 1.1.2.8 2004/08/26 00:18:43 matthiaswm Exp $"
|
||||
// "$Id: fl_color_mac.cxx,v 1.1.2.9 2004/08/27 20:02:44 matthiaswm Exp $"
|
||||
//
|
||||
// MacOS color functions for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -71,6 +71,7 @@ void fl_color(Fl_Color i) {
|
||||
rgb.blue = (b<<8)|b;
|
||||
RGBForeColor(&rgb);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
if (!fl_gc) return; // no context yet? We will assign the color later.
|
||||
float fr = r/255.0f;
|
||||
float fg = g/255.0f;
|
||||
float fb = b/255.0f;
|
||||
@ -107,5 +108,5 @@ void Fl::set_color(Fl_Color i, unsigned c) {
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: fl_color_mac.cxx,v 1.1.2.8 2004/08/26 00:18:43 matthiaswm Exp $".
|
||||
// End of "$Id: fl_color_mac.cxx,v 1.1.2.9 2004/08/27 20:02:44 matthiaswm Exp $".
|
||||
//
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: fl_font_mac.cxx,v 1.1.2.18 2004/08/26 06:18:12 matthiaswm Exp $"
|
||||
// "$Id: fl_font_mac.cxx,v 1.1.2.19 2004/08/27 20:02:45 matthiaswm Exp $"
|
||||
//
|
||||
// MacOS font selection routines for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -131,6 +131,7 @@ void fl_font(Fl_FontSize* s) {
|
||||
}
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
if (!s) return;
|
||||
if (!fl_gc) return; // no worries, we will assign the font to the context later
|
||||
CGContextSelectFont(fl_gc, s->q_name, (float)s->size, kCGEncodingMacRoman);
|
||||
#else
|
||||
# error : need to defined either Quartz or Quickdraw
|
||||
@ -225,5 +226,5 @@ void fl_draw(const char* str, int n, int x, int y) {
|
||||
|
||||
|
||||
//
|
||||
// End of "$Id: fl_font_mac.cxx,v 1.1.2.18 2004/08/26 06:18:12 matthiaswm Exp $".
|
||||
// End of "$Id: fl_font_mac.cxx,v 1.1.2.19 2004/08/27 20:02:45 matthiaswm Exp $".
|
||||
//
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: fl_rect.cxx,v 1.10.2.4.2.15 2004/08/26 22:24:24 matthiaswm Exp $"
|
||||
// "$Id: fl_rect.cxx,v 1.10.2.4.2.16 2004/08/27 20:02:45 matthiaswm Exp $"
|
||||
//
|
||||
// Rectangle drawing routines for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -429,9 +429,6 @@ extern Fl_Region fl_window_region;
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
#warning quartz
|
||||
extern Fl_Region fl_window_region;
|
||||
extern Fl_Color fl_color_;
|
||||
extern class Fl_FontSize *fl_fontsize;
|
||||
extern void fl_font(class Fl_FontSize*);
|
||||
#endif
|
||||
|
||||
// undo any clobbering of clip done by your program:
|
||||
@ -472,17 +469,9 @@ void fl_restore_clip() {
|
||||
if ( r )
|
||||
SectRgn( portClip, r, portClip );
|
||||
Rect portRect; GetPortBounds(port, &portRect);
|
||||
// remove all clipping
|
||||
# warning : Quartz will now destroy all font, color and line settings
|
||||
CGContextRestoreGState(fl_gc);
|
||||
// get rid of the following call for performance reasons
|
||||
Fl_X::q_clear_clipping();
|
||||
ClipCGContextToRegion(fl_gc, &portRect, portClip );
|
||||
// restore settings lost by "Restore"
|
||||
CGContextSaveGState(fl_gc);
|
||||
CGContextTranslateCTM(fl_gc, 0.5, portRect.bottom-portRect.top-0.5f);
|
||||
CGContextScaleCTM(fl_gc, 1.0f, -1.0f);
|
||||
fl_font(fl_fontsize);
|
||||
fl_color(fl_color_);
|
||||
Fl_X::q_fill_context();
|
||||
DisposeRgn( portClip );
|
||||
}
|
||||
}
|
||||
@ -662,5 +651,5 @@ int fl_clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: fl_rect.cxx,v 1.10.2.4.2.15 2004/08/26 22:24:24 matthiaswm Exp $".
|
||||
// End of "$Id: fl_rect.cxx,v 1.10.2.4.2.16 2004/08/27 20:02:45 matthiaswm Exp $".
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user