Ticket #5535: SE_PersistenWnd2.diff
File SE_PersistenWnd2.diff, 2.5 KB (added by , 14 years ago) |
---|
-
StyledEditWindow.cpp
26 26 #include <Debug.h> 27 27 #include <File.h> 28 28 #include <FilePanel.h> 29 #include <fs_attr.h> 29 30 #include <Locale.h> 30 31 #include <Menu.h> 31 32 #include <MenuBar.h> … … 44 45 45 46 const float kLineViewWidth = 30.0; 46 47 48 #define ATTRNAME_SE_INFO "se-info" 49 47 50 #undef TR_CONTEXT 48 51 #define TR_CONTEXT "StyledEditWindow" 49 52 … … 315 318 316 319 317 320 void 321 StyledEditWindow::LoadAttrs() 322 { 323 if (!fSaveMessage) 324 return; 325 326 entry_ref dir; 327 const char* name; 328 if (fSaveMessage->FindRef("directory", &dir) != B_OK 329 || fSaveMessage->FindString("name", &name) != B_OK) 330 return; 331 332 BPath documentPath(&dir); 333 documentPath.Append(name); 334 335 BNode documentNode(documentPath.Path()); 336 if (documentNode.InitCheck() != B_OK) 337 return; 338 339 BRect newFrame(Frame()); 340 ssize_t bytesRead = documentNode.ReadAttr(ATTRNAME_SE_INFO, B_RECT_TYPE, 0, &newFrame, sizeof(BRect)); 341 342 if (bytesRead == -1) 343 return; 344 345 MoveTo(newFrame.left, newFrame.top); 346 ResizeTo(newFrame.Width(), newFrame.Height()); 347 } 348 349 void 350 StyledEditWindow::SaveAttrs() 351 { 352 if (!fSaveMessage) 353 return; 354 355 entry_ref dir; 356 const char* name; 357 if (fSaveMessage->FindRef("directory", &dir) != B_OK 358 || fSaveMessage->FindString("name", &name) != B_OK) 359 return; 360 361 BPath documentPath(&dir); 362 documentPath.Append(name); 363 364 BNode documentNode(documentPath.Path()); 365 if (documentNode.InitCheck() != B_OK) 366 return; 367 368 BRect frame(Frame()); 369 documentNode.WriteAttr(ATTRNAME_SE_INFO, B_RECT_TYPE, 0, &frame, sizeof(BRect)); 370 } 371 372 373 void 318 374 StyledEditWindow::MessageReceived(BMessage* message) 319 375 { 320 376 if (message->WasDropped()) { … … 768 824 void 769 825 StyledEditWindow::Quit() 770 826 { 827 SaveAttrs(); 771 828 styled_edit_app->CloseDocument(); 772 829 BWindow::Quit(); 773 830 } … … 1035 1092 fSaveMessage->AddRef("directory", &parentRef); 1036 1093 fSaveMessage->AddString("name", name); 1037 1094 SetTitle(name); 1095 1096 LoadAttrs(); 1038 1097 } 1039 1098 fTextView->Select(0, 0); 1040 1099 } -
StyledEditWindow.h
48 48 49 49 private: 50 50 void InitWindow(uint32 encoding = 0); 51 void LoadAttrs(); 52 void SaveAttrs(); 51 53 bool Search(BString searchfor, bool casesens, bool wrap, bool backsearch); 52 54 void FindSelection(); 53 55 bool Replace(BString findthis, BString replacewith, bool casesens,