[haiku-commits] haiku: hrev43984 - src/apps/deskbar

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 10 Apr 2012 07:37:05 +0200 (CEST)

hrev43984 adds 4 changesets to branch 'master'
old head: 44fcb75e778e358512f21a9d91648a2a690c9f0b
new head: 95e02d49729b6639eee2368bf96508fc17cf9be0

----------------------------------------------------------------------------

40b6c14: If full time format, don't abbreviate the time zone.

573f748: Add 12/24 hour and time formatting options to Deskbar.
  
  * 12/24 hour settings come from and alter BLocale
  * Time formats are short, medium, long. Short is default. Come from
    Locale kit.
  * Don't delete fClock (now fTime) when hiding, just hide and show
    the view.
  * BarView now has nothing to do with setting or keeping track of
    time settings. This is all handled in TTimeView. TReplicantTray
    is responsible for updating the replicant tray and doing showing
    and hiding. TTimeView is responsible for drawing according to the
    clock settings.
  * Remove fShowInterval and fShowSeconds from BarView
  * Remove ampmMode setting and replace it with timeFormat.
  * Reset targets in DeskbarMenu.
  
  Originally I was trying to solve a bug where the TTimeView
  was relying on the Deskbar settings too much. The settings
  should only by set on quit and accessed on startup or a crash can
  cause Deskbar to be in an unusual state.
  
  I realize that the timezone is not very helpful. I'd like to provide
  the day of week in a short format instead, i.e. Wed for Wednesday or
  similar based on your locale. Blame the Locale Kit for now allowing
  me to be able to use a custom TimeFormat. Once a custom TimeFormats
  becomes possible from the Locale Kit Deskbar can be updated to use
  them.

2a2dc95: Update timeView popup menu

95e02d4: Remove superfluous colons

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

----------------------------------------------------------------------------

14 files changed, 445 insertions(+), 295 deletions(-)
src/apps/deskbar/BarApp.cpp               |   15 +-
src/apps/deskbar/BarApp.h                 |    2 +-
src/apps/deskbar/BarView.cpp              |    8 +-
src/apps/deskbar/BarView.h                |   10 +-
src/apps/deskbar/BarWindow.cpp            |    3 +-
src/apps/deskbar/DeskbarMenu.cpp          |   12 +-
src/apps/deskbar/Jamfile                  |    2 +-
src/apps/deskbar/PreferencesWindow.cpp    |  202 ++++++++++++++-----
src/apps/deskbar/PreferencesWindow.h      |   11 +-
src/apps/deskbar/StatusView.cpp           |  132 +++++++-----
src/apps/deskbar/StatusView.h             |   12 +-
src/apps/deskbar/TimeView.cpp             |  281 +++++++++++++------------
src/apps/deskbar/TimeView.h               |   42 ++--
src/kits/locale/FormattingConventions.cpp |    8 +-

############################################################################

Commit:      40b6c14db7fb21b461a17038587d344487fa28bf
URL:         http://cgit.haiku-os.org/haiku/commit/?id=40b6c14
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Tue Apr 10 00:49:35 2012 UTC

If full time format, don't abbreviate the time zone.

----------------------------------------------------------------------------

diff --git a/src/kits/locale/FormattingConventions.cpp 
b/src/kits/locale/FormattingConventions.cpp
index 2d9159e..67c0dad 100644
--- a/src/kits/locale/FormattingConventions.cpp
+++ b/src/kits/locale/FormattingConventions.cpp
@@ -465,7 +465,7 @@ BFormattingConventions::GetTimeFormat(BTimeFormatStyle 
style,
        icuString.toUTF8(stringConverter);
 
        int8 use24HourClock = fExplicitUse24HourClock != CLOCK_HOURS_UNSET
-               ?  fExplicitUse24HourClock : fCachedUse24HourClock;
+               ? fExplicitUse24HourClock : fCachedUse24HourClock;
        if (use24HourClock != CLOCK_HOURS_UNSET) {
                // adjust to 12/24-hour clock as requested
                bool localeUses24HourClock = !FormatUsesAmPm(outFormat);
@@ -478,8 +478,10 @@ BFormattingConventions::GetTimeFormat(BTimeFormatStyle 
style,
                }
        }
 
-       // use abbreviated timezone in short timezone format
-       CoerceFormatToAbbreviatedTimezone(outFormat);
+       if (style != B_FULL_TIME_FORMAT) {
+               // use abbreviated timezone in short timezone format
+               CoerceFormatToAbbreviatedTimezone(outFormat);
+       }
 
        fCachedTimeFormats[style] = outFormat;
 

############################################################################

Commit:      573f748c5f8fb7ed75beb0ceb7eb097d3ab0c038
URL:         http://cgit.haiku-os.org/haiku/commit/?id=573f748
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Mon Apr  9 10:39:11 2012 UTC

Add 12/24 hour and time formatting options to Deskbar.

* 12/24 hour settings come from and alter BLocale
* Time formats are short, medium, long. Short is default. Come from
  Locale kit.
* Don't delete fClock (now fTime) when hiding, just hide and show
  the view.
* BarView now has nothing to do with setting or keeping track of
  time settings. This is all handled in TTimeView. TReplicantTray
  is responsible for updating the replicant tray and doing showing
  and hiding. TTimeView is responsible for drawing according to the
  clock settings.
* Remove fShowInterval and fShowSeconds from BarView
* Remove ampmMode setting and replace it with timeFormat.
* Reset targets in DeskbarMenu.

Originally I was trying to solve a bug where the TTimeView
was relying on the Deskbar settings too much. The settings
should only by set on quit and accessed on startup or a crash can
cause Deskbar to be in an unusual state.

I realize that the timezone is not very helpful. I'd like to provide
the day of week in a short format instead, i.e. Wed for Wednesday or
similar based on your locale. Blame the Locale Kit for now allowing
me to be able to use a custom TimeFormat. Once a custom TimeFormats
becomes possible from the Locale Kit Deskbar can be updated to use
them.

----------------------------------------------------------------------------

diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
index e63afc3..97291c9 100644
--- a/src/apps/deskbar/BarApp.cpp
+++ b/src/apps/deskbar/BarApp.cpp
@@ -196,11 +196,12 @@ TBarApp::SaveSettings()
                storedSettings.AddBool("vertical", fSettings.vertical);
                storedSettings.AddBool("left", fSettings.left);
                storedSettings.AddBool("top", fSettings.top);
-               storedSettings.AddBool("ampmMode", fSettings.ampmMode);
-
                storedSettings.AddInt32("state", fSettings.state);
                storedSettings.AddFloat("width", fSettings.width);
+
                storedSettings.AddBool("showTime", fSettings.showTime);
+               storedSettings.AddBool("timeFormat", fSettings.timeFormat);
+
                storedSettings.AddPoint("switcherLoc", fSettings.switcherLoc);
                storedSettings.AddInt32("recentAppsCount", 
fSettings.recentAppsCount);
                storedSettings.AddInt32("recentDocsCount", 
fSettings.recentDocsCount);
@@ -237,8 +238,8 @@ TBarApp::InitSettings()
        settings.vertical = true;
        settings.left = false;
        settings.top = true;
-       settings.ampmMode = true;
        settings.showTime = true;
+       settings.timeFormat = B_SHORT_TIME_FORMAT;
        settings.state = kExpandoState;
        settings.width = 0;
        settings.switcherLoc = BPoint(5000, 5000);
@@ -287,10 +288,6 @@ TBarApp::InitSettings()
                                settings.left = false;
                        if (storedSettings.FindBool("top", &settings.top) != 
B_OK)
                                settings.top = true;
-                       if (storedSettings.FindBool("ampmMode", 
&settings.ampmMode)
-                               != B_OK) {
-                               settings.ampmMode = true;
-                       }
                        if (storedSettings.FindInt32("state", 
(int32*)&settings.state)
                                != B_OK) {
                                settings.state = kExpandoState;
@@ -301,6 +298,10 @@ TBarApp::InitSettings()
                                != B_OK) {
                                settings.showTime = true;
                        }
+                       if (storedSettings.FindUInt32("timeFormat", 
&settings.timeFormat)
+                               != B_OK) {
+                               settings.timeFormat = B_SHORT_TIME_FORMAT;
+                       }
                        if (storedSettings.FindPoint("switcherLoc", 
&settings.switcherLoc)
                                != B_OK) {
                                settings.switcherLoc = BPoint(5000, 5000);
diff --git a/src/apps/deskbar/BarApp.h b/src/apps/deskbar/BarApp.h
index 693fd88..4871240 100644
--- a/src/apps/deskbar/BarApp.h
+++ b/src/apps/deskbar/BarApp.h
@@ -102,8 +102,8 @@ struct desk_settings {
        bool vertical;
        bool left;
        bool top;
-       bool ampmMode;
        bool showTime;
+       uint32 timeFormat;
        uint32 state;
        float width;
        BPoint switcherLoc;
diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp
index adb7d01..fa7cbb5 100644
--- a/src/apps/deskbar/BarView.cpp
+++ b/src/apps/deskbar/BarView.cpp
@@ -70,13 +70,11 @@ const int32 kMenuTrackMargin = 20;
 
 
 TBarView::TBarView(BRect frame, bool vertical, bool left, bool top,
-               bool showInterval, uint32 state, float, bool showClock)
+               uint32 state, float)
        : BView(frame, "BarView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW),
        fBarMenuBar(NULL),
        fExpando(NULL),
        fTrayLocation(1),
-       fShowInterval(showInterval),
-       fShowClock(showClock),
        fVertical(vertical),
        fTop(top),
        fLeft(left),
@@ -502,12 +500,10 @@ TBarView::SaveSettings()
        settings->vertical = fVertical;
        settings->left = fLeft;
        settings->top = fTop;
-       settings->ampmMode = fShowInterval;
        settings->state = (uint32)fState;
        settings->width = 0;
-       settings->showTime = fShowClock;
 
-       fReplicantTray->RememberClockSettings();
+       fReplicantTray->SaveTimeSettings();
 }
 
 
diff --git a/src/apps/deskbar/BarView.h b/src/apps/deskbar/BarView.h
index 065ff6b..1fd309b 100644
--- a/src/apps/deskbar/BarView.h
+++ b/src/apps/deskbar/BarView.h
@@ -71,7 +71,7 @@ class TTeamMenuItem;
 class TBarView : public BView {
        public:
                TBarView(BRect frame, bool vertical, bool left, bool top,
-                       bool ampmMode, uint32 state, float width, bool 
showClock);
+                       uint32 state, float width);
                ~TBarView();
 
                virtual void AttachedToWindow();
@@ -102,11 +102,7 @@ class TBarView : public BView {
                bool MiniState() const { return fState == kMiniState; };
                int32 State() const { return fState; };
 
-               // optional functionality methods
-               bool MilTime() const { return fShowInterval; };
-               void ShowClock(bool show) { fShowClock = show; };
-               bool ShowingClock() const { return fShowClock; };
-
+               // drag and drop methods
                void CacheDragData(const BMessage* incoming);
                status_t DragStart();
                static bool MenuTrackingHook(BMenu* menu, void* castToThis);
@@ -172,8 +168,6 @@ class TBarView : public BView {
                TDragRegion* fDragRegion;
                TReplicantTray* fReplicantTray;
 
-               bool fShowInterval : 1;
-               bool fShowClock : 1;
                bool fVertical : 1;
                bool fTop : 1;
                bool fLeft : 1;
diff --git a/src/apps/deskbar/BarWindow.cpp b/src/apps/deskbar/BarWindow.cpp
index fe5cec6..45aa591 100644
--- a/src/apps/deskbar/BarWindow.cpp
+++ b/src/apps/deskbar/BarWindow.cpp
@@ -96,8 +96,7 @@ TBarWindow::TBarWindow()
        if (settings->alwaysOnTop)
                SetFeel(B_FLOATING_ALL_WINDOW_FEEL);
        fBarView = new TBarView(Bounds(), settings->vertical, settings->left,
-               settings->top, settings->ampmMode, settings->state, 
settings->width,
-               settings->showTime);
+               settings->top, settings->state, settings->width);
        AddChild(fBarView);
 
        RemoveShortcut('H', B_COMMAND_KEY | B_CONTROL_KEY);
diff --git a/src/apps/deskbar/DeskbarMenu.cpp b/src/apps/deskbar/DeskbarMenu.cpp
index fe82902..e2b2016 100644
--- a/src/apps/deskbar/DeskbarMenu.cpp
+++ b/src/apps/deskbar/DeskbarMenu.cpp
@@ -387,12 +387,22 @@ TDeskbarMenu::ResetTargets()
                                case kToggleDraggers:
                                case kConfigShow:
                                case kAlwaysTop:
-                               case kShowSeconds:
+                               case kExpandNewTeams:
+                               case kHideLabels:
+                               case kResizeTeamIcons:
+                               case kSortRunningApps:
+                               case kTrackerFirst:
                                case kRebootSystem:
                                case kSuspendSystem:
                                case kShutdownSystem:
                                        item->SetTarget(be_app);
                                        break;
+
+                               case kShowHideTime:
+                               case kTimeIntervalChanged:
+                               case kTimeFormatChanged:
+                                       
item->SetTarget(fBarView->fReplicantTray);
+                                       break;
                        }
                }
        }
diff --git a/src/apps/deskbar/Jamfile b/src/apps/deskbar/Jamfile
index 91523b8..a2c3e55 100644
--- a/src/apps/deskbar/Jamfile
+++ b/src/apps/deskbar/Jamfile
@@ -1,6 +1,6 @@
 SubDir HAIKU_TOP src apps deskbar ;
 
-UsePrivateHeaders app interface shared tracker ;
+UsePrivateHeaders app interface locale shared tracker ;
 UsePrivateHeaders private shared ;
 SubDirHdrs $(HAIKU_TOP) src kits tracker ;
 
diff --git a/src/apps/deskbar/PreferencesWindow.cpp 
b/src/apps/deskbar/PreferencesWindow.cpp
index 38947ac..aae6556 100644
--- a/src/apps/deskbar/PreferencesWindow.cpp
+++ b/src/apps/deskbar/PreferencesWindow.cpp
@@ -9,8 +9,11 @@
 
 #include "PreferencesWindow.h"
 
+#include <ctype.h>
+
 #include <Catalog.h>
 #include <CheckBox.h>
+#include <FormattingConventions.h>
 #include <GroupLayout.h>
 #include <Locale.h>
 #include <LayoutBuilder.h>
@@ -18,8 +21,8 @@
 #include <RadioButton.h>
 #include <SeparatorView.h>
 #include <Slider.h>
-
-#include <ctype.h>
+#include <StringView.h>
+#include <View.h>
 
 #include "BarApp.h"
 #include "StatusView.h"
@@ -33,7 +36,7 @@ PreferencesWindow::PreferencesWindow(BRect frame)
        BWindow(frame, B_TRANSLATE("Deskbar preferences"), B_TITLED_WINDOW,
                B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS | B_NOT_ZOOMABLE)
 {
-       // Controls
+       // Menu controls
        fMenuRecentDocuments = new BCheckBox(B_TRANSLATE("Recent documents:"),
                new BMessage(kUpdateRecentCounts));
        fMenuRecentApplications = new BCheckBox(B_TRANSLATE("Recent 
applications:"),
@@ -48,6 +51,7 @@ PreferencesWindow::PreferencesWindow(BRect frame)
        fMenuRecentFolderCount = new BTextControl(NULL, NULL,
                new BMessage(kUpdateRecentCounts));
 
+       // Applications controls
        fAppsSort = new BCheckBox(B_TRANSLATE("Sort running applications"),
                new BMessage(kSortRunningApps));
        fAppsSortTrackerFirst = new BCheckBox(B_TRANSLATE("Tracker always 
first"),
@@ -68,8 +72,7 @@ PreferencesWindow::PreferencesWindow(BRect frame)
                B_TRANSLATE("Large"));
        fAppsIconSizeSlider->SetModificationMessage(new 
BMessage(kResizeTeamIcons));
 
-       fClockSeconds = new BCheckBox(B_TRANSLATE("Show seconds"),
-               new BMessage(kShowSeconds));
+       // Window controls
        fWindowAlwaysOnTop = new BCheckBox(B_TRANSLATE("Always on top"),
                new BMessage(kAlwaysTop));
        fWindowAutoRaise = new BCheckBox(B_TRANSLATE("Auto-raise"),
@@ -77,6 +80,39 @@ PreferencesWindow::PreferencesWindow(BRect frame)
        fWindowAutoHide = new BCheckBox(B_TRANSLATE("Auto-hide"),
                new BMessage(kAutoHide));
 
+       // Clock controls
+       BMessage* timeInterval12HoursMessage = new 
BMessage(kTimeIntervalChanged);
+       timeInterval12HoursMessage->AddBool("use24HourClock", false);
+       fTimeInterval12HourRadioButton = new BRadioButton("time inteval",
+               B_TRANSLATE("12 hour"), timeInterval12HoursMessage);
+
+       BMessage* timeInterval24HoursMessage = new 
BMessage(kTimeIntervalChanged);
+       timeInterval24HoursMessage->AddBool("use24HourClock", true);
+       fTimeInterval24HourRadioButton = new BRadioButton("time inteval",
+               B_TRANSLATE("24 hour"), timeInterval24HoursMessage);
+
+       BMessage* timeFormatShortMessage = new BMessage(kTimeFormatChanged);
+       timeFormatShortMessage->AddUInt32("time format", B_SHORT_TIME_FORMAT);
+       fTimeFormatShortRadioButton = new BRadioButton("time format",
+               "Short", timeFormatShortMessage);
+
+       BMessage* timeFormatMediumMessage = new BMessage(kTimeFormatChanged);
+       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
+       TBarApp* barApp = static_cast<TBarApp*>(be_app);
+       desk_settings* settings = barApp->Settings();
+
+       // Menu settings
        BTextView* docTextView = fMenuRecentDocumentCount->TextView();
        BTextView* appTextView = fMenuRecentApplicationCount->TextView();
        BTextView* folderTextView = fMenuRecentFolderCount->TextView();
@@ -93,29 +129,18 @@ PreferencesWindow::PreferencesWindow(BRect frame)
        appTextView->SetMaxBytes(4);
        folderTextView->SetMaxBytes(4);
 
-       // Values
-       TBarApp* barApp = static_cast<TBarApp*>(be_app);
-       desk_settings* appSettings = barApp->Settings();
-
-       fAppsSort->SetValue(appSettings->sortRunningApps);
-       fAppsSortTrackerFirst->SetValue(appSettings->trackerAlwaysFirst);
-       fAppsShowExpanders->SetValue(appSettings->superExpando);
-       fAppsExpandNew->SetValue(appSettings->expandNewTeams);
-       fAppsHideLabels->SetValue(appSettings->hideLabels);
-       fAppsIconSizeSlider->SetValue(appSettings->iconSize / 
kIconSizeInterval);
-
-       int32 docCount = appSettings->recentDocsCount;
-       int32 appCount = appSettings->recentAppsCount;
-       int32 folderCount = appSettings->recentFoldersCount;
+       int32 docCount = settings->recentDocsCount;
+       int32 appCount = settings->recentAppsCount;
+       int32 folderCount = settings->recentFoldersCount;
 
-       fMenuRecentDocuments->SetValue(appSettings->recentDocsEnabled);
-       fMenuRecentDocumentCount->SetEnabled(appSettings->recentDocsEnabled);
+       fMenuRecentDocuments->SetValue(settings->recentDocsEnabled);
+       fMenuRecentDocumentCount->SetEnabled(settings->recentDocsEnabled);
 
-       fMenuRecentApplications->SetValue(appSettings->recentAppsEnabled);
-       fMenuRecentApplicationCount->SetEnabled(appSettings->recentAppsEnabled);
+       fMenuRecentApplications->SetValue(settings->recentAppsEnabled);
+       fMenuRecentApplicationCount->SetEnabled(settings->recentAppsEnabled);
 
-       fMenuRecentFolders->SetValue(appSettings->recentFoldersEnabled);
-       fMenuRecentFolderCount->SetEnabled(appSettings->recentFoldersEnabled);
+       fMenuRecentFolders->SetValue(settings->recentFoldersEnabled);
+       fMenuRecentFolderCount->SetEnabled(settings->recentFoldersEnabled);
 
        BString docString;
        BString appString;
@@ -129,16 +154,37 @@ PreferencesWindow::PreferencesWindow(BRect frame)
        fMenuRecentApplicationCount->SetText(appString.String());
        fMenuRecentFolderCount->SetText(folderString.String());
 
-       TReplicantTray* replicantTray = barApp->BarView()->fReplicantTray;
-
-       fClockSeconds->SetValue(replicantTray->ShowingSeconds());
-
-       bool showingClock = barApp->BarView()->ShowingClock();
-       fClockSeconds->SetEnabled(showingClock);
-
-       fWindowAlwaysOnTop->SetValue(appSettings->alwaysOnTop);
-       fWindowAutoRaise->SetValue(appSettings->autoRaise);
-       fWindowAutoHide->SetValue(appSettings->autoHide);
+       // Applications settings
+       fAppsSort->SetValue(settings->sortRunningApps);
+       fAppsSortTrackerFirst->SetValue(settings->trackerAlwaysFirst);
+       fAppsShowExpanders->SetValue(settings->superExpando);
+       fAppsExpandNew->SetValue(settings->expandNewTeams);
+       fAppsHideLabels->SetValue(settings->hideLabels);
+       fAppsIconSizeSlider->SetValue(settings->iconSize / kIconSizeInterval);
+
+       // Window settings
+       fWindowAlwaysOnTop->SetValue(settings->alwaysOnTop);
+       fWindowAutoRaise->SetValue(settings->autoRaise);
+       fWindowAutoHide->SetValue(settings->autoHide);
+
+       // Clock settings
+       BFormattingConventions conventions;
+       BLocale::Default()->GetFormattingConventions(&conventions);
+       if (conventions.Use24HourClock())
+               fTimeInterval24HourRadioButton->SetValue(B_CONTROL_ON);
+       else
+               fTimeInterval12HourRadioButton->SetValue(B_CONTROL_ON);
+
+       switch (settings->timeFormat) {
+               case B_LONG_TIME_FORMAT:
+                       fTimeFormatLongRadioButton->SetValue(B_CONTROL_ON);
+                       break;
+               case B_MEDIUM_TIME_FORMAT:
+                       fTimeFormatMediumRadioButton->SetValue(B_CONTROL_ON);
+                       break;
+               default:
+                       fTimeFormatShortRadioButton->SetValue(B_CONTROL_ON);
+       }
 
        _EnableDisableDependentItems();
 
@@ -149,22 +195,27 @@ PreferencesWindow::PreferencesWindow(BRect frame)
        fAppsHideLabels->SetTarget(be_app);
        fAppsIconSizeSlider->SetTarget(be_app);
 
-       fClockSeconds->SetTarget(replicantTray);
-
        fWindowAlwaysOnTop->SetTarget(be_app);
        fWindowAutoRaise->SetTarget(be_app);
        fWindowAutoHide->SetTarget(be_app);
 
+       TReplicantTray* replicantTray = barApp->BarView()->fReplicantTray;
+       fTimeInterval12HourRadioButton->SetTarget(replicantTray);
+       fTimeInterval24HourRadioButton->SetTarget(replicantTray);
+       fTimeFormatShortRadioButton->SetTarget(replicantTray);
+       fTimeFormatMediumRadioButton->SetTarget(replicantTray);
+       fTimeFormatLongRadioButton->SetTarget(replicantTray);
+
        // Layout
        fMenuBox = new BBox("fMenuBox");
        fAppsBox = new BBox("fAppsBox");
-       fClockBox = new BBox("fClockBox");
        fWindowBox = new BBox("fWindowBox");
+       fClockBox = new BBox("fClockBox");
 
        fMenuBox->SetLabel(B_TRANSLATE("Menu"));
        fAppsBox->SetLabel(B_TRANSLATE("Applications"));
-       fClockBox->SetLabel(B_TRANSLATE("Clock"));
        fWindowBox->SetLabel(B_TRANSLATE("Window"));
+       fClockBox->SetLabel(B_TRANSLATE("Clock"));
 
        BView* view;
        view = BLayoutBuilder::Group<>()
@@ -207,23 +258,59 @@ PreferencesWindow::PreferencesWindow(BRect frame)
 
        view = BLayoutBuilder::Group<>()
                .AddGroup(B_VERTICAL, 1)
-                       .Add(fClockSeconds)
+                       .Add(fWindowAlwaysOnTop)
+                       .Add(fWindowAutoRaise)
+                       .Add(fWindowAutoHide)
                        .AddGlue()
                        .SetInsets(10, 10, 10, 10)
                        .End()
                .View();
-       fClockBox->AddChild(view);
+       fWindowBox->AddChild(view);
+
+       BStringView* timeIntervalLabel = new BStringView("interval",
+               B_TRANSLATE("Interval:"));
+       timeIntervalLabel->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED,
+               B_SIZE_UNSET));
+       timeIntervalLabel->SetLowColor((rgb_color){255, 255, 255, 255});
+
+       BGroupLayout* timeIntervalLayout = new BGroupLayout(B_VERTICAL, 0);
+       timeIntervalLayout->SetInsets(10, 0, 0, 0);
+       BView* timeIntervalView = new BView("interval", 0, timeIntervalLayout);
+       timeIntervalView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+       timeIntervalView->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+       timeIntervalView->AddChild(fTimeInterval12HourRadioButton);
+       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<>()
-               .AddGroup(B_VERTICAL, 1)
-                       .Add(fWindowAlwaysOnTop)
-                       .Add(fWindowAutoRaise)
-                       .Add(fWindowAutoHide)
+               .AddGroup(B_VERTICAL, 10)
+                       .AddGroup(B_VERTICAL, 0)
+                               .Add(timeIntervalLabel)
+                               .Add(timeIntervalView)
+                               .End()
+                       .AddGroup(B_VERTICAL, 0)
+                               .Add(timeFormatLabel)
+                               .Add(timeFormatView)
+                               .End()
                        .AddGlue()
                        .SetInsets(10, 10, 10, 10)
                        .End()
                .View();
-       fWindowBox->AddChild(view);
+       fClockBox->AddChild(view);
 
        BLayoutBuilder::Group<>(this)
                .AddGrid(5, 5)
@@ -275,6 +362,14 @@ PreferencesWindow::MessageReceived(BMessage* message)
 
 
 void
+PreferencesWindow::WindowActivated(bool active)
+{
+       if (!active && IsMinimized())
+               PostMessage(B_QUIT_REQUESTED);
+}
+
+
+void
 PreferencesWindow::_UpdateRecentCounts()
 {
        BMessage message(kUpdateRecentCounts);
@@ -323,8 +418,17 @@ PreferencesWindow::_EnableDisableDependentItems()
 
 
 void
-PreferencesWindow::WindowActivated(bool active)
+PreferencesWindow::_UpdateTimeFormatRadioButtonLabels()
 {
-       if (!active && IsMinimized())
-               PostMessage(B_QUIT_REQUESTED);
+       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);
 }
diff --git a/src/apps/deskbar/PreferencesWindow.h 
b/src/apps/deskbar/PreferencesWindow.h
index 4f1891f..9bc9c53 100644
--- a/src/apps/deskbar/PreferencesWindow.h
+++ b/src/apps/deskbar/PreferencesWindow.h
@@ -35,6 +35,7 @@ public:
 private:
                        void                    _UpdateRecentCounts();
                        void                    _EnableDisableDependentItems();
+                       void                    
_UpdateTimeFormatRadioButtonLabels();
 
                        BBox*                   fMenuBox;
                        BBox*                   fAppsBox;
@@ -56,11 +57,17 @@ private:
                        BCheckBox*              fAppsHideLabels;
                        BSlider*                fAppsIconSizeSlider;
 
-                       BCheckBox*              fClockSeconds;
-
                        BCheckBox*              fWindowAlwaysOnTop;
                        BCheckBox*              fWindowAutoRaise;
                        BCheckBox*              fWindowAutoHide;
+
+                       BCheckBox*              fShowTime;
+                       BRadioButton*   fTimeInterval24HourRadioButton;
+                       BRadioButton*   fTimeInterval12HourRadioButton;
+
+                       BRadioButton*   fTimeFormatLongRadioButton;
+                       BRadioButton*   fTimeFormatMediumRadioButton;
+                       BRadioButton*   fTimeFormatShortRadioButton;
 };
 
 #endif // _PREFERENCES_WINDOW_H
diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp
index dbac254..e530434 100644
--- a/src/apps/deskbar/StatusView.cpp
+++ b/src/apps/deskbar/StatusView.cpp
@@ -54,6 +54,7 @@ All rights reserved.
 #include <FindDirectory.h>
 #include <Locale.h>
 #include <MenuItem.h>
+#include <MutableLocaleRoster.h>
 #include <NodeInfo.h>
 #include <NodeMonitor.h>
 #include <Path.h>
@@ -126,7 +127,7 @@ DumpList(BList* itemlist)
 TReplicantTray::TReplicantTray(TBarView* parent, bool vertical)
        : BView(BRect(0, 0, 1, 1), "Status", B_FOLLOW_LEFT | B_FOLLOW_TOP,
                        B_WILL_DRAW | B_FRAME_EVENTS),
-       fClock(NULL),
+       fTime(NULL),
        fBarView(parent),
        fShelf(new TReplicantShelf(this)),
        fMultiRowMode(vertical),
@@ -141,12 +142,17 @@ TReplicantTray::TReplicantTray(TBarView* parent, bool 
vertical)
                        2 * (logoBitmap->Bounds().Width() + 8));
                fMinimumTrayWidth = sMinimumWindowWidth - kGutter - 
kDragRegionWidth;
        }
+
+       // Create the time view
+       fTime = new TTimeView(fMinimumTrayWidth, kMaxReplicantHeight - 1.0,
+               ((TBarApp*)be_app)->Settings()->timeFormat);
 }
 
 
 TReplicantTray::~TReplicantTray()
 {
        delete fShelf;
+       delete fTime;
 }
 
 
@@ -164,8 +170,14 @@ TReplicantTray::AttachedToWindow()
        SetDrawingMode(B_OP_COPY);
 
        Window()->SetPulseRate(1000000);
-       DealWithClock(fBarView->ShowingClock());
 
+       AddChild(fTime);
+       fTime->MoveTo(Bounds().right - fTime->Bounds().Width() - 1, 2);
+       if (!((TBarApp*)be_app)->Settings()->showTime) {
+               fTime->Hide();
+               RealignReplicants();
+               AdjustPlacement();
+       }
 
 #ifdef DB_ADDONS
        // load addons and rehydrate archives
@@ -191,50 +203,43 @@ TReplicantTray::DetachedFromWindow()
 
 
 void
-TReplicantTray::RememberClockSettings()
+TReplicantTray::SaveTimeSettings()
 {
-       if (fClock) {
-               desk_settings* settings = ((TBarApp*)be_app)->Settings();
+       if (fTime == NULL)
+               return;
 
-               settings->timeShowSeconds = fClock->ShowingSeconds();
-       }
+       desk_settings* settings = ((TBarApp*)be_app)->Settings();
+       settings->showTime = !fTime->IsHidden();
+       settings->timeFormat = fTime->TimeFormat();
 }
 
 
-bool
-TReplicantTray::ShowingSeconds()
+void
+TReplicantTray::ShowHideTime()
 {
-       if (fClock)
-               return fClock->ShowingSeconds();
-       return false;
+       if (fTime == NULL)
+               return;
+
+       if (fTime->IsHidden())
+               fTime->Show();
+       else
+               fTime->Hide();
+
+       RealignReplicants();
+       AdjustPlacement();
 }
 
 
 void
-TReplicantTray::DealWithClock(bool showClock)
+TReplicantTray::UpdateTimeFormat(uint32 timeFormat)
 {
-       fBarView->ShowClock(showClock);
-
-       if (showClock) {
-               if (!fClock) {
-                       desk_settings* settings = 
((TBarApp*)be_app)->Settings();
-
-                       fClock = new TTimeView(fMinimumTrayWidth, 
kMaxReplicantHeight - 1.0,
-                               settings->timeShowSeconds,
-                               false);
-                       AddChild(fClock);
+       if (fTime == NULL)
+               return;
 
-                       fClock->MoveTo(Bounds().right - 
fClock->Bounds().Width() - 1, 2);
-               }
-       } else {
-               if (fClock) {
-                       RememberClockSettings();
+       fTime->SetTimeFormat(timeFormat);
 
-                       fClock->RemoveSelf();
-                       delete fClock;
-                       fClock = NULL;
-               }
-       }
+       RealignReplicants();
+       AdjustPlacement();
 }
 
 
@@ -261,10 +266,10 @@ TReplicantTray::GetPreferredSize(float* preferredWidth, 
float* preferredHeight)
        } else {
                // if last replicant overruns clock then resize to accomodate
                if (fShelf->CountReplicants() > 0) {
-                       if (fBarView->ShowingClock() && 
fRightBottomReplicant.right + 6
-                               >= fClock->Frame().left) {
+                       if (!fTime->IsHidden() && fTime->Frame().left
+                               < fRightBottomReplicant.right + 6) {
                                width = fRightBottomReplicant.right + 6
-                                       + fClock->Frame().Width();
+                                       + fTime->Frame().Width();
                        } else
                                width = fRightBottomReplicant.right + 3;
                }
@@ -306,25 +311,44 @@ void
 TReplicantTray::MessageReceived(BMessage* message)
 {
        switch (message->what) {
-               case 'time':
+               case kShowHideTime:
                        // from context menu in clock and in this view
-                       DealWithClock(!fBarView->ShowingClock());
-                       RealignReplicants();
-                       AdjustPlacement();
+                       ShowHideTime();
                        break;
 
-               case 'Trfm':
-                       // time string reformat -> realign
-                       DealWithClock(fBarView->ShowingClock());
-                       RealignReplicants();
-                       AdjustPlacement();
+               case kTimeIntervalChanged:
+               {
+                       if (fTime == NULL)
+                               return;
+
+                       bool use24HourClock;
+                       if (message->FindBool("use24HourClock", &use24HourClock)
+                               == B_OK) {
+                               BFormattingConventions conventions;
+                               
BLocale::Default()->GetFormattingConventions(&conventions);
+                               
conventions.SetExplicitUse24HourClock(use24HourClock);
+                               BPrivate::MutableLocaleRoster::Default()->
+                                       
SetDefaultFormattingConventions(conventions);
+                               fTime->Update();
+                               // time string reformat -> realign
+                               RealignReplicants();
+                               AdjustPlacement();
+                       }
+
                        break;
+               }
+
+               case kTimeFormatChanged:
+               {
+                       if (fTime == NULL)
+                               return;
+
+                       uint32 timeFormat;
+                       if (message->FindUInt32("time format", &timeFormat) == 
B_OK)
+                               UpdateTimeFormat(timeFormat);
 
-               case kShowSeconds:
-               case kFullDate:
-                       if (fClock != NULL)
-                               Window()->PostMessage(message, fClock);
                        break;
+               }
 
 #ifdef DB_ADDONS
                case B_NODE_MONITOR:
@@ -347,11 +371,11 @@ TReplicantTray::ShowReplicantMenu(BPoint point)
 
        // If clock is visible show the extended menu, otherwise show "Show 
Time"
 
-       if (fBarView->ShowingClock())
-               fClock->ShowClockOptions(ConvertToScreen(point));
+       if (fTime != NULL)
+               fTime->ShowTimeOptions(ConvertToScreen(point));
        else {
                BMenuItem* item = new BMenuItem(B_TRANSLATE("Show Time"),
-                       new BMessage('time'));
+                       new BMessage(kShowHideTime));
                menu->AddItem(item);
                menu->SetTargetForItems(this);
                BPoint where = ConvertToScreen(point);
@@ -1097,8 +1121,8 @@ TReplicantTray::LocationForReplicant(int32 index, float 
width)
                        // determine free space in this row
                        BRect rect(loc.x, loc.y, loc.x + fMinimumTrayWidth - 
kIconGap
                                - 2.0, loc.y + kMaxReplicantHeight);
-                       if (row == 0 && fBarView->ShowingClock())
-                               rect.right -= fClock->Frame().Width() + 
kIconGap;
+                       if (row == 0 && !fTime->IsHidden())
+                               rect.right -= fTime->Frame().Width() + kIconGap;
 
                        for (int32 i = 0; i < index; i++) {
                                BView* view = NULL;
diff --git a/src/apps/deskbar/StatusView.h b/src/apps/deskbar/StatusView.h
index 138114d..22577f9 100644
--- a/src/apps/deskbar/StatusView.h
+++ b/src/apps/deskbar/StatusView.h
@@ -45,6 +45,7 @@ All rights reserved.
 #include "BarView.h"
 #include "TimeView.h"
 
+
 const float kMaxReplicantHeight = 16.0f;
 const float kMaxReplicantWidth = 16.0f;
 const int32 kMinimumReplicantCount = 6;
@@ -111,11 +112,7 @@ public:
        bool AcceptAddon(BRect frame, BMessage* message);
        void RealignReplicants(int32 startIndex = -1);
 
-       bool ShowingSeconds(void);
-       bool ShowingMiltime(void);
-
-       void RememberClockSettings();
-       void DealWithClock(bool);
+       void SaveTimeSettings();
 
 #ifdef DB_ADDONS
        status_t LoadAddOn(BEntry* entry, int32* id, bool addToSettings = true);
@@ -147,11 +144,14 @@ private:
        BPoint LocationForReplicant(int32 index, float width);
        BShelf* Shelf() const;
 
+       void ShowHideTime();
+       void UpdateTimeFormat(uint32 timeFormat);
+
        status_t _SaveSettings();
 
        friend class TReplicantShelf;
 
-       TTimeView* fClock;
+       TTimeView* fTime;
        TBarView* fBarView;
        TReplicantShelf* fShelf;
        BRect fRightBottomReplicant;
diff --git a/src/apps/deskbar/TimeView.cpp b/src/apps/deskbar/TimeView.cpp
index f6d50bb..256542d 100644
--- a/src/apps/deskbar/TimeView.cpp
+++ b/src/apps/deskbar/TimeView.cpp
@@ -56,8 +56,8 @@ static const float kHMargin = 2.0;
 
 
 enum {
-       kShowClock,
-       kChangeClock,
+       kShowTime,
+       kChangeTime,
        kHide,
        kShowCalendar
 };
@@ -66,23 +66,21 @@ enum {
 #undef B_TRANSLATE_CONTEXT
 #define B_TRANSLATE_CONTEXT "TimeView"
 
-TTimeView::TTimeView(float maxWidth, float height, bool showSeconds,
-       bool)
+TTimeView::TTimeView(float maxWidth, float height, uint32 timeFormat)
        :
        BView(BRect(-100, -100, -90, -90), "_deskbar_tv_",
        B_FOLLOW_RIGHT | B_FOLLOW_TOP,
        B_WILL_DRAW | B_PULSE_NEEDED | B_FRAME_EVENTS),
        fParent(NULL),
-       fShowInterval(true), // ToDo: defaulting this to true until UI is in 
place
-       fShowSeconds(showSeconds),
        fMaxWidth(maxWidth),
        fHeight(height),
-       fOrientation(true)
+       fOrientation(true),
+       fTimeFormat(timeFormat)
 {
-       fTime = fLastTime = time(NULL);
+       fCurrentTime = fLastTime = time(NULL);
        fSeconds = fMinute = fHour = 0;
-       fTimeStr[0] = 0;
-       fDateStr[0] = 0;
+       fCurrentTimeStr[0] = 0;
+       fCurrentDateStr[0] = 0;
        fLastTimeStr[0] = 0;
        fLastDateStr[0] = 0;
        fNeedToUpdate = true;
@@ -95,7 +93,7 @@ TTimeView::TTimeView(float maxWidth, float height, bool 
showSeconds,
 TTimeView::TTimeView(BMessage* data)
        : BView(data)
 {
-       fTime = fLastTime = time(NULL);
+       fCurrentTime = fLastTime = time(NULL);
        data->FindBool("seconds", &fShowSeconds);
 
        fLocale = *BLocale::Default();
@@ -134,7 +132,7 @@ TTimeView::Archive(BMessage* data, bool deep) const
 void
 TTimeView::AttachedToWindow()
 {
-       fTime = time(NULL);
+       fCurrentTime = time(NULL);
 
        SetFont(be_plain_font);
        if (Parent()) {
@@ -149,40 +147,41 @@ TTimeView::AttachedToWindow()
 
 
 void
-TTimeView::GetPreferredSize(float* width, float* height)
+TTimeView::Draw(BRect /*updateRect*/)
 {
-       *height = fHeight;
+       PushState();
 
-       GetCurrentTime();
+       SetHighColor(ViewColor());
+       SetLowColor(ViewColor());
+       FillRect(Bounds());
+       SetHighColor(0, 0, 0, 255);
 
-       // TODO: SetOrientation never gets called, fix that when in vertical 
mode,
-       // we want to limit the width so that it can't overlap the bevels in the
-       // parent view.
-       *width = fOrientation ?
-               min_c(fMaxWidth - kHMargin, kHMargin + StringWidth(fTimeStr))
-               : kHMargin + StringWidth(fTimeStr);
+       DrawString(fCurrentTimeStr, fTimeLocation);
+
+       PopState();
 }
 
 
 void
-TTimeView::ResizeToPreferred()
+TTimeView::FrameMoved(BPoint)
 {
-       float width, height;
-       float oldWidth = Bounds().Width(), oldHeight = Bounds().Height();
-
-       GetPreferredSize(&width, &height);
-       if (height != oldHeight || width != oldWidth) {
-               ResizeTo(width, height);
-               MoveBy(oldWidth - width, 0);
-               fNeedToUpdate = true;
-       }
+       Update();
 }
 
 
 void
-TTimeView::FrameMoved(BPoint)
+TTimeView::GetPreferredSize(float* width, float* height)
 {
-       Update();
+       *height = fHeight;
+
+       GetCurrentTime();
+
+       // TODO: SetOrientation never gets called, fix that when in vertical 
mode,
+       // we want to limit the width so that it can't overlap the bevels in the
+       // parent view.
+       *width = fOrientation ?
+               min_c(fMaxWidth - kHMargin, kHMargin + 
StringWidth(fCurrentTimeStr))
+               : kHMargin + StringWidth(fCurrentTimeStr);
 }
 
 
@@ -190,20 +189,16 @@ void
 TTimeView::MessageReceived(BMessage* message)
 {
        switch (message->what) {
-               case kShowSeconds:
-                       ShowSeconds(!ShowingSeconds());
-                       break;
-
                case B_LOCALE_CHANGED:
                        Update();
                        break;
 
-               case kChangeClock:
+               case kChangeTime:
                        // launch the time prefs app
                        be_roster->Launch("application/x-vnd.Haiku-Time");
                        break;
 
-               case 'time':
+               case kShowHideTime:
                        Window()->PostMessage(message, Parent());
                        break;
 
@@ -224,80 +219,13 @@ TTimeView::MessageReceived(BMessage* message)
 
 
 void
-TTimeView::ShowCalendar(BPoint where)
-{
-       if (fCalendarWindow.IsValid()) {
-               // If the calendar is already shown, just activate it
-               BMessage activate(B_SET_PROPERTY);
-               activate.AddSpecifier("Active");
-               activate.AddBool("data", true);
-
-               if (fCalendarWindow.SendMessage(&activate) == B_OK)
-                       return;
-       }
-
-       where.y = Bounds().bottom + 4.0;
-       ConvertToScreen(&where);
-
-       if (where.y >= BScreen().Frame().bottom)
-               where.y -= (Bounds().Height() + 4.0);
-
-       CalendarMenuWindow* window = new CalendarMenuWindow(where);
-       fCalendarWindow = BMessenger(window);
-
-       window->Show();
-}
-
-
-void
-TTimeView::GetCurrentTime()
-{
-       fLocale.FormatTime(fTimeStr, 64, fTime,
-               fShowSeconds ? B_MEDIUM_TIME_FORMAT : B_SHORT_TIME_FORMAT);
-}
-
-
-void
-TTimeView::GetCurrentDate()
-{
-       char tmp[64];
-
-       fLocale.FormatDate(tmp, 64, fTime, B_FULL_DATE_FORMAT);
-
-       // remove leading 0 from date when month is less than 10 (MM/DD/YY)
-       // or remove leading 0 from date when day is less than 10 (DD/MM/YY)
-       const char* str = tmp;
-       if (str[0] == '0')
-               str++;
-
-       strlcpy(fDateStr, str, sizeof(fDateStr));
-}
-
-
-void
-TTimeView::Draw(BRect /*updateRect*/)
-{
-       PushState();
-
-       SetHighColor(ViewColor());
-       SetLowColor(ViewColor());
-       FillRect(Bounds());
-       SetHighColor(0, 0, 0, 255);
-
-       DrawString(fTimeStr, fTimeLocation);
-
-       PopState();
-}
-
-
-void
 TTimeView::MouseDown(BPoint point)
 {
        uint32 buttons;
 
        Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons);
        if (buttons == B_SECONDARY_MOUSE_BUTTON) {
-               ShowClockOptions(ConvertToScreen(point));
+               ShowTimeOptions(ConvertToScreen(point));
                return;
        } else if (buttons == B_PRIMARY_MOUSE_BUTTON)
                ShowCalendar(point);
@@ -318,27 +246,27 @@ TTimeView::Pulse()
        if (ct == NULL)
                return;
 
-       fTime = curTime;
+       fCurrentTime = curTime;
 
        GetCurrentTime();
        GetCurrentDate();
-       if (strcmp(fTimeStr, fLastTimeStr) != 0) {
+       if (strcmp(fCurrentTimeStr, fLastTimeStr) != 0) {
                // Update bounds when the size of the strings has changed
                // For dates, Update() could be called two times in a row,
                // but that should only happen very rarely
-               if ((fLastTimeStr[1] != fTimeStr[1]
-                       && (fLastTimeStr[1] == ':' || fTimeStr[1] == ':'))
+               if ((fLastTimeStr[1] != fCurrentTimeStr[1]
+                       && (fLastTimeStr[1] == ':' || fCurrentTimeStr[1] == 
':'))
                        || !fLastTimeStr[0])
                        Update();
 
-               strlcpy(fLastTimeStr, fTimeStr, sizeof(fLastTimeStr));
+               strlcpy(fLastTimeStr, fCurrentTimeStr, sizeof(fLastTimeStr));
                fNeedToUpdate = true;
        }
 
        // Update the tooltip if the date has changed
-       if (strcmp(fDateStr, fLastDateStr) != 0) {
-               strlcpy(fLastDateStr, fDateStr, sizeof(fLastDateStr));
-               SetToolTip(fDateStr);
+       if (strcmp(fCurrentDateStr, fLastDateStr) != 0) {
+               strlcpy(fLastDateStr, fCurrentDateStr, sizeof(fLastDateStr));
+               SetToolTip(fCurrentDateStr);
        }
 
        if (fNeedToUpdate) {
@@ -353,40 +281,103 @@ TTimeView::Pulse()
 
 
 void
-TTimeView::ShowSeconds(bool on)
+TTimeView::ResizeToPreferred()
+{
+       float width, height;
+       float oldWidth = Bounds().Width(), oldHeight = Bounds().Height();
+
+       GetPreferredSize(&width, &height);
+       if (height != oldHeight || width != oldWidth) {
+               ResizeTo(width, height);
+               MoveBy(oldWidth - width, 0);
+               fNeedToUpdate = true;
+       }
+}
+
+
+//     # pragma mark - Public methods
+
+
+void
+TTimeView::SetOrientation(bool orientation)
+{
+       fOrientation = orientation;
+       CalculateTextPlacement();
+       Invalidate();
+}
+
+
+void
+TTimeView::SetTimeFormat(uint32 timeFormat)
 {
-       fShowSeconds = on;
+       fTimeFormat = timeFormat;
        Update();
 }
 
 
 void
-TTimeView::Update()
+TTimeView::ShowCalendar(BPoint where)
 {
-       fLocale = *BLocale::Default();
-       GetCurrentTime();
-       GetCurrentDate();
+       if (fCalendarWindow.IsValid()) {
+               // If the calendar is already shown, just activate it
+               BMessage activate(B_SET_PROPERTY);
+               activate.AddSpecifier("Active");
+               activate.AddBool("data", true);
 
-       SetToolTip(fDateStr);
+               if (fCalendarWindow.SendMessage(&activate) == B_OK)
+                       return;
+       }
 
-       ResizeToPreferred();
-       CalculateTextPlacement();
+       where.y = Bounds().bottom + 4.0;
+       ConvertToScreen(&where);
 
-       if (fParent) {
-               BMessage reformat('Trfm');
-               fParent->MessageReceived(&reformat);
-                       // time string format realign
-               fParent->Invalidate();
+       if (where.y >= BScreen().Frame().bottom)
+               where.y -= (Bounds().Height() + 4.0);
+
+       CalendarMenuWindow* window = new CalendarMenuWindow(where);
+       fCalendarWindow = BMessenger(window);
+
+       window->Show();
+}
+
+
+//     # pragma mark - Private methods
+
+
+void
+TTimeView::GetCurrentTime()
+{
+       switch (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);
        }
+       
 }
 
 
 void
-TTimeView::SetOrientation(bool o)
+TTimeView::GetCurrentDate()
 {
-       fOrientation = o;
-       CalculateTextPlacement();
-       Invalidate();
+       char tmp[64];
+
+       fLocale.FormatDate(tmp, 64, fCurrentTime, B_FULL_DATE_FORMAT);
+
+       // remove leading 0 from date when month is less than 10 (MM/DD/YY)
+       // or remove leading 0 from date when day is less than 10 (DD/MM/YY)
+       const char* str = tmp;
+       if (str[0] == '0')
+               str++;
+
+       strlcpy(fCurrentDateStr, str, sizeof(fCurrentDateStr));
 }
 
 
@@ -401,7 +392,7 @@ TTimeView::CalculateTextPlacement()
        BFont font;
        GetFont(&font);
        const char* stringArray[1];
-       stringArray[0] = fTimeStr;
+       stringArray[0] = fCurrentTimeStr;
        BRect rectArray[1];
        escapement_delta delta = { 0.0, 0.0 };
        font.GetBoundingBoxesForStrings(stringArray, 1, B_SCREEN_METRIC, &delta,
@@ -413,22 +404,29 @@ TTimeView::CalculateTextPlacement()
 
 
 void
-TTimeView::ShowClockOptions(BPoint point)
+TTimeView::ShowTimeOptions(BPoint point)
 {
        BPopUpMenu* menu = new BPopUpMenu("", false, false);
        menu->SetFont(be_plain_font);
        BMenuItem* item;
 
-       item = new BMenuItem(B_TRANSLATE("Change time" B_UTF8_ELLIPSIS),
-               new BMessage(kChangeClock));
-       menu->AddItem(item);
-
-       item = new BMenuItem(B_TRANSLATE("Hide time"), new BMessage('time'));
-       menu->AddItem(item);
-
-       item = new BMenuItem(B_TRANSLATE("Show calendar" B_UTF8_ELLIPSIS),
-               new BMessage(kShowCalendar));
-       menu->AddItem(item);
+       if (IsHidden()) {
+               item = new BMenuItem(B_TRANSLATE("Show time"),
+                       new BMessage(kShowHideTime));
+               menu->AddItem(item);
+       } else {
+               item = new BMenuItem(B_TRANSLATE("Change time" B_UTF8_ELLIPSIS),
+                       new BMessage(kChangeTime));
+               menu->AddItem(item);
+
+               item = new BMenuItem(B_TRANSLATE("Hide time"),
+                       new BMessage(kShowHideTime));
+               menu->AddItem(item);
+
+               item = new BMenuItem(B_TRANSLATE("Show calendar" 
B_UTF8_ELLIPSIS),
+                       new BMessage(kShowCalendar));
+               menu->AddItem(item);
+       }
 
        menu->SetTargetForItems(this);
        // Changed to accept screen coord system point;
@@ -437,3 +435,18 @@ TTimeView::ShowClockOptions(BPoint point)
                point.x + 4, point.y +4), true);
 }
 
+
+void
+TTimeView::Update()
+{
+       fLocale = *BLocale::Default();
+       GetCurrentTime();
+       GetCurrentDate();
+       SetToolTip(fCurrentDateStr);
+
+       ResizeToPreferred();
+       CalculateTextPlacement();
+
+       if (fParent)
+               fParent->Invalidate();
+}
diff --git a/src/apps/deskbar/TimeView.h b/src/apps/deskbar/TimeView.h
index c462f6c..47a94b1 100644
--- a/src/apps/deskbar/TimeView.h
+++ b/src/apps/deskbar/TimeView.h
@@ -42,8 +42,9 @@ All rights reserved.
 #include <View.h>
 
 
-const uint32 kShowSeconds = 'ShSc';
-const uint32 kFullDate = 'FDat';
+const uint32 kShowHideTime = 'shtm';
+const uint32 kTimeIntervalChanged = 'tivc';
+const uint32 kTimeFormatChanged = 'tfmc';
 
 class BCountry;
 class BMessageRunner;
@@ -55,8 +56,7 @@ class _EXPORT TTimeView;
 
 class TTimeView : public BView {
        public:
-               TTimeView(float maxWidth, float height, bool showSeconds = 
false,
-                       bool showInterval = false);
+               TTimeView(float maxWidth, float height, uint32 timeFormat);
                TTimeView(BMessage* data);
                ~TTimeView();
 
@@ -67,50 +67,49 @@ class TTimeView : public BView {
 
                void            AttachedToWindow();
                void            Draw(BRect update);
-               void            GetPreferredSize(float* width, float* height);
-               void            ResizeToPreferred();
                void            FrameMoved(BPoint);
+               void            GetPreferredSize(float* width, float* height);
                void            MessageReceived(BMessage*);
                void            MouseDown(BPoint where);
                void            Pulse();
-
-               bool            ShowingSeconds() { return fShowSeconds; }
-               void            ShowSeconds(bool);
-               void            ShowCalendar(BPoint where);
+               void            ResizeToPreferred();
 
                bool            Orientation() const;
                void            SetOrientation(bool o);
 
+               uint32          TimeFormat() const;
+               void            SetTimeFormat(uint32 timeFormat);
+
+               void            ShowCalendar(BPoint where);
+
        private:
                friend class TReplicantTray;
 
-               void            Update();
                void            GetCurrentTime();
                void            GetCurrentDate();
                void            CalculateTextPlacement();
-               void            ShowClockOptions(BPoint);
+               void            ShowTimeOptions(BPoint);
+               void            Update();
 
                BView           *fParent;
                bool            fNeedToUpdate;
 
-               time_t          fTime;
+               time_t          fCurrentTime;
                time_t          fLastTime;
 
-               char            fTimeStr[64];
+               char            fCurrentTimeStr[64];
                char            fLastTimeStr[64];
-               char            fDateStr[64];
+               char            fCurrentDateStr[64];
                char            fLastDateStr[64];
 
                int                     fSeconds;
                int                     fMinute;
                int                     fHour;
 
-               bool            fShowInterval;
-               bool            fShowSeconds;
-
                float           fMaxWidth;
                float           fHeight;
                bool            fOrientation; // vertical = true
+               uint32          fTimeFormat;
                BPoint          fTimeLocation;
                BPoint          fDateLocation;
 
@@ -127,5 +126,12 @@ TTimeView::Orientation() const
 }
 
 
+inline uint32
+TTimeView::TimeFormat() const
+{
+       return fTimeFormat;
+}
+
+
 #endif /* TIME_VIEW_H */
 

############################################################################

Commit:      2a2dc95aa1f99080b0589186770f10ead41621a5
URL:         http://cgit.haiku-os.org/haiku/commit/?id=2a2dc95
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Tue Apr 10 05:27:38 2012 UTC

Update timeView popup menu

----------------------------------------------------------------------------

diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp
index e530434..faef6f2 100644
--- a/src/apps/deskbar/StatusView.cpp
+++ b/src/apps/deskbar/StatusView.cpp
@@ -371,7 +371,7 @@ TReplicantTray::ShowReplicantMenu(BPoint point)
 
        // If clock is visible show the extended menu, otherwise show "Show 
Time"
 
-       if (fTime != NULL)
+       if (!fTime->IsHidden())
                fTime->ShowTimeOptions(ConvertToScreen(point));
        else {
                BMenuItem* item = new BMenuItem(B_TRANSLATE("Show Time"),
diff --git a/src/apps/deskbar/TimeView.cpp b/src/apps/deskbar/TimeView.cpp
index 256542d..69694b7 100644
--- a/src/apps/deskbar/TimeView.cpp
+++ b/src/apps/deskbar/TimeView.cpp
@@ -410,23 +410,17 @@ TTimeView::ShowTimeOptions(BPoint point)
        menu->SetFont(be_plain_font);
        BMenuItem* item;
 
-       if (IsHidden()) {
-               item = new BMenuItem(B_TRANSLATE("Show time"),
-                       new BMessage(kShowHideTime));
-               menu->AddItem(item);
-       } else {
-               item = new BMenuItem(B_TRANSLATE("Change time" B_UTF8_ELLIPSIS),
-                       new BMessage(kChangeTime));
-               menu->AddItem(item);
-
-               item = new BMenuItem(B_TRANSLATE("Hide time"),
-                       new BMessage(kShowHideTime));
-               menu->AddItem(item);
-
-               item = new BMenuItem(B_TRANSLATE("Show calendar" 
B_UTF8_ELLIPSIS),
-                       new BMessage(kShowCalendar));
-               menu->AddItem(item);
-       }
+       item = new BMenuItem(B_TRANSLATE("Change time" B_UTF8_ELLIPSIS),
+               new BMessage(kChangeTime));
+       menu->AddItem(item);
+
+       item = new BMenuItem(B_TRANSLATE("Hide time"),
+               new BMessage(kShowHideTime));
+       menu->AddItem(item);
+
+       item = new BMenuItem(B_TRANSLATE("Show calendar" B_UTF8_ELLIPSIS),
+               new BMessage(kShowCalendar));
+       menu->AddItem(item);
 
        menu->SetTargetForItems(this);
        // Changed to accept screen coord system point;

############################################################################

Revision:    hrev43984
Commit:      95e02d49729b6639eee2368bf96508fc17cf9be0
URL:         http://cgit.haiku-os.org/haiku/commit/?id=95e02d4
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Tue Apr 10 05:36:42 2012 UTC

Remove superfluous colons

----------------------------------------------------------------------------

diff --git a/src/apps/deskbar/PreferencesWindow.cpp 
b/src/apps/deskbar/PreferencesWindow.cpp
index aae6556..53b87d2 100644
--- a/src/apps/deskbar/PreferencesWindow.cpp
+++ b/src/apps/deskbar/PreferencesWindow.cpp
@@ -268,7 +268,7 @@ PreferencesWindow::PreferencesWindow(BRect frame)
        fWindowBox->AddChild(view);
 
        BStringView* timeIntervalLabel = new BStringView("interval",
-               B_TRANSLATE("Interval:"));
+               B_TRANSLATE("Interval"));
        timeIntervalLabel->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED,
                B_SIZE_UNSET));
        timeIntervalLabel->SetLowColor((rgb_color){255, 255, 255, 255});
@@ -282,7 +282,7 @@ PreferencesWindow::PreferencesWindow(BRect frame)
        timeIntervalView->AddChild(fTimeInterval24HourRadioButton);
 
        BStringView* timeFormatLabel = new BStringView("format",
-               B_TRANSLATE("Format:"));
+               B_TRANSLATE("Format"));
        timeFormatLabel->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED,
                B_SIZE_UNSET));
        timeFormatLabel->SetLowColor((rgb_color){255, 255, 255, 255});


Other related posts: