wxPanel *CStartDialog::CreateOrSelectLeagueWizard(wxWizard *parent, std::vector<std::string> &leagues) { m_panel = new wxWizardPageSimple( parent ); wxTheColourDatabase->AddColour( "NAVY", wxColour( 0, 0, 58 ) ); m_label = new wxStaticText( m_panel, wxID_ANY, "Select League" ); m_label->SetForegroundColour( wxTheColourDatabase->Find( "NAVY" ) ); m_labelLogo = new wxStaticBitmap( m_panel, wxID_ANY, wxBITMAP_PNG( logo ) ); m_label1 = new wxStaticText( m_panel, wxID_ANY, "Mode: Demo" ); m_label2 = new wxStaticText( m_panel, wxID_ANY, "Version: 1.0" ); m_url = new wxHyperlinkCtrl( m_panel, wxID_ANY, "www.valuedraft.com", "http://www.valuedraft.com" ); m_leagues = new wxListBox( m_panel, wxID_ANY ); m_new = new wxButton( m_panel, wxID_ANY, "Create New League" ); m_edit = new wxButton( m_panel, wxID_ANY, "Edit Existing League" ); m_delete = new wxButton( m_panel, wxID_ANY, "Delete League" ); wxFont font = m_label->GetFont(); font.SetWeight( wxFONTWEIGHT_BOLD ); font.SetPointSize( 24 ); m_label->SetFont( font ); for( std::vector<std::string>::iterator it = leagues.begin(); it < leagues.end(); it++ ) m_leagues->Append( *it ); wxSizer *horz1 = new wxBoxSizer( wxHORIZONTAL ); wxSizer *vert1 = new wxBoxSizer( wxVERTICAL ); wxSizer *holder = new wxFlexGridSizer( 3, 2, 5, 5 ); wxSizer *logo = new wxBoxSizer( wxVERTICAL ); wxSizer *buttons = new wxBoxSizer( wxVERTICAL ); horz1->Add( 5, 5, 0, wxEXPAND, 0 ); vert1->Add( 5, 5, 0, wxEXPAND, 0 ); holder->Add( m_labelLogo, 0, wxEXPAND, 0 ); logo->Add( m_label1, 0, wxEXPAND, 0 ); logo->Add( 5, 5, 0, wxEXPAND, 0 ); logo->Add( m_label2, 0, wxEXPAND, 0 ); logo->Add( 5, 5, 0, wxEXPAND, 0 ); logo->Add( m_url, 0, wxEXPAND, 0 ); holder->Add( logo, 0, wxEXPAND, 0 ); holder->Add( m_label, 0, wxEXPAND, 0 ); holder->Add( 5, 5, 0, wxEXPAND, 0 ); holder->Add( m_leagues, 0, wxEXPAND, 0 ); buttons->Add( m_new, 0, wxEXPAND, 0 ); buttons->Add( 5, 5, 0, wxEXPAND, 0 ); buttons->Add( m_edit, 0, wxEXPAND, 0 ); buttons->Add( 5, 5, 0, wxEXPAND, 0 ); buttons->Add( m_delete, 0, wxEXPAND, 0 ); holder->Add( buttons, 0, wxEXPAND, 0 ); vert1->Add( holder, 0, wxEXPAND, 0 ); vert1->Add( 5, 5, 0, wxEXPAND, 0 ); horz1->Add( vert1, 0, wxEXPAND, 0 ); horz1->Add( 5, 5, 0, wxEXPAND, 0 ); m_panel->SetSizerAndFit( horz1 ); m_panel->Layout(); m_leagues->SetFocus(); m_leagues->SetSelection( 0 ); return m_panel; }
bool wxMiniApp::OnInit() { wxImage::AddHandler(new wxPNGHandler); wxBitmap bitmap = wxBITMAP_PNG(hadesworkshop_splash); wxSplashScreen* splash = new wxSplashScreen(bitmap, wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT, 6000, NULL, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxSTAY_ON_TOP); splash->Show(true); splash->SetIcon(wxICON(hadesworkshop_icon)); STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); CreateProcess(TEXT("HadesWorkshop.exe"), NULL,NULL,NULL,FALSE, CREATE_NEW_CONSOLE, NULL,NULL,&si,&pi); return true; }
MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size ) : wxScrolledWindow( parent, id, pos, size, wxSUNKEN_BORDER ) , m_bmpSmileXpm(smile_xpm) , m_iconSmileXpm(smile_xpm) { my_horse_ani = NULL; m_ani_images = 0 ; SetBackgroundColour(* wxWHITE); wxBitmap bitmap( 100, 100 ); wxMemoryDC dc; dc.SelectObject( bitmap ); dc.SetBrush( wxBrush( wxS("orange") ) ); dc.SetPen( *wxBLACK_PEN ); dc.DrawRectangle( 0, 0, 100, 100 ); dc.SetBrush( *wxWHITE_BRUSH ); dc.DrawRectangle( 20, 20, 60, 60 ); dc.SelectObject( wxNullBitmap ); // try to find the directory with our images wxString dir; if ( wxFile::Exists(wxT("./horse.png")) ) dir = wxT("./"); else if ( wxFile::Exists(wxT("../horse.png")) ) dir = wxT("../"); else wxLogWarning(wxT("Can't find image files in either '.' or '..'!")); wxImage image = bitmap.ConvertToImage(); #if wxUSE_LIBPNG if ( !image.SaveFile( dir + wxT("test.png"), wxBITMAP_TYPE_PNG )) { wxLogError(wxT("Can't save file")); } image.Destroy(); if ( image.LoadFile( dir + wxT("test.png") ) ) my_square = wxBitmap( image ); image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.png")) ) { wxLogError(wxT("Can't load PNG image")); } else { my_horse_png = wxBitmap( image ); } if ( !image.LoadFile( dir + wxT("toucan.png")) ) { wxLogError(wxT("Can't load PNG image")); } else { my_toucan = wxBitmap(image); } my_toucan_flipped_horiz = wxBitmap(image.Mirror(true)); my_toucan_flipped_vert = wxBitmap(image.Mirror(false)); my_toucan_flipped_both = wxBitmap(image.Mirror(true).Mirror(false)); my_toucan_grey = wxBitmap(image.ConvertToGreyscale()); my_toucan_head = wxBitmap(image.GetSubImage(wxRect(40, 7, 80, 60))); my_toucan_scaled_normal = wxBitmap(image.Scale(110,90,wxIMAGE_QUALITY_NORMAL)); my_toucan_scaled_high = wxBitmap(image.Scale(110,90,wxIMAGE_QUALITY_HIGH)); my_toucan_blur = wxBitmap(image.Blur(10)); #endif // wxUSE_LIBPNG #if wxUSE_LIBJPEG image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.jpg")) ) { wxLogError(wxT("Can't load JPG image")); } else { my_horse_jpeg = wxBitmap( image ); // Colorize by rotating green hue to red wxImage::HSVValue greenHSV = wxImage::RGBtoHSV(wxImage::RGBValue(0, 255, 0)); wxImage::HSVValue redHSV = wxImage::RGBtoHSV(wxImage::RGBValue(255, 0, 0)); image.RotateHue(redHSV.hue - greenHSV.hue); colorized_horse_jpeg = wxBitmap( image ); } if ( !image.LoadFile( dir + wxT("cmyk.jpg")) ) { wxLogError(wxT("Can't load CMYK JPG image")); } else { my_cmyk_jpeg = wxBitmap(image); } #endif // wxUSE_LIBJPEG #if wxUSE_GIF image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.gif" )) ) { wxLogError(wxT("Can't load GIF image")); } else { my_horse_gif = wxBitmap( image ); } #endif #if wxUSE_PCX image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.pcx"), wxBITMAP_TYPE_PCX ) ) { wxLogError(wxT("Can't load PCX image")); } else { my_horse_pcx = wxBitmap( image ); } #endif image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.bmp"), wxBITMAP_TYPE_BMP ) ) { wxLogError(wxT("Can't load BMP image")); } else { my_horse_bmp = wxBitmap( image ); } #if wxUSE_XPM image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.xpm"), wxBITMAP_TYPE_XPM ) ) { wxLogError(wxT("Can't load XPM image")); } else { my_horse_xpm = wxBitmap( image ); } if ( !image.SaveFile( dir + wxT("test.xpm"), wxBITMAP_TYPE_XPM )) { wxLogError(wxT("Can't save file")); } #endif #if wxUSE_PNM image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.pnm"), wxBITMAP_TYPE_PNM ) ) { wxLogError(wxT("Can't load PNM image")); } else { my_horse_pnm = wxBitmap( image ); } image.Destroy(); if ( !image.LoadFile( dir + wxT("horse_ag.pnm"), wxBITMAP_TYPE_PNM ) ) { wxLogError(wxT("Can't load PNM image")); } else { my_horse_asciigrey_pnm = wxBitmap( image ); } image.Destroy(); if ( !image.LoadFile( dir + wxT("horse_rg.pnm"), wxBITMAP_TYPE_PNM ) ) { wxLogError(wxT("Can't load PNM image")); } else { my_horse_rawgrey_pnm = wxBitmap( image ); } #endif #if wxUSE_LIBTIFF image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.tif"), wxBITMAP_TYPE_TIFF ) ) { wxLogError(wxT("Can't load TIFF image")); } else { my_horse_tiff = wxBitmap( image ); } #endif #if wxUSE_LIBTIFF image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.tga"), wxBITMAP_TYPE_TGA ) ) { wxLogError(wxT("Can't load TGA image")); } else { my_horse_tga = wxBitmap( image ); } #endif CreateAntiAliasedBitmap(); my_smile_xbm = wxBitmap( (const char*)smile_bits, smile_width, smile_height, 1 ); // demonstrates XPM automatically using the mask when saving if ( m_bmpSmileXpm.IsOk() ) m_bmpSmileXpm.SaveFile(wxT("saved.xpm"), wxBITMAP_TYPE_XPM); #if wxUSE_ICO_CUR image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.ico"), wxBITMAP_TYPE_ICO, 0 ) ) { wxLogError(wxT("Can't load first ICO image")); } else { my_horse_ico32 = wxBitmap( image ); } image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.ico"), wxBITMAP_TYPE_ICO, 1 ) ) { wxLogError(wxT("Can't load second ICO image")); } else { my_horse_ico16 = wxBitmap( image ); } image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.ico") ) ) { wxLogError(wxT("Can't load best ICO image")); } else { my_horse_ico = wxBitmap( image ); } image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.cur"), wxBITMAP_TYPE_CUR ) ) { wxLogError(wxT("Can't load best ICO image")); } else { my_horse_cur = wxBitmap( image ); xH = 30 + image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X) ; yH = 2420 + image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y) ; } m_ani_images = wxImage::GetImageCount ( dir + wxT("horse3.ani"), wxBITMAP_TYPE_ANI ); if (m_ani_images==0) { wxLogError(wxT("No ANI-format images found")); } else { my_horse_ani = new wxBitmap [m_ani_images]; } int i; for (i=0; i < m_ani_images; i++) { image.Destroy(); if (!image.LoadFile( dir + wxT("horse3.ani"), wxBITMAP_TYPE_ANI, i )) { wxString tmp = wxT("Can't load image number "); tmp << i ; wxLogError(tmp); } else my_horse_ani [i] = wxBitmap( image ); } #endif // wxUSE_ICO_CUR image.Destroy(); // test image loading from stream wxFile file(dir + wxT("horse.bmp")); if ( file.IsOpened() ) { wxFileOffset len = file.Length(); size_t dataSize = (size_t)len; void *data = malloc(dataSize); if ( file.Read(data, dataSize) != len ) { wxLogError(wxT("Reading bitmap file failed")); } else { wxMemoryInputStream mis(data, dataSize); if ( !image.LoadFile(mis) ) { wxLogError(wxT("Can't load BMP image from stream")); } else { my_horse_bmp2 = wxBitmap( image ); } } free(data); } // This macro loads PNG from either resources on the platforms that support // this (Windows and OS X) or from in-memory data (coming from cursor_png.c // included above in our case). my_png_from_res = wxBITMAP_PNG(cursor); // This one always loads PNG from memory but exists for consistency with // the above one and also because it frees you from the need to specify the // length explicitly, without it you'd have to do it and also spell the // array name in full, like this: // // my_png_from_mem = wxBitmap::NewFromPNGData(cursor_png, WXSIZEOF(cursor_png)); my_png_from_mem = wxBITMAP_PNG_FROM_DATA(cursor); }
bool NutcrackerApp::OnInit() { gParameters = std::make_unique<cz::Parameters>(); gParameters->set(argc, argv); // call the base class initialization method, currently it only parses a // few common command-line options but it could be do more in the future // NOTE: Not calling it, as it will show an error message because the I try to use my own command lines // if ( !wxApp::OnInit() ) // return false; #if wxUSE_XPM wxImage::AddHandler(new wxXPMHandler); #endif #if wxUSE_LIBPNG wxImage::AddHandler(new wxPNGHandler); #endif #if wxUSE_LIBJPEG wxImage::AddHandler(new wxJPEGHandler); #endif #if wxUSE_GIF wxImage::AddHandler(new wxGIFHandler); #endif // // Initialize image lists // for (int i = 0; i < SMALLIMG_IDX_MAX; i++) gImageListSmall.Add(wxArtProvider::GetBitmap(wxART_MISSING_IMAGE, wxART_OTHER, wxSize(16, 16))); gImageListSmall.Replace(SMALLIMG_IDX_FOLDER, wxArtProvider::GetBitmap(wxART_FOLDER, wxART_OTHER, wxSize(16, 16))); gImageListSmall.Replace(SMALLIMG_IDX_FILE_OTHER, wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16, 16))); gImageListSmall.Replace(SMALLIMG_IDX_FILE_NUT, wxBITMAP_PNG(APP_IMG_16x16_FILE_NUT)); gImageListSmall.Replace(SMALLIMG_IDX_REFRESH, wxBITMAP_PNG(APP_IMG_16x16_REFRESH)); gImageListSmall.Replace(SMALLIMG_IDX_FOLDER_ADD, wxBITMAP_PNG(APP_IMG_16x16_FOLDER_ADD)); gImageListSmall.Replace(SMALLIMG_IDX_NUT, wxBITMAP_PNG(APP_IMG_16x16_NUT)); gImageListSmall.Replace(SMALLIMG_IDX_CALLSTACK_CURRENT, wxBITMAP_PNG(APP_IMG_16x16_CALLSTACK_CURRENT)); for (int i = 0; i < BIGIMG_IDX_NUT; i++) gImageList32x32.Add(wxArtProvider::GetBitmap(wxART_MISSING_IMAGE, wxART_OTHER, wxSize(32, 32))); gImageList32x32.Replace(BIGIMG_IDX_NUT, wxBITMAP_PNG(APP_IMG_32x32_NUT)); gWorkspace = std::make_shared<Workspace>(); // create the main application window MainWnd *mainWnd = new MainWnd(); mainWnd->Show(true); if (gParameters->has("workspace")) { try { gWorkspace->load(gParameters->get("workspace")); } catch (std::exception& e) { showException(e); } } /* postAppLambdaEvent([]() { fireAppEvent(AppEventID::OpenWorkspace); }); */ std::shared_ptr<std::function<void()>> func; // // Test project handling // // success: wxApp::OnRun() will be called which will enter the main message // loop and the application will run. If we returned false here, the // application would exit immediately. return true; }