Change Time Format Options in Deskbar preferences.
Added two new methods to the Locale Kit in order to create a custom time formats from a format string. One method is outputs into a char* array, the other into a BString() and you can set the timezone. These methods should be cleaned up, we only need 2, one to get the time in a predefined style, the other to get a custom time format. Also should probably do the same for dates and datetimes. But I'll let this go for now. I added myself to the Locale.cpp file. I retained the copyright instead of assigning it to Haiku, Inc. because the file is under the OpenBeOS license and I don't know what the concequences of copyright sharing are for that license, unlike MIT. These new methods are used to generate custom time formats in Deskbar. Instead of using a set of Radio Buttons to choose between the predefined time options I build my own by creating a format string and passing it to the Locale Kit. The format string is generated from 3 checkboxes, show seconds, show day of week, and show time zone. You can mix and match between them choose any that you like. By default they are all off. There are 3 new deskbar settings associated with these new options: showSeconds, showDayOfWeek, and showTimeZone. timeFormat has gone away. The time format string gets cached and updated only when Update() gets called on the TimeView class. In order to fit all the options in (there is 1 more than before) I had to reduce the font size of the clock to 11pt when all options are turned on in 12 hour mode. For those with no imagination it looks like this: http://imagebin.org/208162 Renamed "Open time preferences..." menuitem to "Time preferences...". Renamed "Show Time" and "Hide Time" to "Show time" and "Hide time". Other changes include refactoring the header files a bit. There were a lot of headers included by header files uneccessarily. For instance BarWindow.h now only includes <Window.h> and <Deskbar.h>. This change is mainly to to speed up the compile time since it takes a while right now. I copy the fBarView pointer from BarWindow in the BarApp constructor and then use that throughout the file rather than getting the pointer from the window each time by calling BarView(). BarView() is still available in the header for other classes though. I moved some message constants around since it was getting a bit jumbled. Most of the messages related to settings are in PreferenceWindow.h. fChangeState is moved to BarView.h since that is where the ChangeState() function is and BarView.cpp uses that constant. The time interval and format constants are in TimeView.h. Make some methods public in their respective classes where it made sense. The preference window methods to update dependent items are public, that might get called from BarWindow when a message gets received at some point. Also made ShowHideTime() and Time() public in StatusView.h. These methods activate showing and hiding the clock and return the fTime clock object. No reason they should be private. I reindented the StatusView.h and PreferenceWindow.h headers to the standard style. Question here, are the public: protected: and private: lines inside of classes suppose to get indented 1 tab or not? I've seen both, the style guide says no indent but 1 indent seems reasonable and looks pretty good. Style fixes here and there. That's enough for one commit I think.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2011, Haiku, Inc.
|
* Copyright 2003-2012, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _B_LOCALE_H_
|
#ifndef _B_LOCALE_H_
|
||||||
@@ -119,9 +119,14 @@ public:
|
|||||||
// has been implemented!
|
// has been implemented!
|
||||||
ssize_t FormatTime(char* string, size_t maxSize,
|
ssize_t FormatTime(char* string, size_t maxSize,
|
||||||
time_t time, BTimeFormatStyle style) const;
|
time_t time, BTimeFormatStyle style) const;
|
||||||
|
ssize_t FormatTime(char* string, size_t maxSize,
|
||||||
|
time_t time, BString format) const;
|
||||||
status_t FormatTime(BString* string, time_t time,
|
status_t FormatTime(BString* string, time_t time,
|
||||||
BTimeFormatStyle style,
|
BTimeFormatStyle style,
|
||||||
const BTimeZone* timeZone = NULL) const;
|
const BTimeZone* timeZone = NULL) const;
|
||||||
|
status_t FormatTime(BString* string, time_t time,
|
||||||
|
BString format,
|
||||||
|
const BTimeZone* timeZone) const;
|
||||||
status_t FormatTime(BString* string,
|
status_t FormatTime(BString* string,
|
||||||
int*& fieldPositions, int& fieldCount,
|
int*& fieldPositions, int& fieldCount,
|
||||||
time_t time, BTimeFormatStyle style) const;
|
time_t time, BTimeFormatStyle style) const;
|
||||||
|
|||||||
+37
-20
@@ -33,7 +33,9 @@ holders.
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Debug.h>
|
|
||||||
|
#include "BarApp.h"
|
||||||
|
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -42,6 +44,7 @@ All rights reserved.
|
|||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
|
#include <Debug.h>
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <Dragger.h>
|
#include <Dragger.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
@@ -54,13 +57,14 @@ All rights reserved.
|
|||||||
|
|
||||||
#include "icons.h"
|
#include "icons.h"
|
||||||
#include "tracker_private.h"
|
#include "tracker_private.h"
|
||||||
#include "BarApp.h"
|
|
||||||
#include "BarView.h"
|
#include "BarView.h"
|
||||||
#include "BarWindow.h"
|
#include "BarWindow.h"
|
||||||
|
#include "PreferencesWindow.h"
|
||||||
#include "DeskbarUtils.h"
|
#include "DeskbarUtils.h"
|
||||||
#include "FSUtils.h"
|
#include "FSUtils.h"
|
||||||
#include "PublicCommands.h"
|
#include "PublicCommands.h"
|
||||||
#include "ResourceSet.h"
|
#include "ResourceSet.h"
|
||||||
|
#include "StatusView.h"
|
||||||
#include "Switcher.h"
|
#include "Switcher.h"
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
|
|
||||||
@@ -97,6 +101,7 @@ TBarApp::TBarApp()
|
|||||||
InitIconPreloader();
|
InitIconPreloader();
|
||||||
|
|
||||||
fBarWindow = new TBarWindow();
|
fBarWindow = new TBarWindow();
|
||||||
|
fBarView = fBarWindow->BarView();
|
||||||
|
|
||||||
be_roster->StartWatching(this);
|
be_roster->StartWatching(this);
|
||||||
|
|
||||||
@@ -127,7 +132,7 @@ TBarApp::TBarApp()
|
|||||||
// Call UpdatePlacement() after the window is shown because expanded apps
|
// Call UpdatePlacement() after the window is shown because expanded apps
|
||||||
// need to resize the window.
|
// need to resize the window.
|
||||||
if (fBarWindow->Lock()) {
|
if (fBarWindow->Lock()) {
|
||||||
BarView()->UpdatePlacement();
|
fBarView->UpdatePlacement();
|
||||||
fBarWindow->Unlock();
|
fBarWindow->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +205,9 @@ TBarApp::SaveSettings()
|
|||||||
storedSettings.AddFloat("width", fSettings.width);
|
storedSettings.AddFloat("width", fSettings.width);
|
||||||
|
|
||||||
storedSettings.AddBool("showTime", fSettings.showTime);
|
storedSettings.AddBool("showTime", fSettings.showTime);
|
||||||
storedSettings.AddBool("timeFormat", fSettings.timeFormat);
|
storedSettings.AddBool("showSeconds", fSettings.showSeconds);
|
||||||
|
storedSettings.AddBool("showDayOfWeek", fSettings.showDayOfWeek);
|
||||||
|
storedSettings.AddBool("showTimeZone", fSettings.showTimeZone);
|
||||||
|
|
||||||
storedSettings.AddPoint("switcherLoc", fSettings.switcherLoc);
|
storedSettings.AddPoint("switcherLoc", fSettings.switcherLoc);
|
||||||
storedSettings.AddInt32("recentAppsCount", fSettings.recentAppsCount);
|
storedSettings.AddInt32("recentAppsCount", fSettings.recentAppsCount);
|
||||||
@@ -239,7 +246,9 @@ TBarApp::InitSettings()
|
|||||||
settings.left = false;
|
settings.left = false;
|
||||||
settings.top = true;
|
settings.top = true;
|
||||||
settings.showTime = true;
|
settings.showTime = true;
|
||||||
settings.timeFormat = B_SHORT_TIME_FORMAT;
|
settings.showSeconds = false;
|
||||||
|
settings.showDayOfWeek = false;
|
||||||
|
settings.showTimeZone = false;
|
||||||
settings.state = kExpandoState;
|
settings.state = kExpandoState;
|
||||||
settings.width = 0;
|
settings.width = 0;
|
||||||
settings.switcherLoc = BPoint(5000, 5000);
|
settings.switcherLoc = BPoint(5000, 5000);
|
||||||
@@ -298,9 +307,17 @@ TBarApp::InitSettings()
|
|||||||
!= B_OK) {
|
!= B_OK) {
|
||||||
settings.showTime = true;
|
settings.showTime = true;
|
||||||
}
|
}
|
||||||
if (storedSettings.FindUInt32("timeFormat", &settings.timeFormat)
|
if (storedSettings.FindBool("showSeconds", &settings.showSeconds)
|
||||||
!= B_OK) {
|
!= B_OK) {
|
||||||
settings.timeFormat = B_SHORT_TIME_FORMAT;
|
settings.showSeconds = false;
|
||||||
|
}
|
||||||
|
if (storedSettings.FindBool("showDayOfWeek", &settings.showDayOfWeek)
|
||||||
|
!= B_OK) {
|
||||||
|
settings.showDayOfWeek = false;
|
||||||
|
}
|
||||||
|
if (storedSettings.FindBool("showTimeZone", &settings.showTimeZone)
|
||||||
|
!= B_OK) {
|
||||||
|
settings.showTimeZone = false;
|
||||||
}
|
}
|
||||||
if (storedSettings.FindPoint("switcherLoc", &settings.switcherLoc)
|
if (storedSettings.FindPoint("switcherLoc", &settings.switcherLoc)
|
||||||
!= B_OK) {
|
!= B_OK) {
|
||||||
@@ -494,7 +511,7 @@ TBarApp::MessageReceived(BMessage* message)
|
|||||||
!fSettings.autoRaise;
|
!fSettings.autoRaise;
|
||||||
|
|
||||||
fBarWindow->Lock();
|
fBarWindow->Lock();
|
||||||
BarView()->UpdateEventMask();
|
fBarView->UpdateEventMask();
|
||||||
fBarWindow->Unlock();
|
fBarWindow->Unlock();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -502,8 +519,8 @@ TBarApp::MessageReceived(BMessage* message)
|
|||||||
fSettings.autoHide = !fSettings.autoHide;
|
fSettings.autoHide = !fSettings.autoHide;
|
||||||
|
|
||||||
fBarWindow->Lock();
|
fBarWindow->Lock();
|
||||||
BarView()->UpdateEventMask();
|
fBarView->UpdateEventMask();
|
||||||
BarView()->HideDeskbar(fSettings.autoHide);
|
fBarView->HideDeskbar(fSettings.autoHide);
|
||||||
fBarWindow->Unlock();
|
fBarWindow->Unlock();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -511,7 +528,7 @@ TBarApp::MessageReceived(BMessage* message)
|
|||||||
fSettings.trackerAlwaysFirst = !fSettings.trackerAlwaysFirst;
|
fSettings.trackerAlwaysFirst = !fSettings.trackerAlwaysFirst;
|
||||||
|
|
||||||
fBarWindow->Lock();
|
fBarWindow->Lock();
|
||||||
BarView()->PlaceApplicationBar();
|
fBarView->PlaceApplicationBar();
|
||||||
fBarWindow->Unlock();
|
fBarWindow->Unlock();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -519,7 +536,7 @@ TBarApp::MessageReceived(BMessage* message)
|
|||||||
fSettings.sortRunningApps = !fSettings.sortRunningApps;
|
fSettings.sortRunningApps = !fSettings.sortRunningApps;
|
||||||
|
|
||||||
fBarWindow->Lock();
|
fBarWindow->Lock();
|
||||||
BarView()->PlaceApplicationBar();
|
fBarView->PlaceApplicationBar();
|
||||||
fBarWindow->Unlock();
|
fBarWindow->Unlock();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -535,7 +552,7 @@ TBarApp::MessageReceived(BMessage* message)
|
|||||||
fSettings.superExpando = !fSettings.superExpando;
|
fSettings.superExpando = !fSettings.superExpando;
|
||||||
|
|
||||||
fBarWindow->Lock();
|
fBarWindow->Lock();
|
||||||
BarView()->PlaceApplicationBar();
|
fBarView->PlaceApplicationBar();
|
||||||
fBarWindow->Unlock();
|
fBarWindow->Unlock();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -543,7 +560,7 @@ TBarApp::MessageReceived(BMessage* message)
|
|||||||
fSettings.expandNewTeams = !fSettings.expandNewTeams;
|
fSettings.expandNewTeams = !fSettings.expandNewTeams;
|
||||||
|
|
||||||
fBarWindow->Lock();
|
fBarWindow->Lock();
|
||||||
BarView()->PlaceApplicationBar();
|
fBarView->PlaceApplicationBar();
|
||||||
fBarWindow->Unlock();
|
fBarWindow->Unlock();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -551,7 +568,7 @@ TBarApp::MessageReceived(BMessage* message)
|
|||||||
fSettings.hideLabels = !fSettings.hideLabels;
|
fSettings.hideLabels = !fSettings.hideLabels;
|
||||||
|
|
||||||
fBarWindow->Lock();
|
fBarWindow->Lock();
|
||||||
BarView()->PlaceApplicationBar();
|
fBarView->PlaceApplicationBar();
|
||||||
fBarWindow->Unlock();
|
fBarWindow->Unlock();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -571,14 +588,14 @@ TBarApp::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
ResizeTeamIcons();
|
ResizeTeamIcons();
|
||||||
|
|
||||||
if (BarView()->MiniState())
|
if (fBarView->MiniState())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
fBarWindow->Lock();
|
fBarWindow->Lock();
|
||||||
if (BarView()->Vertical())
|
if (fBarView->Vertical())
|
||||||
BarView()->PlaceApplicationBar();
|
fBarView->PlaceApplicationBar();
|
||||||
else
|
else
|
||||||
BarView()->UpdatePlacement();
|
fBarView->UpdatePlacement();
|
||||||
|
|
||||||
fBarWindow->Unlock();
|
fBarWindow->Unlock();
|
||||||
break;
|
break;
|
||||||
@@ -761,7 +778,7 @@ TBarApp::AddTeam(team_id team, uint32 flags, const char* sig, entry_ref* ref)
|
|||||||
sBarTeamInfoList.AddItem(barInfo);
|
sBarTeamInfoList.AddItem(barInfo);
|
||||||
|
|
||||||
if (fSettings.expandNewTeams)
|
if (fSettings.expandNewTeams)
|
||||||
BarView()->AddExpandedItem(sig);
|
fBarView->AddExpandedItem(sig);
|
||||||
|
|
||||||
int32 subsCount = sSubscribers.CountItems();
|
int32 subsCount = sSubscribers.CountItems();
|
||||||
if (subsCount > 0) {
|
if (subsCount > 0) {
|
||||||
|
|||||||
+28
-38
@@ -37,11 +37,6 @@ All rights reserved.
|
|||||||
|
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Catalog.h>
|
|
||||||
#include <List.h>
|
|
||||||
#include "BarWindow.h"
|
|
||||||
#include "PreferencesWindow.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------ */
|
/* ------------------------------------ */
|
||||||
// Private app_server defines that I need to use
|
// Private app_server defines that I need to use
|
||||||
@@ -51,20 +46,6 @@ All rights reserved.
|
|||||||
#define _STD_W_TYPE_ 0
|
#define _STD_W_TYPE_ 0
|
||||||
|
|
||||||
|
|
||||||
class BarTeamInfo {
|
|
||||||
public:
|
|
||||||
BarTeamInfo(BList* teams, uint32 flags, char* sig, BBitmap* icon,
|
|
||||||
char* name);
|
|
||||||
BarTeamInfo(const BarTeamInfo &info);
|
|
||||||
~BarTeamInfo();
|
|
||||||
|
|
||||||
BList* teams;
|
|
||||||
uint32 flags;
|
|
||||||
char* sig;
|
|
||||||
BBitmap* icon;
|
|
||||||
char* name;
|
|
||||||
};
|
|
||||||
|
|
||||||
const uint32 kWin95 = 'Bill';
|
const uint32 kWin95 = 'Bill';
|
||||||
const uint32 kAmiga = 'Ncro';
|
const uint32 kAmiga = 'Ncro';
|
||||||
const uint32 kMac = 'WcOS';
|
const uint32 kMac = 'WcOS';
|
||||||
@@ -76,14 +57,6 @@ const uint32 kAddTeam = 'AdTm';
|
|||||||
const uint32 kRemoveTeam = 'RmTm';
|
const uint32 kRemoveTeam = 'RmTm';
|
||||||
const uint32 kRestart = 'Rtrt';
|
const uint32 kRestart = 'Rtrt';
|
||||||
const uint32 kShutDown = 'ShDn';
|
const uint32 kShutDown = 'ShDn';
|
||||||
const uint32 kTrackerFirst = 'TkFt';
|
|
||||||
const uint32 kSortRunningApps = 'SAps';
|
|
||||||
const uint32 kSuperExpando = 'SprE';
|
|
||||||
const uint32 kExpandNewTeams = 'ExTm';
|
|
||||||
const uint32 kHideLabels = 'hLbs';
|
|
||||||
const uint32 kResizeTeamIcons = 'RTIs';
|
|
||||||
const uint32 kAutoRaise = 'AtRs';
|
|
||||||
const uint32 kAutoHide = 'AtHd';
|
|
||||||
const uint32 kRestartTracker = 'Trak';
|
const uint32 kRestartTracker = 'Trak';
|
||||||
|
|
||||||
// from roster_private.h
|
// from roster_private.h
|
||||||
@@ -103,7 +76,9 @@ struct desk_settings {
|
|||||||
bool left;
|
bool left;
|
||||||
bool top;
|
bool top;
|
||||||
bool showTime;
|
bool showTime;
|
||||||
uint32 timeFormat;
|
bool showSeconds;
|
||||||
|
bool showDayOfWeek;
|
||||||
|
bool showTimeZone;
|
||||||
uint32 state;
|
uint32 state;
|
||||||
float width;
|
float width;
|
||||||
BPoint switcherLoc;
|
BPoint switcherLoc;
|
||||||
@@ -126,11 +101,28 @@ struct desk_settings {
|
|||||||
bool recentFoldersEnabled;
|
bool recentFoldersEnabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TBarView;
|
|
||||||
class BFile;
|
class BFile;
|
||||||
|
class BList;
|
||||||
|
class BBitmap;
|
||||||
|
class PreferencesWindow;
|
||||||
|
class TBarView;
|
||||||
|
class TBarWindow;
|
||||||
|
|
||||||
|
|
||||||
|
class BarTeamInfo {
|
||||||
|
public:
|
||||||
|
BarTeamInfo(BList* teams, uint32 flags, char* sig, BBitmap* icon,
|
||||||
|
char* name);
|
||||||
|
BarTeamInfo(const BarTeamInfo &info);
|
||||||
|
~BarTeamInfo();
|
||||||
|
|
||||||
|
BList* teams;
|
||||||
|
uint32 flags;
|
||||||
|
char* sig;
|
||||||
|
BBitmap* icon;
|
||||||
|
char* name;
|
||||||
|
};
|
||||||
|
|
||||||
using namespace BPrivate;
|
|
||||||
|
|
||||||
class TBarApp : public BApplication {
|
class TBarApp : public BApplication {
|
||||||
public:
|
public:
|
||||||
@@ -141,12 +133,9 @@ class TBarApp : public BApplication {
|
|||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual void RefsReceived(BMessage* refs);
|
virtual void RefsReceived(BMessage* refs);
|
||||||
|
|
||||||
desk_settings* Settings()
|
desk_settings* Settings() { return &fSettings; }
|
||||||
{ return &fSettings; }
|
TBarView* BarView() const { return fBarView; }
|
||||||
TBarView* BarView() const
|
TBarWindow* BarWindow() const { return fBarWindow; }
|
||||||
{ return fBarWindow->BarView(); }
|
|
||||||
TBarWindow* BarWindow() const
|
|
||||||
{ return fBarWindow; }
|
|
||||||
|
|
||||||
static void Subscribe(const BMessenger &subscriber, BList*);
|
static void Subscribe(const BMessenger &subscriber, BList*);
|
||||||
static void Unsubscribe(const BMessenger &subscriber);
|
static void Unsubscribe(const BMessenger &subscriber);
|
||||||
@@ -165,6 +154,7 @@ class TBarApp : public BApplication {
|
|||||||
BRect IconRect();
|
BRect IconRect();
|
||||||
|
|
||||||
TBarWindow* fBarWindow;
|
TBarWindow* fBarWindow;
|
||||||
|
TBarView* fBarView;
|
||||||
BMessenger fSwitcherMessenger;
|
BMessenger fSwitcherMessenger;
|
||||||
BMessenger fStatusViewMessenger;
|
BMessenger fStatusViewMessenger;
|
||||||
BFile* fSettingsFile;
|
BFile* fSettingsFile;
|
||||||
@@ -177,5 +167,5 @@ class TBarApp : public BApplication {
|
|||||||
static BList sSubscribers;
|
static BList sSubscribers;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BAR_APP_H
|
|
||||||
|
|
||||||
|
#endif // BAR_APP_H
|
||||||
|
|||||||
@@ -36,12 +36,17 @@ All rights reserved.
|
|||||||
#ifndef BARVIEW_H
|
#ifndef BARVIEW_H
|
||||||
#define BARVIEW_H
|
#define BARVIEW_H
|
||||||
|
|
||||||
|
|
||||||
#include <Deskbar.h>
|
#include <Deskbar.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
#include "NavMenu.h"
|
#include "NavMenu.h"
|
||||||
#include "ObjectList.h"
|
#include "ObjectList.h"
|
||||||
|
|
||||||
|
|
||||||
|
const uint32 kStateChanged = 'stch';
|
||||||
|
|
||||||
|
|
||||||
enum DeskbarShelf {
|
enum DeskbarShelf {
|
||||||
B_DESKBAR_ANY_SHELF = 0,
|
B_DESKBAR_ANY_SHELF = 0,
|
||||||
B_DESKBAR_TRAY = 1
|
B_DESKBAR_TRAY = 1
|
||||||
@@ -53,6 +58,7 @@ enum {
|
|||||||
kFullState = 2
|
kFullState = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const float kMiniHeight = 46.0f;
|
const float kMiniHeight = 46.0f;
|
||||||
const float kHModeHeight = 21.0f;
|
const float kHModeHeight = 21.0f;
|
||||||
const float kMenuBarHeight = 21.0f;
|
const float kMenuBarHeight = 21.0f;
|
||||||
@@ -60,6 +66,7 @@ const float kStatusHeight = 22.0f;
|
|||||||
const float kHiddenDimension = 1.0f;
|
const float kHiddenDimension = 1.0f;
|
||||||
const float kMaxPreventHidingDist = 80.0f;
|
const float kMaxPreventHidingDist = 80.0f;
|
||||||
|
|
||||||
|
|
||||||
class BShelf;
|
class BShelf;
|
||||||
class TBarMenuBar;
|
class TBarMenuBar;
|
||||||
class TExpandoMenuBar;
|
class TExpandoMenuBar;
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ All rights reserved.
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
|
#include <Catalog.h>
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ private:
|
|||||||
bool _IsFocusMessage(BMessage* message);
|
bool _IsFocusMessage(BMessage* message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static TDeskbarMenu* sDeskbarMenu;
|
static TDeskbarMenu* sDeskbarMenu;
|
||||||
TBarView* fBarView;
|
TBarView* fBarView;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -400,7 +400,9 @@ TDeskbarMenu::ResetTargets()
|
|||||||
|
|
||||||
case kShowHideTime:
|
case kShowHideTime:
|
||||||
case kTimeIntervalChanged:
|
case kTimeIntervalChanged:
|
||||||
case kTimeFormatChanged:
|
case kShowSeconds:
|
||||||
|
case kShowDayOfWeek:
|
||||||
|
case kShowTimeZone:
|
||||||
item->SetTarget(fBarView->fReplicantTray);
|
item->SetTarget(fBarView->fReplicantTray);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ All rights reserved.
|
|||||||
#include "BarApp.h"
|
#include "BarApp.h"
|
||||||
#include "BarMenuTitle.h"
|
#include "BarMenuTitle.h"
|
||||||
#include "BarView.h"
|
#include "BarView.h"
|
||||||
|
#include "BarWindow.h"
|
||||||
#include "DeskbarMenu.h"
|
#include "DeskbarMenu.h"
|
||||||
#include "DeskbarUtils.h"
|
#include "DeskbarUtils.h"
|
||||||
#include "ExpandoMenuBar.h"
|
#include "ExpandoMenuBar.h"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
* All Rights Reserved. Distributed under the terms of the MIT License.
|
* All Rights Reserved. Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
|
* John Scipione, jscipione@gmail.com
|
||||||
* Jonas Sundström, jonas@kirilla.com
|
* Jonas Sundström, jonas@kirilla.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -11,6 +12,8 @@
|
|||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include <Box.h>
|
||||||
|
#include <Button.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <CheckBox.h>
|
#include <CheckBox.h>
|
||||||
#include <FormattingConventions.h>
|
#include <FormattingConventions.h>
|
||||||
@@ -22,6 +25,7 @@
|
|||||||
#include <SeparatorView.h>
|
#include <SeparatorView.h>
|
||||||
#include <Slider.h>
|
#include <Slider.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
|
#include <TextControl.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
#include "BarApp.h"
|
#include "BarApp.h"
|
||||||
@@ -91,22 +95,12 @@ PreferencesWindow::PreferencesWindow(BRect frame)
|
|||||||
fTimeInterval24HourRadioButton = new BRadioButton("time inteval",
|
fTimeInterval24HourRadioButton = new BRadioButton("time inteval",
|
||||||
B_TRANSLATE("24 hour"), timeInterval24HoursMessage);
|
B_TRANSLATE("24 hour"), timeInterval24HoursMessage);
|
||||||
|
|
||||||
BMessage* timeFormatShortMessage = new BMessage(kTimeFormatChanged);
|
fShowSeconds = new BCheckBox(B_TRANSLATE("Show seconds"),
|
||||||
timeFormatShortMessage->AddUInt32("time format", B_SHORT_TIME_FORMAT);
|
new BMessage(kShowSeconds));
|
||||||
fTimeFormatShortRadioButton = new BRadioButton("time format",
|
fShowDayOfWeek = new BCheckBox(B_TRANSLATE("Show day of week"),
|
||||||
"Short", timeFormatShortMessage);
|
new BMessage(kShowDayOfWeek));
|
||||||
|
fShowTimeZone = new BCheckBox(B_TRANSLATE("Show time zone"),
|
||||||
BMessage* timeFormatMediumMessage = new BMessage(kTimeFormatChanged);
|
new BMessage(kShowTimeZone));
|
||||||
timeFormatMediumMessage->AddUInt32("time format", B_MEDIUM_TIME_FORMAT);
|
|
||||||
fTimeFormatMediumRadioButton = new BRadioButton("time format",
|
|
||||||
"Medium", timeFormatMediumMessage);
|
|
||||||
|
|
||||||
BMessage* timeFormatLongMessage = new BMessage(kTimeFormatChanged);
|
|
||||||
timeFormatLongMessage->AddUInt32("time format", B_LONG_TIME_FORMAT);
|
|
||||||
fTimeFormatLongRadioButton = new BRadioButton("time format",
|
|
||||||
"Long", timeFormatLongMessage);
|
|
||||||
|
|
||||||
_UpdateTimeFormatRadioButtonLabels();
|
|
||||||
|
|
||||||
// Get settings from BarApp
|
// Get settings from BarApp
|
||||||
TBarApp* barApp = static_cast<TBarApp*>(be_app);
|
TBarApp* barApp = static_cast<TBarApp*>(be_app);
|
||||||
@@ -175,18 +169,18 @@ PreferencesWindow::PreferencesWindow(BRect frame)
|
|||||||
else
|
else
|
||||||
fTimeInterval12HourRadioButton->SetValue(B_CONTROL_ON);
|
fTimeInterval12HourRadioButton->SetValue(B_CONTROL_ON);
|
||||||
|
|
||||||
switch (settings->timeFormat) {
|
TReplicantTray* replicantTray = barApp->BarView()->ReplicantTray();
|
||||||
case B_LONG_TIME_FORMAT:
|
if (replicantTray->Time() != NULL) {
|
||||||
fTimeFormatLongRadioButton->SetValue(B_CONTROL_ON);
|
fShowSeconds->SetValue(replicantTray->Time()->ShowSeconds());
|
||||||
break;
|
fShowDayOfWeek->SetValue(replicantTray->Time()->ShowDayOfWeek());
|
||||||
case B_MEDIUM_TIME_FORMAT:
|
fShowTimeZone->SetValue(replicantTray->Time()->ShowTimeZone());
|
||||||
fTimeFormatMediumRadioButton->SetValue(B_CONTROL_ON);
|
} else {
|
||||||
break;
|
fShowSeconds->SetValue(settings->showSeconds);
|
||||||
default:
|
fShowDayOfWeek->SetValue(settings->showDayOfWeek);
|
||||||
fTimeFormatShortRadioButton->SetValue(B_CONTROL_ON);
|
fShowTimeZone->SetValue(settings->showTimeZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
_EnableDisableDependentItems();
|
EnableDisableDependentItems();
|
||||||
|
|
||||||
// Targets
|
// Targets
|
||||||
fAppsSort->SetTarget(be_app);
|
fAppsSort->SetTarget(be_app);
|
||||||
@@ -199,12 +193,12 @@ PreferencesWindow::PreferencesWindow(BRect frame)
|
|||||||
fWindowAutoRaise->SetTarget(be_app);
|
fWindowAutoRaise->SetTarget(be_app);
|
||||||
fWindowAutoHide->SetTarget(be_app);
|
fWindowAutoHide->SetTarget(be_app);
|
||||||
|
|
||||||
TReplicantTray* replicantTray = barApp->BarView()->fReplicantTray;
|
|
||||||
fTimeInterval12HourRadioButton->SetTarget(replicantTray);
|
fTimeInterval12HourRadioButton->SetTarget(replicantTray);
|
||||||
fTimeInterval24HourRadioButton->SetTarget(replicantTray);
|
fTimeInterval24HourRadioButton->SetTarget(replicantTray);
|
||||||
fTimeFormatShortRadioButton->SetTarget(replicantTray);
|
|
||||||
fTimeFormatMediumRadioButton->SetTarget(replicantTray);
|
fShowSeconds->SetTarget(replicantTray);
|
||||||
fTimeFormatLongRadioButton->SetTarget(replicantTray);
|
fShowDayOfWeek->SetTarget(replicantTray);
|
||||||
|
fShowTimeZone->SetTarget(replicantTray);
|
||||||
|
|
||||||
// Layout
|
// Layout
|
||||||
fMenuBox = new BBox("fMenuBox");
|
fMenuBox = new BBox("fMenuBox");
|
||||||
@@ -281,21 +275,6 @@ PreferencesWindow::PreferencesWindow(BRect frame)
|
|||||||
timeIntervalView->AddChild(fTimeInterval12HourRadioButton);
|
timeIntervalView->AddChild(fTimeInterval12HourRadioButton);
|
||||||
timeIntervalView->AddChild(fTimeInterval24HourRadioButton);
|
timeIntervalView->AddChild(fTimeInterval24HourRadioButton);
|
||||||
|
|
||||||
BStringView* timeFormatLabel = new BStringView("format",
|
|
||||||
B_TRANSLATE("Format"));
|
|
||||||
timeFormatLabel->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED,
|
|
||||||
B_SIZE_UNSET));
|
|
||||||
timeFormatLabel->SetLowColor((rgb_color){255, 255, 255, 255});
|
|
||||||
|
|
||||||
BGroupLayout* timeFormatLayout = new BGroupLayout(B_VERTICAL, 0);
|
|
||||||
timeFormatLayout->SetInsets(10, 0, 0, 0);
|
|
||||||
BView* timeFormatView = new BView("format", 0, timeFormatLayout);
|
|
||||||
timeFormatView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
timeFormatView->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
timeFormatView->AddChild(fTimeFormatShortRadioButton);
|
|
||||||
timeFormatView->AddChild(fTimeFormatMediumRadioButton);
|
|
||||||
timeFormatView->AddChild(fTimeFormatLongRadioButton);
|
|
||||||
|
|
||||||
view = BLayoutBuilder::Group<>()
|
view = BLayoutBuilder::Group<>()
|
||||||
.AddGroup(B_VERTICAL, 10)
|
.AddGroup(B_VERTICAL, 10)
|
||||||
.AddGroup(B_VERTICAL, 0)
|
.AddGroup(B_VERTICAL, 0)
|
||||||
@@ -303,8 +282,9 @@ PreferencesWindow::PreferencesWindow(BRect frame)
|
|||||||
.Add(timeIntervalView)
|
.Add(timeIntervalView)
|
||||||
.End()
|
.End()
|
||||||
.AddGroup(B_VERTICAL, 0)
|
.AddGroup(B_VERTICAL, 0)
|
||||||
.Add(timeFormatLabel)
|
.Add(fShowSeconds)
|
||||||
.Add(timeFormatView)
|
.Add(fShowDayOfWeek)
|
||||||
|
.Add(fShowTimeZone)
|
||||||
.End()
|
.End()
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
.SetInsets(10, 10, 10, 10)
|
.SetInsets(10, 10, 10, 10)
|
||||||
@@ -328,7 +308,7 @@ PreferencesWindow::PreferencesWindow(BRect frame)
|
|||||||
|
|
||||||
PreferencesWindow::~PreferencesWindow()
|
PreferencesWindow::~PreferencesWindow()
|
||||||
{
|
{
|
||||||
_UpdateRecentCounts();
|
UpdateRecentCounts();
|
||||||
be_app->PostMessage(kConfigClose);
|
be_app->PostMessage(kConfigClose);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,16 +322,16 @@ PreferencesWindow::MessageReceived(BMessage* message)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kUpdateRecentCounts:
|
case kUpdateRecentCounts:
|
||||||
_UpdateRecentCounts();
|
UpdateRecentCounts();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kSuperExpando:
|
case kSuperExpando:
|
||||||
_EnableDisableDependentItems();
|
EnableDisableDependentItems();
|
||||||
be_app->PostMessage(message);
|
be_app->PostMessage(message);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kStateChanged:
|
case kStateChanged:
|
||||||
_EnableDisableDependentItems();
|
EnableDisableDependentItems();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -370,7 +350,7 @@ PreferencesWindow::WindowActivated(bool active)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PreferencesWindow::_UpdateRecentCounts()
|
PreferencesWindow::UpdateRecentCounts()
|
||||||
{
|
{
|
||||||
BMessage message(kUpdateRecentCounts);
|
BMessage message(kUpdateRecentCounts);
|
||||||
|
|
||||||
@@ -388,12 +368,12 @@ PreferencesWindow::_UpdateRecentCounts()
|
|||||||
|
|
||||||
be_app->PostMessage(&message);
|
be_app->PostMessage(&message);
|
||||||
|
|
||||||
_EnableDisableDependentItems();
|
EnableDisableDependentItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PreferencesWindow::_EnableDisableDependentItems()
|
PreferencesWindow::EnableDisableDependentItems()
|
||||||
{
|
{
|
||||||
TBarApp* barApp = static_cast<TBarApp*>(be_app);
|
TBarApp* barApp = static_cast<TBarApp*>(be_app);
|
||||||
if (barApp->BarView()->Vertical()
|
if (barApp->BarView()->Vertical()
|
||||||
@@ -415,20 +395,3 @@ PreferencesWindow::_EnableDisableDependentItems()
|
|||||||
fWindowAutoRaise->SetEnabled(
|
fWindowAutoRaise->SetEnabled(
|
||||||
fWindowAlwaysOnTop->Value() == B_CONTROL_OFF);
|
fWindowAlwaysOnTop->Value() == B_CONTROL_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
PreferencesWindow::_UpdateTimeFormatRadioButtonLabels()
|
|
||||||
{
|
|
||||||
time_t timeValue = (time_t)time(NULL);
|
|
||||||
BString result;
|
|
||||||
|
|
||||||
BLocale::Default()->FormatTime(&result, timeValue, B_SHORT_TIME_FORMAT);
|
|
||||||
fTimeFormatShortRadioButton->SetLabel(result);
|
|
||||||
|
|
||||||
BLocale::Default()->FormatTime(&result, timeValue, B_MEDIUM_TIME_FORMAT);
|
|
||||||
fTimeFormatMediumRadioButton->SetLabel(result);
|
|
||||||
|
|
||||||
BLocale::Default()->FormatTime(&result, timeValue, B_LONG_TIME_FORMAT);
|
|
||||||
fTimeFormatLongRadioButton->SetLabel(result);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,22 +6,36 @@
|
|||||||
#define _PREFERENCES_WINDOW_H
|
#define _PREFERENCES_WINDOW_H
|
||||||
|
|
||||||
|
|
||||||
#include <Box.h>
|
|
||||||
#include <Button.h>
|
|
||||||
#include <CheckBox.h>
|
|
||||||
#include <RadioButton.h>
|
|
||||||
#include <Slider.h>
|
|
||||||
#include <StringView.h>
|
|
||||||
#include <TextControl.h>
|
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
const uint32 kConfigShow = 'show';
|
const uint32 kConfigShow = 'show';
|
||||||
const uint32 kConfigClose = 'canc';
|
const uint32 kConfigClose = 'canc';
|
||||||
const uint32 kUpdateRecentCounts = 'upct';
|
const uint32 kUpdateRecentCounts = 'upct';
|
||||||
const uint32 kEditMenuInTracker = 'mtrk';
|
const uint32 kEditMenuInTracker = 'mtrk';
|
||||||
const uint32 kStateChanged = 'stch';
|
|
||||||
|
|
||||||
|
const uint32 kTrackerFirst = 'TkFt';
|
||||||
|
const uint32 kSortRunningApps = 'SAps';
|
||||||
|
const uint32 kSuperExpando = 'SprE';
|
||||||
|
const uint32 kExpandNewTeams = 'ExTm';
|
||||||
|
const uint32 kHideLabels = 'hLbs';
|
||||||
|
const uint32 kResizeTeamIcons = 'RTIs';
|
||||||
|
const uint32 kAutoRaise = 'AtRs';
|
||||||
|
const uint32 kAutoHide = 'AtHd';
|
||||||
|
|
||||||
|
const uint32 kShowHideTime = 'ShTm';
|
||||||
|
const uint32 kTimeIntervalChanged = 'TiCh';
|
||||||
|
const uint32 kShowSeconds = 'SwSc';
|
||||||
|
const uint32 kShowDayOfWeek = 'SwDw';
|
||||||
|
const uint32 kShowTimeZone = 'SwTz';
|
||||||
|
|
||||||
|
class BBox;
|
||||||
|
class BButton;
|
||||||
|
class BCheckBox;
|
||||||
|
class BRadioButton;
|
||||||
|
class BSlider;
|
||||||
|
class BStringView;
|
||||||
|
class BTextControl;
|
||||||
|
|
||||||
class PreferencesWindow : public BWindow
|
class PreferencesWindow : public BWindow
|
||||||
{
|
{
|
||||||
@@ -29,14 +43,13 @@ public:
|
|||||||
PreferencesWindow(BRect frame);
|
PreferencesWindow(BRect frame);
|
||||||
~PreferencesWindow();
|
~PreferencesWindow();
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual void WindowActivated(bool active);
|
virtual void WindowActivated(bool active);
|
||||||
|
|
||||||
|
void UpdateRecentCounts();
|
||||||
|
void EnableDisableDependentItems();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _UpdateRecentCounts();
|
|
||||||
void _EnableDisableDependentItems();
|
|
||||||
void _UpdateTimeFormatRadioButtonLabels();
|
|
||||||
|
|
||||||
BBox* fMenuBox;
|
BBox* fMenuBox;
|
||||||
BBox* fAppsBox;
|
BBox* fAppsBox;
|
||||||
BBox* fClockBox;
|
BBox* fClockBox;
|
||||||
@@ -61,14 +74,13 @@ private:
|
|||||||
BCheckBox* fWindowAutoRaise;
|
BCheckBox* fWindowAutoRaise;
|
||||||
BCheckBox* fWindowAutoHide;
|
BCheckBox* fWindowAutoHide;
|
||||||
|
|
||||||
BCheckBox* fShowTime;
|
|
||||||
BRadioButton* fTimeInterval24HourRadioButton;
|
BRadioButton* fTimeInterval24HourRadioButton;
|
||||||
BRadioButton* fTimeInterval12HourRadioButton;
|
BRadioButton* fTimeInterval12HourRadioButton;
|
||||||
|
|
||||||
BRadioButton* fTimeFormatLongRadioButton;
|
BCheckBox* fShowSeconds;
|
||||||
BRadioButton* fTimeFormatMediumRadioButton;
|
BCheckBox* fShowDayOfWeek;
|
||||||
BRadioButton* fTimeFormatShortRadioButton;
|
BCheckBox* fShowTimeZone;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _PREFERENCES_WINDOW_H
|
|
||||||
|
|
||||||
|
#endif // _PREFERENCES_WINDOW_H
|
||||||
|
|||||||
@@ -143,9 +143,15 @@ TReplicantTray::TReplicantTray(TBarView* parent, bool vertical)
|
|||||||
fMinimumTrayWidth = sMinimumWindowWidth - kGutter - kDragRegionWidth;
|
fMinimumTrayWidth = sMinimumWindowWidth - kGutter - kDragRegionWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BFormattingConventions conventions;
|
||||||
|
BLocale::Default()->GetFormattingConventions(&conventions);
|
||||||
|
bool use24HourClock = conventions.Use24HourClock();
|
||||||
|
desk_settings* settings = ((TBarApp*)be_app)->Settings();
|
||||||
|
|
||||||
// Create the time view
|
// Create the time view
|
||||||
fTime = new TTimeView(fMinimumTrayWidth, kMaxReplicantHeight - 1.0,
|
fTime = new TTimeView(fMinimumTrayWidth, kMaxReplicantHeight - 1.0,
|
||||||
((TBarApp*)be_app)->Settings()->timeFormat);
|
use24HourClock, settings->showSeconds, settings->showDayOfWeek,
|
||||||
|
settings->showTimeZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -202,47 +208,6 @@ TReplicantTray::DetachedFromWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TReplicantTray::SaveTimeSettings()
|
|
||||||
{
|
|
||||||
if (fTime == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
desk_settings* settings = ((TBarApp*)be_app)->Settings();
|
|
||||||
settings->showTime = !fTime->IsHidden();
|
|
||||||
settings->timeFormat = fTime->TimeFormat();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TReplicantTray::ShowHideTime()
|
|
||||||
{
|
|
||||||
if (fTime == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (fTime->IsHidden())
|
|
||||||
fTime->Show();
|
|
||||||
else
|
|
||||||
fTime->Hide();
|
|
||||||
|
|
||||||
RealignReplicants();
|
|
||||||
AdjustPlacement();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TReplicantTray::UpdateTimeFormat(uint32 timeFormat)
|
|
||||||
{
|
|
||||||
if (fTime == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
fTime->SetTimeFormat(timeFormat);
|
|
||||||
|
|
||||||
RealignReplicants();
|
|
||||||
AdjustPlacement();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*! Width is set to a minimum of kMinimumReplicantCount by kMaxReplicantWidth
|
/*! Width is set to a minimum of kMinimumReplicantCount by kMaxReplicantWidth
|
||||||
if not in multirowmode and greater than kMinimumReplicantCount
|
if not in multirowmode and greater than kMinimumReplicantCount
|
||||||
the width should be calculated based on the actual replicant widths
|
the width should be calculated based on the actual replicant widths
|
||||||
@@ -329,7 +294,7 @@ TReplicantTray::MessageReceived(BMessage* message)
|
|||||||
conventions.SetExplicitUse24HourClock(use24HourClock);
|
conventions.SetExplicitUse24HourClock(use24HourClock);
|
||||||
BPrivate::MutableLocaleRoster::Default()->
|
BPrivate::MutableLocaleRoster::Default()->
|
||||||
SetDefaultFormattingConventions(conventions);
|
SetDefaultFormattingConventions(conventions);
|
||||||
fTime->Update();
|
fTime->SetUse24HourClock(use24HourClock);
|
||||||
// time string reformat -> realign
|
// time string reformat -> realign
|
||||||
RealignReplicants();
|
RealignReplicants();
|
||||||
AdjustPlacement();
|
AdjustPlacement();
|
||||||
@@ -338,17 +303,38 @@ TReplicantTray::MessageReceived(BMessage* message)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case kTimeFormatChanged:
|
case kShowSeconds:
|
||||||
{
|
|
||||||
if (fTime == NULL)
|
if (fTime == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint32 timeFormat;
|
fTime->SetShowSeconds(!fTime->ShowSeconds());
|
||||||
if (message->FindUInt32("time format", &timeFormat) == B_OK)
|
|
||||||
UpdateTimeFormat(timeFormat);
|
|
||||||
|
|
||||||
|
// time string reformat -> realign
|
||||||
|
RealignReplicants();
|
||||||
|
AdjustPlacement();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kShowDayOfWeek:
|
||||||
|
if (fTime == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fTime->SetShowDayOfWeek(!fTime->ShowDayOfWeek());
|
||||||
|
|
||||||
|
// time string reformat -> realign
|
||||||
|
RealignReplicants();
|
||||||
|
AdjustPlacement();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kShowTimeZone:
|
||||||
|
if (fTime == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fTime->SetShowTimeZone(!fTime->ShowTimeZone());
|
||||||
|
|
||||||
|
// time string reformat -> realign
|
||||||
|
RealignReplicants();
|
||||||
|
AdjustPlacement();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DB_ADDONS
|
#ifdef DB_ADDONS
|
||||||
case B_NODE_MONITOR:
|
case B_NODE_MONITOR:
|
||||||
@@ -363,28 +349,6 @@ TReplicantTray::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TReplicantTray::ShowReplicantMenu(BPoint point)
|
|
||||||
{
|
|
||||||
BPopUpMenu* menu = new BPopUpMenu("", false, false);
|
|
||||||
menu->SetFont(be_plain_font);
|
|
||||||
|
|
||||||
// If clock is visible show the extended menu, otherwise show "Show Time"
|
|
||||||
|
|
||||||
if (!fTime->IsHidden())
|
|
||||||
fTime->ShowTimeOptions(ConvertToScreen(point));
|
|
||||||
else {
|
|
||||||
BMenuItem* item = new BMenuItem(B_TRANSLATE("Show Time"),
|
|
||||||
new BMessage(kShowHideTime));
|
|
||||||
menu->AddItem(item);
|
|
||||||
menu->SetTargetForItems(this);
|
|
||||||
BPoint where = ConvertToScreen(point);
|
|
||||||
menu->Go(where, true, true, BRect(where - BPoint(4, 4),
|
|
||||||
where + BPoint(4, 4)), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TReplicantTray::MouseDown(BPoint where)
|
TReplicantTray::MouseDown(BPoint where)
|
||||||
{
|
{
|
||||||
@@ -423,8 +387,55 @@ TReplicantTray::MouseDown(BPoint where)
|
|||||||
BView::MouseDown(where);
|
BView::MouseDown(where);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TReplicantTray::ShowReplicantMenu(BPoint point)
|
||||||
|
{
|
||||||
|
BPopUpMenu* menu = new BPopUpMenu("", false, false);
|
||||||
|
menu->SetFont(be_plain_font);
|
||||||
|
|
||||||
|
// If clock is visible show the extended menu, otherwise show "Show time"
|
||||||
|
|
||||||
|
if (!fTime->IsHidden())
|
||||||
|
fTime->ShowTimeOptions(ConvertToScreen(point));
|
||||||
|
else {
|
||||||
|
BMenuItem* item = new BMenuItem(B_TRANSLATE("Show time"),
|
||||||
|
new BMessage(kShowHideTime));
|
||||||
|
menu->AddItem(item);
|
||||||
|
menu->SetTargetForItems(this);
|
||||||
|
BPoint where = ConvertToScreen(point);
|
||||||
|
menu->Go(where, true, true, BRect(where - BPoint(4, 4),
|
||||||
|
where + BPoint(4, 4)), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TReplicantTray::SetMultiRow(bool state)
|
||||||
|
{
|
||||||
|
fMultiRowMode = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TReplicantTray::ShowHideTime()
|
||||||
|
{
|
||||||
|
if (fTime == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (fTime->IsHidden())
|
||||||
|
fTime->Show();
|
||||||
|
else
|
||||||
|
fTime->Hide();
|
||||||
|
|
||||||
|
RealignReplicants();
|
||||||
|
AdjustPlacement();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef DB_ADDONS
|
#ifdef DB_ADDONS
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TReplicantTray::InitAddOnSupport()
|
TReplicantTray::InitAddOnSupport()
|
||||||
{
|
{
|
||||||
@@ -1219,13 +1230,6 @@ TReplicantTray::RealignReplicants(int32 startIndex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TReplicantTray::SetMultiRow(bool state)
|
|
||||||
{
|
|
||||||
fMultiRowMode = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
TReplicantTray::_SaveSettings()
|
TReplicantTray::_SaveSettings()
|
||||||
{
|
{
|
||||||
@@ -1239,11 +1243,25 @@ TReplicantTray::_SaveSettings()
|
|||||||
if ((result = file.InitCheck()) == B_OK)
|
if ((result = file.InitCheck()) == B_OK)
|
||||||
result = fAddOnSettings.Flatten(&file);
|
result = fAddOnSettings.Flatten(&file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TReplicantTray::SaveTimeSettings()
|
||||||
|
{
|
||||||
|
if (fTime == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
desk_settings* settings = ((TBarApp*)be_app)->Settings();
|
||||||
|
settings->showTime = !fTime->IsHidden();
|
||||||
|
settings->showSeconds = fTime->ShowSeconds();
|
||||||
|
settings->showDayOfWeek = fTime->ShowDayOfWeek();
|
||||||
|
settings->showTimeZone = fTime->ShowTimeZone();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -76,85 +76,98 @@ class TReplicantShelf;
|
|||||||
|
|
||||||
class TReplicantTray : public BView {
|
class TReplicantTray : public BView {
|
||||||
public:
|
public:
|
||||||
TReplicantTray(TBarView* bv, bool vertical);
|
TReplicantTray(TBarView* barView,
|
||||||
virtual ~TReplicantTray();
|
bool vertical);
|
||||||
|
virtual ~TReplicantTray();
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void DetachedFromWindow();
|
virtual void DetachedFromWindow();
|
||||||
virtual void MouseDown(BPoint point);
|
virtual void MouseDown(BPoint point);
|
||||||
virtual void MessageReceived(BMessage*);
|
virtual void MessageReceived(BMessage*);
|
||||||
virtual void GetPreferredSize(float*, float*);
|
virtual void GetPreferredSize(float*, float*);
|
||||||
|
|
||||||
void AdjustPlacement();
|
void AdjustPlacement();
|
||||||
|
void ShowReplicantMenu(BPoint);
|
||||||
|
|
||||||
void ShowReplicantMenu(BPoint);
|
void SetMultiRow(bool state);
|
||||||
|
bool IsMultiRow() const
|
||||||
|
{ return fMultiRowMode; }
|
||||||
|
|
||||||
void SetMultiRow(bool state);
|
TTimeView* Time() const { return fTime; }
|
||||||
bool IsMultiRow() const { return fMultiRowMode; }
|
void ShowHideTime();
|
||||||
|
|
||||||
status_t ItemInfo(int32 target, const char** name);
|
status_t ItemInfo(int32 target, const char** name);
|
||||||
status_t ItemInfo(const char* name, int32* id);
|
status_t ItemInfo(const char* name, int32* id);
|
||||||
status_t ItemInfo(int32 index, const char** name, int32* id);
|
status_t ItemInfo(int32 index, const char** name,
|
||||||
|
int32* id);
|
||||||
|
|
||||||
bool IconExists(int32 target, bool byIndex = false);
|
bool IconExists(int32 target, bool byIndex = false);
|
||||||
bool IconExists(const char* name);
|
bool IconExists(const char* name);
|
||||||
|
|
||||||
int32 IconCount() const;
|
int32 IconCount() const;
|
||||||
|
|
||||||
status_t AddIcon(BMessage*, int32* id, const entry_ref* = NULL);
|
status_t AddIcon(BMessage*, int32* id,
|
||||||
|
const entry_ref* = NULL);
|
||||||
|
|
||||||
void RemoveIcon(int32 target, bool byIndex = false);
|
void RemoveIcon(int32 target,
|
||||||
void RemoveIcon(const char* name);
|
bool byIndex = false);
|
||||||
|
void RemoveIcon(const char* name);
|
||||||
|
|
||||||
BRect IconFrame(int32 target, bool byIndex = false);
|
BRect IconFrame(int32 target,
|
||||||
BRect IconFrame(const char* name);
|
bool byIndex = false);
|
||||||
|
BRect IconFrame(const char* name);
|
||||||
|
|
||||||
bool AcceptAddon(BRect frame, BMessage* message);
|
bool AcceptAddon(BRect frame,
|
||||||
void RealignReplicants(int32 startIndex = -1);
|
BMessage* message);
|
||||||
|
void RealignReplicants(int32 startIndex = -1);
|
||||||
|
|
||||||
void SaveTimeSettings();
|
void SaveTimeSettings();
|
||||||
|
|
||||||
#ifdef DB_ADDONS
|
#ifdef DB_ADDONS
|
||||||
status_t LoadAddOn(BEntry* entry, int32* id, bool addToSettings = true);
|
status_t LoadAddOn(BEntry* entry, int32* id,
|
||||||
|
bool addToSettings = true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BView* ViewAt(int32* index, int32* id, int32 target, bool byIndex = false);
|
BView* ViewAt(int32* index, int32* id,
|
||||||
BView* ViewAt(int32* index, int32* id, const char* name);
|
int32 target,
|
||||||
|
bool byIndex = false);
|
||||||
|
BView* ViewAt(int32* index, int32* id,
|
||||||
|
const char* name);
|
||||||
|
|
||||||
void RealReplicantAdjustment(int32 startindex);
|
void RealReplicantAdjustment(int32 startindex);
|
||||||
|
|
||||||
#ifdef DB_ADDONS
|
#ifdef DB_ADDONS
|
||||||
void InitAddOnSupport();
|
void InitAddOnSupport();
|
||||||
void DeleteAddOnSupport();
|
void DeleteAddOnSupport();
|
||||||
|
|
||||||
DeskbarItemInfo* DeskbarItemFor(node_ref &nodeRef);
|
DeskbarItemInfo* DeskbarItemFor(node_ref &nodeRef);
|
||||||
DeskbarItemInfo* DeskbarItemFor(int32 id);
|
DeskbarItemInfo* DeskbarItemFor(int32 id);
|
||||||
bool NodeExists(node_ref &nodeRef);
|
bool NodeExists(node_ref &nodeRef);
|
||||||
|
|
||||||
void HandleEntryUpdate(BMessage*);
|
void HandleEntryUpdate(BMessage*);
|
||||||
status_t AddItem(int32 id, node_ref nodeRef, BEntry &entry, bool isAddon);
|
status_t AddItem(int32 id, node_ref nodeRef,
|
||||||
|
BEntry &entry, bool isAddon);
|
||||||
|
|
||||||
void UnloadAddOn(node_ref*, dev_t*, bool which, bool removeAll);
|
void UnloadAddOn(node_ref*, dev_t*, bool which,
|
||||||
void RemoveItem(int32 id);
|
bool removeAll);
|
||||||
|
void RemoveItem(int32 id);
|
||||||
|
|
||||||
void MoveItem(entry_ref*, ino_t toDirectory);
|
void MoveItem(entry_ref*, ino_t toDirectory);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BPoint LocationForReplicant(int32 index, float width);
|
BPoint LocationForReplicant(int32 index,
|
||||||
BShelf* Shelf() const;
|
float width);
|
||||||
|
BShelf* Shelf() const;
|
||||||
|
|
||||||
void ShowHideTime();
|
status_t _SaveSettings();
|
||||||
void UpdateTimeFormat(uint32 timeFormat);
|
|
||||||
|
|
||||||
status_t _SaveSettings();
|
|
||||||
|
|
||||||
friend class TReplicantShelf;
|
friend class TReplicantShelf;
|
||||||
|
|
||||||
TTimeView* fTime;
|
TTimeView* fTime;
|
||||||
TBarView* fBarView;
|
TBarView* fBarView;
|
||||||
TReplicantShelf* fShelf;
|
TReplicantShelf* fShelf;
|
||||||
BRect fRightBottomReplicant;
|
BRect fRightBottomReplicant;
|
||||||
int32 fLastReplicant;
|
int32 fLastReplicant;
|
||||||
|
|
||||||
bool fMultiRowMode;
|
bool fMultiRowMode;
|
||||||
|
|||||||
+105
-24
@@ -66,16 +66,20 @@ enum {
|
|||||||
#undef B_TRANSLATE_CONTEXT
|
#undef B_TRANSLATE_CONTEXT
|
||||||
#define B_TRANSLATE_CONTEXT "TimeView"
|
#define B_TRANSLATE_CONTEXT "TimeView"
|
||||||
|
|
||||||
TTimeView::TTimeView(float maxWidth, float height, uint32 timeFormat)
|
TTimeView::TTimeView(float maxWidth, float height, bool use24HourClock,
|
||||||
|
bool showSeconds, bool showDayOfWeek, bool showTimeZone)
|
||||||
:
|
:
|
||||||
BView(BRect(-100, -100, -90, -90), "_deskbar_tv_",
|
BView(BRect(-100, -100, -90, -90), "_deskbar_tv_",
|
||||||
B_FOLLOW_RIGHT | B_FOLLOW_TOP,
|
B_FOLLOW_RIGHT | B_FOLLOW_TOP,
|
||||||
B_WILL_DRAW | B_PULSE_NEEDED | B_FRAME_EVENTS),
|
B_WILL_DRAW | B_PULSE_NEEDED | B_FRAME_EVENTS),
|
||||||
fParent(NULL),
|
fParent(NULL),
|
||||||
fMaxWidth(maxWidth),
|
fMaxWidth(maxWidth),
|
||||||
fHeight(height),
|
fHeight(height),
|
||||||
fOrientation(true),
|
fOrientation(true),
|
||||||
fTimeFormat(timeFormat)
|
fUse24HourClock(use24HourClock),
|
||||||
|
fShowSeconds(showSeconds),
|
||||||
|
fShowDayOfWeek(showDayOfWeek),
|
||||||
|
fShowTimeZone(showTimeZone)
|
||||||
{
|
{
|
||||||
fCurrentTime = fLastTime = time(NULL);
|
fCurrentTime = fLastTime = time(NULL);
|
||||||
fSeconds = fMinute = fHour = 0;
|
fSeconds = fMinute = fHour = 0;
|
||||||
@@ -84,6 +88,7 @@ TTimeView::TTimeView(float maxWidth, float height, uint32 timeFormat)
|
|||||||
fLastTimeStr[0] = 0;
|
fLastTimeStr[0] = 0;
|
||||||
fLastDateStr[0] = 0;
|
fLastDateStr[0] = 0;
|
||||||
fNeedToUpdate = true;
|
fNeedToUpdate = true;
|
||||||
|
UpdateTimeFormat();
|
||||||
|
|
||||||
fLocale = *BLocale::Default();
|
fLocale = *BLocale::Default();
|
||||||
}
|
}
|
||||||
@@ -141,8 +146,8 @@ TTimeView::AttachedToWindow()
|
|||||||
} else
|
} else
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
ResizeToPreferred();
|
|
||||||
CalculateTextPlacement();
|
CalculateTextPlacement();
|
||||||
|
ResizeToPreferred();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -307,10 +312,62 @@ TTimeView::SetOrientation(bool orientation)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
bool
|
||||||
TTimeView::SetTimeFormat(uint32 timeFormat)
|
TTimeView::Use24HourClock() const
|
||||||
{
|
{
|
||||||
fTimeFormat = timeFormat;
|
return fUse24HourClock;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TTimeView::SetUse24HourClock(bool use24HourClock)
|
||||||
|
{
|
||||||
|
fUse24HourClock = use24HourClock;
|
||||||
|
Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
TTimeView::ShowSeconds() const
|
||||||
|
{
|
||||||
|
return fShowSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TTimeView::SetShowSeconds(bool show)
|
||||||
|
{
|
||||||
|
fShowSeconds = show;
|
||||||
|
Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
TTimeView::ShowDayOfWeek() const
|
||||||
|
{
|
||||||
|
return fShowDayOfWeek;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TTimeView::SetShowDayOfWeek(bool show)
|
||||||
|
{
|
||||||
|
fShowDayOfWeek = show;
|
||||||
|
Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
TTimeView::ShowTimeZone() const
|
||||||
|
{
|
||||||
|
return fShowTimeZone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TTimeView::SetShowTimeZone(bool show)
|
||||||
|
{
|
||||||
|
fShowTimeZone = show;
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,20 +404,7 @@ TTimeView::ShowCalendar(BPoint where)
|
|||||||
void
|
void
|
||||||
TTimeView::GetCurrentTime()
|
TTimeView::GetCurrentTime()
|
||||||
{
|
{
|
||||||
switch (fTimeFormat) {
|
fLocale.FormatTime(fCurrentTimeStr, 64, fCurrentTime, fTimeFormat);
|
||||||
case B_LONG_TIME_FORMAT:
|
|
||||||
fLocale.FormatTime(fCurrentTimeStr, 64, fCurrentTime,
|
|
||||||
B_LONG_TIME_FORMAT);
|
|
||||||
break;
|
|
||||||
case B_MEDIUM_TIME_FORMAT:
|
|
||||||
fLocale.FormatTime(fCurrentTimeStr, 64, fCurrentTime,
|
|
||||||
B_MEDIUM_TIME_FORMAT);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
fLocale.FormatTime(fCurrentTimeStr, 64, fCurrentTime,
|
|
||||||
B_SHORT_TIME_FORMAT);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -391,6 +435,15 @@ TTimeView::CalculateTextPlacement()
|
|||||||
|
|
||||||
BFont font;
|
BFont font;
|
||||||
GetFont(&font);
|
GetFont(&font);
|
||||||
|
|
||||||
|
// If 12 hour clock with all options turned on shrink font size to fit.
|
||||||
|
if (!fUse24HourClock && fShowSeconds && fShowDayOfWeek && fShowTimeZone)
|
||||||
|
font.SetSize(11.0);
|
||||||
|
else
|
||||||
|
font.SetSize(12.0);
|
||||||
|
|
||||||
|
SetFont(&font, B_FONT_SIZE);
|
||||||
|
|
||||||
const char* stringArray[1];
|
const char* stringArray[1];
|
||||||
stringArray[0] = fCurrentTimeStr;
|
stringArray[0] = fCurrentTimeStr;
|
||||||
BRect rectArray[1];
|
BRect rectArray[1];
|
||||||
@@ -410,7 +463,7 @@ TTimeView::ShowTimeOptions(BPoint point)
|
|||||||
menu->SetFont(be_plain_font);
|
menu->SetFont(be_plain_font);
|
||||||
BMenuItem* item;
|
BMenuItem* item;
|
||||||
|
|
||||||
item = new BMenuItem(B_TRANSLATE("Open time preferences" B_UTF8_ELLIPSIS),
|
item = new BMenuItem(B_TRANSLATE("Time preferences" B_UTF8_ELLIPSIS),
|
||||||
new BMessage(kChangeTime));
|
new BMessage(kChangeTime));
|
||||||
menu->AddItem(item);
|
menu->AddItem(item);
|
||||||
|
|
||||||
@@ -438,9 +491,37 @@ TTimeView::Update()
|
|||||||
GetCurrentDate();
|
GetCurrentDate();
|
||||||
SetToolTip(fCurrentDateStr);
|
SetToolTip(fCurrentDateStr);
|
||||||
|
|
||||||
ResizeToPreferred();
|
UpdateTimeFormat();
|
||||||
|
|
||||||
CalculateTextPlacement();
|
CalculateTextPlacement();
|
||||||
|
ResizeToPreferred();
|
||||||
|
|
||||||
if (fParent)
|
if (fParent)
|
||||||
fParent->Invalidate();
|
fParent->Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TTimeView::UpdateTimeFormat()
|
||||||
|
{
|
||||||
|
BString timeFormat;
|
||||||
|
|
||||||
|
if (fShowDayOfWeek)
|
||||||
|
timeFormat.Append("eee ");
|
||||||
|
|
||||||
|
if (fUse24HourClock)
|
||||||
|
timeFormat.Append("H:mm");
|
||||||
|
else
|
||||||
|
timeFormat.Append("h:mm");
|
||||||
|
|
||||||
|
if (fShowSeconds)
|
||||||
|
timeFormat.Append(":ss");
|
||||||
|
|
||||||
|
if (!fUse24HourClock)
|
||||||
|
timeFormat.Append(" a");
|
||||||
|
|
||||||
|
if (fShowTimeZone)
|
||||||
|
timeFormat.Append(" V");
|
||||||
|
|
||||||
|
fTimeFormat = timeFormat;
|
||||||
|
}
|
||||||
|
|||||||
+65
-56
@@ -41,10 +41,8 @@ All rights reserved.
|
|||||||
#include <Messenger.h>
|
#include <Messenger.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
|
#include "PreferencesWindow.h" // For message constants
|
||||||
|
|
||||||
const uint32 kShowHideTime = 'shtm';
|
|
||||||
const uint32 kTimeIntervalChanged = 'tivc';
|
|
||||||
const uint32 kTimeFormatChanged = 'tfmc';
|
|
||||||
|
|
||||||
class BCountry;
|
class BCountry;
|
||||||
class BMessageRunner;
|
class BMessageRunner;
|
||||||
@@ -53,69 +51,88 @@ class BMessageRunner;
|
|||||||
class _EXPORT TTimeView;
|
class _EXPORT TTimeView;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
class TTimeView : public BView {
|
class TTimeView : public BView {
|
||||||
public:
|
public:
|
||||||
TTimeView(float maxWidth, float height, uint32 timeFormat);
|
TTimeView(float maxWidth, float height,
|
||||||
TTimeView(BMessage* data);
|
bool use24HourClock, bool showSeconds,
|
||||||
~TTimeView();
|
bool showDayOfWeek, bool showTimeZone);
|
||||||
|
TTimeView(BMessage* data);
|
||||||
|
~TTimeView();
|
||||||
|
|
||||||
#ifdef AS_REPLICANT
|
#ifdef AS_REPLICANT
|
||||||
status_t Archive(BMessage* data, bool deep = true) const;
|
status_t Archive(BMessage* data,
|
||||||
static BArchivable* Instantiate(BMessage* data);
|
bool deep = true) const;
|
||||||
|
static BArchivable* Instantiate(BMessage* data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void AttachedToWindow();
|
void AttachedToWindow();
|
||||||
void Draw(BRect update);
|
void Draw(BRect update);
|
||||||
void FrameMoved(BPoint);
|
void FrameMoved(BPoint);
|
||||||
void GetPreferredSize(float* width, float* height);
|
void GetPreferredSize(float* width, float* height);
|
||||||
void MessageReceived(BMessage*);
|
void MessageReceived(BMessage*);
|
||||||
void MouseDown(BPoint where);
|
void MouseDown(BPoint where);
|
||||||
void Pulse();
|
void Pulse();
|
||||||
void ResizeToPreferred();
|
void ResizeToPreferred();
|
||||||
|
|
||||||
bool Orientation() const;
|
bool Orientation() const;
|
||||||
void SetOrientation(bool o);
|
void SetOrientation(bool o);
|
||||||
|
|
||||||
uint32 TimeFormat() const;
|
bool Use24HourClock() const;
|
||||||
void SetTimeFormat(uint32 timeFormat);
|
void SetUse24HourClock(bool use24HourClock);
|
||||||
|
|
||||||
void ShowCalendar(BPoint where);
|
bool ShowSeconds() const;
|
||||||
|
void SetShowSeconds(bool show);
|
||||||
|
|
||||||
private:
|
bool ShowDayOfWeek() const;
|
||||||
|
void SetShowDayOfWeek(bool show);
|
||||||
|
|
||||||
|
bool ShowTimeZone() const;
|
||||||
|
void SetShowTimeZone(bool show);
|
||||||
|
|
||||||
|
void ShowCalendar(BPoint where);
|
||||||
|
|
||||||
|
private:
|
||||||
friend class TReplicantTray;
|
friend class TReplicantTray;
|
||||||
|
|
||||||
void GetCurrentTime();
|
void GetCurrentTime();
|
||||||
void GetCurrentDate();
|
void GetCurrentDate();
|
||||||
void CalculateTextPlacement();
|
void CalculateTextPlacement();
|
||||||
void ShowTimeOptions(BPoint);
|
void ShowTimeOptions(BPoint);
|
||||||
void Update();
|
void Update();
|
||||||
|
void UpdateTimeFormat();
|
||||||
|
|
||||||
BView *fParent;
|
BView* fParent;
|
||||||
bool fNeedToUpdate;
|
bool fNeedToUpdate;
|
||||||
|
|
||||||
time_t fCurrentTime;
|
time_t fCurrentTime;
|
||||||
time_t fLastTime;
|
time_t fLastTime;
|
||||||
|
|
||||||
char fCurrentTimeStr[64];
|
char fCurrentTimeStr[64];
|
||||||
char fLastTimeStr[64];
|
char fLastTimeStr[64];
|
||||||
char fCurrentDateStr[64];
|
char fCurrentDateStr[64];
|
||||||
char fLastDateStr[64];
|
char fLastDateStr[64];
|
||||||
|
|
||||||
int fSeconds;
|
int fSeconds;
|
||||||
int fMinute;
|
int fMinute;
|
||||||
int fHour;
|
int fHour;
|
||||||
|
|
||||||
float fMaxWidth;
|
float fMaxWidth;
|
||||||
float fHeight;
|
float fHeight;
|
||||||
bool fOrientation; // vertical = true
|
bool fOrientation; // vertical = true
|
||||||
uint32 fTimeFormat;
|
|
||||||
BPoint fTimeLocation;
|
|
||||||
BPoint fDateLocation;
|
|
||||||
|
|
||||||
BMessenger fCalendarWindow;
|
bool fUse24HourClock;
|
||||||
|
bool fShowSeconds;
|
||||||
|
bool fShowDayOfWeek;
|
||||||
|
bool fShowTimeZone;
|
||||||
|
BString fTimeFormat;
|
||||||
|
|
||||||
BLocale fLocale; // For date and time localizing purposes
|
BPoint fTimeLocation;
|
||||||
|
BPoint fDateLocation;
|
||||||
|
|
||||||
|
BMessenger fCalendarWindow;
|
||||||
|
|
||||||
|
// For date and time localization purposes
|
||||||
|
BLocale fLocale;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -126,12 +143,4 @@ TTimeView::Orientation() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline uint32
|
|
||||||
TTimeView::TimeFormat() const
|
|
||||||
{
|
|
||||||
return fTimeFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* TIME_VIEW_H */
|
#endif /* TIME_VIEW_H */
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright 2003, Axel Dörfler, axeld@pinc-software.de.
|
* Copyright 2003, Axel Dörfler, axeld@pinc-software.de.
|
||||||
** Copyright 2010-2011, Oliver Tappe, zooey@hirschkaefer.de.
|
* Copyright 2010-2011, Oliver Tappe, zooey@hirschkaefer.de.
|
||||||
** All rights reserved. Distributed under the terms of the OpenBeOS License.
|
* Copyright 2012, John Scipione, jscipione@gmail.com
|
||||||
*/
|
* All rights reserved. Distributed under the terms of the OpenBeOS License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <AutoDeleter.h>
|
#include <AutoDeleter.h>
|
||||||
@@ -509,6 +510,34 @@ BLocale::FormatTime(char* string, size_t maxSize, time_t time,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ssize_t
|
||||||
|
BLocale::FormatTime(char* string, size_t maxSize, time_t time,
|
||||||
|
BString format) const
|
||||||
|
{
|
||||||
|
BAutolock lock(fLock);
|
||||||
|
if (!lock.IsLocked())
|
||||||
|
return B_ERROR;
|
||||||
|
|
||||||
|
if (format == NULL || format.CountChars() <= 0)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
ObjectDeleter<DateFormat> timeFormatter(_CreateTimeFormatter(format));
|
||||||
|
if (timeFormatter.Get() == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
UnicodeString icuString;
|
||||||
|
timeFormatter->format((UDate)time * 1000, icuString);
|
||||||
|
|
||||||
|
CheckedArrayByteSink stringConverter(string, maxSize);
|
||||||
|
icuString.toUTF8(stringConverter);
|
||||||
|
|
||||||
|
if (stringConverter.Overflowed())
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
return stringConverter.NumberOfBytesWritten();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BLocale::FormatTime(BString* string, time_t time, BTimeFormatStyle style,
|
BLocale::FormatTime(BString* string, time_t time, BTimeFormatStyle style,
|
||||||
const BTimeZone* timeZone) const
|
const BTimeZone* timeZone) const
|
||||||
@@ -542,6 +571,40 @@ BLocale::FormatTime(BString* string, time_t time, BTimeFormatStyle style,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BLocale::FormatTime(BString* string, time_t time, BString format,
|
||||||
|
const BTimeZone* timeZone) const
|
||||||
|
{
|
||||||
|
BAutolock lock(fLock);
|
||||||
|
if (!lock.IsLocked())
|
||||||
|
return B_ERROR;
|
||||||
|
|
||||||
|
if (format == NULL || format.CountChars() <= 0)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
ObjectDeleter<DateFormat> timeFormatter(_CreateTimeFormatter(format));
|
||||||
|
if (timeFormatter.Get() == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
if (timeZone != NULL) {
|
||||||
|
ObjectDeleter<TimeZone> icuTimeZone(
|
||||||
|
TimeZone::createTimeZone(timeZone->ID().String()));
|
||||||
|
if (icuTimeZone.Get() == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
timeFormatter->setTimeZone(*icuTimeZone.Get());
|
||||||
|
}
|
||||||
|
|
||||||
|
UnicodeString icuString;
|
||||||
|
timeFormatter->format((UDate)time * 1000, icuString);
|
||||||
|
|
||||||
|
string->Truncate(0);
|
||||||
|
BStringByteSink stringConverter(string);
|
||||||
|
icuString.toUTF8(stringConverter);
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BLocale::FormatTime(BString* string, int*& fieldPositions, int& fieldCount,
|
BLocale::FormatTime(BString* string, int*& fieldPositions, int& fieldCount,
|
||||||
time_t time, BTimeFormatStyle style) const
|
time_t time, BTimeFormatStyle style) const
|
||||||
@@ -607,7 +670,7 @@ BLocale::GetTimeFields(BDateElement*& fields, int& fieldCount,
|
|||||||
icu::FieldPositionIterator positionIterator;
|
icu::FieldPositionIterator positionIterator;
|
||||||
UnicodeString icuString;
|
UnicodeString icuString;
|
||||||
time_t now;
|
time_t now;
|
||||||
timeFormatter->format((UDate)time(&now) * 1000, icuString,
|
timeFormatter->format((UDate)time(&now) * 1000, icuString,
|
||||||
&positionIterator, error);
|
&positionIterator, error);
|
||||||
|
|
||||||
if (error != U_ZERO_ERROR)
|
if (error != U_ZERO_ERROR)
|
||||||
|
|||||||
Reference in New Issue
Block a user