* now accepts NULL arguments for "width" and "height" in GetPreferredSize()
* minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15086 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
6338e9da5d
commit
8196fa8da4
@ -3,18 +3,20 @@
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Marc Flerackers (mflerackers@androme.be)
|
||||
* Mike Wilber
|
||||
* Stefano Ceccherini (burton666@libero.it)
|
||||
* Ivan Tonizza
|
||||
* Stephan Aßmus, <superstippi@gmx.de>
|
||||
* Marc Flerackers (mflerackers@androme.be)
|
||||
* Mike Wilber
|
||||
* Stefano Ceccherini (burton666@libero.it)
|
||||
* Ivan Tonizza
|
||||
* Stephan Aßmus, <superstippi@gmx.de>
|
||||
*/
|
||||
|
||||
|
||||
#include <Button.h>
|
||||
#include <Font.h>
|
||||
#include <String.h>
|
||||
#include <Window.h>
|
||||
|
||||
|
||||
BButton::BButton(BRect frame, const char *name, const char *label, BMessage *message,
|
||||
uint32 resizingMode, uint32 flags)
|
||||
: BControl(frame, name, label, message, resizingMode, flags |= B_WILL_DRAW),
|
||||
@ -47,8 +49,8 @@ BButton::Instantiate(BMessage *archive)
|
||||
{
|
||||
if (validate_instantiation(archive, "BButton"))
|
||||
return new BButton(archive);
|
||||
else
|
||||
return NULL;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -382,14 +384,12 @@ BButton::MouseDown(BPoint point)
|
||||
if (Window()->Flags() & B_ASYNCHRONOUS_CONTROLS) {
|
||||
SetTracking(true);
|
||||
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
|
||||
|
||||
} else {
|
||||
BRect bounds = Bounds();
|
||||
uint32 buttons;
|
||||
|
||||
do {
|
||||
Window()->UpdateIfNeeded();
|
||||
|
||||
snooze(40000);
|
||||
|
||||
GetMouse(&point, &buttons, true);
|
||||
@ -548,20 +548,25 @@ BButton::SetValue(int32 value)
|
||||
|
||||
|
||||
void
|
||||
BButton::GetPreferredSize(float *width, float *height)
|
||||
BButton::GetPreferredSize(float *_width, float *_height)
|
||||
{
|
||||
font_height fh;
|
||||
GetFontHeight(&fh);
|
||||
if (_height) {
|
||||
font_height fontHeight;
|
||||
GetFontHeight(&fontHeight);
|
||||
|
||||
*height = 12.0f + (float)ceil(fh.ascent + fh.descent);
|
||||
*width = 20.0f + (float)ceil(StringWidth(Label()));
|
||||
|
||||
if (*width < 75.0f)
|
||||
*width = 75.0f;
|
||||
*_height = 12.0f + (float)ceil(fontHeight.ascent + fontHeight.descent)
|
||||
+ (fDrawAsDefault ? 6.0f : 0);
|
||||
}
|
||||
|
||||
if (fDrawAsDefault) {
|
||||
*width += 6.0f;
|
||||
*height += 6.0f;
|
||||
if (_width) {
|
||||
float width = 20.0f + (float)ceil(StringWidth(Label()));
|
||||
if (width < 75.0f)
|
||||
width = 75.0f;
|
||||
|
||||
if (fDrawAsDefault)
|
||||
width += 6.0f;
|
||||
|
||||
*_width = width;
|
||||
}
|
||||
}
|
||||
|
||||
@ -743,9 +748,11 @@ BButton::DrawFocusLine(float x, float y, float width, bool visible)
|
||||
{
|
||||
if (visible)
|
||||
SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
|
||||
else
|
||||
else {
|
||||
SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
|
||||
B_LIGHTEN_1_TINT));
|
||||
}
|
||||
|
||||
// Blue Line
|
||||
StrokeLine(BPoint(x, y), BPoint(x + width, y));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user