Fixed horizontal button spacing issues and window size issues when in the B_OFFSET_SPACING mode.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11146 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Matthew Wilber
2005-01-30 03:33:54 +00:00
parent 5207cc7a8c
commit 6fb0eac31e
+32 -10
View File
@@ -47,7 +47,6 @@
#include <Beep.h> #include <Beep.h>
#include <Autolock.h> #include <Autolock.h>
#include <stdio.h>
// Project Includes ------------------------------------------------------------ // Project Includes ------------------------------------------------------------
@@ -55,7 +54,7 @@
// Local Defines --------------------------------------------------------------- // Local Defines ---------------------------------------------------------------
// Default size of the Alert window. // Default size of the Alert window.
#define DEFAULT_RECT BRect(0, 0, 320, 75) #define DEFAULT_RECT BRect(0, 0, 310, 75)
#define max(LHS, RHS) ((LHS) > (RHS) ? (LHS) : (RHS)) #define max(LHS, RHS) ((LHS) > (RHS) ? (LHS) : (RHS))
// Globals --------------------------------------------------------------------- // Globals ---------------------------------------------------------------------
@@ -67,6 +66,7 @@ const int kDefButtonBottomOffset = 6;
const int kButtonRightOffset = 6; const int kButtonRightOffset = 6;
const int kButtonSpaceOffset = 6; const int kButtonSpaceOffset = 6;
const int kButtonOffsetSpaceOffset = 26; const int kButtonOffsetSpaceOffset = 26;
const int kButtonMinOffsetSpaceOffset = kButtonOffsetSpaceOffset / 2;
const int kButtonLeftOffset = 62; const int kButtonLeftOffset = 62;
const int kButtonUsualWidth = 75; const int kButtonUsualWidth = 75;
@@ -549,9 +549,27 @@ BAlert::InitObject(const char* text, const char* button0, const char* button1,
fButtons[i]->Frame().Width() - kButtonSpaceOffset; fButtons[i]->Frame().Width() - kButtonSpaceOffset;
buttonY -= kButtonBottomOffset; buttonY -= kButtonBottomOffset;
if (i == 0) { if (i == 0) {
if (spacing == B_OFFSET_SPACING) if (spacing == B_OFFSET_SPACING) {
buttonX -= kButtonOffsetSpaceOffset; if (buttonCount == 3)
else if (buttonCount == 3) buttonX -= kButtonOffsetSpaceOffset;
else {
// If there are two buttons, the left wall of
// button0 needs to line up with the left wall
// of the TextView.
buttonX = (MasterView->Bitmap()) ?
kTextIconOffset : kTextLeftOffset;
if (fButtons[i + 1]->Frame().left -
(buttonX + fButtons[i]->Frame().Width()) <
kButtonMinOffsetSpaceOffset) {
// Recompute buttonX using min offset space
// if using the current buttonX would not
// provide enough space or cause an overlap.
buttonX = fButtons[i + 1]->Frame().left -
fButtons[i]->Frame().Width() -
kButtonMinOffsetSpaceOffset;
}
}
} else if (buttonCount == 3)
buttonX -= 3; buttonX -= 3;
} }
} }
@@ -567,14 +585,18 @@ BAlert::InitObject(const char* text, const char* button0, const char* button1,
else else
totalWidth += kWindowMinOffset; totalWidth += kWindowMinOffset;
if (spacing == B_OFFSET_SPACING) if (spacing == B_OFFSET_SPACING) {
totalWidth = max(kWindowOffsetMinWidth, totalWidth); totalWidth -= 2;
else { if (buttonCount == 3)
totalWidth = max(kWindowOffsetMinWidth, totalWidth);
else
totalWidth = max(kWindowMinWidth, totalWidth);
} else {
totalWidth += 5; totalWidth += 5;
totalWidth = max(kWindowMinWidth, totalWidth); totalWidth = max(kWindowMinWidth, totalWidth);
} }
ResizeTo(totalWidth, Bounds().Height()); ResizeTo(totalWidth, Bounds().Height());
// Set up the text view // Set up the text view
BRect TextViewRect(kTextLeftOffset, kTextTopOffset, BRect TextViewRect(kTextLeftOffset, kTextTopOffset,
Bounds().right - kTextRightOffset, Bounds().right - kTextRightOffset,
@@ -592,7 +614,7 @@ BAlert::InitObject(const char* text, const char* button0, const char* button1,
fTextView->MakeSelectable(false); fTextView->MakeSelectable(false);
fTextView->SetWordWrap(true); fTextView->SetWordWrap(true);
// Now resize the window vertically so that all the text is visible // Now resize the TextView vertically so that all the text is visible
float textHeight = fTextView->TextHeight(0, fTextView->CountLines()); float textHeight = fTextView->TextHeight(0, fTextView->CountLines());
TextViewRect.OffsetTo(0, 0); TextViewRect.OffsetTo(0, 0);
textHeight -= TextViewRect.Height(); textHeight -= TextViewRect.Height();