void ValueSample::init() { COLOR color[] = { CLR_RED, CLR_GREEN, CLR_BLUE, CLR_YELLOW }; logo.showLogo(1500); createDlg(); if (!hwnd) OThrowPM("Dialog creation failed.", 0, OException::unrecoverable); VSet.inherit(hwnd); VSet.setItemAttr(1, 0, VIA_ICON); VSet.setItemAttr(2, 0, VIA_BITMAP); VSet.setItemAttr(3, 0, VIA_COLORINDEX); if ((VSet.selected.icon = WinLoadPointer(HWND_DESKTOP, NULLHANDLE, VALUE_ICON)) == NULLHANDLE) OThrowPM("Loading icon failed.", 0, OException::unrecoverable); if (!VSet.setItem(1, 0, (ULONG)VSet.selected.icon)) OThrowPM("Could not set icons.", 0, OException::unrecoverable); if ((VSet.selected.bitmap = GpiLoadBitmap(WinGetPS(hwnd), NULLHANDLE, VALUE_BMP, 0, 0)) == NULLHANDLE) OThrowPM("Loading bitmap failed.", 0, OException::unrecoverable); if (!VSet.setItem(2, 0, (ULONG)VSet.selected.bitmap)) OThrowPM("Could not set bitmaps.", 0, OException::unrecoverable); for (ULONG count = 1; count <= 4; count++) if (!VSet.setItem(3, count, color[count-1])) OThrowPM("Could not set color.", 0, OException::unrecoverable); centerDlg(); showDlg(); }
FloDataInputDlg::FloDataInputDlg(QWidget *parent, FlowchartsTemplate *flocha) : QDialog(parent), m_flocha(flocha) { okBtn = nullptr; cancelBtn = nullptr; label1 = nullptr; label2 = nullptr; label3 = nullptr; combotype1 = nullptr; combotype2 = nullptr; combooper = nullptr; lineedit1 = nullptr; lineedit2 = nullptr; lineedit3 = nullptr; dataBackup_edit.clear(); dataBackup_combo.clear(); createDlg(); if(m_flocha == nullptr) { QMessageBox::warning(this,tr("error"),tr("flocha is null")); return; } }
void KICAD_MANAGER_FRAME::OnCreateProjectFromTemplate( wxCommandEvent& event ) { DIALOG_TEMPLATE_SELECTOR* ps = new DIALOG_TEMPLATE_SELECTOR( this ); wxFileName templatePath; wxString envStr; // KiCad system template path. ENV_VAR_MAP_CITER it = Pgm().GetLocalEnvVariables().find( "KICAD_TEMPLATE_DIR" ); if( it != Pgm().GetLocalEnvVariables().end() && it->second.GetValue() != wxEmptyString ) { templatePath.AssignDir( it->second.GetValue() ); ps->AddTemplatesPage( _( "System Templates" ), templatePath ); } // User template path. it = Pgm().GetLocalEnvVariables().find( "KICAD_USER_TEMPLATE_DIR" ); if( it != Pgm().GetLocalEnvVariables().end() && it->second.GetValue() != wxEmptyString ) { templatePath.AssignDir( it->second.GetValue() ); ps->AddTemplatesPage( _( "User Templates" ), templatePath ); } // Show the project template selector dialog if( ps->ShowModal() != wxID_OK ) return; if( ps->GetSelectedTemplate() == NULL ) { wxMessageBox( _( "No project template was selected. Cannot generate new project." ), _( "Error" ), wxOK | wxICON_ERROR, this ); return; } // Get project destination folder and project file name. wxString default_dir = wxFileName( Prj().GetProjectFullName() ).GetPathWithSep(); wxString title = _( "New Project Folder" ); wxFileDialog dlg( this, title, default_dir, wxEmptyString, ProjectFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); // Add a "Create a new directory" checkbox dlg.SetExtraControlCreator( &DIR_CHECKBOX::Create ); if( dlg.ShowModal() == wxID_CANCEL ) return; wxFileName fn( dlg.GetPath() ); // wxFileName automatically extracts an extension. But if it isn't // a .pro extension, we should keep it as part of the filename if( !fn.GetExt().IsEmpty() && fn.GetExt().ToStdString() != ProjectFileExtension ) fn.SetName( fn.GetName() + wxT( "." ) + fn.GetExt() ); fn.SetExt( ProjectFileExtension ); // enforce extension if( !fn.IsAbsolute() ) fn.MakeAbsolute(); // Append a new directory with the same name of the project file. if( static_cast<DIR_CHECKBOX*>( dlg.GetExtraControl() )->CreateNewDir() ) fn.AppendDir( fn.GetName() ); // Check if the project directory is empty if it already exists. wxDir directory( fn.GetPath() ); if( !fn.DirExists() ) { if( !fn.Mkdir() ) { wxString msg; msg.Printf( _( "Directory \"%s\" could not be created.\n\n" "Please make sure you have write permissions and try again." ), fn.GetPath() ); DisplayErrorMessage( this, msg ); return; } } if( !fn.IsDirWritable() ) { wxString msg; msg.Printf( _( "Cannot write to folder \"%s\"." ), fn.GetPath() ); wxMessageDialog msgDlg( this, msg, _( "Error!" ), wxICON_ERROR | wxOK | wxCENTER ); msgDlg.SetExtendedMessage( _( "Please check your access permissions to this folder " "and try again." ) ); msgDlg.ShowModal(); return; } ClearMsg(); // Make sure we are not overwriting anything in the destination folder. std::vector< wxFileName > destFiles; if( ps->GetSelectedTemplate()->GetDestinationFiles( fn, destFiles ) ) { std::vector< wxFileName > overwrittenFiles; for( const auto& file : destFiles ) { if( file.FileExists() ) overwrittenFiles.push_back( file ); } if( !overwrittenFiles.empty() ) { wxString extendedMsg = _( "Overwriting files:" ) + "\n"; for( const auto& file : overwrittenFiles ) extendedMsg += "\n" + file.GetFullName(); KIDIALOG msgDlg( this, _( "Similar files already exist in the destination folder." ), _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); msgDlg.SetExtendedMessage( extendedMsg ); msgDlg.SetOKLabel( _( "Overwrite" ) ); msgDlg.DoNotShowCheckbox( __FILE__, __LINE__ ); if( msgDlg.ShowModal() == wxID_CANCEL ) return; } } wxString errorMsg; // The selected template widget contains the template we're attempting to use to // create a project if( !ps->GetSelectedTemplate()->CreateProject( fn, &errorMsg ) ) { wxMessageDialog createDlg( this, _( "A problem occurred creating new project from template!" ), _( "Template Error" ), wxOK | wxICON_ERROR ); if( !errorMsg.empty() ) createDlg.SetExtendedMessage( errorMsg ); createDlg.ShowModal(); return; } CreateNewProject( fn.GetFullPath() ); LoadProject( fn ); }