bool os_initialize( adobe::application_t* theApp ) { // // On the Mac we need to install the application menus, respond // to AppleEvents and set the resource path. We set the resource // path first. // ProcessSerialNumber psn; ADOBE_REQUIRE_STATUS( GetCurrentProcess( &psn ) ); FSRef location; ADOBE_REQUIRE_STATUS( GetProcessBundleLocation( &psn, &location ) ); theApp->set_resource_directory( fsref_to_path( location ) / "Contents" / "Resources" ); // // Now load our bundle, sign up for AppleEvents and show the menu. // CFBundleRef bundle = CFBundleGetMainBundle(); IBNibRef nibs = 0; if( !bundle ) return false; ADOBE_REQUIRE_STATUS( CreateNibReferenceWithCFBundle( bundle, kMainNibFileName, &nibs ) ); if( !nibs ) { ::CFRelease( bundle ); return false; } // // Sign up to handle the "Open" AppleEvent. // static adobe::auto_resource<AEEventHandlerUPP> ae_handler( NewAEEventHandlerUPP( handle_open ) ); AEInstallEventHandler( kCoreEventClass, kAEOpenDocuments, ae_handler.get(), 0, false ); // // Install the menu, and it's event handler. // ADOBE_REQUIRE_STATUS( SetMenuBarFromNib( nibs, kMenuBarNibName ) ); static EventTypeSpec hi_event = { kEventClassCommand, kHICommandFromMenu }; static adobe::auto_resource<EventHandlerUPP> hi_handler( NewEventHandlerUPP( menu_command ) ); InstallApplicationEventHandler( hi_handler.get(), 1, &hi_event, theApp, 0 ); // // Register this app as an Appearance Client // // Apple docs: "This function does nothing on Mac OS X. Do not call it." // // RegisterAppearanceClient(); return true; }
void set_field_text<edit_text_t>(edit_text_t& widget, const std::string& text) { assert(widget.control_m); widget.type_2_debounce_m = true; std::string filtered(text); std::string::size_type pos(0); while (true) { pos = filtered.find('\n', pos); if (pos == std::string::npos) break; filtered.replace(pos, 1, "\r"); } if (widget.scrollable_m) ADOBE_REQUIRE_STATUS(::TXNSetData(::HITextViewGetTXNObject(widget.control_m), kTXNTextData, filtered.c_str(), filtered.size(), kTXNStartOffset, kTXNEndOffset)); else implementation::set_widget_data(widget.control_m, kControlEntireControl, kControlEditTextCFStringTag, explicit_cast<auto_cfstring_t>(filtered).get()); widget.type_2_debounce_m = false; }
platform_display_type display_t::insert<platform_display_type>(platform_display_type& parent, const platform_display_type& element) { static const platform_display_type null_parent_s = platform_display_type(); if (parent != null_parent_s) ADOBE_REQUIRE_STATUS(::HIViewAddSubview(parent, element)); return element; }
void os_mainloop(adobe::application_t& app) { adobe::auto_resource< ::EventLoopTimerUPP > loop_upp(::NewEventLoopTimerUPP(do_deferred_dequeue)); adobe::auto_resource< ::EventLoopTimerRef > idle_timer_ref; ::EventLoopTimerRef temp_timer_ref; ADOBE_REQUIRE_STATUS(::InstallEventLoopTimer(::GetMainEventLoop(), 1, .01, loop_upp.get(), &app, &temp_timer_ref)); idle_timer_ref.reset(temp_timer_ref); ::RunApplicationEventLoop(); }
platform_display_type insert<button_t>(display_t& display, platform_display_type& parent, button_t& element) { static const ::Rect bounds_s = { 0, 0, 1024, 1024 }; assert(element.control_m == false); button_state_set_t::iterator state(button_default_state(element.state_set_m)); ::HIViewRef parent_ref(parent); ::WindowRef window(::GetControlOwner(parent_ref)); ADOBE_REQUIRE_STATUS(::CreatePushButtonControl(window, &bounds_s, explicit_cast<auto_cfstring_t>(state->name_m).get(), &element.control_m)); implementation::set_theme(element.control_m, element.theme_m); implementation::set_active(element.control_m, element.enabled_m); if (state->alt_text_m.empty() == false) implementation::set_control_alt_text(element.control_m, state->alt_text_m); element.hit_handler_m.handler_m.install(element.control_m); implementation::set_widget_data(element.control_m, kControlEntireControl, kControlPushButtonDefaultTag, static_cast< ::Boolean >(element.is_default_m)); implementation::set_widget_data(element.control_m, kControlEntireControl, kControlPushButtonCancelTag, static_cast< ::Boolean >(element.is_cancel_m)); assert(element.mod_key_handler_m.handler_m.is_installed() == false); if (element.state_set_m.size() > 1) element.mod_key_handler_m.handler_m.install(window); return display.insert(parent, element.control_m); }