Skip to content

Commit

Permalink
OS X: removed all Carbon and Quickdraw references. Starting with 1.3,…
Browse files Browse the repository at this point in the history
… we only support Cocoa and Quartz.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7351 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Matthias Melcher committed Mar 29, 2010
1 parent b77071a commit 941901e
Show file tree
Hide file tree
Showing 31 changed files with 111 additions and 1,127 deletions.
37 changes: 0 additions & 37 deletions FL/Fl_Native_File_Chooser_MAC.H
Expand Up @@ -57,20 +57,10 @@ public:
NEW_FOLDER = 0x0002, // Show 'New Folder' icon (if supported)
PREVIEW = 0x0004, // enable preview mode
};
#ifndef __APPLE_COCOA__
protected:
NavDialogCreationOptions _opts; // file navigation options
#endif
private:
int _btype; // kind-of browser to show()
int _options; // general options
#ifdef __APPLE_COCOA__
void *_panel;
#else
NavDialogRef _ref; // file navigation reference
NavActionState _keepstate; // holds button permissions
NavMenuItemSpec _tempitem; // Popup menu selection
#endif
char **_pathnames; // array of pathnames
int _tpathnames; // total pathnames
char *_directory; // default pathname to use
Expand All @@ -92,41 +82,14 @@ private:
int _filt_value; // index of the selected filter
char *_errmsg; // error message

#ifndef __APPLE_COCOA__
// PRIVATE CLASS TO HANDLE NAVIGATION DIALOG REPLY STRUCT
// Class-ified, mainly to ensure proper cleanup.
//
class NavReply {
int _valid_reply;
NavReplyRecord _reply;
public:
NavReply();
~NavReply();
int get_reply(NavDialogRef& ref);
int get_saveas_basename(char *s, int slen);
int get_dirname(char *s, int slen);
int get_pathnames(char **&pathnames, int& tpathnames);
};
#endif
// Private methods
void errmsg(const char *msg);
void clear_pathnames();
void set_single_pathname(const char *s);
#ifdef __APPLE_COCOA__
int get_saveas_basename(void);
#else
int get_saveas_basename(NavDialogRef& ref);
int get_pathnames(NavDialogRef& ref);
static void event_handler(NavEventCallbackMessage callBackSelector,
NavCBRecPtr cbparm, void *data);
#endif
void clear_filters();
void add_filter(const char *, const char *);
void parse_filter(const char *from);
#ifndef __APPLE_COCOA__
static Boolean filter_proc_cb(AEDesc *, void *, void *, NavFilterModes);
Boolean filter_proc_cb2(AEDesc*, void*, void*, NavFilterModes);
#endif
int post();

public:
Expand Down
2 changes: 0 additions & 2 deletions FL/Fl_Sys_Menu_Bar.H
Expand Up @@ -53,7 +53,6 @@ public:
fl_sys_menu_bar = this;
}
void menu(const Fl_Menu_Item *m);
#if defined(__APPLE_COCOA__) || defined(FL_DOXYGEN)
int add(const char* label, int shortcut, Fl_Callback*, void *user_data=0, int flags=0);
void remove(int n);
void replace(int rank, const char *name);
Expand All @@ -63,7 +62,6 @@ public:
// function doMenuOrItemOperation is in file Fl_cocoa.mm because it contains objective-c code
static void *doMenuOrItemOperation( menuOrItemOperation operation, ...);
#endif
#endif
};

#else
Expand Down
33 changes: 0 additions & 33 deletions FL/mac.H
Expand Up @@ -72,8 +72,6 @@ typedef float CGFloat;
struct XPoint { int x, y; };
struct XRectangle {int x, y, width, height;};

#ifdef __APPLE_COCOA__

typedef void *Window; // this is really a pter to the subclass FLWindow of NSWindow
typedef struct flCocoaRegion {
int count;
Expand All @@ -99,25 +97,6 @@ extern void *fl_system_menu;
typedef CGContextRef Fl_Offscreen;
typedef CGImageRef Fl_Bitmask;

#else

typedef WindowRef Window;
typedef RgnHandle Fl_Region;
inline Fl_Region XRectangleRegion(int x, int y, int w, int h) {
Fl_Region R = NewRgn();
SetRectRgn(R, x, y, x+w, y+h);
return R;
}
inline void XDestroyRegion(Fl_Region r) {
DisposeRgn(r);
}
extern CursHandle fl_default_cursor;
extern Handle fl_system_menu;
typedef GWorldPtr Fl_Offscreen;
typedef GWorldPtr Fl_Bitmask; // Carbon requires a 1-bit GWorld instead of a BitMap

#endif

void fl_clip_region(Fl_Region);

# include "Fl_Window.H"
Expand All @@ -135,11 +114,7 @@ public:
Fl_X *next; // linked tree to support subwindows
Fl_X *xidChildren, *xidNext; // more subwindow tree
int wait_for_expose;
#ifdef __APPLE_COCOA__
void *cursor; // is really NSCursor*
#else
CursHandle cursor;
#endif
static Fl_X* first;
static Fl_X* i(const Fl_Window* w) {return w->i;}
static int fake_X_wm(const Fl_Window*,int&,int&,int&,int&,int&);
Expand All @@ -154,18 +129,12 @@ public:
static void q_end_image();
};

#ifdef __APPLE_COCOA__
extern void MacDestroyWindow(Fl_Window*,void *);
extern void MacMapWindow(Fl_Window*,void *);
extern void MacUnmapWindow(Fl_Window*,void *);
extern WindowRef MACwindowRef(Fl_Window *w);
extern Fl_Region MacRectRegionIntersect(Fl_Region current, int x,int y,int w, int h);
extern void MacCollapseWindow(Window w);
#else
extern void MacDestroyWindow(Fl_Window*,WindowPtr);
extern void MacMapWindow(Fl_Window*,WindowPtr);
extern void MacUnmapWindow(Fl_Window*,WindowPtr);
#endif

extern int MacUnlinkWindow(Fl_X*,Fl_X*start=0L);

Expand Down Expand Up @@ -204,7 +173,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);
#endif // FL_DOXYGEN

#if defined(__APPLE_COCOA__) || defined(FL_DOXYGEN)
/** \defgroup group_macosx Mac OS X-specific functions
@{ */

Expand All @@ -219,7 +187,6 @@ extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b)
*/
extern void fl_mac_set_about( Fl_Callback *cb, void *user_data, int shortcut = 0);
/** @} */
#endif

//
// End of "$Id$".
Expand Down
43 changes: 10 additions & 33 deletions src/Fl.cxx
Expand Up @@ -410,16 +410,12 @@ double Fl::wait(double time_to_wait) {
// the idle function may turn off idle, we can then wait:
if (idle) time_to_wait = 0.0;
}
#ifdef __APPLE_COCOA__
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
#endif
flush();
if (idle && !in_idle) // 'idle' may have been set within flush()
time_to_wait = 0.0;
double retval = fl_wait(time_to_wait);
#ifdef __APPLE_COCOA__
[pool release];
#endif
return retval;

#else
Expand Down Expand Up @@ -1290,11 +1286,7 @@ int Fl_Window::handle(int ev)
#if defined(USE_X11) || defined(WIN32)
XMapWindow(fl_display, fl_xid(this)); // extra map calls are harmless
#elif defined(__APPLE_QUARTZ__)
#ifdef __APPLE_COCOA__
MacMapWindow(this, i->xid);
#else
MacMapWindow(this, fl_xid(this));
#endif
MacMapWindow(this, i->xid);
#else
# error unsupported platform
#endif // __APPLE__
Expand All @@ -1316,11 +1308,7 @@ int Fl_Window::handle(int ev)
#if defined(USE_X11) || defined(WIN32)
XUnmapWindow(fl_display, fl_xid(this));
#elif defined(__APPLE_QUARTZ__)
#ifdef __APPLE_COCOA__
MacUnmapWindow(this, i->xid);
#else
MacUnmapWindow(this, fl_xid(this));
#endif
#else
# error platform unsupported
#endif
Expand Down Expand Up @@ -1473,22 +1461,15 @@ void Fl_Widget::damage(uchar fl, int X, int Y, int W, int H) {
CombineRgn(i->region, i->region, R, RGN_OR);
XDestroyRegion(R);
#elif defined(__APPLE_QUARTZ__)
#ifdef __APPLE_COCOA__
CGRect arg = fl_cgrectmake_cocoa(X, Y, W, H);
int j; // don't add a rectangle totally inside the Fl_Region
for(j = 0; j < i->region->count; j++) {
if(CGRectContainsRect(i->region->rects[j], arg)) break;
}
if( j >= i->region->count) {
i->region->rects = (CGRect*)realloc(i->region->rects, (++(i->region->count)) * sizeof(CGRect));
i->region->rects[i->region->count - 1] = arg;
}
#else
Fl_Region R = NewRgn();
SetRectRgn(R, X, Y, X+W, Y+H);
UnionRgn(R, i->region, i->region);
DisposeRgn(R);
#endif
CGRect arg = fl_cgrectmake_cocoa(X, Y, W, H);
int j; // don't add a rectangle totally inside the Fl_Region
for(j = 0; j < i->region->count; j++) {
if(CGRectContainsRect(i->region->rects[j], arg)) break;
}
if( j >= i->region->count) {
i->region->rects = (CGRect*)realloc(i->region->rects, (++(i->region->count)) * sizeof(CGRect));
i->region->rects[i->region->count - 1] = arg;
}
#else
# error unsupported platform
#endif
Expand All @@ -1512,11 +1493,7 @@ void Fl_Window::flush() {
#ifdef WIN32
# include "Fl_win32.cxx"
#elif defined(__APPLE__)
#ifdef __APPLE_COCOA__
# include "Fl_cocoa.mm"
#else
# include "Fl_mac.cxx"
#endif
#endif

//
Expand Down
42 changes: 13 additions & 29 deletions src/Fl_Bitmap.cxx
Expand Up @@ -40,6 +40,8 @@
#include "flstring.h"

#if defined(__APPLE_QUARTZ__)


Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *array) {
static uchar reverse[16] = /* Bit reversal lookup table */
{ 0x00, 0x88, 0x44, 0xcc, 0x22, 0xaa, 0x66, 0xee,
Expand All @@ -58,7 +60,11 @@ Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *array) {
void fl_delete_bitmask(Fl_Bitmask bm) {
if (bm) CGImageRelease((CGImageRef)bm);
}


#elif defined(WIN32) // Windows bitmask functions...


// 'fl_create_bitmap()' - Create a 1-bit bitmap for drawing...
static Fl_Bitmask fl_create_bitmap(int w, int h, const uchar *data) {
// we need to pad the lines out to words & swap the bits
Expand Down Expand Up @@ -146,39 +152,15 @@ Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data) {
return bm;
}

#if 0 // This doesn't appear to be used anywhere...
Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data, int for_mask) {
// we need to pad the lines out to words & swap the bits
// in each byte.
int w1 = (w+7)/8;
int w2 = ((w+15)/16)*2;
uchar* newarray = new uchar[w2*h];
const uchar* src = data;
uchar* dest = newarray;
Fl_Bitmask bm;
static uchar reverse[16] = /* Bit reversal lookup table */
{ 0x00, 0x88, 0x44, 0xcc, 0x22, 0xaa, 0x66, 0xee,
0x11, 0x99, 0x55, 0xdd, 0x33, 0xbb, 0x77, 0xff };

for (int y=0; y < h; y++) {
for (int n = 0; n < w1; n++, src++)
*dest++ = (reverse[*src & 0x0f] & 0xf0) |
(reverse[(*src >> 4) & 0x0f] & 0x0f);
dest += w2-w1;
}

bm = CreateBitmap(w, h, 1, 1, newarray);

delete[] newarray;

return bm;
}
# endif // 0

void fl_delete_bitmask(Fl_Bitmask bm) {
DeleteObject((HGDIOBJ)bm);
}


#else // X11 bitmask functions


Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data) {
return XCreateBitmapFromData(fl_display, fl_window, (const char *)data,
(w+7)&-8, h);
Expand All @@ -187,6 +169,8 @@ Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data) {
void fl_delete_bitmask(Fl_Bitmask bm) {
fl_delete_offscreen((Fl_Offscreen)bm);
}


#endif // __APPLE__


Expand Down Expand Up @@ -368,7 +352,7 @@ Fl_Bitmap::~Fl_Bitmap() {

void Fl_Bitmap::uncache() {
if (id_) {
#if defined(__APPLE__) && defined(__APPLE_COCOA__)
#ifdef __APPLE_COCOA__
fl_delete_bitmask((Fl_Bitmask)id_);
#else
fl_delete_bitmask((Fl_Offscreen)id_);
Expand Down
10 changes: 2 additions & 8 deletions src/Fl_Font.H
Expand Up @@ -58,18 +58,12 @@ public:
TEXTMETRIC metr;
int angle;
FL_EXPORT Fl_Font_Descriptor(const char* fontname, Fl_Fontsize size);
# elif defined(__APPLE_QD__)
FL_EXPORT Fl_Font_Descriptor(const char* fontname, Fl_Fontsize size);
short font, face, size;
short ascent, descent;
short width[256];
bool knowMetrics;
# elif defined(__APPLE_QUARTZ__)
FL_EXPORT Fl_Font_Descriptor(const char* fontname, Fl_Fontsize size);
ATSUTextLayout layout;
#if defined(__APPLE_COCOA__) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
CTFontRef fontref;
#endif
# endif
ATSUStyle style;
short ascent, descent, q_width;
// short width[256];
Expand Down
10 changes: 0 additions & 10 deletions src/Fl_Gl_Choice.H
Expand Up @@ -57,10 +57,6 @@
#ifdef WIN32
# include <FL/gl.h>
# define GLContext HGLRC
#elif defined(__APPLE_QD__)
# include <OpenGL/gl.h>
# include <AGL/agl.h>
# define GLContext AGLContext
#elif defined(__APPLE_QUARTZ__)
// warning: the Quartz version should probably use Core GL (CGL) instead of AGL
# include <OpenGL/gl.h>
Expand All @@ -80,8 +76,6 @@ public:
#ifdef WIN32
int pixelformat; // the visual to use
PIXELFORMATDESCRIPTOR pfd; // some wgl calls need this thing
#elif defined(__APPLE_QD__)
AGLPixelFormat pixelformat;
#elif defined(__APPLE_QUARTZ__)
// warning: the Quartz version should probably use Core GL (CGL) instead of AGL
AGLPixelFormat pixelformat;
Expand All @@ -101,10 +95,6 @@ class Fl_Window;

GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice*, int layer=0);

#elif defined(__APPLE_QD__)

GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice*, int layer=0);

#elif defined(__APPLE_QUARTZ__)
// warning: the Quartz version should probably use Core GL (CGL) instead of AGL

Expand Down

0 comments on commit 941901e

Please sign in to comment.