2 * Copyright 1999, Be Incorporated. All Rights Reserved.
3 * This file may be used under the terms of the Be Sample Code License.
9 #include <Application.h>
10 #include <FindDirectory.h>
20 TClockWindow::TClockWindow(BRect frame
, const char* title
)
21 : BWindow(frame
, title
, B_TITLED_WINDOW
,
22 B_NOT_RESIZABLE
| B_NOT_ZOOMABLE
| B_AVOID_FRONT
, B_ALL_WORKSPACES
),
29 TClockWindow::~TClockWindow()
35 TClockWindow::QuitRequested()
38 if (find_directory (B_USER_SETTINGS_DIRECTORY
, &path
, true) == B_OK
) {
39 path
.Append("Clock_settings");
40 int ref
= creat(path
.Path(), 0777);
42 BPoint lefttop
= Frame().LeftTop();
43 write(ref
, (char *)&lefttop
, sizeof(BPoint
));
44 short face
= fOnScreenView
->ReturnFace();
45 write(ref
, (char *)&face
, sizeof(short));
46 bool seconds
= fOnScreenView
->ReturnSeconds();
47 write(ref
, (char *)&seconds
, sizeof(bool));
51 be_app
->PostMessage(B_QUIT_REQUESTED
);
57 TClockWindow::_InitWindow()
59 // half second pulse rate
62 fOnScreenView
= new TOnscreenView(BRect(0, 0, 82, 82), "Clock", 22, 15, 41);
63 AddChild(fOnScreenView
);
67 if (find_directory (B_USER_SETTINGS_DIRECTORY
, &path
) == B_OK
) {
68 path
.Append("Clock_settings");
69 ref
= open(path
.Path(), O_RDONLY
);
72 read(ref
, (char*)&leftTop
, sizeof(leftTop
));
75 read(ref
, (char *)&face
, sizeof(short));
76 fOnScreenView
->UseFace(face
);
79 read(ref
, (char *)&secs
, sizeof(bool));
80 fOnScreenView
->ShowSecs(secs
);
86 BRect frame
= Frame();
87 frame
.InsetBy(-4, -4);
88 // it's not visible so reposition. I'm not going to get
89 // fancy here, just place in the default location
90 if (!frame
.Intersects(BScreen(this).Frame()))