Cleanup, no functional change
* coding style adjustements * fixed all warnings git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37792 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -26,11 +26,11 @@
|
|||||||
|
|
||||||
class OffscreenClock : public BView {
|
class OffscreenClock : public BView {
|
||||||
public:
|
public:
|
||||||
OffscreenClock(BRect frame, const char *name);
|
OffscreenClock(BRect frame, const char* name);
|
||||||
virtual ~OffscreenClock();
|
virtual ~OffscreenClock();
|
||||||
|
|
||||||
void SetTime(int32 hour, int32 minute, int32 second);
|
void SetTime(int32 hour, int32 minute, int32 second);
|
||||||
void GetTime(int32 *hour, int32 *minute, int32 *second);
|
void GetTime(int32* hour, int32* minute, int32* second);
|
||||||
bool IsDirty() const { return fDirty; }
|
bool IsDirty() const { return fDirty; }
|
||||||
void DrawClock();
|
void DrawClock();
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
OffscreenClock::OffscreenClock(BRect frame, const char *name)
|
OffscreenClock::OffscreenClock(BRect frame, const char* name)
|
||||||
:
|
:
|
||||||
BView(frame, name, B_FOLLOW_NONE, B_WILL_DRAW),
|
BView(frame, name, B_FOLLOW_NONE, B_WILL_DRAW),
|
||||||
fHours(0),
|
fHours(0),
|
||||||
@@ -108,7 +108,7 @@ OffscreenClock::SetTime(int32 hour, int32 minute, int32 second)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
OffscreenClock::GetTime(int32 *hour, int32 *minute, int32 *second)
|
OffscreenClock::GetTime(int32* hour, int32* minute, int32* second)
|
||||||
{
|
{
|
||||||
*hour = fHours;
|
*hour = fHours;
|
||||||
*minute = fMinutes;
|
*minute = fMinutes;
|
||||||
@@ -359,7 +359,7 @@ OffscreenClock::_DrawHands(float x, float y, float radius,
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
TAnalogClock::TAnalogClock(BRect frame, const char *name)
|
TAnalogClock::TAnalogClock(BRect frame, const char* name)
|
||||||
:
|
:
|
||||||
BView(frame, name, B_FOLLOW_NONE, B_WILL_DRAW | B_DRAW_ON_CHILDREN),
|
BView(frame, name, B_FOLLOW_NONE, B_WILL_DRAW | B_DRAW_ON_CHILDREN),
|
||||||
fBitmap(NULL),
|
fBitmap(NULL),
|
||||||
@@ -397,7 +397,7 @@ TAnalogClock::AttachedToWindow()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TAnalogClock::MessageReceived(BMessage *message)
|
TAnalogClock::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
int32 change;
|
int32 change;
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
@@ -468,7 +468,7 @@ TAnalogClock::MouseUp(BPoint point)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TAnalogClock::MouseMoved(BPoint point, uint32 transit, const BMessage *message)
|
TAnalogClock::MouseMoved(BPoint point, uint32 transit, const BMessage* message)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fDraggingMinuteHand)
|
if (fDraggingMinuteHand)
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2007, Haiku, Inc. All Rights Reserved.
|
* Copyright 2004-2010, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Mike Berg <[email protected]>
|
* Mike Berg <[email protected]>
|
||||||
* Julun <[email protected]>
|
* Julun <[email protected]>
|
||||||
*/
|
*/
|
||||||
#ifndef ANALOG_CLOCK_H
|
#ifndef _ANALOG_CLOCK_H
|
||||||
#define ANALOG_CLOCK_H
|
#define _ANALOG_CLOCK_H
|
||||||
|
|
||||||
|
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
@@ -18,32 +18,34 @@ class OffscreenClock;
|
|||||||
|
|
||||||
|
|
||||||
class TAnalogClock : public BView {
|
class TAnalogClock : public BView {
|
||||||
public:
|
public:
|
||||||
TAnalogClock(BRect frame, const char *name);
|
TAnalogClock(BRect frame, const char* name);
|
||||||
virtual ~TAnalogClock();
|
virtual ~TAnalogClock();
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual void MouseDown(BPoint point);
|
virtual void MouseDown(BPoint point);
|
||||||
virtual void MouseUp(BPoint point);
|
virtual void MouseUp(BPoint point);
|
||||||
virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
|
virtual void MouseMoved(BPoint point, uint32 transit,
|
||||||
|
const BMessage* message);
|
||||||
|
|
||||||
void SetTime(int32 hour, int32 minute, int32 second);
|
void SetTime(int32 hour, int32 minute, int32 second);
|
||||||
|
|
||||||
bool IsChangingTime() { return fTimeChangeIsOngoing; }
|
bool IsChangingTime()
|
||||||
void ChangeTimeFinished();
|
{ return fTimeChangeIsOngoing; }
|
||||||
private:
|
void ChangeTimeFinished();
|
||||||
void _InitView(BRect frame);
|
private:
|
||||||
|
void _InitView(BRect frame);
|
||||||
|
|
||||||
BBitmap *fBitmap;
|
BBitmap* fBitmap;
|
||||||
OffscreenClock *fClock;
|
OffscreenClock* fClock;
|
||||||
|
|
||||||
bool fDraggingHourHand;
|
bool fDraggingHourHand;
|
||||||
bool fDraggingMinuteHand;
|
bool fDraggingMinuteHand;
|
||||||
|
|
||||||
bool fTimeChangeIsOngoing;
|
bool fTimeChangeIsOngoing;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ANALOG_CLOCK_H
|
|
||||||
|
|
||||||
|
#endif // _ANALOG_CLOCK_H
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
||||||
|
|
||||||
TTimeBaseView::TTimeBaseView(BRect frame, const char *name)
|
TTimeBaseView::TTimeBaseView(BRect frame, const char* name)
|
||||||
: BView(frame, name, B_FOLLOW_NONE, B_PULSE_NEEDED),
|
: BView(frame, name, B_FOLLOW_NONE, B_PULSE_NEEDED),
|
||||||
fMessage(H_TIME_UPDATE)
|
fMessage(H_TIME_UPDATE)
|
||||||
{
|
{
|
||||||
@@ -43,7 +43,7 @@ TTimeBaseView::AttachedToWindow()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TTimeBaseView::ChangeTime(BMessage *message)
|
TTimeBaseView::ChangeTime(BMessage* message)
|
||||||
{
|
{
|
||||||
bool isTime;
|
bool isTime;
|
||||||
if (message->FindBool("time", &isTime) != B_OK)
|
if (message->FindBool("time", &isTime) != B_OK)
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2007, Haiku, Inc. All Rights Reserved.
|
* Copyright 2004-2010, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Mike Berg <[email protected]>
|
* Mike Berg <[email protected]>
|
||||||
* Julun <[email protected]>
|
* Julun <[email protected]>
|
||||||
*/
|
*/
|
||||||
#ifndef TIMEBASE_H
|
#ifndef _BASE_VIEW_H
|
||||||
#define TIMEBASE_H
|
#define _BASE_VIEW_H
|
||||||
|
|
||||||
|
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
@@ -15,21 +15,21 @@
|
|||||||
|
|
||||||
|
|
||||||
class TTimeBaseView: public BView {
|
class TTimeBaseView: public BView {
|
||||||
public:
|
public:
|
||||||
TTimeBaseView(BRect frame, const char *name);
|
TTimeBaseView(BRect frame, const char* name);
|
||||||
virtual ~TTimeBaseView();
|
virtual ~TTimeBaseView();
|
||||||
|
|
||||||
virtual void Pulse();
|
|
||||||
virtual void AttachedToWindow();
|
|
||||||
|
|
||||||
void ChangeTime(BMessage *message);
|
virtual void Pulse();
|
||||||
|
virtual void AttachedToWindow();
|
||||||
|
|
||||||
private:
|
void ChangeTime(BMessage* message);
|
||||||
void _SendNotices();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BMessage fMessage;
|
void _SendNotices();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BMessage fMessage;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TIMEBASE_H
|
|
||||||
|
|
||||||
|
#endif // _BASE_VIEW_H
|
||||||
|
|||||||
@@ -16,18 +16,18 @@
|
|||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ReplaceTransparentColor(BBitmap *bitmap, rgb_color with)
|
ReplaceTransparentColor(BBitmap* bitmap, rgb_color with)
|
||||||
{
|
{
|
||||||
// other color spaces not implemented yet
|
// other color spaces not implemented yet
|
||||||
ASSERT(bitmap->ColorSpace() == B_COLOR_8_BIT);
|
ASSERT(bitmap->ColorSpace() == B_COLOR_8_BIT);
|
||||||
|
|
||||||
BScreen screen(B_MAIN_SCREEN_ID);
|
BScreen screen(B_MAIN_SCREEN_ID);
|
||||||
uint32 withIndex = screen.IndexForColor(with);
|
uint32 withIndex = screen.IndexForColor(with);
|
||||||
|
|
||||||
uchar *bits = (uchar *)bitmap->Bits();
|
uchar* bits = (uchar*)bitmap->Bits();
|
||||||
int32 bitsLength = bitmap->BitsLength();
|
int32 bitsLength = bitmap->BitsLength();
|
||||||
for (int32 index = 0; index < bitsLength; index++)
|
for (int32 index = 0; index < bitsLength; index++)
|
||||||
if (bits[index] == B_TRANSPARENT_8_BIT)
|
if (bits[index] == B_TRANSPARENT_8_BIT)
|
||||||
bits[index] = withIndex;
|
bits[index] = withIndex;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -8,14 +8,14 @@
|
|||||||
* Julun <[email protected]>
|
* Julun <[email protected]>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef ANALOG_CLOCK_H
|
#ifndef _BITMAPS_H
|
||||||
#define ANALOG_CLOCK_H
|
#define _BITMAPS_H
|
||||||
|
|
||||||
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
|
|
||||||
|
|
||||||
void ReplaceTransparentColor(BBitmap *bitmap, rgb_color with);
|
void ReplaceTransparentColor(BBitmap* bitmap, rgb_color with);
|
||||||
|
|
||||||
const int32 kUpArrowWidth = 16;
|
const int32 kUpArrowWidth = 16;
|
||||||
const int32 kUpArrowHeight = 7;
|
const int32 kUpArrowHeight = 7;
|
||||||
@@ -45,5 +45,6 @@ const unsigned char kDownArrowBits [] = {
|
|||||||
0xff,0xff,0xff,0xff,0xff,0x13,0xff,0xff,0xff,0xff,0xff,0xff,0x18,0x3f,0xff,0xff
|
0xff,0xff,0xff,0xff,0xff,0x13,0xff,0xff,0xff,0xff,0xff,0xff,0x18,0x3f,0xff,0xff
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ANALOG_CLOCK_H
|
|
||||||
|
#endif // _BITMAPS_H
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ TTimeEdit::InitView()
|
|||||||
void
|
void
|
||||||
TTimeEdit::DrawSection(uint32 index, bool hasFocus)
|
TTimeEdit::DrawSection(uint32 index, bool hasFocus)
|
||||||
{
|
{
|
||||||
TSection *section = NULL;
|
TSection* section = NULL;
|
||||||
section = static_cast<TSection*> (fSectionList->ItemAt(index));
|
section = static_cast<TSection*> (fSectionList->ItemAt(index));
|
||||||
|
|
||||||
if (!section)
|
if (!section)
|
||||||
@@ -110,7 +110,7 @@ TTimeEdit::DrawSection(uint32 index, bool hasFocus)
|
|||||||
country->FormatTime(&text, fieldPositions, fieldCount, time, true);
|
country->FormatTime(&text, fieldPositions, fieldCount, time, true);
|
||||||
// TODO : this should be cached somehow to not redo it for each field
|
// TODO : this should be cached somehow to not redo it for each field
|
||||||
|
|
||||||
if (index * 2 + 1 > fieldCount) {
|
if (index * 2 + 1 > (uint32)fieldCount) {
|
||||||
free(fieldPositions);
|
free(fieldPositions);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ TTimeEdit::DrawSection(uint32 index, bool hasFocus)
|
|||||||
void
|
void
|
||||||
TTimeEdit::DrawSeparator(uint32 index)
|
TTimeEdit::DrawSeparator(uint32 index)
|
||||||
{
|
{
|
||||||
TSection *section = NULL;
|
TSection* section = NULL;
|
||||||
section = static_cast<TSection*> (fSectionList->ItemAt(index));
|
section = static_cast<TSection*> (fSectionList->ItemAt(index));
|
||||||
|
|
||||||
if (!section)
|
if (!section)
|
||||||
@@ -154,7 +154,7 @@ TTimeEdit::DrawSeparator(uint32 index)
|
|||||||
country->FormatTime(&text, fieldPositions, fieldCount, time, true);
|
country->FormatTime(&text, fieldPositions, fieldCount, time, true);
|
||||||
// TODO : this should be cached somehow to not redo it for each field
|
// TODO : this should be cached somehow to not redo it for each field
|
||||||
|
|
||||||
if (index * 2 + 2 > fieldCount) {
|
if (index * 2 + 2 > (uint32)fieldCount) {
|
||||||
free(fieldPositions);
|
free(fieldPositions);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -257,9 +257,9 @@ TTimeEdit::DoDownPress()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TTimeEdit::BuildDispatch(BMessage *message)
|
TTimeEdit::BuildDispatch(BMessage* message)
|
||||||
{
|
{
|
||||||
const char *fields[3] = { "hour", "minute", "second" };
|
const char* fields[3] = { "hour", "minute", "second" };
|
||||||
|
|
||||||
message->AddBool("time", true);
|
message->AddBool("time", true);
|
||||||
|
|
||||||
@@ -445,7 +445,7 @@ TTimeEdit::_SectionValue(int32 index) const
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
TDateEdit::TDateEdit(BRect frame, const char *name, uint32 sections)
|
TDateEdit::TDateEdit(BRect frame, const char* name, uint32 sections)
|
||||||
: TSectionEdit(frame, name, sections)
|
: TSectionEdit(frame, name, sections)
|
||||||
{
|
{
|
||||||
InitView();
|
InitView();
|
||||||
@@ -484,7 +484,7 @@ TDateEdit::KeyDown(const char* bytes, int32 numBytes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if year add 2000
|
// if year add 2000
|
||||||
|
|
||||||
BDateElement* dateFormat;
|
BDateElement* dateFormat;
|
||||||
int fieldCount;
|
int fieldCount;
|
||||||
BCountry* here;
|
BCountry* here;
|
||||||
@@ -523,7 +523,7 @@ TDateEdit::InitView()
|
|||||||
void
|
void
|
||||||
TDateEdit::DrawSection(uint32 index, bool hasFocus)
|
TDateEdit::DrawSection(uint32 index, bool hasFocus)
|
||||||
{
|
{
|
||||||
TSection *section = NULL;
|
TSection* section = NULL;
|
||||||
section = static_cast<TSection*> (fSectionList->ItemAt(index));
|
section = static_cast<TSection*> (fSectionList->ItemAt(index));
|
||||||
|
|
||||||
if (!section)
|
if (!section)
|
||||||
@@ -547,7 +547,7 @@ TDateEdit::DrawSection(uint32 index, bool hasFocus)
|
|||||||
false);
|
false);
|
||||||
// TODO : this should be cached somehow to not redo it for each field
|
// TODO : this should be cached somehow to not redo it for each field
|
||||||
|
|
||||||
if (index * 2 + 1 > fieldCount) {
|
if (index * 2 + 1 > (uint32)fieldCount) {
|
||||||
free(fieldPositions);
|
free(fieldPositions);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -575,7 +575,7 @@ TDateEdit::DrawSeparator(uint32 index)
|
|||||||
if (index == 3)
|
if (index == 3)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TSection *section = NULL;
|
TSection* section = NULL;
|
||||||
section = static_cast<TSection*> (fSectionList->ItemAt(index));
|
section = static_cast<TSection*> (fSectionList->ItemAt(index));
|
||||||
BRect bounds = section->Frame();
|
BRect bounds = section->Frame();
|
||||||
|
|
||||||
@@ -594,7 +594,7 @@ TDateEdit::DrawSeparator(uint32 index)
|
|||||||
false);
|
false);
|
||||||
// TODO : this should be cached somehow to not redo it for each field
|
// TODO : this should be cached somehow to not redo it for each field
|
||||||
|
|
||||||
if (index * 2 + 2 > fieldCount) {
|
if (index * 2 + 2 > (uint32)fieldCount) {
|
||||||
free(fieldPositions);
|
free(fieldPositions);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -625,7 +625,7 @@ TDateEdit::SetSections(BRect area)
|
|||||||
float sepWidth = SeparatorWidth();
|
float sepWidth = SeparatorWidth();
|
||||||
|
|
||||||
// year
|
// year
|
||||||
TSection *section = NULL;
|
TSection* section = NULL;
|
||||||
float width = be_plain_font->StringWidth("0000") +6;
|
float width = be_plain_font->StringWidth("0000") +6;
|
||||||
bounds.right = area.right;
|
bounds.right = area.right;
|
||||||
bounds.left = bounds.right -width;
|
bounds.left = bounds.right -width;
|
||||||
@@ -708,9 +708,9 @@ TDateEdit::DoDownPress()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TDateEdit::BuildDispatch(BMessage *message)
|
TDateEdit::BuildDispatch(BMessage* message)
|
||||||
{
|
{
|
||||||
const char *fields[3] = { "month", "day", "year" };
|
const char* fields[3] = { "month", "day", "year" };
|
||||||
|
|
||||||
message->AddBool("time", false);
|
message->AddBool("time", false);
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
* Julun <[email protected]>
|
* Julun <[email protected]>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef DATETIME_H
|
#ifndef _DATE_TIME_EDIT_H
|
||||||
#define DATETIME_H
|
#define _DATE_TIME_EDIT_H
|
||||||
|
|
||||||
|
|
||||||
#include "SectionEdit.h"
|
#include "SectionEdit.h"
|
||||||
@@ -19,36 +19,37 @@
|
|||||||
|
|
||||||
|
|
||||||
class TTimeEdit : public TSectionEdit {
|
class TTimeEdit : public TSectionEdit {
|
||||||
public:
|
public:
|
||||||
TTimeEdit(BRect frame, const char *name,
|
TTimeEdit(BRect frame, const char* name,
|
||||||
uint32 sections);
|
uint32 sections);
|
||||||
virtual ~TTimeEdit();
|
virtual ~TTimeEdit();
|
||||||
virtual void KeyDown(const char* bytes, int32 numBytes);
|
|
||||||
|
|
||||||
virtual void InitView();
|
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||||
virtual void DrawSection(uint32 index, bool isfocus);
|
|
||||||
virtual void DrawSeparator(uint32 index);
|
|
||||||
|
|
||||||
virtual void SetSections(BRect area);
|
virtual void InitView();
|
||||||
virtual void SectionFocus(uint32 index);
|
virtual void DrawSection(uint32 index, bool isfocus);
|
||||||
virtual float SeparatorWidth() const;
|
virtual void DrawSeparator(uint32 index);
|
||||||
|
|
||||||
virtual void DoUpPress();
|
virtual void SetSections(BRect area);
|
||||||
virtual void DoDownPress();
|
virtual void SectionFocus(uint32 index);
|
||||||
|
virtual float SeparatorWidth() const;
|
||||||
|
|
||||||
virtual void BuildDispatch(BMessage *message);
|
virtual void DoUpPress();
|
||||||
|
virtual void DoDownPress();
|
||||||
|
|
||||||
void SetTime(int32 hour, int32 minute, int32 second);
|
virtual void BuildDispatch(BMessage* message);
|
||||||
|
|
||||||
private:
|
void SetTime(int32 hour, int32 minute, int32 second);
|
||||||
void _CheckRange();
|
|
||||||
bool _IsValidDoubleDigi(int32 value);
|
|
||||||
int32 _SectionValue(int32 index) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BDateTime fTime;
|
void _CheckRange();
|
||||||
bigtime_t fLastKeyDownTime;
|
bool _IsValidDoubleDigi(int32 value);
|
||||||
int32 fLastKeyDownInt;
|
int32 _SectionValue(int32 index) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
BDateTime fTime;
|
||||||
|
bigtime_t fLastKeyDownTime;
|
||||||
|
int32 fLastKeyDownInt;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -85,5 +86,5 @@ class TDateEdit : public TSectionEdit {
|
|||||||
int32 fLastKeyDownInt;
|
int32 fLastKeyDownInt;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DATETIME_H
|
#endif // _DATE_TIME_EDIT_H
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ using BPrivate::B_LOCAL_TIME;
|
|||||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||||
# include <syscalls.h>
|
# include <syscalls.h>
|
||||||
#else
|
#else
|
||||||
extern "C" void _kset_tzfilename_(const char *name, size_t length, bool isGMT);
|
extern "C" void _kset_tzfilename_(const char* name, size_t length, bool isGMT);
|
||||||
# define _kern_set_tzfilename _kset_tzfilename_
|
# define _kern_set_tzfilename _kset_tzfilename_
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ DateTimeView::Draw(BRect /*updateRect*/)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DateTimeView::MessageReceived(BMessage *message)
|
DateTimeView::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
int32 change;
|
int32 change;
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
@@ -249,7 +249,7 @@ DateTimeView::_InitView()
|
|||||||
|
|
||||||
// clock radio buttons
|
// clock radio buttons
|
||||||
bounds.top = fClock->Frame().bottom + 10.0;
|
bounds.top = fClock->Frame().bottom + 10.0;
|
||||||
BStringView *text = new BStringView(bounds, "clockSetTo", "Clock set to:");
|
BStringView* text = new BStringView(bounds, "clockSetTo", "Clock set to:");
|
||||||
AddChild(text);
|
AddChild(text);
|
||||||
text->ResizeToPreferred();
|
text->ResizeToPreferred();
|
||||||
|
|
||||||
@@ -342,7 +342,7 @@ DateTimeView::_UpdateGmtSettings()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DateTimeView::_UpdateDateTime(BMessage *message)
|
DateTimeView::_UpdateDateTime(BMessage* message)
|
||||||
{
|
{
|
||||||
int32 day;
|
int32 day;
|
||||||
int32 month;
|
int32 month;
|
||||||
|
|||||||
@@ -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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
* Julun <[email protected]>
|
* Julun <[email protected]>
|
||||||
* Philippe Saint-Pierre <[email protected]>
|
* Philippe Saint-Pierre <[email protected]>
|
||||||
*/
|
*/
|
||||||
#ifndef DATE_TIME_VIEW_H
|
#ifndef _DATE_TIME_VIEW_H
|
||||||
#define DATE_TIME_VIEW_H
|
#define _DATE_TIME_VIEW_H
|
||||||
|
|
||||||
|
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
@@ -28,41 +28,41 @@ using BPrivate::BCalendarView;
|
|||||||
|
|
||||||
|
|
||||||
class DateTimeView : public BView {
|
class DateTimeView : public BView {
|
||||||
public:
|
public:
|
||||||
DateTimeView(BRect frame);
|
DateTimeView(BRect frame);
|
||||||
virtual ~DateTimeView();
|
virtual ~DateTimeView();
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void Draw(BRect updaterect);
|
virtual void Draw(BRect updaterect);
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
bool CheckCanRevert();
|
bool CheckCanRevert();
|
||||||
bool GetUseGmtTime();
|
bool GetUseGmtTime();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _InitView();
|
void _InitView();
|
||||||
void _ReadRTCSettings();
|
void _ReadRTCSettings();
|
||||||
void _WriteRTCSettings();
|
void _WriteRTCSettings();
|
||||||
void _UpdateGmtSettings();
|
void _UpdateGmtSettings();
|
||||||
void _UpdateDateTime(BMessage *message);
|
void _UpdateDateTime(BMessage* message);
|
||||||
void _Revert();
|
void _Revert();
|
||||||
time_t _PrefletUptime() const;
|
time_t _PrefletUptime() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BRadioButton *fLocalTime;
|
BRadioButton* fLocalTime;
|
||||||
BRadioButton *fGmtTime;
|
BRadioButton* fGmtTime;
|
||||||
TDateEdit *fDateEdit;
|
TDateEdit* fDateEdit;
|
||||||
TTimeEdit *fTimeEdit;
|
TTimeEdit* fTimeEdit;
|
||||||
BCalendarView *fCalendarView;
|
BCalendarView* fCalendarView;
|
||||||
TAnalogClock *fClock;
|
TAnalogClock* fClock;
|
||||||
|
|
||||||
bool fUseGmtTime;
|
bool fUseGmtTime;
|
||||||
bool fOldUseGmtTime;
|
bool fOldUseGmtTime;
|
||||||
bool fInitialized;
|
bool fInitialized;
|
||||||
|
|
||||||
time_t fTimeAtStart;
|
time_t fTimeAtStart;
|
||||||
bigtime_t fSystemTimeAtStart;
|
bigtime_t fSystemTimeAtStart;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DATE_TIME_VIEW_H
|
|
||||||
|
|
||||||
|
#endif // _DATE_TIME_VIEW_H
|
||||||
|
|||||||
@@ -18,10 +18,39 @@
|
|||||||
#include "TimeMessages.h"
|
#include "TimeMessages.h"
|
||||||
|
|
||||||
|
|
||||||
|
TSection::TSection(BRect frame)
|
||||||
|
:
|
||||||
|
fFrame(frame)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRect
|
||||||
|
TSection::Bounds() const
|
||||||
|
{
|
||||||
|
BRect frame(fFrame);
|
||||||
|
return frame.OffsetByCopy(B_ORIGIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TSection::SetFrame(BRect frame)
|
||||||
|
{
|
||||||
|
fFrame = frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRect
|
||||||
|
TSection::Frame() const
|
||||||
|
{
|
||||||
|
return fFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const uint32 kArrowAreaWidth = 16;
|
const uint32 kArrowAreaWidth = 16;
|
||||||
|
|
||||||
|
|
||||||
TSectionEdit::TSectionEdit(BRect frame, const char *name, uint32 sections)
|
TSectionEdit::TSectionEdit(BRect frame, const char* name, uint32 sections)
|
||||||
:
|
:
|
||||||
BControl(frame, name, NULL, NULL, B_FOLLOW_NONE, B_NAVIGABLE | B_WILL_DRAW),
|
BControl(frame, name, NULL, NULL, B_FOLLOW_NONE, B_NAVIGABLE | B_WILL_DRAW),
|
||||||
fSectionList(NULL),
|
fSectionList(NULL),
|
||||||
@@ -74,9 +103,9 @@ TSectionEdit::MouseDown(BPoint where)
|
|||||||
else if (fDownRect.Contains(where))
|
else if (fDownRect.Contains(where))
|
||||||
DoDownPress();
|
DoDownPress();
|
||||||
else if (fSectionList->CountItems()> 0) {
|
else if (fSectionList->CountItems()> 0) {
|
||||||
TSection *section;
|
TSection* section;
|
||||||
for (uint32 idx = 0; idx < fSectionCount; idx++) {
|
for (uint32 idx = 0; idx < fSectionCount; idx++) {
|
||||||
section = (TSection *)fSectionList->ItemAt(idx);
|
section = (TSection*)fSectionList->ItemAt(idx);
|
||||||
if (section->Frame().Contains(where)) {
|
if (section->Frame().Contains(where)) {
|
||||||
SectionFocus(idx);
|
SectionFocus(idx);
|
||||||
return;
|
return;
|
||||||
@@ -102,7 +131,7 @@ TSectionEdit::MakeFocus(bool focused)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TSectionEdit::KeyDown(const char *bytes, int32 numbytes)
|
TSectionEdit::KeyDown(const char* bytes, int32 numbytes)
|
||||||
{
|
{
|
||||||
if (fFocus == -1)
|
if (fFocus == -1)
|
||||||
SectionFocus(0);
|
SectionFocus(0);
|
||||||
|
|||||||
@@ -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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -7,8 +7,8 @@
|
|||||||
* Julun <[email protected]>
|
* Julun <[email protected]>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef SECTIONEDIT_H
|
#ifndef _SECTION_EDIT_H
|
||||||
#define SECTIONEDIT_H
|
#define _SECTION_EDIT_H
|
||||||
|
|
||||||
|
|
||||||
#include <Control.h>
|
#include <Control.h>
|
||||||
@@ -19,75 +19,66 @@ class BList;
|
|||||||
|
|
||||||
|
|
||||||
class TSection {
|
class TSection {
|
||||||
public:
|
public:
|
||||||
TSection(BRect frame)
|
TSection(BRect frame);
|
||||||
: fFrame(frame) {}
|
|
||||||
|
|
||||||
BRect Bounds() const
|
BRect Bounds() const;
|
||||||
{
|
void SetFrame(BRect frame);
|
||||||
BRect frame(fFrame);
|
BRect Frame() const;
|
||||||
return frame.OffsetByCopy(B_ORIGIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetFrame(BRect frame)
|
private:
|
||||||
{ fFrame = frame; }
|
BRect fFrame;
|
||||||
|
|
||||||
BRect Frame() const
|
|
||||||
{ return fFrame; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
BRect fFrame;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TSectionEdit: public BControl {
|
class TSectionEdit: public BControl {
|
||||||
public:
|
public:
|
||||||
TSectionEdit(BRect frame, const char *name,
|
TSectionEdit(BRect frame, const char* name,
|
||||||
uint32 sections);
|
uint32 sections);
|
||||||
virtual ~TSectionEdit();
|
virtual ~TSectionEdit();
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
virtual void MouseDown(BPoint point);
|
virtual void MouseDown(BPoint point);
|
||||||
virtual void MakeFocus(bool focused = true);
|
virtual void MakeFocus(bool focused = true);
|
||||||
virtual void KeyDown(const char *bytes, int32 numBytes);
|
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||||
|
|
||||||
uint32 CountSections() const;
|
uint32 CountSections() const;
|
||||||
int32 FocusIndex() const;
|
int32 FocusIndex() const;
|
||||||
BRect SectionArea() const;
|
BRect SectionArea() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void InitView();
|
virtual void InitView();
|
||||||
|
|
||||||
// hooks
|
// hooks
|
||||||
virtual void DrawBorder(const BRect& updateRect);
|
virtual void DrawBorder(const BRect& updateRect);
|
||||||
virtual void DrawSection(uint32 index, bool isFocus) {}
|
virtual void DrawSection(uint32 index, bool isFocus) {}
|
||||||
virtual void DrawSeparator(uint32 index) {}
|
virtual void DrawSeparator(uint32 index) {}
|
||||||
|
|
||||||
virtual void SectionFocus(uint32 index) {}
|
virtual void SectionFocus(uint32 index) {}
|
||||||
virtual void SectionChange(uint32 index, uint32 value) {}
|
virtual void SectionChange(uint32 index, uint32 value) {}
|
||||||
virtual void SetSections(BRect area) {}
|
virtual void SetSections(BRect area) {}
|
||||||
virtual float SeparatorWidth() const;
|
virtual float SeparatorWidth() const;
|
||||||
|
|
||||||
virtual void DoUpPress() {}
|
virtual void DoUpPress() {}
|
||||||
virtual void DoDownPress() {}
|
virtual void DoDownPress() {}
|
||||||
|
|
||||||
virtual void DispatchMessage();
|
virtual void DispatchMessage();
|
||||||
virtual void BuildDispatch(BMessage *message) = 0;
|
virtual void BuildDispatch(BMessage* message) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BList *fSectionList;
|
BList* fSectionList;
|
||||||
|
|
||||||
BRect fUpRect;
|
BRect fUpRect;
|
||||||
BRect fDownRect;
|
BRect fDownRect;
|
||||||
BRect fSectionArea;
|
BRect fSectionArea;
|
||||||
|
|
||||||
int32 fFocus;
|
int32 fFocus;
|
||||||
uint32 fSectionCount;
|
uint32 fSectionCount;
|
||||||
uint32 fHoldValue;
|
uint32 fHoldValue;
|
||||||
|
|
||||||
bool fShowFocus;
|
bool fShowFocus;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#endif // _SECTION_EDIT_H
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TTZDisplay::TTZDisplay(BRect frame, const char *name, const char *label)
|
TTZDisplay::TTZDisplay(BRect frame, const char* name, const char* label)
|
||||||
: BView(frame, name, B_FOLLOW_NONE, B_WILL_DRAW),
|
: BView(frame, name, B_FOLLOW_NONE, B_WILL_DRAW),
|
||||||
fLabel(label),
|
fLabel(label),
|
||||||
fText(""),
|
fText(""),
|
||||||
@@ -62,7 +62,7 @@ TTZDisplay::Draw(BRect /* updateRect */)
|
|||||||
|
|
||||||
BRect bounds = Bounds();
|
BRect bounds = Bounds();
|
||||||
FillRect(Bounds(), B_SOLID_LOW);
|
FillRect(Bounds(), B_SOLID_LOW);
|
||||||
|
|
||||||
float fontHeight = _FontHeight();
|
float fontHeight = _FontHeight();
|
||||||
|
|
||||||
BPoint pt(bounds.left + 2.0, fontHeight / 2.0 + 2.0);
|
BPoint pt(bounds.left + 2.0, fontHeight / 2.0 + 2.0);
|
||||||
@@ -70,7 +70,7 @@ TTZDisplay::Draw(BRect /* updateRect */)
|
|||||||
|
|
||||||
pt.y += fontHeight;
|
pt.y += fontHeight;
|
||||||
DrawString(fText.String(), pt);
|
DrawString(fText.String(), pt);
|
||||||
|
|
||||||
pt.x = bounds.right - StringWidth(fTime.String()) - 2.0;
|
pt.x = bounds.right - StringWidth(fTime.String()) - 2.0;
|
||||||
DrawString(fTime.String(), pt);
|
DrawString(fTime.String(), pt);
|
||||||
}
|
}
|
||||||
@@ -84,7 +84,7 @@ TTZDisplay::Label() const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TTZDisplay::SetLabel(const char *label)
|
TTZDisplay::SetLabel(const char* label)
|
||||||
{
|
{
|
||||||
fLabel.SetTo(label);
|
fLabel.SetTo(label);
|
||||||
Draw(Bounds());
|
Draw(Bounds());
|
||||||
@@ -99,7 +99,7 @@ TTZDisplay::Text() const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TTZDisplay::SetText(const char *text)
|
TTZDisplay::SetText(const char* text)
|
||||||
{
|
{
|
||||||
fText.SetTo(text);
|
fText.SetTo(text);
|
||||||
Draw(Bounds());
|
Draw(Bounds());
|
||||||
@@ -119,11 +119,11 @@ TTZDisplay::SetTime(int32 hour, int32 minute)
|
|||||||
int32 ahour = hour;
|
int32 ahour = hour;
|
||||||
if (hour > 12)
|
if (hour > 12)
|
||||||
ahour = hour -12;
|
ahour = hour -12;
|
||||||
|
|
||||||
if (ahour == 0)
|
if (ahour == 0)
|
||||||
ahour = 12;
|
ahour = 12;
|
||||||
|
|
||||||
const char *ap = "AM";
|
const char* ap = "AM";
|
||||||
if (hour > 11)
|
if (hour > 11)
|
||||||
ap = "PM";
|
ap = "PM";
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
* Julun <[email protected]>
|
* Julun <[email protected]>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef TTZDISPLAY_H
|
#ifndef _TZ_DISPLAY_H
|
||||||
#define TTZDISPLAY_H
|
#define _TZ_DISPLAY_H
|
||||||
|
|
||||||
|
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
@@ -17,29 +17,30 @@
|
|||||||
|
|
||||||
|
|
||||||
class TTZDisplay : public BView {
|
class TTZDisplay : public BView {
|
||||||
public:
|
public:
|
||||||
TTZDisplay(BRect frame, const char *name, const char *label);
|
TTZDisplay(BRect frame, const char* name,
|
||||||
virtual ~TTZDisplay();
|
const char* label);
|
||||||
|
virtual ~TTZDisplay();
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void ResizeToPreferred();
|
virtual void ResizeToPreferred();
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
|
|
||||||
const char* Label() const;
|
const char* Label() const;
|
||||||
void SetLabel(const char *label);
|
void SetLabel(const char* label);
|
||||||
|
|
||||||
const char* Text() const;
|
const char* Text() const;
|
||||||
void SetText(const char *text);
|
void SetText(const char* text);
|
||||||
|
|
||||||
const char* Time() const;
|
const char* Time() const;
|
||||||
void SetTime(int32 hour, int32 minute);
|
void SetTime(int32 hour, int32 minute);
|
||||||
|
|
||||||
private:
|
|
||||||
BString fLabel;
|
|
||||||
BString fText;
|
|
||||||
BString fTime;
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
BString fLabel;
|
||||||
|
BString fText;
|
||||||
|
BString fTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TTZDISPLAY_H
|
|
||||||
|
#endif // _TZ_DISPLAY_H
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ TimeApplication::ReadyToRun()
|
|||||||
void
|
void
|
||||||
TimeApplication::AboutRequested()
|
TimeApplication::AboutRequested()
|
||||||
{
|
{
|
||||||
BAlert *alert = new BAlert("about",
|
BAlert* alert = new BAlert("about",
|
||||||
"Time & Date, writen by:\n\n\tAndrew Edward McCall\n\tMike Berg\n\t"
|
"Time & Date, writen by:\n\n\tAndrew Edward McCall\n\tMike Berg\n\t"
|
||||||
"Julun\n\tPhilippe Saint-Pierre\n\nCopyright 2004-2008, Haiku.", "OK");
|
"Julun\n\tPhilippe Saint-Pierre\n\nCopyright 2004-2008, Haiku.", "OK");
|
||||||
alert->Go();
|
alert->Go();
|
||||||
|
|||||||
+12
-11
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2007, Haiku. All rights reserved.
|
* Copyright 2002-2010, Haiku. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -7,8 +7,8 @@
|
|||||||
* Mike Berg <[email protected]>
|
* Mike Berg <[email protected]>
|
||||||
* Julun <[email protected]>
|
* Julun <[email protected]>
|
||||||
*/
|
*/
|
||||||
#ifndef TIME_H
|
#ifndef _TIME_H
|
||||||
#define TIME_H
|
#define _TIME_H
|
||||||
|
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
@@ -18,16 +18,17 @@ class TTimeWindow;
|
|||||||
|
|
||||||
|
|
||||||
class TimeApplication : public BApplication {
|
class TimeApplication : public BApplication {
|
||||||
public:
|
public:
|
||||||
TimeApplication();
|
TimeApplication();
|
||||||
virtual ~TimeApplication();
|
virtual ~TimeApplication();
|
||||||
|
|
||||||
virtual void ReadyToRun();
|
virtual void ReadyToRun();
|
||||||
virtual void AboutRequested();
|
virtual void AboutRequested();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TTimeWindow *fWindow;
|
TTimeWindow* fWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TIME_H
|
|
||||||
|
#endif // _TIME_H
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ resource app_version {
|
|||||||
internal = 0,
|
internal = 0,
|
||||||
|
|
||||||
short_info = "Time",
|
short_info = "Time",
|
||||||
long_info = "Time ©2002-2009 Haiku"
|
long_info = "Time ©2002-2010 Haiku"
|
||||||
};
|
};
|
||||||
|
|
||||||
resource vector_icon {
|
resource vector_icon {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2007, Haiku. All rights reserved.
|
* Copyright 2002-2010, Haiku. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -8,14 +8,14 @@
|
|||||||
* Julun <host.haiku@gmx.de>
|
* Julun <host.haiku@gmx.de>
|
||||||
* Philippe Saint-Pierre <stpere@gmail.com>
|
* Philippe Saint-Pierre <stpere@gmail.com>
|
||||||
*/
|
*/
|
||||||
#ifndef TIME_MESSAGES_H
|
#ifndef _TIME_MESSAGES_H
|
||||||
#define TIME_MESSAGES_H
|
#define _TIME_MESSAGES_H
|
||||||
|
|
||||||
|
|
||||||
//Timezone messages
|
//Timezone messages
|
||||||
const uint32 H_CITY_CHANGED = 'h_CC';
|
const uint32 H_CITY_CHANGED = 'h_CC';
|
||||||
const uint32 H_CITY_SET = 'h_CS';
|
const uint32 H_CITY_SET = 'h_CS';
|
||||||
|
|
||||||
|
|
||||||
//SetButton
|
//SetButton
|
||||||
const uint32 H_SET_TIME_ZONE = 'hSTZ';
|
const uint32 H_SET_TIME_ZONE = 'hSTZ';
|
||||||
|
|
||||||
@@ -46,5 +46,6 @@ const uint32 kMsgRevert = 'rvrt';
|
|||||||
// change time finished
|
// change time finished
|
||||||
const uint32 kChangeTimeFinished = 'tcfi';
|
const uint32 kChangeTimeFinished = 'tcfi';
|
||||||
|
|
||||||
#endif //TIME_MESSAGES_H
|
|
||||||
|
#endif // _TIME_MESSAGES_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2007, Haiku. All rights reserved.
|
* Copyright 2002-2010, Haiku. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -7,8 +7,8 @@
|
|||||||
* Mike Berg <mike@berg-net.us>
|
* Mike Berg <mike@berg-net.us>
|
||||||
* Julun <host.haiku@gmx.de>
|
* Julun <host.haiku@gmx.de>
|
||||||
*/
|
*/
|
||||||
#ifndef TIME_SETTINGS_H
|
#ifndef _TIME_SETTINGS_H
|
||||||
#define TIME_SETTINGS_H
|
#define _TIME_SETTINGS_H
|
||||||
|
|
||||||
|
|
||||||
#include <Point.h>
|
#include <Point.h>
|
||||||
@@ -16,16 +16,17 @@
|
|||||||
|
|
||||||
|
|
||||||
class TimeSettings {
|
class TimeSettings {
|
||||||
public :
|
public :
|
||||||
TimeSettings();
|
TimeSettings();
|
||||||
~TimeSettings();
|
~TimeSettings();
|
||||||
|
|
||||||
BPoint LeftTop() const;
|
BPoint LeftTop() const;
|
||||||
void SetLeftTop(const BPoint leftTop);
|
void SetLeftTop(const BPoint leftTop);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BString fSettingsFile;
|
BString fSettingsFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TIME_SETTINGS_H
|
|
||||||
|
#endif // _TIME_SETTINGS_H
|
||||||
|
|
||||||
|
|||||||
@@ -41,13 +41,13 @@ TTimeWindow::~TTimeWindow()
|
|||||||
void
|
void
|
||||||
TTimeWindow::SetRevertStatus()
|
TTimeWindow::SetRevertStatus()
|
||||||
{
|
{
|
||||||
fRevertButton->SetEnabled(fDateTimeView->CheckCanRevert()
|
fRevertButton->SetEnabled(fDateTimeView->CheckCanRevert()
|
||||||
|| fTimeZoneView->CheckCanRevert());
|
|| fTimeZoneView->CheckCanRevert());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TTimeWindow::MessageReceived(BMessage *message)
|
TTimeWindow::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch(message->what) {
|
switch(message->what) {
|
||||||
case H_USER_CHANGE:
|
case H_USER_CHANGE:
|
||||||
@@ -56,7 +56,7 @@ TTimeWindow::MessageReceived(BMessage *message)
|
|||||||
_SendTimeChangeFinished();
|
_SendTimeChangeFinished();
|
||||||
SetRevertStatus();
|
SetRevertStatus();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_ABOUT_REQUESTED:
|
case B_ABOUT_REQUESTED:
|
||||||
be_app->PostMessage(B_ABOUT_REQUESTED);
|
be_app->PostMessage(B_ABOUT_REQUESTED);
|
||||||
break;
|
break;
|
||||||
@@ -79,41 +79,41 @@ TTimeWindow::MessageReceived(BMessage *message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TTimeWindow::QuitRequested()
|
TTimeWindow::QuitRequested()
|
||||||
{
|
{
|
||||||
TimeSettings().SetLeftTop(Frame().LeftTop());
|
TimeSettings().SetLeftTop(Frame().LeftTop());
|
||||||
|
|
||||||
fBaseView->StopWatchingAll(fTimeZoneView);
|
fBaseView->StopWatchingAll(fTimeZoneView);
|
||||||
fBaseView->StopWatchingAll(fDateTimeView);
|
fBaseView->StopWatchingAll(fDateTimeView);
|
||||||
|
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||||
|
|
||||||
return BWindow::QuitRequested();
|
return BWindow::QuitRequested();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TTimeWindow::_InitWindow()
|
TTimeWindow::_InitWindow()
|
||||||
{
|
{
|
||||||
SetPulseRate(500000);
|
SetPulseRate(500000);
|
||||||
|
|
||||||
fDateTimeView = new DateTimeView(Bounds());
|
fDateTimeView = new DateTimeView(Bounds());
|
||||||
|
|
||||||
BRect bounds = fDateTimeView->Bounds();
|
BRect bounds = fDateTimeView->Bounds();
|
||||||
fTimeZoneView = new TimeZoneView(bounds);
|
fTimeZoneView = new TimeZoneView(bounds);
|
||||||
|
|
||||||
fBaseView = new TTimeBaseView(bounds, "baseView");
|
fBaseView = new TTimeBaseView(bounds, "baseView");
|
||||||
AddChild(fBaseView);
|
AddChild(fBaseView);
|
||||||
|
|
||||||
fBaseView->StartWatchingAll(fDateTimeView);
|
fBaseView->StartWatchingAll(fDateTimeView);
|
||||||
fBaseView->StartWatchingAll(fTimeZoneView);
|
fBaseView->StartWatchingAll(fTimeZoneView);
|
||||||
|
|
||||||
bounds.OffsetBy(10.0, 10.0);
|
bounds.OffsetBy(10.0, 10.0);
|
||||||
BTabView *tabView = new BTabView(bounds.InsetByCopy(-5.0, -5.0),
|
BTabView* tabView = new BTabView(bounds.InsetByCopy(-5.0, -5.0),
|
||||||
"tabView" , B_WIDTH_AS_USUAL, B_FOLLOW_NONE);
|
"tabView" , B_WIDTH_AS_USUAL, B_FOLLOW_NONE);
|
||||||
|
|
||||||
BTab *tab = new BTab();
|
BTab* tab = new BTab();
|
||||||
tabView->AddTab(fDateTimeView, tab);
|
tabView->AddTab(fDateTimeView, tab);
|
||||||
tab->SetLabel("Date & Time");
|
tab->SetLabel("Date & Time");
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ TTimeWindow::_InitWindow()
|
|||||||
|
|
||||||
fRevertButton = new BButton(rect, "revert", "Revert",
|
fRevertButton = new BButton(rect, "revert", "Revert",
|
||||||
new BMessage(kMsgRevert), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW);
|
new BMessage(kMsgRevert), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW);
|
||||||
|
|
||||||
fRevertButton->ResizeToPreferred();
|
fRevertButton->ResizeToPreferred();
|
||||||
fRevertButton->SetEnabled(false);
|
fRevertButton->SetEnabled(false);
|
||||||
float buttonHeight = fRevertButton->Bounds().Height();
|
float buttonHeight = fRevertButton->Bounds().Height();
|
||||||
@@ -139,7 +139,7 @@ TTimeWindow::_InitWindow()
|
|||||||
fBaseView->AddChild(fRevertButton);
|
fBaseView->AddChild(fRevertButton);
|
||||||
fRevertButton->SetTarget(this);
|
fRevertButton->SetTarget(this);
|
||||||
|
|
||||||
fBaseView->ResizeTo(tabView->Bounds().Width() + 10.0,
|
fBaseView->ResizeTo(tabView->Bounds().Width() + 10.0,
|
||||||
tabView->Bounds().Height() + buttonHeight + 30.0);
|
tabView->Bounds().Height() + buttonHeight + 30.0);
|
||||||
|
|
||||||
ResizeTo(fBaseView->Bounds().Width(), fBaseView->Bounds().Height());
|
ResizeTo(fBaseView->Bounds().Width(), fBaseView->Bounds().Height());
|
||||||
|
|||||||
@@ -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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -7,8 +7,8 @@
|
|||||||
* Julun <host.haiku@gmx.de>
|
* Julun <host.haiku@gmx.de>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef TIME_WINDOW_H
|
#ifndef _TIME_WINDOW_H
|
||||||
#define TIME_WINDOW_H
|
#define _TIME_WINDOW_H
|
||||||
|
|
||||||
|
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
@@ -21,26 +21,27 @@ class TimeZoneView;
|
|||||||
|
|
||||||
|
|
||||||
class TTimeWindow : public BWindow {
|
class TTimeWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
TTimeWindow(BRect rect);
|
TTimeWindow(BRect rect);
|
||||||
virtual ~TTimeWindow();
|
virtual ~TTimeWindow();
|
||||||
|
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
void SetRevertStatus();
|
void SetRevertStatus();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _InitWindow();
|
void _InitWindow();
|
||||||
void _AlignWindow();
|
void _AlignWindow();
|
||||||
|
|
||||||
void _SendTimeChangeFinished();
|
void _SendTimeChangeFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TTimeBaseView *fBaseView;
|
TTimeBaseView* fBaseView;
|
||||||
DateTimeView *fDateTimeView;
|
DateTimeView* fDateTimeView;
|
||||||
TimeZoneView *fTimeZoneView;
|
TimeZoneView* fTimeZoneView;
|
||||||
BButton *fRevertButton;
|
BButton* fRevertButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TIME_WINDOW_H
|
|
||||||
|
#endif // _TIME_WINDOW_H
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
* Adrien Destugues <pulkomandy@pulkomandy.ath.cx>
|
* Adrien Destugues <pulkomandy@pulkomandy.ath.cx>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __TIMEZONELISTITEM_H__
|
#ifndef _TIME_ZONE_LIST_ITEM_H
|
||||||
#define __TIMEZONELISTITEM_H__
|
#define _TIME_ZONE_LIST_ITEM_H
|
||||||
|
|
||||||
|
|
||||||
#include <StringItem.h>
|
#include <StringItem.h>
|
||||||
@@ -19,17 +19,19 @@ class BTimeZone;
|
|||||||
|
|
||||||
|
|
||||||
class TimeZoneListItem : public BStringItem {
|
class TimeZoneListItem : public BStringItem {
|
||||||
public:
|
public:
|
||||||
TimeZoneListItem(const char* text, BCountry* country,
|
TimeZoneListItem(const char* text,
|
||||||
BTimeZone* timeZone);
|
BCountry* country, BTimeZone* timeZone);
|
||||||
~TimeZoneListItem();
|
~TimeZoneListItem();
|
||||||
|
|
||||||
void DrawItem(BView* owner, BRect frame, bool complete = false);
|
void DrawItem(BView* owner, BRect frame,
|
||||||
void Code(char* buffer);
|
bool complete = false);
|
||||||
|
void Code(char* buffer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BBitmap* fIcon;
|
BBitmap* fIcon;
|
||||||
BTimeZone* fTimeZone;
|
BTimeZone* fTimeZone;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
#endif // _TIME_ZONE_LIST_ITEM_H
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ TimeZoneView::TimeZoneView(BRect frame)
|
|||||||
fCurrentZone = NULL;
|
fCurrentZone = NULL;
|
||||||
fOldZone = NULL;
|
fOldZone = NULL;
|
||||||
// TODO : get default timezone from locale kit
|
// TODO : get default timezone from locale kit
|
||||||
InitView();
|
_InitView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -73,9 +73,9 @@ TimeZoneView::_Revert()
|
|||||||
// TODO : else, select ??!
|
// TODO : else, select ??!
|
||||||
|
|
||||||
fCityList->ScrollToSelection();
|
fCityList->ScrollToSelection();
|
||||||
fCurrent->SetText(((TimeZoneListItem *)fCityList->ItemAt(czone))->Text());
|
fCurrent->SetText(((TimeZoneListItem*)fCityList->ItemAt(czone))->Text());
|
||||||
SetPreview();
|
_SetPreview();
|
||||||
SetTimeZone();
|
_SetTimeZone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ TimeZoneView::AttachedToWindow()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TimeZoneView::MessageReceived(BMessage *message)
|
TimeZoneView::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case B_OBSERVER_NOTICE_CHANGE:
|
case B_OBSERVER_NOTICE_CHANGE:
|
||||||
@@ -126,7 +126,7 @@ TimeZoneView::MessageReceived(BMessage *message)
|
|||||||
message->FindInt32(B_OBSERVE_WHAT_CHANGE, &change);
|
message->FindInt32(B_OBSERVE_WHAT_CHANGE, &change);
|
||||||
switch(change) {
|
switch(change) {
|
||||||
case H_TM_CHANGED:
|
case H_TM_CHANGED:
|
||||||
UpdateDateTime(message);
|
_UpdateDateTime(message);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -138,7 +138,7 @@ TimeZoneView::MessageReceived(BMessage *message)
|
|||||||
|
|
||||||
case H_SET_TIME_ZONE:
|
case H_SET_TIME_ZONE:
|
||||||
{
|
{
|
||||||
SetTimeZone();
|
_SetTimeZone();
|
||||||
((TTimeWindow*)Window())->SetRevertStatus();
|
((TTimeWindow*)Window())->SetRevertStatus();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ TimeZoneView::MessageReceived(BMessage *message)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case H_CITY_CHANGED:
|
case H_CITY_CHANGED:
|
||||||
SetPreview();
|
_SetPreview();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -159,7 +159,7 @@ TimeZoneView::MessageReceived(BMessage *message)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TimeZoneView::UpdateDateTime(BMessage *message)
|
TimeZoneView::_UpdateDateTime(BMessage* message)
|
||||||
{
|
{
|
||||||
int32 hour;
|
int32 hour;
|
||||||
int32 minute;
|
int32 minute;
|
||||||
@@ -174,14 +174,14 @@ TimeZoneView::UpdateDateTime(BMessage *message)
|
|||||||
|
|
||||||
// do calc to get other zone time
|
// do calc to get other zone time
|
||||||
if (fCityList->CurrentSelection() > -1)
|
if (fCityList->CurrentSelection() > -1)
|
||||||
SetPreview();
|
_SetPreview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TimeZoneView::InitView()
|
TimeZoneView::_InitView()
|
||||||
{
|
{
|
||||||
// left side
|
// left side
|
||||||
BRect frameLeft(Bounds());
|
BRect frameLeft(Bounds());
|
||||||
@@ -194,9 +194,9 @@ TimeZoneView::InitView()
|
|||||||
fCityList->SetSelectionMessage(new BMessage(H_CITY_CHANGED));
|
fCityList->SetSelectionMessage(new BMessage(H_CITY_CHANGED));
|
||||||
fCityList->SetInvocationMessage(new BMessage(H_SET_TIME_ZONE));
|
fCityList->SetInvocationMessage(new BMessage(H_SET_TIME_ZONE));
|
||||||
|
|
||||||
BuildRegionMenu();
|
_BuildRegionMenu();
|
||||||
|
|
||||||
BScrollView *scrollList = new BScrollView("scrollList", fCityList,
|
BScrollView* scrollList = new BScrollView("scrollList", fCityList,
|
||||||
B_FOLLOW_ALL, 0, false, true);
|
B_FOLLOW_ALL, 0, false, true);
|
||||||
AddChild(scrollList);
|
AddChild(scrollList);
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ TimeZoneView::InitView()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TimeZoneView::BuildRegionMenu()
|
TimeZoneView::_BuildRegionMenu()
|
||||||
{
|
{
|
||||||
// Get a list of countries
|
// Get a list of countries
|
||||||
// For each country, get all the timezones and AddItemUnder them
|
// For each country, get all the timezones and AddItemUnder them
|
||||||
@@ -266,7 +266,9 @@ TimeZoneView::BuildRegionMenu()
|
|||||||
fCityList->AddItem(countryItem);
|
fCityList->AddItem(countryItem);
|
||||||
|
|
||||||
BTimeZone* timeZone;
|
BTimeZone* timeZone;
|
||||||
for (int j = 0; timeZone = (BTimeZone*)tzList.ItemAt(j); j++) {
|
for (int j = 0;
|
||||||
|
(timeZone = (BTimeZone*)tzList.ItemAt(j)) != NULL;
|
||||||
|
j++) {
|
||||||
BString readableName;
|
BString readableName;
|
||||||
timeZone->GetName(readableName);
|
timeZone->GetName(readableName);
|
||||||
BStringItem* tzItem = new TimeZoneListItem(readableName,
|
BStringItem* tzItem = new TimeZoneListItem(readableName,
|
||||||
@@ -283,17 +285,17 @@ TimeZoneView::BuildRegionMenu()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TimeZoneView::SetPreview()
|
TimeZoneView::_SetPreview()
|
||||||
{
|
{
|
||||||
int32 selection = fCityList->CurrentSelection();
|
int32 selection = fCityList->CurrentSelection();
|
||||||
if (selection >= 0) {
|
if (selection >= 0) {
|
||||||
TimeZoneListItem *item = (TimeZoneListItem *)fCityList->ItemAt(
|
TimeZoneListItem* item = (TimeZoneListItem*)fCityList->ItemAt(
|
||||||
selection);
|
selection);
|
||||||
|
|
||||||
// set timezone to selection
|
// set timezone to selection
|
||||||
char buffer[50];
|
char buffer[50];
|
||||||
item->Code(buffer);
|
item->Code(buffer);
|
||||||
SetTimeZone(buffer);
|
_SetTimeZone(buffer);
|
||||||
|
|
||||||
// calc preview time
|
// calc preview time
|
||||||
time_t current = time(NULL);
|
time_t current = time(NULL);
|
||||||
@@ -305,7 +307,7 @@ TimeZoneView::SetPreview()
|
|||||||
fPreview->SetTime(localTime.tm_hour, localTime.tm_min);
|
fPreview->SetTime(localTime.tm_hour, localTime.tm_min);
|
||||||
|
|
||||||
fCurrentZone->Code(buffer);
|
fCurrentZone->Code(buffer);
|
||||||
SetTimeZone(buffer);
|
_SetTimeZone(buffer);
|
||||||
|
|
||||||
fSetZone->SetEnabled((strcmp(fCurrent->Text(), item->Text()) != 0));
|
fSetZone->SetEnabled((strcmp(fCurrent->Text(), item->Text()) != 0));
|
||||||
}
|
}
|
||||||
@@ -313,11 +315,11 @@ TimeZoneView::SetPreview()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TimeZoneView::SetCurrent(const char *text)
|
TimeZoneView::_SetCurrent(const char* text)
|
||||||
{
|
{
|
||||||
char buffer[50];
|
char buffer[50];
|
||||||
fCurrentZone->Code(buffer);
|
fCurrentZone->Code(buffer);
|
||||||
SetTimeZone(buffer);
|
_SetTimeZone(buffer);
|
||||||
|
|
||||||
time_t current = time(NULL);
|
time_t current = time(NULL);
|
||||||
struct tm localTime;
|
struct tm localTime;
|
||||||
@@ -329,7 +331,7 @@ TimeZoneView::SetCurrent(const char *text)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TimeZoneView::SetTimeZone()
|
TimeZoneView::_SetTimeZone()
|
||||||
{
|
{
|
||||||
/* set time based on supplied timezone. How to do this?
|
/* set time based on supplied timezone. How to do this?
|
||||||
1) replace symlink "timezone" in B_USER_SETTINGS_DIR with a link to the
|
1) replace symlink "timezone" in B_USER_SETTINGS_DIR with a link to the
|
||||||
@@ -344,10 +346,10 @@ TimeZoneView::SetTimeZone()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
char timeZoneCode[50];
|
char timeZoneCode[50];
|
||||||
((TimeZoneListItem *)fCityList->ItemAt(selection))->Code(timeZoneCode);
|
((TimeZoneListItem*)fCityList->ItemAt(selection))->Code(timeZoneCode);
|
||||||
|
|
||||||
// update environment
|
// update environment
|
||||||
SetTimeZone(timeZoneCode);
|
_SetTimeZone(timeZoneCode);
|
||||||
|
|
||||||
// update display
|
// update display
|
||||||
time_t current = time(NULL);
|
time_t current = time(NULL);
|
||||||
@@ -365,12 +367,12 @@ TimeZoneView::SetTimeZone()
|
|||||||
fHour = localTime.tm_hour;
|
fHour = localTime.tm_hour;
|
||||||
fMinute = localTime.tm_min;
|
fMinute = localTime.tm_min;
|
||||||
fCurrentZone = (TimeZoneListItem*)(fCityList->ItemAt(selection));
|
fCurrentZone = (TimeZoneListItem*)(fCityList->ItemAt(selection));
|
||||||
SetCurrent(((TimeZoneListItem *)fCityList->ItemAt(selection))->Text());
|
_SetCurrent(((TimeZoneListItem*)fCityList->ItemAt(selection))->Text());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TimeZoneView::SetTimeZone(const char *zone)
|
TimeZoneView::_SetTimeZone(const char* zone)
|
||||||
{
|
{
|
||||||
putenv(BString("TZ=").Append(zone).String());
|
putenv(BString("TZ=").Append(zone).String());
|
||||||
tzset();
|
tzset();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2009, Haiku, Inc. All Rights Reserved.
|
* Copyright 2004-2010, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -23,36 +23,36 @@ class TimeZoneListItem;
|
|||||||
|
|
||||||
|
|
||||||
class TimeZoneView : public BView {
|
class TimeZoneView : public BView {
|
||||||
public:
|
public:
|
||||||
TimeZoneView(BRect frame);
|
TimeZoneView(BRect frame);
|
||||||
virtual ~TimeZoneView();
|
virtual ~TimeZoneView();
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
bool CheckCanRevert();
|
bool CheckCanRevert();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateDateTime(BMessage *message);
|
void _UpdateDateTime(BMessage* message);
|
||||||
void SetTimeZone();
|
void _SetTimeZone();
|
||||||
void SetTimeZone(const char *zone);
|
void _SetTimeZone(const char* zone);
|
||||||
void SetPreview();
|
void _SetPreview();
|
||||||
void SetCurrent(const char *text);
|
void _SetCurrent(const char* text);
|
||||||
void InitView();
|
void _InitView();
|
||||||
void BuildRegionMenu();
|
void _BuildRegionMenu();
|
||||||
void _Revert();
|
void _Revert();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BOutlineListView *fCityList;
|
BOutlineListView* fCityList;
|
||||||
BButton *fSetZone;
|
BButton* fSetZone;
|
||||||
TTZDisplay *fCurrent;
|
TTZDisplay* fCurrent;
|
||||||
TTZDisplay *fPreview;
|
TTZDisplay* fPreview;
|
||||||
|
|
||||||
int32 fHour;
|
int32 fHour;
|
||||||
int32 fMinute;
|
int32 fMinute;
|
||||||
TimeZoneListItem *fCurrentZone;
|
TimeZoneListItem* fCurrentZone;
|
||||||
TimeZoneListItem *fOldZone;
|
TimeZoneListItem* fOldZone;
|
||||||
bool fInitialized;
|
bool fInitialized;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //Zone_View_H
|
|
||||||
|
|
||||||
|
#endif // ZONE_VIEW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user