Ticket #5280: patch
File patch, 4.1 KB (added by , 15 years ago) |
---|
-
src/apps/expander/ExpanderWindow.cpp
25 25 #include <MenuBar.h> 26 26 #include <MenuItem.h> 27 27 #include <Path.h> 28 #include <Screen.h> 28 29 #include <ScrollView.h> 29 30 #include <StringView.h> 30 31 #include <TextView.h> … … 76 77 fListingText->SetText(""); 77 78 fListingText->MakeEditable(false); 78 79 fListingText->SetStylable(false); 80 fListingText->SetWordWrap(false); 79 81 BFont font = be_fixed_font; 80 82 fListingText->SetFontAndColor(&font); 81 83 BScrollView* scrollView = new BScrollView("", fListingText, 82 B_INVALIDATE_AFTER_LAYOUT, false, true);84 B_INVALIDATE_AFTER_LAYOUT, true, true); 83 85 84 86 BView* topView = layout->View(); 85 87 const float spacing = be_control_look->DefaultItemSpacing(); … … 158 160 159 161 160 162 void 161 ExpanderWindow::FrameResized(float width, float height)162 {163 if (fListingText->DoesWordWrap()) {164 BRect textRect;165 textRect = fListingText->Bounds();166 textRect.OffsetTo(B_ORIGIN);167 textRect.InsetBy(1, 1);168 fListingText->SetTextRect(textRect);169 }170 }171 172 173 void174 163 ExpanderWindow::MessageReceived(BMessage* msg) 175 164 { 176 165 switch (msg->what) { … … 318 307 BString string; 319 308 int32 i = 0; 320 309 while (msg->FindString("output", i++, &string) == B_OK) { 321 // expand the window if we need... 322 float delta = fListingText->StringWidth(string.String()) 323 - fListingText->Frame().Width(); 324 if (delta > fLargestDelta) { 325 fLargestDelta = delta; 326 } 310 float lineLength = fListingText->StringWidth(string.String()); 311 312 if (lineLength > fLongestLine) 313 fLongestLine = lineLength; 314 327 315 fListingText->Insert(string.String()); 328 316 } 329 317 fListingText->ScrollToSelection(); … … 338 326 StopExpanding(); 339 327 OpenDestFolder(); 340 328 CloseWindowOrKeepOpen(); 341 } else if (fListingStarted) {329 } else if (fListingStarted) { 342 330 fSourceChanged = false; 343 331 StopListing(); 344 if (fLargestDelta > 0.0f) 345 ResizeBy(fLargestDelta, 0.0f); 346 fLargestDelta = 0.0f; 332 333 _ExpandListingText(); 347 334 } else 348 335 fStatusView->SetText(""); 349 336 break; … … 563 550 564 551 565 552 void 553 ExpanderWindow::_ExpandListingText() 554 { 555 if (fLongestLine > fListingText->Frame().Width()) { 556 BScreen screen; 557 BRect screenFrame = screen.Frame(); 558 float delta = fLongestLine - fListingText->Frame().Width(); 559 560 if (Frame().right + delta > screenFrame.right) 561 delta = screenFrame.right - Frame().right - 4.0f; 562 563 ResizeBy(delta, 0.0f); 564 } 565 } 566 567 568 void 566 569 ExpanderWindow::_UpdateWindowSize(bool showContents) 567 570 { 568 571 float minWidth, maxWidth, minHeight, maxHeight; … … 571 574 float bottom = fSizeLimit; 572 575 573 576 if (showContents) { 577 BFont font; 574 578 font_height fontHeight; 575 be_plain_font->GetHeight(&fontHeight); 579 fListingText->GetFont(&font); 580 font.GetHeight(&fontHeight); 576 581 float lineHeight = ceilf(fontHeight.ascent + fontHeight.descent 577 582 + fontHeight.leading); 578 583 … … 594 599 { 595 600 _UpdateWindowSize(true); 596 601 597 fLargestDelta = 0.0f; 598 599 if (!fSourceChanged) 602 if (!fSourceChanged) { 603 _ExpandListingText(); 600 604 return; 605 } 601 606 607 fLongestLine = 0.0f; 608 602 609 ExpanderRule* rule = fRules.MatchingRule(&fSourceRef); 603 610 if (!rule) 604 611 return; -
src/apps/expander/ExpanderWindow.h
34 34 const entry_ref* ref, BMessage* settings); 35 35 virtual ~ExpanderWindow(); 36 36 37 virtual void FrameResized(float width, float height);38 37 virtual void MessageReceived(BMessage* msg); 39 38 virtual bool QuitRequested(); 40 39 … … 52 51 void StartExpanding(); 53 52 void StopExpanding(); 54 53 void _UpdateWindowSize(bool showContents); 54 void _ExpandListingText(); 55 55 void StartListing(); 56 56 void StopListing(); 57 57 bool ValidateDest(); … … 90 90 ExpanderPreferences* fPreferences; 91 91 ExpanderRules fRules; 92 92 93 float fL argestDelta;93 float fLongestLine; 94 94 float fSizeLimit; 95 95 }; 96 96