summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Fl.cxx15
-rw-r--r--src/Fl_Gl_Choice.H10
-rw-r--r--src/Fl_Gl_Choice.cxx23
-rw-r--r--src/Fl_Gl_Window.cxx12
-rw-r--r--src/Fl_Input_.cxx42
-rw-r--r--src/Fl_mac.cxx13
-rw-r--r--src/fl_cursor.cxx10
-rw-r--r--src/fl_dnd_mac.cxx9
-rw-r--r--src/fl_font_mac.cxx112
-rw-r--r--src/fl_font_win32.cxx7
-rw-r--r--src/fl_font_x.cxx8
-rw-r--r--src/fl_font_xft.cxx8
-rw-r--r--src/fl_read_image_mac.cxx9
-rw-r--r--src/fl_rect.cxx13
-rw-r--r--src/fl_scroll_area.cxx6
-rw-r--r--src/gl_draw.cxx23
-rw-r--r--src/gl_start.cxx8
17 files changed, 183 insertions, 145 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx
index 80129c998..00924a3f0 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl.cxx,v 1.24.2.41.2.66 2004/08/31 22:00:45 matthiaswm Exp $"
+// "$Id: Fl.cxx,v 1.24.2.41.2.67 2004/09/09 21:34:45 matthiaswm Exp $"
//
// Main event handling code for the Fast Light Tool Kit (FLTK).
//
@@ -23,6 +23,11 @@
// Please report all bugs and problems to "fltk-bugs@fltk.org".
//
+// warning: the Apple Quartz version still uses some Quickdraw calls,
+// mostly to get around the single active context in QD and
+// to implement clipping. This should be changed into pure
+// Quartz calls in the near future.
+
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/x.H>
@@ -320,7 +325,6 @@ Fl_Window* fl_find(Window xid) {
#ifdef __APPLE_QD__
if (window->xid == xid && !window->w->window()) {
#elif defined(__APPLE_QUARTZ__)
-# warning QUARTZ
if (window->xid == xid && !window->w->window()) {
#else
if (window->xid == xid) {
@@ -747,7 +751,6 @@ void Fl_Window::hide() {
if ( pc->xidChildren == ip ) pc->xidChildren = ip->xidNext;
}
#elif defined(__APPLE_QUARTZ__)
-# warning quartz
// remove all childwindow links
for ( Fl_X *pc = Fl_X::first; pc; pc = pc->next )
{
@@ -790,7 +793,6 @@ void Fl_Window::hide() {
if ( ip->xid == fl_window )
fl_window = 0;
#elif defined(__APPLE_QUARTZ__)
-# warning quartz
Fl_X::q_release_context(ip);
if ( ip->xid == fl_window )
fl_window = 0;
@@ -806,7 +808,6 @@ void Fl_Window::hide() {
XDestroyWindow(fl_display, ip->xid);
}
#elif defined(__APPLE_QUARTZ__)
-# warning quartz
if ( !parent() ) // don't destroy shared windows!
{
//+ RemoveTrackingHandler( dndTrackingHandler, ip->xid );
@@ -865,7 +866,6 @@ int Fl_Window::handle(int ev)
hide();
set_visible();
#elif defined(__APPLE_QUARTZ__)
-# warning quartz
hide();
set_visible();
#else
@@ -992,7 +992,6 @@ void Fl_Widget::damage(uchar fl, int X, int Y, int W, int H) {
UnionRgn(R, i->region, i->region);
DisposeRgn(R);
#elif defined(__APPLE_QUARTZ__)
-# warning quartz
Fl_Region R = NewRgn();
SetRectRgn(R, X, Y, X+W, Y+H);
UnionRgn(R, i->region, i->region);
@@ -1021,5 +1020,5 @@ void Fl_Window::flush() {
}
//
-// End of "$Id: Fl.cxx,v 1.24.2.41.2.66 2004/08/31 22:00:45 matthiaswm Exp $".
+// End of "$Id: Fl.cxx,v 1.24.2.41.2.67 2004/09/09 21:34:45 matthiaswm Exp $".
//
diff --git a/src/Fl_Gl_Choice.H b/src/Fl_Gl_Choice.H
index 9f1c6e19c..d06a7c23e 100644
--- a/src/Fl_Gl_Choice.H
+++ b/src/Fl_Gl_Choice.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Gl_Choice.H,v 1.4.2.6.2.4 2004/08/25 00:20:25 matthiaswm Exp $"
+// "$Id: Fl_Gl_Choice.H,v 1.4.2.6.2.5 2004/09/09 21:34:46 matthiaswm Exp $"
//
// OpenGL definitions for the Fast Light Tool Kit (FLTK).
//
@@ -62,7 +62,7 @@
# include <AGL/agl.h>
# define GLContext AGLContext
#elif defined(__APPLE_QUARTZ__)
-#warning quartz
+// warning: the Quartz version should probably use Core GL (CGL) instead of AGL
# include <OpenGL/gl.h>
# include <AGL/agl.h>
# define GLContext AGLContext
@@ -83,7 +83,7 @@ public:
#elif defined(__APPLE_QD__)
AGLPixelFormat pixelformat;
#elif defined(__APPLE_QUARTZ__)
-#warning quartz
+ // warning: the Quartz version should probably use Core GL (CGL) instead of AGL
AGLPixelFormat pixelformat;
#else
XVisualInfo *vis; // the visual to use
@@ -106,7 +106,7 @@ GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice*, int layer=0);
GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice*, int layer=0);
#elif defined(__APPLE_QUARTZ__)
-#warning quartz
+// warning: the Quartz version should probably use Core GL (CGL) instead of AGL
GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice*, int layer=0);
@@ -128,5 +128,5 @@ void fl_delete_gl_context(GLContext);
#endif
//
-// End of "$Id: Fl_Gl_Choice.H,v 1.4.2.6.2.4 2004/08/25 00:20:25 matthiaswm Exp $".
+// End of "$Id: Fl_Gl_Choice.H,v 1.4.2.6.2.5 2004/09/09 21:34:46 matthiaswm Exp $".
//
diff --git a/src/Fl_Gl_Choice.cxx b/src/Fl_Gl_Choice.cxx
index ec9f8f10b..ef86cad59 100644
--- a/src/Fl_Gl_Choice.cxx
+++ b/src/Fl_Gl_Choice.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.20 2004/08/25 00:20:25 matthiaswm Exp $"
+// "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.21 2004/09/09 21:34:46 matthiaswm Exp $"
//
// OpenGL visual selection code for the Fast Light Tool Kit (FLTK).
//
@@ -33,10 +33,7 @@
# include <FL/gl_draw.H>
# include "flstring.h"
-# ifdef __APPLE_QD__
-# include <FL/Fl_Window.H>
-# elif defined(__APPLE_QUARTZ__)
-#warning quartz
+# ifdef __APPLE__
# include <FL/Fl_Window.H>
# endif
@@ -102,7 +99,7 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) {
if (!fmt) return 0;
#elif defined(__APPLE_QUARTZ__)
-#warning quartz
+ // warning: the Quartz version should probably use Core GL (CGL) instead of AGL
const int *blist;
int list[32];
@@ -261,7 +258,7 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) {
# elif defined(__APPLE_QD__)
g->pixelformat = fmt;
# elif defined(__APPLE_QUARTZ__)
-#warning quartz
+ // warning: the Quartz version should probably use Core GL (CGL) instead of AGL
g->pixelformat = fmt;
# else
g->vis = visp;
@@ -343,8 +340,8 @@ GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int lay
return (context);
}
# elif defined(__APPLE_QUARTZ__)
-#warning quartz
-GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int layer) {
+ // warning: the Quartz version should probably use Core GL (CGL) instead of AGL
+ GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int layer) {
GLContext context, shared_ctx = context_list ? context_list[0] : 0;
context = aglCreateContext( g->pixelformat, shared_ctx);
if (!context) return 0;
@@ -389,7 +386,7 @@ void fl_set_gl_context(Fl_Window* w, GLContext context) {
aglSetDrawable(context, GetWindowPort( fl_xid(w) ) );
aglSetCurrentContext(context);
# elif defined(__APPLE_QUARTZ__)
-#warning
+ // warning: the Quartz version should probably use Core GL (CGL) instead of AGL
if ( w->parent() ) { //: resize our GL buffer rectangle
Rect wrect; GetWindowPortBounds( fl_xid(w), &wrect );
GLint rect[] = { w->x(), wrect.bottom-w->h()-w->y(), w->w(), w->h() };
@@ -412,7 +409,7 @@ void fl_no_gl_context() {
# elif defined(__APPLE_QD__)
aglSetCurrentContext(0);
# elif defined(__APPLE_QUARTZ__)
-#warning quartz
+ // warning: the Quartz version should probably use Core GL (CGL) instead of AGL
aglSetCurrentContext(0);
# else
glXMakeCurrent(fl_display, 0, 0);
@@ -428,7 +425,7 @@ void fl_delete_gl_context(GLContext context) {
aglSetDrawable( context, NULL );
aglDestroyContext( context );
# elif defined(__APPLE_QUARTZ__)
-#warning quartz
+ // warning: the Quartz version should probably use Core GL (CGL) instead of AGL
aglSetCurrentContext( NULL );
aglSetDrawable( context, NULL );
aglDestroyContext( context );
@@ -442,5 +439,5 @@ void fl_delete_gl_context(GLContext context) {
//
-// End of "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.20 2004/08/25 00:20:25 matthiaswm Exp $".
+// End of "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.21 2004/09/09 21:34:46 matthiaswm Exp $".
//
diff --git a/src/Fl_Gl_Window.cxx b/src/Fl_Gl_Window.cxx
index 96d5ca57d..6f7325c2d 100644
--- a/src/Fl_Gl_Window.cxx
+++ b/src/Fl_Gl_Window.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Gl_Window.cxx,v 1.12.2.22.2.21 2004/08/25 00:20:25 matthiaswm Exp $"
+// "$Id: Fl_Gl_Window.cxx,v 1.12.2.22.2.22 2004/09/09 21:34:46 matthiaswm Exp $"
//
// OpenGL window code for the Fast Light Tool Kit (FLTK).
//
@@ -109,7 +109,7 @@ int Fl_Gl_Window::mode(int m, const int *a) {
#elif defined(__APPLE_QD__)
redraw();
#elif defined(__APPLE_QUARTZ__)
-#warning quartz
+ // warning: the Quartz version should probably use Core GL (CGL) instead of AGL
redraw();
#else
// under X, if the visual changes we must make a new X window (yuck!):
@@ -195,7 +195,7 @@ void Fl_Gl_Window::swap_buffers() {
#elif defined(__APPLE_QD__)
aglSwapBuffers((AGLContext)context_);
#elif defined(__APPLE_QUARTZ__)
-# warning quartz
+ // warning: the Quartz version should probably use Core GL (CGL) instead of AGL
aglSwapBuffers((AGLContext)context_);
#else
glXSwapBuffers(fl_display, fl_xid(this));
@@ -219,7 +219,7 @@ void Fl_Gl_Window::flush() {
ClipRect( &rect );
SetPort( old );
#elif defined(__APPLE_QUARTZ__)
-#warning quartz
+ // warning: the Quartz version should probably use Core GL (CGL) instead of AGL
//: clear previous clipping in this shared port
GrafPtr port = GetWindowPort( fl_xid(this) );
Rect rect; SetRect( &rect, 0, 0, 0x7fff, 0x7fff );
@@ -269,7 +269,7 @@ void Fl_Gl_Window::flush() {
#ifdef __APPLE_QD__
SWAP_TYPE = COPY;
#elif defined __APPLE_QUARTZ__
-#warning quartz
+ // warning: the Quartz version should probably use Core GL (CGL) instead of AGL
SWAP_TYPE = COPY;
#else
SWAP_TYPE = UNDEFINED;
@@ -445,5 +445,5 @@ void Fl_Gl_Window::draw_overlay() {}
#endif
//
-// End of "$Id: Fl_Gl_Window.cxx,v 1.12.2.22.2.21 2004/08/25 00:20:25 matthiaswm Exp $".
+// End of "$Id: Fl_Gl_Window.cxx,v 1.12.2.22.2.22 2004/09/09 21:34:46 matthiaswm Exp $".
//
diff --git a/src/Fl_Input_.cxx b/src/Fl_Input_.cxx
index f9378f6e9..79dd91b30 100644
--- a/src/Fl_Input_.cxx
+++ b/src/Fl_Input_.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Input_.cxx,v 1.21.2.11.2.30 2004/07/27 16:02:21 easysw Exp $"
+// "$Id: Fl_Input_.cxx,v 1.21.2.11.2.31 2004/09/09 21:34:46 matthiaswm Exp $"
//
// Common input widget routines for the Fast Light Tool Kit (FLTK).
//
@@ -40,6 +40,8 @@
#define MAXBUF 1024
+extern void fl_draw(const char*, int, float, float);
+
////////////////////////////////////////////////////////////////
// Copy string p..e to the buffer, replacing characters with ^X and \nnn
@@ -222,7 +224,7 @@ void Fl_Input_::drawtext(int X, int Y, int W, int H) {
p = value();
// visit each line and draw it:
int desc = height-fl_descent();
- int xpos = X - xscroll_ + 1;
+ float xpos = X - xscroll_ + 1;
int ypos = -yscroll_;
for (; ypos < H;) {
@@ -237,19 +239,19 @@ void Fl_Input_::drawtext(int X, int Y, int W, int H) {
if (readonly()) erase_cursor_only = 0; // this isn't the most efficient way
if (erase_cursor_only && p > pp) goto CONTINUE2; // this line is after
// calculate area to erase:
- int r = X+W;
- int xx;
+ float r = X+W;
+ float xx;
if (p >= pp) {
xx = X;
if (erase_cursor_only) r = xpos+2;
else if (readonly()) xx -= 3;
} else {
- xx = xpos+(int)expandpos(p, pp, buf, 0);
+ xx = xpos+expandpos(p, pp, buf, 0);
if (erase_cursor_only) r = xx+2;
else if (readonly()) xx -= 3;
}
// clip to and erase it:
- fl_push_clip(xx, Y+ypos, r-xx, height);
+ fl_push_clip((int)xx, Y+ypos, (int)(r-xx+1), height);
draw_box(box(), X-Fl::box_dx(box()), Y-Fl::box_dy(box()),
W+Fl::box_dw(box()), H+Fl::box_dh(box()), color());
// it now draws entire line over it
@@ -260,30 +262,30 @@ void Fl_Input_::drawtext(int X, int Y, int W, int H) {
// Draw selection area if required:
if (selstart < selend && selstart <= e-value() && selend > p-value()) {
const char* pp = value()+selstart;
- int x1 = xpos;
+ float x1 = xpos;
int offset1 = 0;
if (pp > p) {
fl_color(tc);
- x1 += int(expandpos(p, pp, buf, &offset1));
- fl_draw(buf, offset1, xpos, Y+ypos+desc);
+ x1 += expandpos(p, pp, buf, &offset1);
+ fl_draw(buf, offset1, xpos, (float)(Y+ypos+desc));
}
pp = value()+selend;
- int x2 = X+W;
+ float x2 = X+W;
int offset2;
- if (pp <= e) x2 = xpos+int(expandpos(p, pp, buf, &offset2));
+ if (pp <= e) x2 = xpos+expandpos(p, pp, buf, &offset2);
else offset2 = strlen(buf);
fl_color(selection_color());
- fl_rectf(x1, Y+ypos, x2-x1, height);
+ fl_rectf((int)(x1+0.5), Y+ypos, (int)(x2-x1+0.5), height);
fl_color(fl_contrast(textcolor(), selection_color()));
- fl_draw(buf+offset1, offset2-offset1, x1, Y+ypos+desc);
+ fl_draw(buf+offset1, offset2-offset1, x1, (float)(Y+ypos+desc));
if (pp < e) {
fl_color(tc);
- fl_draw(buf+offset2, x2, Y+ypos+desc);
+ fl_draw(buf+offset2, strlen(buf+offset2), x2, (float)(Y+ypos+desc));
}
} else {
// draw unselected text
fl_color(tc);
- fl_draw(buf, xpos, Y+ypos+desc);
+ fl_draw(buf, strlen(buf), xpos, (float)(Y+ypos+desc));
}
if (do_mu) fl_pop_clip();
@@ -294,11 +296,11 @@ void Fl_Input_::drawtext(int X, int Y, int W, int H) {
position() >= p-value() && position() <= e-value()) {
fl_color(cursor_color());
if (readonly()) {
- fl_line(xpos+curx-3, Y+ypos+height-1,
- xpos+curx, Y+ypos+height-4,
- xpos+curx+3, Y+ypos+height-1);
+ fl_line((int)(xpos+curx-2.5f), Y+ypos+height-1,
+ (int)(xpos+curx+0.5f), Y+ypos+height-4,
+ (int)(xpos+curx+3.5f), Y+ypos+height-1);
} else {
- fl_rectf(xpos+curx, Y+ypos, 2, height);
+ fl_rectf((int)(xpos+curx+0.5), Y+ypos, 2, height);
}
}
@@ -855,5 +857,5 @@ Fl_Input_::~Fl_Input_() {
}
//
-// End of "$Id: Fl_Input_.cxx,v 1.21.2.11.2.30 2004/07/27 16:02:21 easysw Exp $".
+// End of "$Id: Fl_Input_.cxx,v 1.21.2.11.2.31 2004/09/09 21:34:46 matthiaswm Exp $".
//
diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx
index 07a80e392..faf6dde4c 100644
--- a/src/Fl_mac.cxx
+++ b/src/Fl_mac.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_mac.cxx,v 1.1.2.63 2004/08/31 22:00:48 matthiaswm Exp $"
+// "$Id: Fl_mac.cxx,v 1.1.2.64 2004/09/09 21:34:46 matthiaswm Exp $"
//
// MacOS specific code for the Fast Light Tool Kit (FLTK).
//
@@ -36,6 +36,10 @@
// One Compile to copy them all and in the bundle bind them,
// in the Land of MacOS X where the Drop-Shadows lie.
+// warning: the Apple Quartz version still uses some Quickdraw calls,
+// mostly to get around the single active context in QD and
+// to implement clipping. This should be changed into pure
+// Quartz calls in the near future.
// we don't need the following definition because we deliver only
// true mouse moves. On very slow systems however, this flag may
@@ -56,10 +60,6 @@ extern "C" {
#include "flstring.h"
#include <unistd.h>
-#ifdef __APPLE_QUARTZ__
-#warning quartz
-#endif
-
// #define DEBUG_SELECT // UNCOMMENT FOR SELECT()/THREAD DEBUGGING
#ifdef DEBUG_SELECT
#include <stdio.h> // testing
@@ -1867,7 +1867,6 @@ void Fl_Window::make_current()
fl_clip_region( 0 );
SetPortClipRegion( GetWindowPort(i->xid), fl_window_region );
#ifdef __APPLE_QUARTZ__
-#warning : bracket all the QD stuff above with ifdefs!
QDBeginCGContext(GetWindowPort(i->xid), &i->gc);
fl_gc = i->gc;
CGContextSaveGState(fl_gc);
@@ -2014,6 +2013,6 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) {
//
-// End of "$Id: Fl_mac.cxx,v 1.1.2.63 2004/08/31 22:00:48 matthiaswm Exp $".
+// End of "$Id: Fl_mac.cxx,v 1.1.2.64 2004/09/09 21:34:46 matthiaswm Exp $".
//
diff --git a/src/fl_cursor.cxx b/src/fl_cursor.cxx
index 1de6684fc..9bfdc6268 100644
--- a/src/fl_cursor.cxx
+++ b/src/fl_cursor.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_cursor.cxx,v 1.6.2.6.2.11 2004/08/25 00:20:27 matthiaswm Exp $"
+// "$Id: fl_cursor.cxx,v 1.6.2.6.2.12 2004/09/09 21:34:46 matthiaswm Exp $"
//
// Mouse cursor support for the Fast Light Tool Kit (FLTK).
//
@@ -109,9 +109,9 @@ void Fl_Window::cursor(Fl_Cursor c, Fl_Color, Fl_Color) {
}
#elif defined(__APPLE__)
-#ifdef __APPLE_QUARTZ__
-#warning are cursor shaped handled in Quickdraw/Quartz or in Carbon?
-#endif
+
+// warning: this function is only implemented in Quickdraw. The function
+// below may not work If FLTK is compiled with Quartz enabled
static Cursor crsrHAND =
{
@@ -315,5 +315,5 @@ void Fl_Window::cursor(Fl_Cursor c, Fl_Color fg, Fl_Color bg) {
#endif
//
-// End of "$Id: fl_cursor.cxx,v 1.6.2.6.2.11 2004/08/25 00:20:27 matthiaswm Exp $".
+// End of "$Id: fl_cursor.cxx,v 1.6.2.6.2.12 2004/09/09 21:34:46 matthiaswm Exp $".
//
diff --git a/src/fl_dnd_mac.cxx b/src/fl_dnd_mac.cxx
index 05fc5a82c..257540be9 100644
--- a/src/fl_dnd_mac.cxx
+++ b/src/fl_dnd_mac.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_dnd_mac.cxx,v 1.1.2.6 2004/08/25 00:20:27 matthiaswm Exp $"
+// "$Id: fl_dnd_mac.cxx,v 1.1.2.7 2004/09/09 21:34:47 matthiaswm Exp $"
//
// Drag & Drop code for the Fast Light Tool Kit (FLTK).
//
@@ -31,9 +31,8 @@
#include <FL/x.H>
#include <FL/Fl_Window.H>
-#ifdef __APPLE_QUARTZ__
-#warning quartz
-#endif
+// warning: this function is only implemented in Quickdraw. The function
+// below may not work If FLTK is compiled with Quartz enabled
extern EventRef fl_os_event;
extern char *fl_selection_buffer;
@@ -85,5 +84,5 @@ int Fl::dnd()
//
-// End of "$Id: fl_dnd_mac.cxx,v 1.1.2.6 2004/08/25 00:20:27 matthiaswm Exp $".
+// End of "$Id: fl_dnd_mac.cxx,v 1.1.2.7 2004/09/09 21:34:47 matthiaswm Exp $".
//
diff --git a/src/fl_font_mac.cxx b/src/fl_font_mac.cxx
index 5ddf479f0..eabe3d189 100644
--- a/src/fl_font_mac.cxx
+++ b/src/fl_font_mac.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_font_mac.cxx,v 1.1.2.21 2004/09/09 00:55:41 matthiaswm Exp $"
+// "$Id: fl_font_mac.cxx,v 1.1.2.22 2004/09/09 21:34:47 matthiaswm Exp $"
//
// MacOS font selection routines for the Fast Light Tool Kit (FLTK).
//
@@ -32,6 +32,10 @@
//: SetFractEnable
Fl_FontSize::Fl_FontSize(const char* name, int Size) {
+ next = 0;
+# if HAVE_GL
+ listbase = 0;
+# endif
#ifdef __APPLE_QD__
knowMetrics = 0;
switch (*name++) {
@@ -49,9 +53,6 @@ Fl_FontSize::Fl_FontSize(const char* name, int Size) {
ascent = fOut->ascent; //: the following three lines give only temporary aproimations
descent = fOut->descent;
for (int i=0; i<256; i++) width[i] = fOut->widMax;
-#if HAVE_GL
- listbase = 0;
-#endif
minsize = maxsize = size;
#elif defined(__APPLE_QUARTZ__)
q_name = strdup(name);
@@ -200,37 +201,6 @@ int fl_descent() {
else return -1;
}
-// TODO: the text has to be translated according to the macroman_lut to give
-// the correct result!
-double fl_width(const char* c, int n) {
-#ifdef __APPLE_QD__
- return (double)TextWidth( c, 0, n );
-#else
- if (!fl_gc) {
- Fl_Window *w = Fl::first_window();
- if (w) w->make_current();
- if (!fl_gc) return -1;
- }
- // according to the Apple developer docs, this is the correct way to
- // find the length of a rendered text...
- CGContextSetTextPosition(fl_gc, 0, 0);
- CGContextSetTextDrawingMode(fl_gc, kCGTextInvisible);
- CGContextShowText(fl_gc, c, n);
- CGContextSetTextDrawingMode(fl_gc, kCGTextFill);
- CGPoint p = CGContextGetTextPosition(fl_gc);
- return p.x;
-#endif
-}
-
-// todo : fl_width returns wrong results for OS X
-double fl_width(uchar c) {
-#ifdef __APPLE_QD__
- return (double)TextWidth( &c, 0, 1 );
-#else
- return fl_width((const char*)&c, 1);
-#endif
-}
-
// MRS: The default character set is MacRoman, which is different from
// ISO-8859-1; in FLTK 2.0 we'll use UTF-8 with Quartz...
@@ -253,30 +223,78 @@ static uchar macroman_lut[256] = {
240, 150, 152, 151, 153, 155, 154, 214, 191, 157, 156, 158, 159, 253, 254, 216
};
-void fl_draw(const char* str, int n, int x, int y) {
- int i; // Looping var
- uchar buf[1024], // Temporary buffer
- *bufptr; // Pointer into buffer
+static char *iso_buf = 0;
+static int n_iso_buf = 0;
+
+// this function must be available for OpenGL character drawing as well
+const char *fl_iso2macRoman(const char *s, int n) {
+ if (n>n_iso_buf) {
+ if (iso_buf) free(iso_buf);
+ iso_buf = (char*)malloc(n+500);
+ n_iso_buf = n;
+ }
+ uchar *src = (uchar*)s;
+ uchar *dst = (uchar*)iso_buf;
+ for (;n--;) {
+ *dst++ = macroman_lut[*src++];
+ }
+ return iso_buf;
+}
+double fl_width(const char* c, int n) {
+#ifdef __APPLE_QD__
+ return (double)TextWidth( c, 0, n );
+#else
+ if (!fl_gc) {
+ Fl_Window *w = Fl::first_window();
+ if (w) w->make_current();
+ if (!fl_gc) return -1;
+ }
+ const char *txt = fl_iso2macRoman(c, n);
+ // according to the Apple developer docs, this is the correct way to
+ // find the length of a rendered text...
+ CGContextSetTextPosition(fl_gc, 0, 0);
+ CGContextSetTextDrawingMode(fl_gc, kCGTextInvisible);
+ CGContextShowText(fl_gc, txt, n);
+ CGContextSetTextDrawingMode(fl_gc, kCGTextFill);
+ CGPoint p = CGContextGetTextPosition(fl_gc);
+ return p.x;
+#endif
+}
+
+double fl_width(uchar c) {
+#ifdef __APPLE_QD__
+ return (double)TextWidth((const char*)(macroman_lut + c), 0, 1 );
+#else
+ return fl_width((const char*)(&c), 1);
+#endif
+}
- // First convert string to MacRoman encoding...
- if (n > (int)sizeof(buf))
- n = (int)sizeof(buf);
+void fl_draw(const char *str, int n, float x, float y);
- for (i = n, bufptr = buf; i > 0; i --)
- *bufptr++ = macroman_lut[*str++ & 255];
+void fl_draw(const char* str, int n, int x, int y) {
#ifdef __APPLE_QD__
- // Then draw it...
+ const char *txt = fl_iso2macRoman(str, n);
MoveTo(x, y);
DrawText((const char *)buf, 0, n);
#elif defined(__APPLE_QUARTZ__)
- CGContextShowTextAtPoint(fl_gc, (float)x, (float)y, (const char*)buf, n);
+ fl_draw(str, n, (float)x, (float)y);
#else
# error : neither Quartz no Quickdraw chosen
#endif
}
+void fl_draw(const char *str, int n, float x, float y) {
+#ifdef __APPLE_QD__
+ fl_draw(str, n, (int)x, (int)y);
+#elif defined(__APPLE_QUARTZ__)
+ const char *txt = fl_iso2macRoman(str, n);
+ CGContextShowTextAtPoint(fl_gc, x, y, txt, n);
+#else
+# error : neither Quartz no Quickdraw chosen
+#endif
+}
//
-// End of "$Id: fl_font_mac.cxx,v 1.1.2.21 2004/09/09 00:55:41 matthiaswm Exp $".
+// End of "$Id: fl_font_mac.cxx,v 1.1.2.22 2004/09/09 21:34:47 matthiaswm Exp $".
//
diff --git a/src/fl_font_win32.cxx b/src/fl_font_win32.cxx
index a9b5dbcb7..de344289a 100644
--- a/src/fl_font_win32.cxx
+++ b/src/fl_font_win32.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_font_win32.cxx,v 1.9.2.3.2.7 2004/09/07 20:59:17 easysw Exp $"
+// "$Id: fl_font_win32.cxx,v 1.9.2.3.2.8 2004/09/09 21:34:47 matthiaswm Exp $"
//
// WIN32 font selection routines for the Fast Light Tool Kit (FLTK).
//
@@ -158,7 +158,10 @@ void fl_draw(const char* str, int n, int x, int y) {
SetTextColor(fl_gc, oldColor);
}
+void fl_draw(const char* str, int n, float x, float y) {
+ return fl_draw(str, n, (int)x, (int)y);
+}
//
-// End of "$Id: fl_font_win32.cxx,v 1.9.2.3.2.7 2004/09/07 20:59:17 easysw Exp $".
+// End of "$Id: fl_font_win32.cxx,v 1.9.2.3.2.8 2004/09/09 21:34:47 matthiaswm Exp $".
//
diff --git a/src/fl_font_x.cxx b/src/fl_font_x.cxx
index 0c87ba536..4dd3b783b 100644
--- a/src/fl_font_x.cxx
+++ b/src/fl_font_x.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_font_x.cxx,v 1.10.2.6 2004/09/07 20:59:17 easysw Exp $"
+// "$Id: fl_font_x.cxx,v 1.10.2.7 2004/09/09 21:34:47 matthiaswm Exp $"
//
// Standard X11 font selection code for the Fast Light Tool Kit (FLTK).
//
@@ -252,7 +252,11 @@ void fl_draw(const char* str, int n, int x, int y) {
}
XDrawString(fl_display, fl_window, fl_gc, x, y, str, n);
}
+
+void fl_draw(const char* str, int n, float x, float y) {
+ return fl_draw(str, n, (int)x, (int)y);
+}
//
-// End of "$Id: fl_font_x.cxx,v 1.10.2.6 2004/09/07 20:59:17 easysw Exp $".
+// End of "$Id: fl_font_x.cxx,v 1.10.2.7 2004/09/09 21:34:47 matthiaswm Exp $".
//
diff --git a/src/fl_font_xft.cxx b/src/fl_font_xft.cxx
index 227583546..a37e4868c 100644
--- a/src/fl_font_xft.cxx
+++ b/src/fl_font_xft.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_font_xft.cxx,v 1.4.2.14 2004/09/07 20:59:18 easysw Exp $"
+// "$Id: fl_font_xft.cxx,v 1.4.2.15 2004/09/09 21:34:47 matthiaswm Exp $"
//
// Xft font code for the Fast Light Tool Kit (FLTK).
//
@@ -254,6 +254,10 @@ void fl_draw(const char *str, int n, int x, int y) {
XftDrawString8(draw, &color, current_font, x, y, (XftChar8 *)str, n);
}
+void fl_draw(const char* str, int n, float x, float y) {
+ return fl_draw(str, n, (int)x, (int)y);
+}
+
//
-// End of "$Id: fl_font_xft.cxx,v 1.4.2.14 2004/09/07 20:59:18 easysw Exp $"
+// End of "$Id: fl_font_xft.cxx,v 1.4.2.15 2004/09/09 21:34:47 matthiaswm Exp $"
//
diff --git a/src/fl_read_image_mac.cxx b/src/fl_read_image_mac.cxx
index dd57096dd..4c3202476 100644
--- a/src/fl_read_image_mac.cxx
+++ b/src/fl_read_image_mac.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_read_image_mac.cxx,v 1.1.2.6 2004/08/25 00:20:27 matthiaswm Exp $"
+// "$Id: fl_read_image_mac.cxx,v 1.1.2.7 2004/09/09 21:34:47 matthiaswm Exp $"
//
// WIN32 image reading routines for the Fast Light Tool Kit (FLTK).
//
@@ -25,9 +25,8 @@
#include <config.h>
-#ifdef __APPLE_QUARTZ__
-#warning quartz
-#endif
+// warning: this function is only implemented in Quickdraw. The function
+// below may not work If FLTK is compiled with Quartz enabled
//
// 'fl_read_image()' - Read an image from the current window.
@@ -122,5 +121,5 @@ fl_read_image(uchar *p, // I - Pixel buffer or NULL to allocate
//
-// End of "$Id: fl_read_image_mac.cxx,v 1.1.2.6 2004/08/25 00:20:27 matthiaswm Exp $".
+// End of "$Id: fl_read_image_mac.cxx,v 1.1.2.7 2004/09/09 21:34:47 matthiaswm Exp $".
//
diff --git a/src/fl_rect.cxx b/src/fl_rect.cxx
index 2a19f8fa0..5353ea0ad 100644
--- a/src/fl_rect.cxx
+++ b/src/fl_rect.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_rect.cxx,v 1.10.2.4.2.17 2004/08/31 22:00:48 matthiaswm Exp $"
+// "$Id: fl_rect.cxx,v 1.10.2.4.2.18 2004/09/09 21:34:47 matthiaswm Exp $"
//
// Rectangle drawing routines for the Fast Light Tool Kit (FLTK).
//
@@ -432,7 +432,9 @@ Fl_Region XRectangleRegion(int x, int y, int w, int h) {
#ifdef __APPLE_QD__
extern Fl_Region fl_window_region;
#elif defined(__APPLE_QUARTZ__)
-#warning quartz
+// warning: the Quartz implementation currently uses Quickdraw calls to achieve
+// clipping. A future version should instead use 'CGContectClipToRect'
+// and friends.
extern Fl_Region fl_window_region;
#endif
@@ -464,7 +466,6 @@ void fl_restore_clip() {
}
# endif
#elif defined(__APPLE_QUARTZ__)
-#warning quartz
if ( fl_window )
{
GrafPtr port = GetWindowPort( fl_window );
@@ -511,7 +512,6 @@ void fl_push_clip(int x, int y, int w, int h) {
#elif defined(__APPLE_QD__)
SectRgn(r, current, r);
#elif defined(__APPLE_QUARTZ__)
-#warning quartz
SectRgn(r, current, r);
#else
Fl_Region temp = XCreateRegion();
@@ -527,7 +527,6 @@ void fl_push_clip(int x, int y, int w, int h) {
r = NewRgn();
SetEmptyRgn(r);
#elif defined(__APPLE_QUARTZ__)
-#warning quartz
r = NewRgn();
SetEmptyRgn(r);
#else
@@ -569,7 +568,6 @@ int fl_not_clipped(int x, int y, int w, int h) {
rect.left = x; rect.top = y; rect.right = x+w; rect.bottom = y+h;
return RectInRgn(&rect, r);
#elif defined(__APPLE_QUARTZ__)
-#warning quartz
if (!r) return 1;
Rect rect;
rect.left = x; rect.top = y; rect.right = x+w; rect.bottom = y+h;
@@ -620,7 +618,6 @@ int fl_clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){
if ( h==H && w==W ) return 0;
return 0;
#elif defined(__APPLE_QUARTZ__)
-#warning quartz
RgnHandle rr = NewRgn();
SetRectRgn( rr, x, y, x+w, y+h );
SectRgn( r, rr, rr );
@@ -656,5 +653,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.17 2004/08/31 22:00:48 matthiaswm Exp $".
+// End of "$Id: fl_rect.cxx,v 1.10.2.4.2.18 2004/09/09 21:34:47 matthiaswm Exp $".
//
diff --git a/src/fl_scroll_area.cxx b/src/fl_scroll_area.cxx
index b6a4a1ccc..d4c2f3d82 100644
--- a/src/fl_scroll_area.cxx
+++ b/src/fl_scroll_area.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_scroll_area.cxx,v 1.4.2.3.2.7 2004/08/25 00:20:27 matthiaswm Exp $"
+// "$Id: fl_scroll_area.cxx,v 1.4.2.3.2.8 2004/09/09 21:34:48 matthiaswm Exp $"
//
// Scrolling routines for the Fast Light Tool Kit (FLTK).
//
@@ -111,7 +111,7 @@ void fl_scroll(int X, int Y, int W, int H, int dx, int dy,
CopyBits( GetPortBitMapForCopyBits( GetWindowPort(fl_window) ),
GetPortBitMapForCopyBits( GetWindowPort(fl_window) ), &src, &dst, srcCopy, 0L);
#elif defined(__APPLE_QUARTZ__)
-#warning
+ // warning: there does not seem to be an equivalent to this function in Quartz
Rect src = { src_y, src_x, src_y+src_h, src_x+src_w };
Rect dst = { dest_y, dest_x, dest_y+src_h, dest_x+src_w };
static RGBColor bg = { 0xffff, 0xffff, 0xffff }; RGBBackColor( &bg );
@@ -136,5 +136,5 @@ void fl_scroll(int X, int Y, int W, int H, int dx, int dy,
}
//
-// End of "$Id: fl_scroll_area.cxx,v 1.4.2.3.2.7 2004/08/25 00:20:27 matthiaswm Exp $".
+// End of "$Id: fl_scroll_area.cxx,v 1.4.2.3.2.8 2004/09/09 21:34:48 matthiaswm Exp $".
//
diff --git a/src/gl_draw.cxx b/src/gl_draw.cxx
index cf8a870c9..fbf43cb7d 100644
--- a/src/gl_draw.cxx
+++ b/src/gl_draw.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: gl_draw.cxx,v 1.7.2.5.2.16 2004/08/31 22:00:49 matthiaswm Exp $"
+// "$Id: gl_draw.cxx,v 1.7.2.5.2.17 2004/09/09 21:34:48 matthiaswm Exp $"
//
// OpenGL drawing support routines for the Fast Light Tool Kit (FLTK).
//
@@ -62,7 +62,16 @@ void gl_font(int fontid, int size) {
aglUseFont(aglGetCurrentContext(), fl_fontsize->font, fl_fontsize->face,
fl_fontsize->size, 0, 256, fl_fontsize->listbase);
#elif defined(__APPLE_QUARTZ__)
-#warning quartz : add ATS font calls!
+ short font, face, size;
+ uchar fn[256];
+ fn[0]=strlen(fl_fontsize->q_name);
+ strcpy((char*)(fn+1), fl_fontsize->q_name);
+ GetFNum(fn, &font);
+ face = 0;
+ size = fl_fontsize->size;
+ fl_fontsize->listbase = glGenLists(256);
+ aglUseFont(aglGetCurrentContext(), font, face,
+ size, 0, 256, fl_fontsize->listbase);
#else
# if USE_XFT
fl_xfont = fl_xxfont();
@@ -116,9 +125,17 @@ void gl_remove_displaylist_fonts()
#endif
}
+#ifdef __APPLE__
+const char *fl_iso2macRoman(const char*, int);
+#endif
void gl_draw(const char* str, int n) {
+#ifdef __APPLE__
+ const char *txt = fl_iso2macRoman(str, n);
+ glCallLists(n, GL_UNSIGNED_BYTE, txt);
+#else
glCallLists(n, GL_UNSIGNED_BYTE, str);
+#endif
}
void gl_draw(const char* str, int n, int x, int y) {
@@ -209,5 +226,5 @@ void gl_draw_image(const uchar* b, int x, int y, int w, int h, int d, int ld) {
#endif
//
-// End of "$Id: gl_draw.cxx,v 1.7.2.5.2.16 2004/08/31 22:00:49 matthiaswm Exp $".
+// End of "$Id: gl_draw.cxx,v 1.7.2.5.2.17 2004/09/09 21:34:48 matthiaswm Exp $".
//
diff --git a/src/gl_start.cxx b/src/gl_start.cxx
index 2cff9a4e8..95d02a01f 100644
--- a/src/gl_start.cxx
+++ b/src/gl_start.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: gl_start.cxx,v 1.6.2.5.2.10 2004/08/25 00:20:27 matthiaswm Exp $"
+// "$Id: gl_start.cxx,v 1.6.2.5.2.11 2004/09/09 21:34:48 matthiaswm Exp $"
//
// OpenGL context routines for the Fast Light Tool Kit (FLTK).
//
@@ -69,7 +69,7 @@ void gl_start() {
// \todo Mac : We need to check the code and verify it with Apple Sample code. The 'shiny'-test should at least work with the software OpenGL emulator
context = fl_create_gl_context(Fl_Window::current(), gl_choice);
#elif defined(__APPLE_QUARTZ__)
-#warning quartz
+ // warning: the Quartz version should probably use Core GL (CGL) instead of AGL
context = fl_create_gl_context(Fl_Window::current(), gl_choice);
#else
context = fl_create_gl_context(fl_visual);
@@ -116,7 +116,7 @@ int Fl::gl_visual(int mode, int *alist) {
#elif defined(__APPLE_QD__)
gl_choice = c;
#elif defined(__APPLE_QUARTZ__)
-#warning
+ // warning: the Quartz version should probably use Core GL (CGL) instead of AGL
gl_choice = c;
#else
fl_visual = c->vis;
@@ -128,5 +128,5 @@ int Fl::gl_visual(int mode, int *alist) {
#endif
//
-// End of "$Id: gl_start.cxx,v 1.6.2.5.2.10 2004/08/25 00:20:27 matthiaswm Exp $".
+// End of "$Id: gl_start.cxx,v 1.6.2.5.2.11 2004/09/09 21:34:48 matthiaswm Exp $".
//