From 8b24b02f060e46f2714889158df0b1535850995d Mon Sep 17 00:00:00 2001 From: Clemens Zeidler Date: Thu, 30 Jul 2009 18:28:29 +0000 Subject: [PATCH] Center the ExtendedInfoWindow on the screen. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31990 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/powerstatus/ExtendedInfoWindow.cpp | 14 ++++++++++++++ src/apps/powerstatus/ExtendedInfoWindow.h | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/apps/powerstatus/ExtendedInfoWindow.cpp b/src/apps/powerstatus/ExtendedInfoWindow.cpp index 4cdc949a8a..923ccae82e 100644 --- a/src/apps/powerstatus/ExtendedInfoWindow.cpp +++ b/src/apps/powerstatus/ExtendedInfoWindow.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include @@ -77,6 +78,19 @@ BatteryInfoView::GetPreferredSize(float *width, float *height) } +void +BatteryInfoView::AttachedToWindow() +{ + BRect rect = BScreen().Frame(); + BRect windowFrame = Window()->Frame(); + BPoint position; + // center window on screen + position.x = (rect.Width() - windowFrame.Width()) / 2; + position.y = (rect.Height() - windowFrame.Height()) / 2; + Window()->MoveTo(position); +} + + BSize BatteryInfoView::_MeasureString(const BString& string) { diff --git a/src/apps/powerstatus/ExtendedInfoWindow.h b/src/apps/powerstatus/ExtendedInfoWindow.h index 5532364ec2..87a6bf25bb 100644 --- a/src/apps/powerstatus/ExtendedInfoWindow.h +++ b/src/apps/powerstatus/ExtendedInfoWindow.h @@ -38,7 +38,8 @@ class BatteryInfoView : public BView acpi_extended_battery_info& extInfo); virtual void Draw(BRect updateRect); virtual void GetPreferredSize(float *width, float *height); - + virtual void AttachedToWindow(); + private: BSize _MeasureString(const BString& string); void _FillStringList();