Ticket #5535: SE_PersistentWnd.diff
File SE_PersistentWnd.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 entry_ref documentRef; 333 BPath documentPath(&dir); 334 documentPath.Append(name); 335 336 int fd = open(documentPath.Path(), O_RDONLY); 337 338 BRect newFrame; 339 ssize_t bytesRead = fs_read_attr(fd, ATTRNAME_SE_INFO, B_RECT_TYPE, 0, &newFrame, sizeof(BRect)); 340 341 close(fd); 342 343 if (-1 == bytesRead) 344 return; 345 346 MoveTo(newFrame.left, newFrame.top); 347 ResizeTo(newFrame.right - newFrame.left , 348 newFrame.bottom - newFrame.top); 349 } 350 351 void 352 StyledEditWindow::SaveAttrs() 353 { 354 if (!fSaveMessage) 355 return; 356 357 entry_ref dir; 358 const char* name; 359 if (fSaveMessage->FindRef("directory", &dir) != B_OK 360 || fSaveMessage->FindString("name", &name) != B_OK) 361 return; 362 363 entry_ref documentRef; 364 BPath documentPath(&dir); 365 documentPath.Append(name); 366 367 int fd = open(documentPath.Path(), O_WRONLY); 368 369 BRect frame(Frame()); 370 fs_write_attr(fd, ATTRNAME_SE_INFO, B_RECT_TYPE, 0, &frame, sizeof(BRect)); 371 372 close(fd); 373 } 374 375 376 void 318 377 StyledEditWindow::MessageReceived(BMessage* message) 319 378 { 320 379 if (message->WasDropped()) { … … 768 827 void 769 828 StyledEditWindow::Quit() 770 829 { 830 SaveAttrs(); 771 831 styled_edit_app->CloseDocument(); 772 832 BWindow::Quit(); 773 833 } … … 1035 1095 fSaveMessage->AddRef("directory", &parentRef); 1036 1096 fSaveMessage->AddString("name", name); 1037 1097 SetTitle(name); 1098 1099 LoadAttrs(); 1038 1100 } 1039 1101 fTextView->Select(0, 0); 1040 1102 } -
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,