[haiku-commits] r37527 - haiku/trunk/src/preferences/time

  • From: pulkomandy@xxxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 15 Jul 2010 13:04:21 +0200 (CEST)

Author: pulkomandy
Date: 2010-07-15 13:04:21 +0200 (Thu, 15 Jul 2010)
New Revision: 37527
Changeset: http://dev.haiku-os.org/changeset/37527

Modified:
   haiku/trunk/src/preferences/time/DateTimeEdit.cpp
Log:
 * Fix the time preflet to work in all languages, including ones with the AM/PM 
field before the time (try chinese for example).


Modified: haiku/trunk/src/preferences/time/DateTimeEdit.cpp
===================================================================
--- haiku/trunk/src/preferences/time/DateTimeEdit.cpp   2010-07-15 07:32:15 UTC 
(rev 37526)
+++ haiku/trunk/src/preferences/time/DateTimeEdit.cpp   2010-07-15 11:04:21 UTC 
(rev 37527)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004-2007, Haiku, Inc. All Rights Reserved.
+ * Copyright 2004-2010, Haiku, Inc. All Rights Reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -7,11 +7,12 @@
  *             Mike Berg <mike@xxxxxxxxxxx>
  *             Julun <host.haiku@xxxxxx>
  *             Clemens <mail@xxxxxxxxxxxxxxxxxx>
- *
+ *             Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
  */
 
 #include "DateTimeEdit.h"
 
+#include <stdlib.h>
 
 #include <List.h>
 #include <Locale.h>
@@ -20,9 +21,6 @@
 #include <Window.h>
 
 
-#include <stdlib.h>
-
-
 using BPrivate::B_LOCAL_TIME;
 
 
@@ -89,7 +87,6 @@
 void
 TTimeEdit::DrawSection(uint32 index, bool hasFocus)
 {
-       // user defined section drawing
        TSection *section = NULL;
        section = static_cast<TSection*> (fSectionList->ItemAt(index));
 
@@ -97,14 +94,12 @@
                return;
 
        BRect bounds = section->Frame();
-       uint32 value = _SectionValue(index);
        time_t time = fTime.Hour() * 3600 + fTime.Minute() * 60 + 
fTime.Second();
 
        SetLowColor(ViewColor());
-       if (hasFocus) {
+       BString field;
+       if (hasFocus)
                SetLowColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
-               value = fHoldValue;
-       }
 
        BString text;
        int* fieldPositions;
@@ -115,12 +110,11 @@
        country->FormatTime(&text, fieldPositions, fieldCount, time, true);
                // TODO : this should be cached somehow to not redo it for each 
field
 
-       if (index * 2 + 1 >= fieldCount) {
+       if (index * 2 + 1 > fieldCount) {
                free(fieldPositions);
                return;
        }
 
-       BString field;
        text.CopyCharsInto(field, fieldPositions[index * 2],
                fieldPositions[index * 2 + 1] - fieldPositions[index * 2]);
 
@@ -285,8 +279,18 @@
                if (fFocus == index)
                        data = fHoldValue;
 
-               if (dateFormat[index] < 3)
-                       message->AddInt32(fields[dateFormat[index]], data);
+               switch(dateFormat[index]) {
+                       case B_HOUR:
+                               message->AddInt32(fields[0], data);
+                               break;
+                       case B_MINUTE:
+                               message->AddInt32(fields[1], data);
+                               break;
+                       case B_SECOND:
+                               message->AddInt32(fields[2], data);
+                       default:
+                               break;
+               }
        }
 
        free(dateFormat);
@@ -470,8 +474,7 @@
                if (_IsValidDoubleDigi(doubleDigi))
                        number = doubleDigi;
                fLastKeyDownTime = 0;
-       }
-       else {
+       } else {
                fLastKeyDownTime = currentTime;
                fLastKeyDownInt = number;
        }


Other related posts:

  • » [haiku-commits] r37527 - haiku/trunk/src/preferences/time - pulkomandy