From c5232cc8683a8b9a8ae3325785f5ee5c513da682 Mon Sep 17 00:00:00 2001
From: ejno <none>
Date: Wed, 26 Jun 2013 12:51:53 +0000
Subject: [PATCH] improved Zoom behavior for StyleEdit
---
src/apps/stylededit/StyledEditWindow.cpp | 27 +++++++++++++++++++++++++++
src/apps/stylededit/StyledEditWindow.h | 1 +
2 files changed, 28 insertions(+)
diff --git a/src/apps/stylededit/StyledEditWindow.cpp b/src/apps/stylededit/StyledEditWindow.cpp
index 4eee321..8532ae5 100644
a
|
b
|
StyledEditWindow::QuitRequested()
|
157 | 157 | |
158 | 158 | |
159 | 159 | void |
| 160 | StyledEditWindow::Zoom(BPoint origin, float fullWidth, float fullHeight) |
| 161 | { |
| 162 | const float minDimension = 256.f; |
| 163 | |
| 164 | float width = Bounds().right, height; |
| 165 | |
| 166 | if (!fTextView->DoesWordWrap()) { |
| 167 | width = 0.f; |
| 168 | int32 numLines = fTextView->CountLines(); |
| 169 | |
| 170 | for (int32 i = 0; i < numLines; i++) |
| 171 | width = max_c(fTextView->LineWidth(i), width); |
| 172 | |
| 173 | width += 3.f * (fTextView->Frame().left - Bounds().left + Bounds().right - fTextView->Frame().right); |
| 174 | width = min_c(max_c(width, minDimension), fullWidth); |
| 175 | } |
| 176 | |
| 177 | height = fTextView->TextHeight(0, fTextView->CountLines()); |
| 178 | height += 2.f * (fTextView->Frame().top - Bounds().top + Bounds().bottom - fTextView->Frame().bottom); |
| 179 | height = min_c(max_c(height, minDimension), fullHeight); |
| 180 | |
| 181 | MoveTo(origin); |
| 182 | ResizeTo(width, height); |
| 183 | } |
| 184 | |
| 185 | |
| 186 | void |
160 | 187 | StyledEditWindow::MessageReceived(BMessage* message) |
161 | 188 | { |
162 | 189 | if (message->WasDropped()) { |
diff --git a/src/apps/stylededit/StyledEditWindow.h b/src/apps/stylededit/StyledEditWindow.h
index bf239a6..4c31879 100644
a
|
b
|
public:
|
37 | 37 | |
38 | 38 | virtual void Quit(); |
39 | 39 | virtual bool QuitRequested(); |
| 40 | virtual void Zoom(BPoint origin, float width, float height); |
40 | 41 | virtual void MessageReceived(BMessage* message); |
41 | 42 | virtual void MenusBeginning(); |
42 | 43 | |