Mac OS: more accurate definition of the Window system-specific type.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9170 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
4fbc766422
commit
409afd29cc
7
FL/mac.H
7
FL/mac.H
@ -25,7 +25,12 @@
|
||||
# error "Never use <FL/mac.H> directly; include <FL/x.H> instead."
|
||||
#endif // !Fl_X_H
|
||||
|
||||
typedef void* Window; // this is really a pointer to the subclass FLWindow of NSWindow
|
||||
#ifdef __OBJC__
|
||||
@class FLWindow; // a subclass of the NSWindow Cocoa class
|
||||
typedef FLWindow *Window;
|
||||
#else
|
||||
typedef class FLWindow_opaque *Window; // pointer to the FLWindow objective-c class
|
||||
#endif // __OBJC__
|
||||
|
||||
#if !(defined(FL_LIBRARY) || defined(FL_INTERNALS)) // this part is used when compiling an application program
|
||||
# include <FL/Fl_Widget.H>
|
||||
|
||||
@ -1028,7 +1028,7 @@ void fl_open_callback(void (*cb)(const char *)) {
|
||||
w = Fl::next_window(w);
|
||||
}
|
||||
if (w) {
|
||||
[(FLWindow*)Fl_X::i(w)->xid makeKeyWindow];
|
||||
[Fl_X::i(w)->xid makeKeyWindow];
|
||||
}
|
||||
}
|
||||
fl_unlock_function();
|
||||
@ -1059,7 +1059,7 @@ void fl_open_callback(void (*cb)(const char *)) {
|
||||
Fl_X *x;
|
||||
FLWindow *top = 0, *topModal = 0, *topNonModal = 0;
|
||||
for (x = Fl_X::first;x;x = x->next) {
|
||||
FLWindow *cw = (FLWindow*)x->xid;
|
||||
FLWindow *cw = x->xid;
|
||||
Fl_Window *win = x->w;
|
||||
if (win && cw && [cw isVisible]) {
|
||||
if (win->modal()) {
|
||||
@ -1107,7 +1107,7 @@ void fl_open_callback(void (*cb)(const char *)) {
|
||||
FLWindow *top = 0;
|
||||
// sort in all regular windows
|
||||
for (x = Fl_X::first;x;x = x->next) {
|
||||
FLWindow *cw = (FLWindow*)x->xid;
|
||||
FLWindow *cw = x->xid;
|
||||
Fl_Window *win = x->w;
|
||||
if (win && cw) {
|
||||
if (win->modal()) {
|
||||
@ -1119,7 +1119,7 @@ void fl_open_callback(void (*cb)(const char *)) {
|
||||
}
|
||||
// now sort in all modals
|
||||
for (x = Fl_X::first;x;x = x->next) {
|
||||
FLWindow *cw = (FLWindow*)x->xid;
|
||||
FLWindow *cw = x->xid;
|
||||
Fl_Window *win = x->w;
|
||||
if (win && cw && [cw isVisible]) {
|
||||
if (win->modal()) {
|
||||
@ -1130,7 +1130,7 @@ void fl_open_callback(void (*cb)(const char *)) {
|
||||
}
|
||||
// finally all non-modals
|
||||
for (x = Fl_X::first;x;x = x->next) {
|
||||
FLWindow *cw = (FLWindow*)x->xid;
|
||||
FLWindow *cw = x->xid;
|
||||
Fl_Window *win = x->w;
|
||||
if (win && cw && [cw isVisible]) {
|
||||
if (win->non_modal()) {
|
||||
@ -1991,7 +1991,7 @@ void Fl_X::make(Fl_Window* w)
|
||||
}
|
||||
if (w->as_gl_window()) { // if creating a sub-GL-window
|
||||
while (win->window()) win = win->window();
|
||||
[(FLWindow*)Fl_X::i(win)->xid setContainsGLsubwindow:YES];
|
||||
[Fl_X::i(win)->xid setContainsGLsubwindow:YES];
|
||||
}
|
||||
fl_show_iconic = 0;
|
||||
}
|
||||
@ -2153,8 +2153,8 @@ void Fl_Window::size_range_() {
|
||||
NSSize minSize = { minw, minh + bt };
|
||||
NSSize maxSize = { maxw?maxw:32000, maxh?maxh + bt:32000 };
|
||||
if (i && i->xid) {
|
||||
[(NSWindow*)i->xid setMinSize:minSize];
|
||||
[(NSWindow*)i->xid setMaxSize:maxSize];
|
||||
[i->xid setMinSize:minSize];
|
||||
[i->xid setMaxSize:maxSize];
|
||||
}
|
||||
}
|
||||
|
||||
@ -2187,8 +2187,7 @@ void Fl_Window::label(const char *name, const char *mininame) {
|
||||
Fl_Widget::label(name);
|
||||
iconlabel_ = mininame;
|
||||
if (shown() || i) {
|
||||
NSWindow* nsw = (NSWindow*)i->xid;
|
||||
q_set_window_title(nsw, name, mininame);
|
||||
q_set_window_title(i->xid, name, mininame);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2209,12 +2208,12 @@ void Fl_Window::show() {
|
||||
Fl_X::make(this);
|
||||
} else {
|
||||
if ( !parent() ) {
|
||||
if ([(NSWindow*)i->xid isMiniaturized]) {
|
||||
if ([i->xid isMiniaturized]) {
|
||||
i->w->redraw();
|
||||
[(NSWindow*)i->xid deminiaturize:nil];
|
||||
[i->xid deminiaturize:nil];
|
||||
}
|
||||
if (!fl_capture) {
|
||||
[(NSWindow*)i->xid makeKeyAndOrderFront:nil];
|
||||
[i->xid makeKeyAndOrderFront:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2251,12 +2250,12 @@ void Fl_Window::resize(int X,int Y,int W,int H) {
|
||||
dim.origin.y = main_screen_height - (Y + H);
|
||||
dim.size.width = W;
|
||||
dim.size.height = H + bt;
|
||||
[(NSWindow*)i->xid setFrame:dim display:YES];
|
||||
[i->xid setFrame:dim display:YES];
|
||||
} else {
|
||||
NSPoint pt;
|
||||
pt.x = X;
|
||||
pt.y = main_screen_height - (Y + h());
|
||||
[(NSWindow*)i->xid setFrameOrigin:pt];
|
||||
[i->xid setFrameOrigin:pt];
|
||||
}
|
||||
}
|
||||
resize_from_system = 0;
|
||||
@ -2293,7 +2292,7 @@ void Fl_Window::make_current()
|
||||
NSView *current_focus = [NSView focusView];
|
||||
// sometimes current_focus is set to a non-FLTK view: don't touch that
|
||||
if ( [current_focus isKindOfClass:[FLView class]] ) [current_focus unlockFocus];
|
||||
[[(NSWindow*)i->xid contentView] lockFocus];
|
||||
[[i->xid contentView] lockFocus];
|
||||
i->gc = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
|
||||
fl_gc = i->gc;
|
||||
Fl_Region fl_window_region = XRectangleRegion(0,0,w(),h());
|
||||
@ -2310,7 +2309,7 @@ void Fl_Window::make_current()
|
||||
// and escapes even clipping!!!
|
||||
// it gets activated when needed (e.g., draw text)
|
||||
CGContextSetShouldAntialias(fl_gc, false);
|
||||
CGFloat hgt = [[(NSWindow*)fl_window contentView] frame].size.height;
|
||||
CGFloat hgt = [[fl_window contentView] frame].size.height;
|
||||
CGContextTranslateCTM(fl_gc, 0.5, hgt-0.5f);
|
||||
CGContextScaleCTM(fl_gc, 1.0f, -1.0f); // now 0,0 is top-left point of the window
|
||||
win = this;
|
||||
@ -2637,18 +2636,18 @@ void Fl_X::relink(Fl_Window *w, Fl_Window *wp) {
|
||||
void Fl_X::destroy() {
|
||||
// subwindows share their xid with their parent window, so should not close it
|
||||
if (!subwindow && w && !w->parent() && xid) {
|
||||
NSView *topview = [(NSWindow *)xid contentView];
|
||||
NSView *topview = [xid contentView];
|
||||
if ( [NSView focusView] == topview ) {
|
||||
[topview unlockFocus];
|
||||
}
|
||||
[topview release];
|
||||
[(NSWindow *)xid close];
|
||||
[xid close];
|
||||
}
|
||||
}
|
||||
|
||||
void Fl_X::map() {
|
||||
if (w && xid) {
|
||||
[(NSWindow *)xid orderFront:nil];
|
||||
[xid orderFront:nil];
|
||||
}
|
||||
//+ link to window list
|
||||
if (w && w->parent()) {
|
||||
@ -2659,7 +2658,7 @@ void Fl_X::map() {
|
||||
|
||||
void Fl_X::unmap() {
|
||||
if (w && !w->parent() && xid) {
|
||||
[(NSWindow *)xid orderOut:nil];
|
||||
[xid orderOut:nil];
|
||||
}
|
||||
if (w && Fl_X::i(w))
|
||||
Fl_X::i(w)->unlink();
|
||||
@ -2737,7 +2736,7 @@ Fl_Region Fl_X::intersect_region_and_rect(Fl_Region current, int x,int y,int w,
|
||||
}
|
||||
|
||||
void Fl_X::collapse() {
|
||||
[(NSWindow *)xid miniaturize:nil];
|
||||
[xid miniaturize:nil];
|
||||
}
|
||||
|
||||
static NSImage *CGBitmapContextToNSImage(CGContextRef c)
|
||||
@ -3184,7 +3183,7 @@ void *Fl_Sys_Menu_Bar::doMenuOrItemOperation(Fl_Sys_Menu_Bar::menuOrItemOperatio
|
||||
|
||||
void Fl_X::set_key_window()
|
||||
{
|
||||
[(NSWindow*)xid makeKeyWindow];
|
||||
[xid makeKeyWindow];
|
||||
}
|
||||
|
||||
static NSImage *imageFromText(const char *text, int *pwidth, int *pheight)
|
||||
@ -3268,7 +3267,7 @@ int Fl::dnd(void)
|
||||
} else {
|
||||
while(win->window()) win = win->window();
|
||||
}
|
||||
NSView *myview = [(NSWindow*)Fl_X::i(win)->xid contentView];
|
||||
NSView *myview = [Fl_X::i(win)->xid contentView];
|
||||
NSEvent *theEvent = [NSApp currentEvent];
|
||||
|
||||
int width, height;
|
||||
@ -3356,7 +3355,7 @@ CGImageRef Fl_X::CGImage_from_window_rect(Fl_Window *win, int x, int y, int w, i
|
||||
|
||||
WindowRef Fl_X::window_ref()
|
||||
{
|
||||
return (WindowRef)[(FLWindow*)xid windowRef];
|
||||
return (WindowRef)[xid windowRef];
|
||||
}
|
||||
|
||||
// so a CGRect matches exactly what is denoted x,y,w,h for clipping purposes
|
||||
|
||||
Loading…
Reference in New Issue
Block a user