void Printer_init( Handle self, HV * profile) { dPROFILE; char * prn; inherited init( self, profile); if ( !apc_prn_create( self)) croak("Cannot create printer"); prn = pget_c( printer); if ( strlen( prn) == 0) prn = my-> get_default_printer( self); my-> set_printer( self, prn); CORE_INIT_TRANSIENT(Printer); }
static Bool load( PImgCodec instance, PImgLoadFileInstance fi) { dPROFILE; LoadRec * l = ( LoadRec *) fi-> instance; png_uint_32 width, height; int obd, bit_depth, color_type, interlace_type, bpp, number_passes, pass, filter; HV * profile; Color background; int alpha_opt, channels, trns_n; Bool icon; Handle alpha_image; png_bytep trns_t; png_color_16p trns_p; if (setjmp(png_jmpbuf( l-> png_ptr)) != 0) return false; profile = fi-> profile; png_read_info(l->png_ptr, l->info_ptr); png_get_IHDR(l->png_ptr, l->info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, NULL, &filter); obd = bit_depth; channels = (int) png_get_channels(l->png_ptr, l->info_ptr); icon = kind_of( fi-> object, CIcon); switch ( bit_depth) { case 1: case 4: case 8: break; case 2: png_set_packing(l->png_ptr); bit_depth = 4; break; case 16: png_set_strip_16(l->png_ptr); bit_depth = 8; break; default: sprintf( fi-> errbuf, "Bit depth %d is not supported", bit_depth); return false; } switch ( color_type) { case PNG_COLOR_TYPE_GRAY: bpp = bit_depth | imGrayScale; break; case PNG_COLOR_TYPE_PALETTE: bpp = bit_depth; break; case PNG_COLOR_TYPE_RGB: png_set_bgr(l-> png_ptr); bpp = 24; break; case PNG_COLOR_TYPE_GRAY_ALPHA: bpp = bit_depth | imGrayScale; break; case PNG_COLOR_TYPE_RGB_ALPHA: png_set_bgr(l-> png_ptr); bpp = 24; break; default: sprintf( fi-> errbuf, "Unknown file color type: %d", color_type); return false; } /* gamma stuff */ { double screen_gamma = default_screen_gamma, gamma = 0.45455; Bool has_gamma = false; if ( pexist( screen_gamma)) { screen_gamma = pget_f( screen_gamma); if ( screen_gamma < PNG_GAMMA_THRESHOLD || screen_gamma > PNG_MAX_GAMMA) { sprintf( fi-> errbuf, "Error: screen_gamma value must be within %g..%g", PNG_GAMMA_THRESHOLD, (double)PNG_MAX_GAMMA); return false; } } #ifdef PNG_gAMA_SUPPORTED if ( pexist( gamma)) { gamma = pget_f( gamma); if ( gamma < PNG_GAMMA_THRESHOLD || gamma > PNG_MAX_GAMMA) { sprintf( fi-> errbuf, "Error: gamma value must be within %g..%g", PNG_GAMMA_THRESHOLD, (double)PNG_MAX_GAMMA); return false; } has_gamma = true; } else if ( png_get_gAMA(l-> png_ptr, l-> info_ptr, &gamma)) { has_gamma = true; } #endif if ( has_gamma) png_set_gamma(l->png_ptr, screen_gamma, gamma); } /* alpha option */ if ( pexist( alpha)) { char * c = pget_c( alpha); if ( stricmp( c, "blend") == 0) alpha_opt = ALPHA_OPT_BLEND; else if ( stricmp( c, "split") == 0) { if ( icon) outc("Alpha channel cannot be loaded to an Icon object") else alpha_opt = ALPHA_OPT_SPLIT; } else if ( stricmp( c, "none") == 0) alpha_opt = ALPHA_OPT_NONE; else { snprintf( fi-> errbuf, 256, "unknown alpha option '%s'", c); return false; } } else
void Application_init( Handle self, HV * profile) { dPROFILE; int hintPause = pget_i( hintPause); Color hintColor = pget_i( hintColor), hintBackColor = pget_i( hintBackColor); SV * hintFont = pget_sv( hintFont); SV * sv; char * hintClass = pget_c( hintClass); if ( application != nilHandle) croak( "Attempt to create more than one application instance"); CDrawable-> init( self, profile); list_create( &var-> widgets, 16, 16); list_create( &var-> modalHorizons, 0, 8); application = self; if ( !apc_application_create( self)) croak( "Error creating application"); /* Widget init */ SvHV_Font( pget_sv( font), &Font_buffer, "Application::init"); my-> set_font( self, Font_buffer); SvHV_Font( pget_sv( popupFont), &Font_buffer, "Application::init"); my-> set_popup_font( self, Font_buffer); { AV * av = ( AV *) SvRV( pget_sv( designScale)); SV ** holder = av_fetch( av, 0, 0); if ( holder) var-> designScale. x = SvNV( *holder); else warn("Array panic on 'designScale'"); holder = av_fetch( av, 1, 0); if ( holder) var-> designScale. y = SvNV( *holder); else warn("Array panic on 'designScale'"); pdelete( designScale); } var-> text = duplicate_string(""); opt_set( optModalHorizon); /* store extra info */ { HV * hv = ( HV *) SvRV( var-> mate); (void) hv_store( hv, "PrinterClass", 12, newSVpv( pget_c( printerClass), 0), 0); (void) hv_store( hv, "PrinterModule", 13, newSVpv( pget_c( printerModule), 0), 0); (void) hv_store( hv, "HelpClass", 9, newSVpv( pget_c( helpClass), 0), 0); (void) hv_store( hv, "HelpModule", 10, newSVpv( pget_c( helpModule), 0), 0); } { HV * profile = newHV(); static Timer_vmt HintTimerVmt; pset_H( owner, self); pset_i( timeout, hintPause); pset_c( name, "HintTimer"); var-> hintTimer = create_instance( "Prima::Timer"); protect_object( var-> hintTimer); hv_clear( profile); memcpy( &HintTimerVmt, CTimer, sizeof( HintTimerVmt)); HintTimerVmt. handle_event = Application_HintTimer_handle_event; (( PTimer) var-> hintTimer)-> self = &HintTimerVmt; pset_H( owner, self); pset_i( color, hintColor); pset_i( backColor, hintBackColor); pset_i( visible, 0); pset_i( selectable, 0); pset_i( showHint, 0); pset_c( name, "HintWidget"); pset_sv( font, hintFont); var-> hintWidget = create_instance( hintClass); protect_object( var-> hintWidget); sv_free(( SV *) profile); } if ( SvTYPE( sv = pget_sv( accelItems)) != SVt_NULL) my-> set_accelItems( self, sv); if ( SvTYPE( sv = pget_sv( popupItems)) != SVt_NULL) my-> set_popupItems( self, sv); pdelete( accelTable); pdelete( accelItems); pdelete( popupItems); my-> set( self, profile); CORE_INIT_TRANSIENT(Application); }