bool QuartzWindow::open( uint32 /* WindowClass */ wc, int* /* WindowAttributes */ attrs, int left, int top, int right, int bottom, const char* title, const char* font_name, int font_size ) { HIRect bounds = (HIRect) CGRectMake(left, top, right, bottom); OSStatus err = HIWindowCreate(wc, attrs, NULL, kHICoordSpace72DPIGlobal, &bounds, &_quartz_win); if (err != noErr) return false; SetWRefCon(my_window(), (int32)this); CFStringRef cftitle = CFStringCreateWithCString(NULL, title, kCFStringEncodingMacRoman); SetWindowTitleWithCFString(my_window(), cftitle); CFRelease(cftitle); WindowSet::add_window(my_window()); _is_open = true; init_colors(); init_events(); return true; }
bool QuartzWindow::pre_draw(bool incremental) { if ( get_graphics_semaphore()) return false; if (!_is_open) return false; if (_was_closed) { TheSpy->deactivate(); _was_closed = false; return false; } if ( myContext == NULL ) { // Self does this for Self windows, so only do it for Spy windows--that's why it's here and not in open SetPortWindowPort(my_window()); QDBeginCGContext( GetWindowPort(my_window()), &myContext); setupCTM(); CGContextSetTextMatrix(myContext, CGAffineTransformMake( 1, 0, 0, -1, 0, 0)); CGContextSelectFont(myContext, default_fixed_font_name(), default_fixed_font_size(), kCGEncodingMacRoman); CGContextSetShouldAntialias(myContext, false); EventTypeSpec es[] = { {kEventClassWindow, kEventWindowBoundsChanged}, {kEventClassWindow, kEventWindowClose} }; OSStatus e = AddEventTypesToHandler(_my_spy_event_handler, sizeof(es) / sizeof(es[0]), es); if (e != noErr) fatal1("could not add types to handler %d\n", e); } if (_bounds_changed) { _bounds_changed = false; adjust_after_resize(); } if (!incremental) { Rect r; get_window_region_rect( kWindowContentRgn, &r); clear_rectangle(0, 0, r.right - r.left, r.bottom - r.top); } return true; }
void QuartzWindow::init_events() { _my_event_handler_upp = NewEventHandlerUPP(::handle_event); OSStatus e = InstallWindowEventHandler(my_window(), _my_event_handler_upp, 0, NULL, this, &_my_event_handler); if (e != noErr) fatal1("could not install event handler: %d\n", e); _my_spy_event_handler_upp = NewEventHandlerUPP(::handle_spy_event); e = InstallWindowEventHandler(my_window(), _my_spy_event_handler_upp, 0, NULL, this, &_my_spy_event_handler); if (e != noErr) fatal1("could not install spy event handler: %d\n", e); }
bool QuartzWindow::change_extent(int left, int top, int w, int h) { // Remember, left, top, w and h are for outer parts of window. // convert to inner CGrafPtr gp = GetWindowPort(my_window()); if (gp != NULL) // already closed by std handler QDEndCGContext( gp, &myContext ); myContext = NULL; MoveWindow( my_window(), left + inset_left(), top + inset_top(), false); SizeWindow( my_window(), w - inset_left() - inset_right(), h - inset_top() - inset_bottom(), true); adjust_after_resize(); return true; }
Gui_MyApplication::Gui_MyApplication(int argc,char** argv,Processor& pro): Gtk::Main(argc,argv), m_processor(pro), m_pro_hand(m_processor,m_opts), m_config(m_opts) { DEV_INFOS("Building GUI"); std::string prefix; #if defined _WIN64 || _WIN32 Gtk::Window::set_default_icon_list(m_icon_list); m_icon_list.push_back(Gui_PixbufOpener::pixbufOpen(ICON128_IMG)); m_icon_list.push_back(Gui_PixbufOpener::pixbufOpen(ICON64_IMG)); m_icon_list.push_back(Gui_PixbufOpener::pixbufOpen(ICON48_IMG)); m_icon_list.push_back(Gui_PixbufOpener::pixbufOpen(ICON24_IMG)); Gtk::Window::set_default_icon_list(m_icon_list); #else Gtk::Window::set_default_icon_name ("opencfu"); #endif if(m_config.getHelloLevelRef() <2){ Gui_HelloWindow hello_window(m_config.getHelloLevelRef()); Gtk::Main::run(hello_window); } Gui_MyWindow my_window(m_pro_hand,m_config); my_window.maximize(); Gtk::Main::run(my_window); }
bool QuartzWindow::tell_platform_size_hints() { HISize minSize, maxSize; // sizes of content region minSize.width = _min_w == -1 ? 0 : (_min_w - inset_left() - inset_right()); minSize.height = _min_h == -1 ? 0 : (_min_h - inset_top() - inset_bottom()); maxSize.width = _max_w == -1 ? 1000000 : (_max_w - inset_left() - inset_right()); maxSize.height = _max_h == -1 ? 1000000 : (_max_h - inset_top() - inset_bottom()); OSStatus e = SetWindowResizeLimits( my_window(), &minSize, &maxSize); return e == noErr; }
void QuartzWindow::activate() { WindowPtr wp = my_window(); if (!IsWindowVisible(wp)) ShowWindow(wp); SelectWindow(wp); OSStatus e = SetUserFocusWindow(wp); if (e) lprintf("SetUserFocus %d\n", e); e = ActivateWindow(wp, true); if (e) lprintf("ActivateWindow %d\n", e); }
void QuartzWindow::close() { if (!is_open()) return; CGrafPtr gp = GetWindowPort(my_window()); if (gp != NULL) // already closed by std handler QDEndCGContext( gp, &myContext ); CGColorRelease((CGColorRef) _red); CGColorRelease((CGColorRef) _yellow); CGColorRelease((CGColorRef) _black); CGColorRelease((CGColorRef) _gray); CGColorRelease((CGColorRef) _white); CGColorSpaceRelease(_color_space); WindowSet::rm_window(my_window()); if (gp != NULL) DisposeWindow(my_window()); _is_open = false; DisposeEventHandlerUPP(_my_event_handler_upp); DisposeEventHandlerUPP(_my_spy_event_handler_upp); _my_event_handler = NULL; _my_spy_event_handler = NULL; _quartz_win = NULL; }
void QuartzWindow::get_window_region_rect(int wh, Rect* r) { HIRect bounds; OSStatus err = HIWindowGetBounds(my_window(), wh, kHICoordSpace72DPIGlobal, &bounds); if (err) { lprintf("HIWindowGetBounds failed: %d\n", err); r->left = r->top = 0; r->bottom = r->right = 1; } else { r->left = (short) CGRectGetMinX(bounds); r->top = (short) CGRectGetMinY(bounds); r->bottom = (short) CGRectGetMaxY(bounds); r->right = (short) CGRectGetMaxX(bounds); } }
int QuartzWindow::menubar_height() { return screen(my_window()) == CGMainDisplayID() ? GetMBarHeight() : 0; }
int QuartzWindow::screen_height() { return CGDisplayPixelsHigh(screen(my_window())); }
int QuartzWindow::screen_width() { return CGDisplayPixelsWide(screen(my_window())); }