void Image::Render (cairo_t *cr, Region *region, bool path_only) { ImageSource *source = GetSource (); cairo_pattern_t *pattern = NULL; cairo_matrix_t matrix; if (!source) return; source->Lock (); cairo_save (cr); Size specified (GetActualWidth (), GetActualHeight ()); Size stretched = ApplySizeConstraints (specified); bool adjust = specified != GetRenderSize (); if (GetStretch () != StretchUniformToFill) specified = specified.Min (stretched); Rect paint = Rect (0, 0, specified.width, specified.height); if (!path_only) { Rect image = Rect (0, 0, source->GetPixelWidth (), source->GetPixelHeight ()); if (GetStretch () == StretchNone) paint = paint.Union (image); if (image.width == 0.0 && image.height == 0.0) goto cleanup; pattern = cairo_pattern_create_for_surface (source->GetSurface (cr)); image_brush_compute_pattern_matrix (&matrix, paint.width, paint.height, image.width, image.height, GetStretch (), AlignmentXCenter, AlignmentYCenter, NULL, NULL); cairo_pattern_set_matrix (pattern, &matrix); #if MAKE_EVERYTHING_SLOW_AND_BUGGY cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD); #endif if (cairo_pattern_status (pattern) == CAIRO_STATUS_SUCCESS) { cairo_set_source (cr, pattern); } cairo_pattern_destroy (pattern); } if (adjust) { // FIXME: Propagate error properly MoonError error; specified = MeasureOverrideWithError (specified, &error); paint = Rect ((stretched.width - specified.width) * 0.5, (stretched.height - specified.height) * 0.5, specified.width, specified.height); } if (!path_only) RenderLayoutClip (cr); paint = paint.Intersection (Rect (0, 0, stretched.width, stretched.height)); paint.Draw (cr); if (!path_only) cairo_fill (cr); cleanup: cairo_restore (cr); source->Unlock (); }
void Game::ShowMenu()//显示菜单 { static bool firstrun=true; //创建界面元素 static FullScrAni menubk; static Button butnew(clientw/2,clienth/3+20); static Button butold(clientw/2,clienth/3+80); static Button butsel(clientw/2,clienth/3+140); static Button buthelp(clientw/2,clienth/3+200); static Button butquit(clientw/2,clienth/3+260); static SelBox sel(clientw/8+110,clienth*2/5+45,150,50); static Rect selbkground(clientw/8,clienth*2/5,clientw/3,clienth/3); static Button butok(clientw/8+20,clienth*2/5+120,100,50); static Button butcl(clientw/8+145,clienth*2/5+120,100,50); manager.Play(MID_MENUBKM); if(firstrun) { //设置动画 menubk.SetAni(ANI_MENUBK); butnew.SetAni(ANI_BUTTON,ANI_BUTTON_NEW); butold.SetAni(ANI_BUTTON,ANI_BUTTON_OLD); butsel.SetAni(ANI_BUTTON,ANI_BUTTON_SEL); buthelp.SetAni(ANI_BUTTON,ANI_BUTTON_HELP); butquit.SetAni(ANI_BUTTON,ANI_BUTTON_QUIT); butok.SetAni(ANI_BUTTON,ANI_BUTTON_OK); butcl.SetAni(ANI_BUTTON,ANI_BUTTON_CANCEL); sel.Add(1).Add(2).Add(3).Add(4).Add(5).Add(6).Add(7).Add(8).Add(9); sel.SetAni(-1,ANI_BUTTON,ANI_BUTTON,-1,ANI_BUTTON_LEFT,ANI_BUTTON_RIGHT); selbkground.SetAni(ANI_SELBKGROUND); } //界面元素的响应 butnew.Deal(); butold.Deal(); butsel.Deal(); buthelp.Deal(); butquit.Deal(); //界面元素的绘制 menubk.Draw(); butnew.Draw(); butold.Draw(); butsel.Draw(); buthelp.Draw(); butquit.Draw(); //检测界面元素的状态 if(butnew.MousePressed())//新的开始 { level=1; butnew.Recover(); state=GAME_CREATE; } if(butold.MousePressed())//旧的回忆 { ReadArchive(); butold.Recover(); state=GAME_RUN; } if(butsel.MousePressed())//选择关卡 { selbkground.Draw(); sel.Deal(); sel.Draw(); butok.Deal(); butcl.Deal(); butok.Draw(); butcl.Draw(); if(butok.MousePressed()) { butsel.Recover(); butok.Recover(); level=atoi(sel.str().c_str()); state=GAME_CREATE; } if(butcl.MousePressed()) { butcl.Recover(); butsel.Recover(); } } if(buthelp.MousePressed())//帮助 { buthelp.Recover(); state=GAME_SHOWHELP; } if(butquit.MousePressed()) { ::PostQuitMessage(0); } firstrun=false; }
int do_dmx_config(int cfgdmx_X, int cfgdmx_Y, int largeurCFGdmxwindow,int hauteurCFGdmxwindow) { //definition des aires devices Rect DeviceArtNetDevice( Vec2D((cfgdmx_X+10),(cfgdmx_Y+50)),Vec2D(180,30)); DeviceArtNetDevice.SetRoundness(15); Rect DeviceEnttecOpen( Vec2D((cfgdmx_X+10),(cfgdmx_Y+80)),Vec2D(180,30)); DeviceEnttecOpen.SetRoundness(15); Rect DeviceEnttecPro( Vec2D((cfgdmx_X+10),(cfgdmx_Y+110)),Vec2D(180,30)); DeviceEnttecPro.SetRoundness(15); Rect DeviceSunlite ( Vec2D((cfgdmx_X+10),(cfgdmx_Y+170)),Vec2D(180,30)); DeviceSunlite.SetRoundness(15); //definition des aires univers Rect ArtNetSendUniverse( Vec2D((cfgdmx_X+220),(cfgdmx_Y+50)),Vec2D(70,30)); ArtNetSendUniverse.SetRoundness(15); //definition des aire d edition d adresse Rect ArtNetSendAdress( Vec2D((cfgdmx_X+320),(cfgdmx_Y+50)),Vec2D(170,30)); ArtNetSendAdress.SetRoundness(15); //SPEC. ARTNET: BROADCAST MODE Rect ArtNetBroadcastMode( Vec2D((cfgdmx_X+520),(cfgdmx_Y+50)),Vec2D(130,30)); ArtNetBroadcastMode.SetRoundness(15); //SPEC ARTNET ARTPOLL Rect ArtNetPollforDevices( Vec2D((cfgdmx_X+670),(cfgdmx_Y+50)),Vec2D(100,30)); ArtNetPollforDevices.SetRoundness(15); //SPEC ARTNET DOUBLE DMX Rect ArtNetDoubleDMX( Vec2D((cfgdmx_X+770),(cfgdmx_Y+50)),Vec2D(60,30)); ArtNetDoubleDMX.SetRoundness(15); //SPEC ENTTEC PROIN Rect EnttecProIN( Vec2D((cfgdmx_X+240),(cfgdmx_Y+110)),Vec2D(170,30)); EnttecProIN.SetRoundness(15); //SPEC SUNLITE Rect SunliteAllowsIN( Vec2D((cfgdmx_X+240),(cfgdmx_Y+170)),Vec2D(150,30)); SunliteAllowsIN.SetRoundness(15); { //SELECTION DE L INTERFACE if(window_focus_id==W_CFGMENU && mouse_x>cfgdmx_X+20 && mouse_x<cfgdmx_X+200 ) { if( mouse_y>(cfgdmx_Y+60) && mouse_y< (cfgdmx_Y+80)) //artnet { DeviceArtNetDevice.Draw(CouleurFond.WithAlpha(0.5)); Survol_interface_numero=1; if(mouse_button==1 && mouse_released==0 ) { SelectDmxDevice(1); } } else if( mouse_y>(cfgdmx_Y+90) && mouse_y< (cfgdmx_Y+110)) //enttec open { DeviceEnttecOpen.Draw(CouleurFond.WithAlpha(0.5)); Survol_interface_numero=2; if(mouse_button==1 && mouse_released==0 ) { SelectDmxDevice(2); } } else if( mouse_y>(cfgdmx_Y+120) && mouse_y< (cfgdmx_Y+140)) //enttec pro { DeviceEnttecPro.Draw(CouleurFond.WithAlpha(0.5)); Survol_interface_numero=3; if(mouse_button==1 && mouse_released==0 ) { SelectDmxDevice(3); } } else if( mouse_y>(cfgdmx_Y+170) && mouse_y< (cfgdmx_Y+200)) //sunlite { DeviceSunlite.Draw(CouleurFond.WithAlpha(0.5)); Survol_interface_numero=4; if(mouse_button==1 && mouse_released==0 ) { SelectDmxDevice(4); } } } //SELECTION DE L UNIVERS if(window_focus_id==W_CFGMENU && mouse_x>cfgdmx_X+230 && mouse_x<cfgdmx_X+300 ) { if( mouse_y>(cfgdmx_Y+60) && mouse_y< (cfgdmx_Y+80) && myDMXinterfaceis==1) //artnet { ArtNetSendUniverse.DrawOutline(CouleurLigne.WithAlpha(0.5)); if(mouse_button==1 && mouse_released==0 ) { Univers=atoi(numeric); if(Univers>15){Univers=15;} reset_numeric_entry(); numeric_postext=0; mouse_released=1; } } } //SELECTION DE L ADRESSE OUT ARTNET OU DU VCOM POUR LES INTERFACES DMX if(window_focus_id==W_CFGMENU && mouse_x>cfgdmx_X+320 && mouse_x<cfgdmx_X+490 ) { if( mouse_y>(cfgdmx_Y+60) && mouse_y< (cfgdmx_Y+80) && myDMXinterfaceis==1) //artnet { ArtNetSendAdress.DrawOutline(CouleurLigne.WithAlpha(0.7)); if(mouse_button==1 && mouse_released==0 && numeric_postext>0) { Close_dmx_interface(); sprintf(ip_artnet,numeric); reset_numeric_entry(); Init_dmx_interface(); mouse_released=1; } } } //SPECIFIC A CHAQUE INTERFACE if(window_focus_id==W_CFGMENU && mouse_x>cfgdmx_X+520 && mouse_x<cfgdmx_X+620 ) { if( mouse_y>(cfgdmx_Y+60) && mouse_y< (cfgdmx_Y+80) && myDMXinterfaceis==1) //artnet BROADCAST MODE ON OFF { ArtNetBroadcastMode.DrawOutline(CouleurLigne.WithAlpha(0.7)); if(mouse_button==1 && mouse_released==0 ) { ArtNetBroadcastMode.DrawOutline(CouleurLigne.WithAlpha(0.7)); Close_dmx_interface(); if(index_broadcast==0) { index_broadcast=1; Init_dmx_interface(); } else if(index_broadcast==1) { index_broadcast=0; Init_dmx_interface(); } mouse_released=1; } } } //SPECIFIC A CHAQUE INTERFACE <ARTNET SUITE> if(window_focus_id==W_CFGMENU && mouse_x>cfgdmx_X+670 && mouse_x<cfgdmx_X+770 ) { if( mouse_y>(cfgdmx_Y+60) && mouse_y< (cfgdmx_Y+80) ) //artpoll for devices { ArtNetPollforDevices.DrawOutline(CouleurLigne.WithAlpha(0.7)); if(mouse_button==1 && mouse_released==0 ) { if (myDMXinterfaceis!=1)//dans le cas d un art poll avec interface usb { initialisation_client_artnet(); ConstructArtPoll(); } if(index_art_polling==0) { reset_poll_list(); ticks_poll=0; index_art_polling=1; index_show_artpoll_reply_content=1; nbrbytessended=sendto(sockartnet, ArtPollBuffer,sizeof( ArtPollBuffer),0,(SOCKADDR*)&sinS,sinsize); } else if(index_art_polling==1) { index_art_polling=0; if (myDMXinterfaceis!=1)//dans le cas d un art poll avec interface usb {fermeture_client_artnet();} } mouse_released=1; } } } //DOUBLE DMX if(window_focus_id==W_CFGMENU && mouse_x>cfgdmx_X+770 && mouse_x<cfgdmx_X+830 ) { if( mouse_y>(cfgdmx_Y+60) && mouse_y< (cfgdmx_Y+80) ) //double dmx { ArtNetDoubleDMX.DrawOutline(CouleurLigne.WithAlpha(0.7)); if(mouse_button==1 && mouse_released==0 && myDMXinterfaceis!=1) { index_artnet_doubledmx=toggle(index_artnet_doubledmx); mouse_released=1; switch(index_artnet_doubledmx) { case 0: fermeture_client_artnet(); break; case 1: initialisation_client_artnet(); //ConstructArtPoll(); ConstructArtPollReply(); nbrbytessended=sendto(sockartnet, ArtPollBuffer,sizeof( ArtPollBuffer),0,(SOCKADDR*)&sinS,sinsize); //ArtNet ArtDmx(); //nbrbytessended=sendto(sockartnet, ArtDmxBuffer,sizeof( ArtDmxBuffer),0,(SOCKADDR*)&sinS,sinsize); break; } } } } //ENTTEC PRO IN MODULE if (window_focus_id==W_CFGMENU && mouse_x>cfgdmx_X+270 && mouse_x<cfgdmx_X+420 && mouse_y>cfgdmx_Y+120 && mouse_y<cfgdmx_Y+140 ) { EnttecProIN.Draw(CouleurFond.WithAlpha(0.5)); if(mouse_button==1 && mouse_released==0 ) { if (index_init_EnttecPROIN_ok==0) { Detect_EnttecProIn() ; Open_ProIn(); } else if (index_init_EnttecPROIN_ok==1) { Close_ProIn() ; index_init_EnttecPROIN_ok=0;} } mouse_released=1; } //sunlite allows IN if (window_focus_id==W_CFGMENU && mouse_x>cfgdmx_X+240 && mouse_x<cfgdmx_X+390 && mouse_y>cfgdmx_Y+180 && mouse_y<cfgdmx_Y+210 && myDMXinterfaceis==5) { SunliteAllowsIN.Draw(CouleurFond.WithAlpha(0.5)); if(mouse_button==1 && mouse_released==0 && window_focus_id==920) { index_allow_sunlite_dmxIN=toggle(index_allow_sunlite_dmxIN); mouse_released=1; } } }//fin condition etre 920 fenetre maitre ///////////////////////////////////////////////////////////////////////////////////// if(myDMXinterfaceis==1){ DeviceArtNetDevice.DrawOutline(CouleurLevel); } else if(myDMXinterfaceis==2){ DeviceEnttecOpen.DrawOutline(CouleurLevel); } else if(myDMXinterfaceis==3){ DeviceEnttecPro.DrawOutline(CouleurLevel); } else if(myDMXinterfaceis==4) { DeviceSunlite.DrawOutline(CouleurLevel); petitchiffre.Print("Version:",cfgdmx_X+400, cfgdmx_Y+190); petitchiffre.Print(ol::ToString(sunlite_version_number),cfgdmx_X+460, cfgdmx_Y+190); petitchiffre.Print("Serial:",cfgdmx_X+500, cfgdmx_Y+190); petitchiffre.Print(ol::ToString(sunlite_serial_number),cfgdmx_X+550, cfgdmx_Y+190); petitchiffre.Print(string_sunlite_is,cfgdmx_X+670, cfgdmx_Y+190); } if(index_art_polling==1) { ArtNetPollforDevices.DrawOutline(CouleurLevel); } if(index_artnet_doubledmx==1) { ArtNetDoubleDMX.Draw(CouleurFader); } ////////////////////////////////////////////// if (index_init_EnttecPROIN_ok==1) { EnttecProIN.DrawOutline(CouleurLevel); } ///////////////////////////////////////////// ///////////////////////////////////////////// switch(index_allow_sunlite_dmxIN) { case 0: petitchiffre.Print("DMX-IN OFF", cfgdmx_X+250, cfgdmx_Y+190); break; case 1: SunliteAllowsIN.Draw(CouleurSurvol); petitchiffre.Print("DMX-IN ON", cfgdmx_X+250, cfgdmx_Y+190); break; } //affichage sprintf(string_title_panel_config,"DMX CONFIGURATION PANEL"); petitpetitchiffre.Print("Universe" ,(cfgdmx_X+220), (cfgdmx_Y+50)); petitpetitchiffre.Print("To IP" ,(cfgdmx_X+350), (cfgdmx_Y+50)); petitpetitchiffre.Print("Mode" ,(cfgdmx_X+560), (cfgdmx_Y+50)); petitpetitchiffre.Print("Call" ,(cfgdmx_X+710), (cfgdmx_Y+50)); //////////////////////////////////////////////////////////////////////////////// petitchiffre.Print("ART-NET" ,(cfgdmx_X+20), (cfgdmx_Y+70)); petitchiffre.Print(ol::ToString(Univers),(cfgdmx_X+240), (cfgdmx_Y+70)); petitchiffre.Print(ip_artnet,(cfgdmx_X+340), (cfgdmx_Y+70)); if(index_broadcast==0) {petitchiffre.Print("UNICAST" ,(cfgdmx_X+540), (cfgdmx_Y+70));} else if (index_broadcast==1) {petitchiffre.Print("BROADCAST" ,(cfgdmx_X+540), (cfgdmx_Y+70));} petitchiffre.Print("ART-POLL",(cfgdmx_X+690), (cfgdmx_Y+70)); petitpetitchiffre.Print("Double",(cfgdmx_X+780), (cfgdmx_Y+65)); petitpetitchiffre.Print("DMX",(cfgdmx_X+790), (cfgdmx_Y+75)); //////////////////////////////////////////////////////////////////////////////// petitchiffre.Print("ENTTEC-OPEN-DMX" ,(cfgdmx_X+20), (cfgdmx_Y+100)); petitchiffre.Print("ENTTEC-PRO OUT /VCOM" ,(cfgdmx_X+20), (cfgdmx_Y+130)); petitchiffre.Print(ol::ToString(istheresomeone_in_enttecpro),(cfgdmx_X+170), (cfgdmx_Y+130)); petitchiffre.Print("ENTTEC-PRO IN /VCOM" ,(cfgdmx_X+250), (cfgdmx_Y+130)); petitchiffre.Print(ol::ToString(vcom_inposition_is),(cfgdmx_X+390), (cfgdmx_Y+130)); //////////////////////////////////////////////////////////////////////////////// petitchiffre.Print("SUNLITE SIUDI " ,(cfgdmx_X+20), (cfgdmx_Y+190)); //////////////////////////////////////////////////////////////////////////////// Rect DmxFeedbackZone(Vec2D((cfgdmx_X+10), (cfgdmx_Y+265)),Vec2D(560,25)); DmxFeedbackZone.SetRoundness(5); DmxFeedbackZone.Draw(CouleurFond.WithAlpha(0.5)); petitchiffre.Print("DMX feedback: >>",(cfgdmx_X+20), (cfgdmx_Y+280)); petitchiffrerouge.Print(string_display_dmx_params,(cfgdmx_X+130), (cfgdmx_Y+280)); affect_dmx_in(cfgdmx_X+710,cfgdmx_Y+200); return(0); }