bool ApplicationTypeWindow::QuitRequested() { if (_NeedsSaving(CHECK_ALL) != 0) { BAlert* alert = new BAlert(B_TRANSLATE("Save request"), B_TRANSLATE("Save changes before closing?"), B_TRANSLATE("Cancel"), B_TRANSLATE("Don't save"), B_TRANSLATE("Save"), B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT); alert->SetShortcut(0, B_ESCAPE); alert->SetShortcut(1, 'd'); alert->SetShortcut(2, 's'); int32 choice = alert->Go(); switch (choice) { case 0: return false; case 1: break; case 2: _Save(); break; } } be_app->PostMessage(kMsgTypeWindowClosed); return true; }
bool PrefWindow::QuitRequested() { if (!fDirty) return true; BAlert *alert = new BAlert("", B_TRANSLATE("Save changes to this settings panel?"), B_TRANSLATE("Cancel"), B_TRANSLATE("Don't save"), B_TRANSLATE("Save"), B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT); alert->SetShortcut(0, B_ESCAPE); alert->SetShortcut(1, 'd'); alert->SetShortcut(2, 's'); int32 index = alert->Go(); if (index == 0) return false; if (index == 2) _Save(); else _Revert(); return true; }
//--------------------------------------------------------- CSG_String CSG_MetaData::asText(int Flags) const { CSG_String s; if( Flags == 0 ) { for(int i=0; i<Get_Children_Count(); i++) { s += Get_Child(i)->Get_Name() + ":\t" + Get_Child(i)->Get_Content() + "\n"; } } else { wxXmlDocument XML; wxXmlNode *pRoot = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, Get_Name().c_str()); XML.SetRoot(pRoot); _Save(pRoot); wxStringOutputStream Stream; XML.Save(Stream); s = &Stream.GetString(); if( Flags == 2 ) // remove <xml> { s = s.AfterFirst('\n'); } } return( s ); }
void PrefWindow::MessageReceived(BMessage *msg) { switch (msg->what) { case MSG_SAVE_PRESSED: _Save(); PostMessage(B_QUIT_REQUESTED); break; case MSG_SAVEAS_PRESSED: _SaveAs(); break; case MSG_REVERT_PRESSED: _Revert(); PostMessage(B_QUIT_REQUESTED); break; case MSG_PREF_MODIFIED: fDirty = true; break; case B_SAVE_REQUESTED: _SaveRequested(msg); break; default: BWindow::MessageReceived(msg); break; } }
//--------------------------------------------------------- bool CSG_MetaData::to_XML(CSG_String &_XML) const { wxXmlDocument XML; wxXmlNode *pRoot = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, Get_Name().c_str()); XML.SetRoot(pRoot); _Save(pRoot); wxMemoryOutputStream Stream; if( XML.Save(Stream) ) { CSG_Array s(sizeof(char), Stream.GetSize()); Stream.CopyTo(s.Get_Array(), s.Get_Size()); _XML = (const char *)s.Get_Array(); return( true ); } return( false ); }
bool PrefWindow::QuitRequested() { if (fDirty) _Save(); return true; }
//--------------------------------------------------------- bool CWKSP_Project::Save(bool bSaveAsOnError) { if( Has_File_Name() ) { return( _Save(m_File_Name, true, true) ); } return( bSaveAsOnError ? Save() : false ); }
void CTSFEditWnd::_SaveToFile(LPTSTR pszFile) { if(pszFile) { HANDLE hFile; hFile = CreateFile( pszFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if(INVALID_HANDLE_VALUE != hFile) { IStream *pStream; //create a stream on global memory if(SUCCEEDED(CreateStreamOnHGlobal(NULL, TRUE, &pStream))) { LARGE_INTEGER li; _Save(pStream); //initialize the file SetFilePointer(hFile, 0, NULL, FILE_BEGIN); SetEndOfFile(hFile); //set the stream pointer to the start of the stream li.QuadPart = 0; pStream->Seek(li, STREAM_SEEK_SET, NULL); //write the contents of the stream to the file BYTE buffer[BLOCK_SIZE]; ULONG uRead; HRESULT hr; uRead = 0; hr = pStream->Read(buffer, BLOCK_SIZE, &uRead); while(uRead > 0) { DWORD dwWritten; WriteFile(hFile, buffer, uRead, &dwWritten, NULL); uRead = 0; hr = pStream->Read(buffer, BLOCK_SIZE, &uRead); } pStream->Release(); } CloseHandle(hFile); } } }
//--------------------------------------------------------- bool CWKSP_Project::Copy(void) { wxString FileName; if( !DLG_Save(FileName, ID_DLG_PROJECT_SAVE) ) { return( false ); } wxFileName Directory(FileName); Directory.AppendDir(Directory.GetFullName()); if( !Directory.DirExists() ) { Directory.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL); } size_t i, j; for(j=0; j<SG_Get_Data_Manager().Grid_System_Count(); j++) { for(i=0; i<SG_Get_Data_Manager().Get_Grid_System(j)->Count(); i++) { _Copy_To_File(g_pData->Get(SG_Get_Data_Manager().Get_Grid_System(j)->Get(i)), Directory.GetFullPath()); } } for(i=0; i<SG_Get_Data_Manager().Get_Point_Cloud()->Count(); i++) { _Copy_To_File(g_pData->Get(SG_Get_Data_Manager().Get_Point_Cloud()->Get(i)), Directory.GetFullPath()); } for(i=0; i<SG_Get_Data_Manager().Get_Shapes()->Count(); i++) { _Copy_To_File(g_pData->Get(SG_Get_Data_Manager().Get_Shapes()->Get(i)), Directory.GetFullPath()); } for(i=0; i<SG_Get_Data_Manager().Get_Table()->Count(); i++) { _Copy_To_File(g_pData->Get(SG_Get_Data_Manager().Get_Table()->Get(i)), Directory.GetFullPath()); } for(i=0; i<SG_Get_Data_Manager().asTIN()->Count(); i++) { _Copy_To_File(g_pData->Get(SG_Get_Data_Manager().asTIN()->Get(i)), Directory.GetFullPath()); } return( _Save(Directory.GetFullPath(), false, true) ); }
void CXTPCalendarResourcesManager::DoExchangeCfg(CXTPPropExchange* pPX) { ASSERT(pPX); if (!pPX) { return; } if (pPX->IsLoading()) { _Load(pPX); } else { _Save(pPX); } }
//--------------------------------------------------------- bool CSG_MetaData::Save(CSG_File &File) const { wxXmlDocument XML; wxXmlNode *pRoot = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, Get_Name().c_str()); XML.SetRoot(pRoot); _Save(pRoot); if( File.is_Writing() && XML.Save(*((wxOutputStream *)File.Get_Stream())) ) { return( true ); } return( false ); }
void CXTPCalendarCustomProperties::DoPropExchange(CXTPPropExchange* pPX) { if (!pPX) { ASSERT(FALSE); return; } if (pPX->IsLoading()) { _Load(pPX); } else { _Save(pPX); } }
BOOL CXTPCalendarResourcesManager::SaveCfg(LPCTSTR pcszFile) { #ifndef _XTP_EXCLUDE_XML CXTPPropExchangeXMLNode px(FALSE, 0, _T("CalendarMultiResourcesConfiguration")); _Save(&px); ::SetFileAttributes(pcszFile, FILE_ATTRIBUTE_NORMAL); ::DeleteFile(pcszFile); px.SaveToFile(pcszFile); return TRUE; #else return FALSE; #endif }
//--------------------------------------------------------- bool CSG_MetaData::Save(const CSG_String &File, const SG_Char *Extension) const { wxXmlDocument XML; wxXmlNode *pRoot = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, Get_Name().c_str()); XML.SetRoot(pRoot); _Save(pRoot); if( XML.Save(SG_File_Make_Path(NULL, File, Extension).c_str()) ) { return( true ); } return( false ); }
HRESULT KG3DAnimationTagContainer::Save(LPCSTR strFileName) { //Safely save to file backup before overwrite the old file and delete the back after save successfully. HRESULT hResult = E_FAIL; HRESULT hRetCode = E_FAIL; TCHAR strBackupFileName[MAX_PATH]; BOOL bSucceeded = TRUE; BOOL bNeedBackup = PathFileExists(strFileName); BOOL bExists = bNeedBackup; DWORD dwIndex = 0; while (bExists) { sprintf_s(strBackupFileName, MAX_PATH, "%s.bak%d", strFileName, dwIndex); bExists = PathFileExists(strBackupFileName); dwIndex++; } if (bNeedBackup) { bSucceeded = CopyFile(strFileName, strBackupFileName, TRUE); if (!bSucceeded) { KGLogPrintf(KGLOG_ERR, "Backup SFX file %s failed.", strFileName); } } hRetCode = _Save(strFileName); KG_COM_PROCESS_ERROR(hRetCode); hResult = S_OK; Exit0: if (SUCCEEDED(hResult) && bSucceeded) { //Delete backup when succeed. DeleteFile(strBackupFileName); } return hResult; }
//--------------------------------------------------------- bool CSG_MetaData::Save(CSG_File &File) const { wxXmlDocument XML; wxXmlNode *pRoot = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, Get_Name().c_str()); XML.SetRoot(pRoot); _Save(pRoot); wxFFileOutputStream Stream(File.Get_Stream()); if( Stream.IsOk() && XML.Save(Stream) ) { return( true ); } return( false ); }
bool ApplicationTypeWindow::QuitRequested() { if (_NeedsSaving(CHECK_ALL) != 0) { BAlert* alert = new BAlert("Save request", "Do you want to save " "the changes?", "Quit, don't save", "Cancel", "Save", B_WIDTH_AS_USUAL, B_WARNING_ALERT); int32 choice = alert->Go(); switch (choice) { case 0: break; case 1: return false; case 2: _Save(); break; } } be_app->PostMessage(kMsgTypeWindowClosed); return true; }
void ApplicationTypeWindow::MessageReceived(BMessage* message) { switch (message->what) { case kMsgToggleAppFlags: _UpdateAppFlagsEnabled(); _CheckSaveMenuItem(CHECK_FLAGS); break; case kMsgSignatureChanged: _CheckSaveMenuItem(CHECK_SIGNATUR); break; case kMsgAppFlagsChanged: _CheckSaveMenuItem(CHECK_FLAGS); break; case kMsgIconChanged: fOriginalInfo.iconChanged = true; _CheckSaveMenuItem(CHECK_ICON); break; case kMsgTypeIconsChanged: fOriginalInfo.typeIconsChanged = true; _CheckSaveMenuItem(CHECK_TYPE_ICONS); break; case kMsgSave: _Save(); break; case kMsgTypeSelected: { int32 index; if (message->FindInt32("index", &index) == B_OK) { SupportedTypeItem* item = (SupportedTypeItem*)fTypeListView->ItemAt(index); fTypeIconView->SetModificationMessage(NULL); fTypeIconView->SetTo(item != NULL ? &item->Icon() : NULL); fTypeIconView->SetModificationMessage( new BMessage(kMsgTypeIconsChanged)); fTypeIconView->SetEnabled(item != NULL); fRemoveTypeButton->SetEnabled(item != NULL); _CheckSaveMenuItem(CHECK_TYPES); } break; } case kMsgAddType: { BWindow* window = new TypeListWindow(NULL, kMsgTypeAdded, this); window->Show(); break; } case kMsgTypeAdded: { const char* type; if (message->FindString("type", &type) != B_OK) break; // check if this type already exists SupportedTypeItem* newItem = new SupportedTypeItem(type); int32 insertAt = 0; for (int32 i = fTypeListView->CountItems(); i-- > 0;) { SupportedTypeItem* item = dynamic_cast<SupportedTypeItem*>( fTypeListView->ItemAt(i)); if (item == NULL) continue; int compare = strcasecmp(item->Type(), type); if (!compare) { // type does already exist, select it and bail out delete newItem; newItem = NULL; fTypeListView->Select(i); break; } if (compare < 0) insertAt = i + 1; } if (newItem == NULL) break; fTypeListView->AddItem(newItem, insertAt); fTypeListView->Select(insertAt); _CheckSaveMenuItem(CHECK_TYPES); break; } case kMsgRemoveType: { int32 index = fTypeListView->CurrentSelection(); if (index < 0) break; delete fTypeListView->RemoveItem(index); fTypeIconView->SetModificationMessage(NULL); fTypeIconView->SetTo(NULL); fTypeIconView->SetModificationMessage( new BMessage(kMsgTypeIconsChanged)); fTypeIconView->SetEnabled(false); fRemoveTypeButton->SetEnabled(false); _CheckSaveMenuItem(CHECK_TYPES); break; } case B_SIMPLE_DATA: { entry_ref ref; if (message->FindRef("refs", &ref) != B_OK) break; // TODO: add to supported types break; } case B_META_MIME_CHANGED: const char* type; int32 which; if (message->FindString("be:type", &type) != B_OK || message->FindInt32("be:which", &which) != B_OK) break; // TODO: update supported types names // if (which == B_MIME_TYPE_DELETED) // _CheckSaveMenuItem(...); break; default: BWindow::MessageReceived(message); } }
//--------------------------------------------------------- bool CWKSP_Project::Save(void) { wxString FileName; return( DLG_Save(FileName, ID_DLG_PROJECT_SAVE) && _Save(FileName, true, true) ); }
//--------------------------------------------------------- bool CWKSP_Project::Save(const wxString &FileName, bool bSaveModified) { return( _Save(FileName, bSaveModified, false) ); }
void SettingsWindow::HandleMessage( Message *pcMessage ) { switch( pcMessage->GetCode() ) { case ID_SETTINGS_SELECT: { int32 nSelected; if( pcMessage->FindInt32( "selection", &nSelected ) == EOK ) { /* Collect the current information entered in all the views */ Settings *pcSettings = new Settings(); WebSettings *pcWebSettings = new WebSettings(); std::vector<SettingsView*>::iterator i; for( i = m_vViews.begin(); i != m_vViews.end(); i++ ) (*i)->Store( pcSettings, pcWebSettings ); /* Hide the old view */ if( NULL != m_pcSelected ) m_pcFrameView->RemoveChild( m_pcSelected ); /* Select the new view and allow it to update with the latest information */ m_pcSelected = m_vViews[nSelected]; m_pcSelected->Update( pcSettings, pcWebSettings ); m_pcFrameView->AddChild( m_pcSelected ); delete( pcSettings ); delete( pcWebSettings ); } break; } case ID_SETTINGS_APPLY: { /* Inform the Views that Apply was clicked */ std::vector<SettingsView*>::iterator i; for( i = m_vViews.begin(); i != m_vViews.end(); i++ ) (*i)->Apply(); _Save( pcMessage->GetCode() ); break; } case ID_SETTINGS_SAVE: { /* Inform the Views that Save was clicked */ std::vector<SettingsView*>::iterator i; for( i = m_vViews.begin(); i != m_vViews.end(); i++ ) (*i)->Save(); _Save( pcMessage->GetCode() ); break; } case ID_SETTINGS_CANCEL: { _SaveGui(); Close(); break; } default: Window::HandleMessage( pcMessage ); } }
void TerminalTagSet::Save(const char *name) { XMLCfgFile cfg; cfg.Load(name); _Save(this, cfg); }
void TerminalTagSet::SaveAs(const char *name) { XMLCfgFile cfg; cfg.Create(name); _Save(this, cfg); }
bool CSG_PointCloud::Save(const CSG_String &File_Name, int Format) { return( _Save(File_Name) ); }
status_t ProtocolSettings::Save(const char* account, BView* parent) { if (!parent) debugger("Couldn't save protocol's settings GUI on a NULL parent!"); BMessage* settings = new BMessage(); BMessage cur; for (int32 i = 0; fTemplate->FindMessage("setting", i, &cur) == B_OK; i++) { const char* name = cur.FindString("name"); // Skip NULL names if (!name) continue; int32 type = -1; if (cur.FindInt32("type", &type) != B_OK) continue; BView* view = parent->FindView(name); if (!view) continue; BTextControl* textControl = dynamic_cast<BTextControl*>(view); if (textControl) { switch (type) { case B_STRING_TYPE: settings->AddString(name, textControl->Text()); break; case B_INT32_TYPE: settings->AddInt32(name, atoi(textControl->Text())); break; default: return B_ERROR; } } BMenuField* menuField = dynamic_cast<BMenuField*>(view); if (menuField) { BMenuItem* item = menuField->Menu()->FindMarked(); if (!item) return B_ERROR; switch (type) { case B_STRING_TYPE: settings->AddString(name, item->Label()); break; case B_INT32_TYPE: settings->AddInt32(name, atoi(item->Label())); break; default: return B_ERROR; } } BCheckBox* checkBox = dynamic_cast<BCheckBox*>(view); if (checkBox) settings->AddBool(name, (checkBox->Value() == B_CONTROL_ON)); NotifyingTextView* textView = dynamic_cast<NotifyingTextView*>(view); if (textView) settings->AddString(name, textView->Text()); } return _Save(account, settings); }