From: Foster B. <fos...@us...> - 2006-01-24 19:39:06
|
Update of /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/modal_dialog_interface In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12473/adobe-source/adobe/test/modal_dialog_interface Added Files: Jamfile.v2 main.cpp Log Message: moved win/ directories to win32/ to anticipate a possible widgets port for WPF; added a 'mini-sheet' to Eve so you can save UI state information (what tab is currently selected) without mucking up your Adam model; started the modal_dialog_interface, an API that'll be used to direct a modal dialog interaction between the user and the application (it's still in its infancy); other misc bug fixes --- NEW FILE: main.cpp --- /* Copyright 2005-2006 Adobe Systems Incorporated Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt or a copy at http://opensource.adobe.com/licenses.html) */ /****************************************************************************************************/ #include <adobe/future/modal_dialog_interface.hpp> #include <adobe/xstring.hpp> #if ADOBE_PLATFORM_MAC #include <adobe/future/widgets/headers/mac/carbon_safe.hpp> #elif ADOBE_PLATFORM_WIN #define WINDOWS_LEAN_AND_MEAN 1 #include <windows.h> #endif #include <iostream> #include <sstream> #include <fstream> #include <boost/filesystem/operations.hpp> #include <boost/filesystem/fstream.hpp> /*************************************************************************************************/ #if defined(BOOST_MSVC) && defined(BOOST_THREAD_USE_LIB) extern "C" void tss_cleanup_implemented() { } #endif /****************************************************************************************************/ namespace { /****************************************************************************************************/ const char* eve_view_definition_g = "/*" " Copyright 2005-2006 Adobe Systems Incorporated" " Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt" " or a copy at http://opensource.adobe.com/licenses.html)" "*/" "" "layout mini_image_size" "{" " interface:" " percent: false;" " " " view dialog (name: 'Mini Image Size')" " {" " column()" " {" " overlay()" " {" " panel(bind: @percent, value: true)" " {" " edit_number(name: 'Height:', bind: @height_percent, digits: 7);" " edit_number(name: 'Width:', bind: @width_percent, digits: 7);" " }" " panel(bind: @percent, value: false)" " {" " edit_number(name: 'Height:', bind: @height_pixels, digits: 7);" " edit_number(name: 'Width:', bind: @width_pixels, digits: 7);" " }" " }" " checkbox(name: 'Constrain Proportions', bind: @constrain);" " checkbox(name: 'Percent', bind: @percent);" " }" " column()" " {" " button(name: 'OK', action: @ok, default: true);" " button(name: 'Cancel', action: @cancel, cancel: true);" " }" " }" "}"; /****************************************************************************************************/ const char* adam_model_definition_g = "/*" " Copyright 2005-2006 Adobe Systems Incorporated" " Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt" " or a copy at http://opensource.adobe.com/licenses.html)" "*/" "" "sheet mini_image_size" "{" "input:" " original_width : 5 * 300;" " original_height : 7 * 300;" "" "interface:" " constrain : true;" "" " width_pixels : original_width <== round(width_pixels);" " height_pixels : original_height <== round(height_pixels);" " width_percent;" " height_percent;" "" "logic:" " relate {" " width_pixels <== round(width_percent * original_width / 100);" " width_percent <== width_pixels * 100 / original_width;" " }" " " " relate {" " height_pixels <== round(height_percent * original_height / 100);" " height_percent <== height_pixels * 100 / original_height;" " }" "" " when (constrain) relate {" " width_percent <== height_percent;" " height_percent <== width_percent;" " }" "" "output:" " result <== { height: height_pixels, width: width_pixels };" "}"; /****************************************************************************************************/ #if ADOBE_PLATFORM_MAC const char* mac_metrics_g = "<xstr id='metric:global'>{ gap: 4 }</xstr>" "" "<xstr id='metric:checkbox' theme='normal'>" " { size: [ 16, 14 ], adjust_size: [ 2, 0 ], spacing: 5, adjust_position: [ -2, 0 ], outset: [ 1, 2, 0, 1 ], adjust_baseline: -1 }</xstr>" "<xstr id='metric:checkbox' theme='small'>" " { size: [ 13, 12 ], adjust_size: [ 1, 0 ], spacing: 7, adjust_position: [ -1, 0 ], outset: [ 1, 2, 0, 1 ], adjust_baseline: -1 }</xstr>" "<xstr id='metric:checkbox' theme='mini'>" " { size: [ 10, 10 ], spacing: 4, outset: [ 0, 1, 0, 0 ], adjust_baseline: -1 }</xstr>" "" "<xstr id='metric:radio_button' theme='normal'>" " { size: [ 19, 16 ], adjust_size: [ 5, 1 ], spacing: 4, adjust_position: [ -2, -1 ], outset: [ 1, 0, 1, 1 ], adjust_baseline: -1 }</xstr>" "<xstr id='metric:radio_button' theme='small'>" " { size: [ 14, 13 ], spacing: 4, outset: [ 0, 0, 0, 1 ] }</xstr>" "<xstr id='metric:radio_button' theme='mini'>" " { size: [ 10, 10 ], spacing: 4, adjust_position: [ 0, 1 ], outset: [ 0, 0, 0, 1 ] }</xstr>" "" "<xstr id='metric:button' theme='normal'>" " { size: [ 20, 21 ], adjust_baseline: 2, outset: [ 1, 0, 1, 2 ] }</xstr>" "<xstr id='metric:button' theme='small'>" " { size: [ 20, 18 ], adjust_size: [ -2, 0 ], adjust_position: [ 1, -1 ], outset: [ 0, 0, 0, 1 ], adjust_baseline: 2 }</xstr>" "<xstr id='metric:button' theme='mini'>" " { size: [ 20, 15 ], adjust_size: [ 2, 0 ], adjust_position: [ -1, 0 ], outset: [ 1, 0, 1, 1 ], adjust_baseline: 2 }</xstr>" "" "<xstr id='metric:group' label='true' theme='normal'>" " { size: [ 0, 12 ], adjust_size: [ 0, 3 ], adjust_position: [ 0, -2 ], frame: [ 1, 14, 1, 1 ] }</xstr>" "<xstr id='metric:group' label='true' theme='small'>" " { size: [ 0, 12 ], adjust_size: [ 0, 3 ], adjust_position: [ 0, -2 ], frame: [ 1, 14, 1, 1 ] }</xstr>" "<xstr id='metric:group' label='true' theme='mini'>" " { size: [ 0, 12 ], adjust_size: [ 0, 3 ], adjust_position: [ 0, -2 ], frame: [ 1, 12, 1, 1 ] }</xstr>" "" "<xstr id='metric:group' label='false' theme='normal'>" " { size: [ 0, 0 ], frame: [ 1, 1, 1, 1 ] }</xstr>" "<xstr id='metric:group' label='false' theme='small'>" " { size: [ 0, 0 ], frame: [ 1, 1, 1, 1 ] }</xstr>" "<xstr id='metric:group' label='false' theme='mini'>" " { size: [ 0, 0 ], frame: [ 1, 1, 1, 1 ] }</xstr>" "" "<xstr id='metric:tab_group' theme='normal'>" " { size: [ 0, 0 ], adjust_size: [ 0 , 8 ], adjust_position: [ 0, -7 ], frame: [ 1, 21, 1, 1 ] }</xstr>" "<xstr id='metric:tab_group' theme='small'>" " { size: [ 0, 0 ], adjust_size: [ 0 , 5 ], adjust_position: [ 0, -4 ], frame: [ 1, 18, 1, 1 ] }</xstr>" "<xstr id='metric:tab_group' theme='mini'>" " { size: [ 0, 0 ], adjust_size: [ 0 , 3 ], adjust_position: [ 0, -2 ], frame: [ 1, 15, 1, 1 ] }</xstr>" "" "<xstr id='metric:static_text' theme='normal'>" " { size: [ 0, 16 ], adjust_size: [ 0, 3 ], adjust_position: [ 0, -3 ], adjust_baseline: -3 }</xstr>" "<xstr id='metric:static_text' theme='small'>" " { size: [ 0, 15 ], adjust_size: [ 0, 3 ], adjust_position: [ 0, -2 ], adjust_baseline: -2 }</xstr>" "<xstr id='metric:static_text' theme='mini'>" " { size: [ 0, 12 ], adjust_size: [ 0, 3 ], adjust_position: [ 0, -2 ], adjust_baseline: -2 }</xstr>" "" "<xstr id='metric:edit_text' scroll='false' theme='normal'>" " { size: [ 3, 16 ], adjust_size: [ -6, -6 ], adjust_position: [ 3, 3 ], outset: [ 3, 3, 3, 3 ], adjust_baseline: 3 }</xstr>" "<xstr id='metric:edit_text' scroll='false' theme='small'>" " { size: [ 3, 14 ], adjust_size: [ -6, -6 ], adjust_position: [ 3, 3 ], outset: [ 3, 3, 3, 3 ], adjust_baseline: 3 }</xstr>" "<xstr id='metric:edit_text' scroll='false' theme='mini'>" " { size: [ 3, 12 ], adjust_size: [ -6, -6 ], adjust_position: [ 3, 3 ], outset: [ 3, 3, 3, 3 ], adjust_baseline: 3 }</xstr>" "" "<xstr id='metric:edit_text' scroll='true' theme='normal'>" " { size: [ 16, 16 ] }</xstr>" "<xstr id='metric:edit_text' scroll='true' theme='small'>" " { size: [ 16, 16 ] }</xstr>" "<xstr id='metric:edit_text' scroll='true' theme='mini'>" " { size: [ 16, 16 ] }</xstr>" "" "<xstr id='metric:popup' label='false' theme='normal'>" " { adjust_size: [ 1, -1 ], adjust_position: [ -1, 0 ], outset: [ 1, 0, 1, 1 ] }</xstr>" "<xstr id='metric:popup' label='false' theme='small'>" " { adjust_size: [ 1, -1 ], adjust_position: [ 1, 0 ], outset: [ 1, 0, 1, 1 ], adjust_baseline: 1 }</xstr>" "<xstr id='metric:popup' label='false' theme='mini'>" " { adjust_size: [ 2, 0 ], adjust_position: [ -1, 0 ] }</xstr>" "" "<xstr id='metric:popup' label='true' theme='normal'>" " { adjust_size: [ 0, -1 ], outset: [ 0, 0, 1, 1 ] }</xstr>" "<xstr id='metric:popup' label='true' theme='small'>" " { adjust_size: [ 1, -1 ], adjust_position: [ 0, 0 ], outset: [ 0, 0, 1, 1 ], adjust_baseline: 1 }</xstr>" "<xstr id='metric:popup' label='true' theme='mini'>" " { adjust_size: [ 1, 0 ] }</xstr>"; #endif /****************************************************************************************************/ adobe::dialog_result_t do_test( std::istream& eve_stream, std::istream& adam_stream) { adobe::dictionary_t input; adobe::record_info_t record; adobe::dictionary_t display_state; adobe::dialog_result_t result = handle_dialog( input, record, display_state, adobe::dialog_display_s, eve_stream, adam_stream); return result; } /****************************************************************************************************/ #if ADOBE_PLATFORM_MAC static OSStatus AppEventHandler( EventHandlerCallRef inCaller, EventRef inEvent, void* inRefcon ); bool os_init() { static IBNibRef sNibRef; static const EventTypeSpec kAppEvents[] = { { kEventClassCommand, kEventCommandProcess } }; OSStatus err(noErr); err = ::CreateNibReference( CFSTR("modal_dialog_interface"), &sNibRef ); if (err != noErr) return false; err = ::SetMenuBarFromNib( sNibRef, CFSTR("MenuBar") ); if (err != noErr) return false; ::InstallApplicationEventHandler( NewEventHandlerUPP( AppEventHandler ), GetEventTypeCount( kAppEvents ), kAppEvents, 0, NULL ); // // Register this app as an Appearance Client // ::RegisterAppearanceClient(); return true; } /****************************************************************************************************/ static OSStatus AppEventHandler(EventHandlerCallRef /*inCaller*/, EventRef /*inEvent*/, void* /*inRefcon*/) { //system_beep(); return eventNotHandledErr; } #endif /****************************************************************************************************/ #if ADOBE_PLATFORM_WIN bool os_init() { return true; } #endif /****************************************************************************************************/ }// namespace /****************************************************************************************************/ #if ADOBE_PLATFORM_WIN int __stdcall WinMain( HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR lpCmdLine, int nCmdShow ) #else int main(int argc, char** argv) #endif try { #if ADOBE_PLATFORM_MAC std::size_t metrics_len(std::strlen(mac_metrics_g)); char* metrics_data(new char[metrics_len] + 1); std::copy(&mac_metrics_g[0], &mac_metrics_g[0] + metrics_len, &metrics_data[0]); adobe::xstring_context_t mac_metrics_context( &metrics_data[0], &metrics_data[metrics_len], adobe::line_position_t( "mac metrics" ) ); #endif if (!os_init()) throw std::runtime_error("OS initialization failed"); #if ADOBE_PLATFORM_MAC if (argc > 2) { std::string db_name(argv[2]); boost::filesystem::path eve_path((db_name + ".eve").c_str(), boost::filesystem::native); boost::filesystem::path adam_path((db_name + ".adm").c_str(), boost::filesystem::native); boost::filesystem::ifstream eve_stream(eve_path); boost::filesystem::ifstream adam_stream(adam_path); //std::cerr << "using file set \"" << db_name << '"' << std::endl; do_test(eve_stream, adam_stream); } else #endif { std::stringstream eve_stream; std::stringstream adam_stream; eve_stream << eve_view_definition_g; adam_stream << adam_model_definition_g; //std::cerr << "using builtin file set" << std::endl; do_test(eve_stream, adam_stream); } return 0; } catch(const std::exception& doh) { std::cerr << "Exception: " << doh.what() << std::endl; return 1; } catch(...) { std::cerr << "Exception: Unknown"<< std::endl; return 1; } --- NEW FILE: Jamfile.v2 --- import testing ; import os ; SOURCE_DIRECTORY = sources ; HEADER_DIRECTORY = headers ; switch [ os.name ] { case NT : # --- Windows --------------------------------------------------------------------------- { PLATFORM_DIRECTORIES_NAME = win32 ; PLATFORM_SETTINGS = <include>resources <include>. <define>WINVER=0x501 <define>_WIN32_WINNT=0x501 <define>_WIN32_IE=0x501 <toolset>msvc:<linkflags>"gdi32.lib user32.lib comctl32.lib shell32.lib" <toolset>gcc:<cxxflags>"-mno-cygwin" <toolset>gcc:<linkflags>"-lgdi32 -lshell32 -luser32 -lcomctl32 -mno-cygwin" ; } case FREEBSD : { PLATFORM_DIRECTORIES_NAME = fltk ; # # Details of *your* local FLTK2 installation must be added here. # PLATFORM_SETTINGS = <linkflags>"-L/usr/X11R6/lib -lXft -L/usr/local/lib -lfreetype -lz -lfontconfig -lXrender -lXext -lXi -lX11" ; } case MACOSX : # --- Mac OS (assumed) ------------------------------------------------------------------ { PLATFORM_DIRECTORIES_NAME = mac ; PLATFORM_SETTINGS = <toolset>darwin:<linkflags>"-framework Carbon" ; PLATFORM_EXTRAS = ; } } project adobe/modal_dialog_interface : requirements <user-interface>gui ; exe modal_dialog_interface : main.cpp ../../future/source/modal_dialog_interface.cpp /adobe/adobe_widgets//adobe_widgets : $(PLATFORM_SETTINGS) ; OS = [ os.name ] ; DEST_PATH = $(BUILD_DIR)/install/$(OS)/ ; switch [ os.name ] { case MACOSX : { # set up the bundle of the app install "modal_dialog_interface.app/Contents" : resources/Info.plist resources/PkgInfo : <variant>release:<location>$(DEST_PATH)"release/modal_dialog_interface.app/Contents" <variant>debug:<location>$(DEST_PATH)"debug/modal_dialog_interface.app/Contents" ; install "modal_dialog_interface.app/Contents/MacOS" : modal_dialog_interface : <variant>release:<location>$(DEST_PATH)"release/modal_dialog_interface.app/Contents/MacOS" <variant>debug:<location>$(DEST_PATH)"debug/modal_dialog_interface.app/Contents/MacOS" ; install "modal_dialog_interface.app/Contents/Resources/begin.nib" : [ glob resources/modal_dialog_interface.nib/*.* ] : <variant>release:<location>$(DEST_PATH)"release/modal_dialog_interface.app/Contents/Resources/modal_dialog_interface.nib" <variant>debug:<location>$(DEST_PATH)"debug/modal_dialog_interface.app/Contents/Resources/modal_dialog_interface.nib" ; install "modal_dialog_interface.app/Contents/Resources" : resources/app_icon.icns : <variant>release:<location>$(DEST_PATH)"release/modal_dialog_interface.app/Contents/Resources" <variant>debug:<location>$(DEST_PATH)"debug/modal_dialog_interface.app/Contents/Resources" ; } } |