From 0c13f74dfbed6c9ccb241f15f3f91bcc2d089c1b Mon Sep 17 00:00:00 2001 From: Karsten Heimrich Date: Sun, 14 Oct 2007 23:10:53 +0000 Subject: [PATCH] * fixed bug #1554, it seems my patch didn't make it in completely even after several trials git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22560 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/clock/cl_view.cpp | 1 + src/apps/clock/cl_view.h | 1 + src/apps/clock/cl_wind.cpp | 62 +++++++++++++++++++++++++++++++------- src/apps/clock/cl_wind.h | 3 +- src/apps/clock/clock.cpp | 1 + src/apps/clock/clock.h | 1 + 6 files changed, 57 insertions(+), 12 deletions(-) diff --git a/src/apps/clock/cl_view.cpp b/src/apps/clock/cl_view.cpp index 694dd4a998..dc7769a305 100644 --- a/src/apps/clock/cl_view.cpp +++ b/src/apps/clock/cl_view.cpp @@ -369,3 +369,4 @@ TOnscreenView::MessageReceived(BMessage *msg) BView::MessageReceived(msg); } } + diff --git a/src/apps/clock/cl_view.h b/src/apps/clock/cl_view.h index 0e36af2366..b9af6d523a 100644 --- a/src/apps/clock/cl_view.h +++ b/src/apps/clock/cl_view.h @@ -73,3 +73,4 @@ class TOnscreenView : public BView { }; #endif + diff --git a/src/apps/clock/cl_wind.cpp b/src/apps/clock/cl_wind.cpp index 690cc43346..d3add2bac4 100644 --- a/src/apps/clock/cl_wind.cpp +++ b/src/apps/clock/cl_wind.cpp @@ -4,26 +4,24 @@ */ #include "cl_wind.h" +#include "cl_view.h" #include #include #include -#include +#include + + #include -#include #include -#include - -#include "cl_view.h" - TClockWindow::TClockWindow(BRect frame, const char* title) : BWindow(frame, title, B_TITLED_WINDOW, - B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AVOID_FRONT, B_ALL_WORKSPACES) + B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AVOID_FRONT, B_ALL_WORKSPACES), + fOnScreenView(NULL) { - SetPulseRate(500000); - // half second pulse rate + _InitWindow(); } @@ -42,9 +40,9 @@ TClockWindow::QuitRequested() if (ref >= 0) { BPoint lefttop = Frame().LeftTop(); write(ref, (char *)&lefttop, sizeof(BPoint)); - short face = theOnscreenView->ReturnFace(); + short face = fOnScreenView->ReturnFace(); write(ref, (char *)&face, sizeof(short)); - bool seconds = theOnscreenView->ReturnSeconds(); + bool seconds = fOnScreenView->ReturnSeconds(); write(ref, (char *)&seconds, sizeof(bool)); close(ref); } @@ -52,3 +50,45 @@ TClockWindow::QuitRequested() be_app->PostMessage(B_QUIT_REQUESTED); return true; } + + +void +TClockWindow::_InitWindow() +{ + // half second pulse rate + SetPulseRate(500000); + + fOnScreenView = new TOnscreenView(BRect(0, 0, 82, 82), "Clock", 22, 15, 41); + AddChild(fOnScreenView); + + int ref; + BPath path; + if (find_directory (B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { + path.Append("Clock_settings"); + ref = open(path.Path(), O_RDONLY); + if (ref >= 0) { + BPoint leftTop; + read(ref, (char*)&leftTop, sizeof(leftTop)); + + short face; + read(ref, (char *)&face, sizeof(short)); + fOnScreenView->UseFace(face); + + bool secs; + read(ref, (char *)&secs, sizeof(bool)); + fOnScreenView->ShowSecs(secs); + + close(ref); + + MoveTo(leftTop); + + BRect frame = Frame(); + frame.InsetBy(-4, -4); + // it's not visible so reposition. I'm not going to get + // fancy here, just place in the default location + if (!frame.Intersects(BScreen(this).Frame())) + MoveTo(100, 100); + } + } +} + diff --git a/src/apps/clock/cl_wind.h b/src/apps/clock/cl_wind.h index 252dd98a59..c26e4dcaf1 100644 --- a/src/apps/clock/cl_wind.h +++ b/src/apps/clock/cl_wind.h @@ -24,7 +24,8 @@ class TClockWindow : public BWindow { void _InitWindow(); private: - TOnscreenView *theOnscreenView; + TOnscreenView *fOnScreenView; }; #endif // _CLOCK_WINDOW_H + diff --git a/src/apps/clock/clock.cpp b/src/apps/clock/clock.cpp index d826281346..7b60b2c33e 100644 --- a/src/apps/clock/clock.cpp +++ b/src/apps/clock/clock.cpp @@ -43,3 +43,4 @@ main(int argc, char* argv[]) return 0; } + diff --git a/src/apps/clock/clock.h b/src/apps/clock/clock.h index 15e4498767..67d716994a 100644 --- a/src/apps/clock/clock.h +++ b/src/apps/clock/clock.h @@ -29,3 +29,4 @@ extern const char *kAppSignature; #endif // _CLOCK_APPLICATION_H +