diff options
| author | Manolo Gouy <Manolo> | 2014-10-23 09:04:30 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2014-10-23 09:04:30 +0000 |
| commit | 69d5e00ce4b6c789873125f42fe942554cd3295a (patch) | |
| tree | 86980ecccc7e635b4592c619aca1477a9da6050c | |
| parent | a6878f94ef10e0f9f38711b6f1807b314effd2c6 (diff) | |
Fixed printing of window title bar buttons under Mac OS X 10.10
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10389 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | src/Fl_cocoa.mm | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index fee2ed45a..76cda2292 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -3946,6 +3946,7 @@ int Fl_Window::decorated_h() void Fl_Paged_Device::print_window(Fl_Window *win, int x_offset, int y_offset) { + NSButton *close, *miniaturize, *zoom; if (!win->shown() || win->parent() || !win->border() || !win->visible()) { this->print_widget(win, x_offset, y_offset); return; @@ -3956,6 +3957,17 @@ void Fl_Paged_Device::print_window(Fl_Window *win, int x_offset, int y_offset) const char *title = win->label(); win->label(""); // temporarily set a void window title win->show(); + if (fl_mac_os_version >= 101000) { + // if linked for OS 10.10, capture of title bar does not capture the title bar buttons + // so we draw them in FLTK + NSWindow *xid = fl_xid(win); + close = [xid standardWindowButton:NSWindowCloseButton]; // 10.2 + miniaturize = [xid standardWindowButton:NSWindowMiniaturizeButton]; + zoom = [xid standardWindowButton:NSWindowZoomButton]; + [close setHidden:YES]; // 10.3 + [miniaturize setHidden:YES]; + [zoom setHidden:YES]; + } fl_gc = NULL; Fl::check(); BOOL to_quartz = dynamic_cast<Fl_Printer*>(this) != NULL; @@ -3967,9 +3979,8 @@ void Fl_Paged_Device::print_window(Fl_Window *win, int x_offset, int y_offset) else bitmap = Fl_X::bitmap_from_window_rect(win, 0, -bt, win->w(), bt, &bpp); win->label(title); // put back the window title - // and print it this->set_current(); // back to the Fl_Paged_Device - if (img && to_quartz) { + if (img && to_quartz) { // print the title bar CGRect rect = { { x_offset, y_offset }, { win->w(), bt } }; Fl_X::q_begin_image(rect, 0, 0, win->w(), bt); CGContextDrawImage(fl_gc, rect, img); @@ -3982,10 +3993,34 @@ void Fl_Paged_Device::print_window(Fl_Window *win, int x_offset, int y_offset) delete rgb; delete[] bitmap; } + if (fl_mac_os_version >= 101000) { // print the title bar buttons + Fl_Color inactive = fl_rgb_color(0xCECE, 0xCECE, 0xCECE); // inactive button color + Fl_Color redish, yellowish, greenish; + if ([[NSUserDefaults standardUserDefaults] integerForKey:@"AppleAquaColorVariant"] == 6) { // graphite appearance + redish = yellowish = greenish = fl_rgb_color(0x8C8C, 0x8C8C, 0x8C8C); + } + else { + redish = fl_rgb_color(0xFFFF, 0x6363, 0x5A5A); + yellowish = fl_rgb_color(0xFFFF, 0xC6C6, 0x4242); + greenish = fl_rgb_color(0x2929, 0xD6D6, 0x5252); + } + + if (![close isEnabled]) fl_color(inactive); else fl_color(redish); + fl_pie(x_offset+8, y_offset+5, 12, 12, 0, 360); + if (![miniaturize isEnabled]) fl_color(inactive); else fl_color(yellowish); + fl_pie(x_offset+28, y_offset+5, 12, 12, 0, 360); + if (![zoom isEnabled]) fl_color(inactive); else fl_color(greenish); + fl_pie(x_offset+48, y_offset+5, 12, 12, 0, 360); + + [close setHidden:NO]; // 10.3 + [miniaturize setHidden:NO]; + [zoom setHidden:NO]; + } if (title) { // print the window title - const int skip = 68; // approx width of the zone of the 3 window control buttons + const int skip = 65; // approx width of the zone of the 3 window control buttons #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 if (fl_mac_os_version >= 100400 && to_quartz) { // use Cocoa string drawing with exact title bar font + // the exact font is LucidaGrande 13 pts (and HelveticaNeueDeskInterface-Regular with 10.10) NSGraphicsContext *current = [NSGraphicsContext currentContext]; [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:fl_gc flipped:YES]];//10.4 NSDictionary *attr = [NSDictionary dictionaryWithObject:[NSFont titleBarFontOfSize:0] @@ -4003,7 +4038,7 @@ void Fl_Paged_Device::print_window(Fl_Window *win, int x_offset, int y_offset) else #endif { - fl_font(FL_HELVETICA, 14); // the exact font is LucidaGrande 13 pts + fl_font(FL_HELVETICA, 14); fl_color(FL_BLACK); int x = x_offset + win->w()/2 - fl_width(title)/2; if (x < x_offset+skip) x = x_offset+skip; |
