Laid out views to fit better on-screen. Made it use BAboutWindow and BWindow::CenterOnScreen(). Partial clean-up of code I passed by. A few obvious comments removed. Hopefully an improvement. Still needs a lot of work.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33563 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
49aa230740
commit
8637183adf
|
@ -2,13 +2,14 @@ SubDir HAIKU_TOP src preferences locale ;
|
|||
|
||||
UseLibraryHeaders icu ;
|
||||
UsePrivateHeaders locale ;
|
||||
UsePrivateHeaders shared ;
|
||||
|
||||
Preference Locale :
|
||||
Locale.cpp
|
||||
LocaleWindow.cpp
|
||||
TimeFormatSettingsView.cpp
|
||||
: be liblocale.so $(TARGET_LIBSTDC++) $(TARGET_LIBSUPC++) libicu-common.so
|
||||
libicu-data.so
|
||||
libicu-data.so libshared.a
|
||||
: Locale.rdef
|
||||
;
|
||||
|
||||
|
@ -22,3 +23,4 @@ DoCatalogs Locale # application name
|
|||
: # translations
|
||||
fi.catkeys fr.catkeys de.catkeys ru.catkeys sv.catkeys
|
||||
;
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "Locale.h"
|
||||
#include "LocaleWindow.h"
|
||||
|
||||
#include <AboutWindow.h>
|
||||
#include <Application.h>
|
||||
#include <Alert.h>
|
||||
#include <Catalog.h>
|
||||
|
@ -49,18 +50,14 @@ class LocalePreflet : public BApplication {
|
|||
LocalePreflet();
|
||||
virtual ~LocalePreflet();
|
||||
|
||||
virtual void ReadyToRun();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
|
||||
virtual void AboutRequested();
|
||||
virtual bool QuitRequested();
|
||||
|
||||
private:
|
||||
Settings fSettings;
|
||||
BWindow *fOpenWindow;
|
||||
BRect fWindowFrame;
|
||||
|
||||
BCatalog cat;
|
||||
LocaleWindow* fLocaleWindow;
|
||||
BCatalog fCatalog;
|
||||
};
|
||||
|
||||
|
||||
|
@ -76,7 +73,6 @@ Settings::Settings()
|
|||
if (Open(&file, B_READ_ONLY) != B_OK
|
||||
|| fMessage.Unflatten(&file) != B_OK) {
|
||||
// set default prefs
|
||||
fMessage.AddRect("window_frame", BRect(50, 50, 550, 500));
|
||||
fMessage.AddString("language", "en");
|
||||
fMessage.AddString("country", "en_US");
|
||||
return;
|
||||
|
@ -86,12 +82,11 @@ Settings::Settings()
|
|||
|
||||
Settings::~Settings()
|
||||
{
|
||||
// only save the settings if something has changed
|
||||
if (!fUpdated)
|
||||
return;
|
||||
|
||||
BFile file;
|
||||
if (Open(&file, B_CREATE_FILE | B_WRITE_ONLY) != B_OK)
|
||||
if (Open(&file, B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY) != B_OK)
|
||||
return;
|
||||
|
||||
fMessage.Flatten(&file);
|
||||
|
@ -114,9 +109,11 @@ Settings::Open(BFile *file, int32 mode)
|
|||
void
|
||||
Settings::UpdateFrom(BMessage *message)
|
||||
{
|
||||
BRect frame;
|
||||
if (message->FindRect("window_frame", &frame) == B_OK)
|
||||
fMessage.ReplaceRect("window_frame", frame);
|
||||
BPoint point;
|
||||
if (message->FindPoint("window_location", &point) == B_OK) {
|
||||
fMessage.RemoveName("window_location");
|
||||
fMessage.AddPoint("window_location", point);
|
||||
}
|
||||
|
||||
BString langName;
|
||||
// We make sure there is at least one string before erasing the previous
|
||||
|
@ -124,10 +121,12 @@ Settings::UpdateFrom(BMessage *message)
|
|||
if (message->FindString("language", &langName) == B_OK) {
|
||||
// Remove any old data as we know we have newer one to replace it
|
||||
fMessage.RemoveName("language");
|
||||
for (int i = 0; message->FindString("language", i, &langName) == B_OK;
|
||||
i++)
|
||||
for (int i = 0;; i++) {
|
||||
if (message->FindString("language", i, &langName) != B_OK)
|
||||
break;
|
||||
fMessage.AddString("language", langName);
|
||||
}
|
||||
}
|
||||
|
||||
if (message->FindString("country",&langName) == B_OK)
|
||||
fMessage.ReplaceString("country", langName);
|
||||
|
@ -141,14 +140,19 @@ Settings::UpdateFrom(BMessage *message)
|
|||
|
||||
|
||||
LocalePreflet::LocalePreflet()
|
||||
: BApplication(kSignature)
|
||||
:
|
||||
BApplication(kSignature)
|
||||
{
|
||||
fWindowFrame = fSettings.Message().FindRect("window_frame");
|
||||
be_locale->GetAppCatalog(&fCatalog);
|
||||
|
||||
be_locale -> GetAppCatalog(&cat);
|
||||
fLocaleWindow = new LocaleWindow();
|
||||
|
||||
BWindow* window = new LocaleWindow(fWindowFrame);
|
||||
window->Show();
|
||||
if (fSettings.Message().HasPoint("window_location")) {
|
||||
BPoint point = fSettings.Message().FindPoint("window_location");
|
||||
fLocaleWindow->MoveTo(point);
|
||||
}
|
||||
|
||||
fLocaleWindow->Show();
|
||||
}
|
||||
|
||||
|
||||
|
@ -157,18 +161,6 @@ LocalePreflet::~LocalePreflet()
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
LocalePreflet::ReadyToRun()
|
||||
{
|
||||
// are there already windows open?
|
||||
if (CountWindows() != 1)
|
||||
return;
|
||||
|
||||
// if not, ask the user to open a file
|
||||
PostMessage(kMsgOpenOpenWindow);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LocalePreflet::MessageReceived(BMessage *message)
|
||||
{
|
||||
|
@ -187,20 +179,11 @@ LocalePreflet::MessageReceived(BMessage *message)
|
|||
void
|
||||
LocalePreflet::AboutRequested()
|
||||
{
|
||||
BAlert *alert = new BAlert("about", TR("Locale\n"
|
||||
"\twritten by Axel Dörfler\n"
|
||||
"\tCopyright 2005, Haiku.\n\n"), "Ok");
|
||||
BTextView *view = alert->TextView();
|
||||
BFont font;
|
||||
|
||||
view->SetStylable(true);
|
||||
|
||||
view->GetFont(&font);
|
||||
font.SetSize(18);
|
||||
font.SetFace(B_BOLD_FACE);
|
||||
view->SetFontAndColor(0, 7, &font);
|
||||
|
||||
alert->Go();
|
||||
const char* authors[3];
|
||||
authors[0] = "Axel Dörfler";
|
||||
authors[1] = "Adrien Destugues";
|
||||
authors[2] = NULL;
|
||||
(new BAboutWindow("Locale", 2005, authors))->Show();
|
||||
}
|
||||
|
||||
|
||||
|
@ -218,7 +201,7 @@ int
|
|||
main(int argc, char **argv)
|
||||
{
|
||||
LocalePreflet app;
|
||||
|
||||
app.Run();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
* Copyright 2005-2009, Axel Dörfler, axeld@pinc-software.de.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef LOCALE_H
|
||||
#define LOCALE_H
|
||||
|
@ -11,15 +11,9 @@
|
|||
|
||||
extern const char* kSignature;
|
||||
|
||||
static const uint32 kMsgOpenFilePanel = 'opFp';
|
||||
static const uint32 kMsgOpenOpenWindow = 'opOw';
|
||||
static const uint32 kMsgOpenWindowClosed = 'clOw';
|
||||
static const uint32 kMsgWindowClosed = 'WiCl';
|
||||
static const uint32 kMsgSettingsChanged = 'SeCh';
|
||||
|
||||
static const uint32 kMsgOpenFindWindow = 'OpFw';
|
||||
static const uint32 kMsgFindWindowClosed = 'clFw';
|
||||
static const uint32 kMsgFindTarget = 'FTgt';
|
||||
static const uint32 kMsgFind = 'find';
|
||||
static const uint32 kMsgSelectLanguage = 'slng';
|
||||
static const uint32 kMsgDefaults = 'dflt';
|
||||
static const uint32 kMsgRevert = 'revt';
|
||||
|
||||
#endif /* LOCALE_H */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
* Copyright 2005-2009, Axel Dörfler, axeld@pinc-software.de.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
|||
#include <Button.h>
|
||||
#include <Catalog.h>
|
||||
#include <GroupLayout.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <ListView.h>
|
||||
#include <Locale.h>
|
||||
#include <LocaleRoster.h>
|
||||
|
@ -35,52 +35,25 @@
|
|||
#define ALPHA 170
|
||||
#define TEXT_OFFSET 5.0
|
||||
|
||||
// Language lists management
|
||||
|
||||
|
||||
// This is a language item. It's a BStringItem but we also want to keep the
|
||||
// language code and not only the displayName
|
||||
class LanguageListItem: public BStringItem
|
||||
{
|
||||
public:
|
||||
LanguageListItem(const char* display, const char* code)
|
||||
: BStringItem(display)
|
||||
, LanguageCode(code)
|
||||
LanguageListItem(const char* text, const char* code)
|
||||
:
|
||||
BStringItem(text),
|
||||
fLanguageCode(code)
|
||||
{}
|
||||
|
||||
~LanguageListItem() {};
|
||||
|
||||
const inline BString getLanguageCode() { return LanguageCode; }
|
||||
void Draw(BView *owner, BRect frame);
|
||||
const inline BString LanguageCode() { return fLanguageCode; }
|
||||
|
||||
private:
|
||||
const BString LanguageCode;
|
||||
const BString fLanguageCode;
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
LanguageListItem::Draw(BView *owner, BRect frame)
|
||||
{
|
||||
owner->SetLowColor(255, 255, 255, 255);
|
||||
owner->FillRect(frame, B_SOLID_LOW);
|
||||
// label
|
||||
owner->SetHighColor(0, 0, 0, 255);
|
||||
font_height fh;
|
||||
owner->GetFontHeight(&fh);
|
||||
const char* text = Text();
|
||||
BString truncatedString(text);
|
||||
owner->TruncateString(&truncatedString, B_TRUNCATE_MIDDLE,
|
||||
frame.Width() - TEXT_OFFSET - 4.0);
|
||||
float height = frame.Height();
|
||||
float textHeight = fh.ascent + fh.descent;
|
||||
BPoint textPoint;
|
||||
textPoint.x = frame.left + TEXT_OFFSET;
|
||||
textPoint.y = frame.top
|
||||
+ ceilf(height / 2.0 - textHeight / 2.0 + fh.ascent);
|
||||
owner->DrawString(truncatedString.String(), textPoint);
|
||||
}
|
||||
|
||||
|
||||
// This is a language list. Basically, a drag-n-drop enabled list.
|
||||
class LanguageListView: public BListView
|
||||
{
|
||||
public:
|
||||
|
@ -107,7 +80,6 @@ class LanguageListView: public BListView
|
|||
if (fDropIndex < 0 || fDropIndex > count)
|
||||
fDropIndex = count;
|
||||
|
||||
// gather all the items from the BMessage
|
||||
BList items;
|
||||
int32 index;
|
||||
for (int32 i = 0; message->FindInt32("index", i, &index)
|
||||
|
@ -115,7 +87,6 @@ class LanguageListView: public BListView
|
|||
if (BListItem* item = ItemAt(index))
|
||||
items.AddItem((void*)item);
|
||||
|
||||
// handle them
|
||||
if (items.CountItems() > 0) {
|
||||
MoveItems(items, fDropIndex);
|
||||
}
|
||||
|
@ -125,7 +96,6 @@ class LanguageListView: public BListView
|
|||
if (fDropIndex < 0 || fDropIndex > count)
|
||||
fDropIndex = count;
|
||||
|
||||
// gather all the items from the BMessage
|
||||
int32 index;
|
||||
for (int32 i = 0; message->FindInt32("index", i, &index)
|
||||
== B_OK; i++)
|
||||
|
@ -224,7 +194,7 @@ LanguageListView::InitiateDrag(BPoint point, int32 index, bool)
|
|||
itemBounds.bottom = itemBounds.top + ceilf(item->Height());
|
||||
if (itemBounds.bottom > dragRect.bottom)
|
||||
itemBounds.bottom = dragRect.bottom;
|
||||
item->Draw(v, itemBounds);
|
||||
item->DrawItem(v, itemBounds);
|
||||
itemBounds.top = itemBounds.bottom + 1.0;
|
||||
}
|
||||
// make a black frame arround the edge
|
||||
|
@ -324,40 +294,31 @@ LanguageListView::MouseMoved(BPoint where, uint32 transit, const BMessage *msg)
|
|||
}
|
||||
|
||||
|
||||
const static uint32 kMsgSelectLanguage = 'slng';
|
||||
const static uint32 kMsgDefaults = 'dflt';
|
||||
const static uint32 kMsgRevert = 'revt';
|
||||
|
||||
|
||||
LocaleWindow::LocaleWindow(BRect rect)
|
||||
: BWindow(rect, "Locale", B_TITLED_WINDOW,
|
||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS
|
||||
| B_AUTO_UPDATE_SIZE_LIMITS)
|
||||
LocaleWindow::LocaleWindow()
|
||||
:
|
||||
BWindow(BRect(0, 0, 0, 0), "Locale", B_TITLED_WINDOW, B_NOT_RESIZABLE
|
||||
| B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
|
||||
{
|
||||
BCountry* defaultCountry;
|
||||
be_locale_roster->GetDefaultCountry(&defaultCountry);
|
||||
|
||||
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||
|
||||
// Buttons at the bottom
|
||||
|
||||
BButton* button = new BButton(TR("Defaults"), new BMessage(kMsgDefaults));
|
||||
|
||||
fRevertButton = new BButton(TR("Revert"), new BMessage(kMsgRevert));
|
||||
fRevertButton->SetEnabled(false);
|
||||
|
||||
// Tabs
|
||||
BTabView* tabView = new BTabView("tabview");
|
||||
|
||||
// Language tab
|
||||
BView *tab = new BView(TR("Language"), B_WILL_DRAW);
|
||||
//tab->SetViewColor(tabView->ViewColor());
|
||||
tab->SetLayout(new BGroupLayout(B_VERTICAL, 0));
|
||||
tabView->AddTab(tab);
|
||||
BView* languageTab = new BView(TR("Language"), B_WILL_DRAW);
|
||||
languageTab->SetLayout(new BGroupLayout(B_VERTICAL, 0));
|
||||
|
||||
{
|
||||
// first list: available languages
|
||||
LanguageListView *listView = new LanguageListView("available",
|
||||
B_MULTIPLE_SELECTION_LIST);
|
||||
BScrollView *scrollView = new BScrollView("scroller", listView,
|
||||
0, false, true, B_FANCY_BORDER);
|
||||
B_WILL_DRAW | B_FRAME_EVENTS, false, true);
|
||||
|
||||
// Fill the language list from the LocaleRoster data
|
||||
BMessage installedLanguages;
|
||||
|
@ -395,7 +356,7 @@ LocaleWindow::LocaleWindow(BRect rect)
|
|||
fPreferredListView = new LanguageListView("preferred",
|
||||
B_MULTIPLE_SELECTION_LIST);
|
||||
BScrollView *scrollViewEnabled = new BScrollView("scroller",
|
||||
fPreferredListView, 0, false, true, B_FANCY_BORDER);
|
||||
fPreferredListView, B_WILL_DRAW | B_FRAME_EVENTS, false, true);
|
||||
|
||||
// get the preferred languages from the Settings. Move them here from
|
||||
// the other list.
|
||||
|
@ -408,49 +369,41 @@ LocaleWindow::LocaleWindow(BRect rect)
|
|||
for (int listPos = 0; LanguageListItem* lli
|
||||
= static_cast<LanguageListItem*>(listView->ItemAt(listPos));
|
||||
listPos++) {
|
||||
if (langCode == lli->getLanguageCode()) {
|
||||
if (langCode == lli->LanguageCode()) {
|
||||
fPreferredListView->AddItem(lli);
|
||||
listView->RemoveItem(lli);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tab->AddChild(BGroupLayoutBuilder(B_HORIZONTAL, 10)
|
||||
.Add(BGroupLayoutBuilder(B_VERTICAL, 10)
|
||||
languageTab->AddChild(BLayoutBuilder::Group<>(B_HORIZONTAL, 10)
|
||||
.AddGroup(B_VERTICAL, 10)
|
||||
.Add(new BStringView("", TR("Available languages")))
|
||||
.Add(scrollView)
|
||||
)
|
||||
.Add(BGroupLayoutBuilder(B_VERTICAL, 10)
|
||||
.End()
|
||||
.AddGroup(B_VERTICAL, 10)
|
||||
.Add(new BStringView("", TR("Preferred languages")))
|
||||
.Add(scrollViewEnabled)
|
||||
)
|
||||
);
|
||||
|
||||
.End()
|
||||
.View());
|
||||
}
|
||||
|
||||
// Country tab
|
||||
tab = new BView(TR("Country"), B_WILL_DRAW);
|
||||
//tab->SetViewColor(tabView->ViewColor());
|
||||
tab->SetLayout(new BGroupLayout(B_VERTICAL, 0));
|
||||
tabView->AddTab(tab);
|
||||
BView* countryTab = new BView(TR("Country"), B_WILL_DRAW);
|
||||
countryTab->SetLayout(new BGroupLayout(B_VERTICAL, 0));
|
||||
|
||||
{
|
||||
BListView* listView = new BListView("country", B_SINGLE_SELECTION_LIST);
|
||||
BScrollView *scrollView = new BScrollView("scroller",
|
||||
listView, 0, false, true, B_FANCY_BORDER);
|
||||
|
||||
listView, B_WILL_DRAW | B_FRAME_EVENTS, false, true);
|
||||
BMessage* msg = new BMessage('csel');
|
||||
listView->SetSelectionMessage(msg);
|
||||
|
||||
|
||||
// get all available countries from ICU
|
||||
// Use DateFormat::getAvailableLocale so we get only the one we can
|
||||
// use. Maybe check the NumberFormat one and see if there is more.
|
||||
int32_t localeCount;
|
||||
const Locale* currentLocale
|
||||
= Locale::getAvailableLocales(localeCount);
|
||||
BCountry* defaultCountry;
|
||||
be_locale_roster->GetDefaultCountry(&defaultCountry);
|
||||
|
||||
for (int index = 0; index < localeCount; index++)
|
||||
{
|
||||
|
@ -467,41 +420,37 @@ LocaleWindow::LocaleWindow(BRect rect)
|
|||
listView->Select(listView->CountItems() - 1);
|
||||
}
|
||||
|
||||
fTimeFormatSettings
|
||||
= new TimeFormatSettingsView(defaultCountry);
|
||||
// TODO: find a real solution intead of this hack
|
||||
listView->SetExplicitMinSize(BSize(300, B_SIZE_UNSET));
|
||||
|
||||
tab->AddChild(BGroupLayoutBuilder(B_HORIZONTAL, 5)
|
||||
fTimeFormatSettings = new TimeFormatSettingsView(defaultCountry);
|
||||
|
||||
countryTab->AddChild(BLayoutBuilder::Group<>(B_HORIZONTAL, 5)
|
||||
.AddGroup(B_VERTICAL, 3)
|
||||
.Add(scrollView)
|
||||
.Add(new BScrollView("advanced", fTimeFormatSettings, 0,
|
||||
false, true, B_NO_BORDER))
|
||||
.End()
|
||||
.Add(fTimeFormatSettings)
|
||||
.View()
|
||||
);
|
||||
|
||||
listView->ScrollToSelection();
|
||||
}
|
||||
|
||||
// check if the window is on screen
|
||||
rect = BScreen().Frame();
|
||||
rect.right -= 20;
|
||||
rect.bottom -= 20;
|
||||
tabView->AddTab(languageTab);
|
||||
tabView->AddTab(countryTab);
|
||||
|
||||
BPoint position = Frame().LeftTop();
|
||||
if (!rect.Contains(position)) {
|
||||
// center window on screen as it doesn't fit on the saved position
|
||||
position.x = (rect.Width() - Bounds().Width()) / 2;
|
||||
position.y = (rect.Height() - Bounds().Height()) / 2;
|
||||
}
|
||||
MoveTo(position);
|
||||
|
||||
// Layout management
|
||||
AddChild(BGroupLayoutBuilder(B_VERTICAL, 3)
|
||||
BLayoutBuilder::Group<>(this)
|
||||
.AddGroup(B_VERTICAL, 3)
|
||||
.Add(tabView)
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 3)
|
||||
.AddGroup(B_HORIZONTAL, 3)
|
||||
.Add(button)
|
||||
.Add(fRevertButton)
|
||||
.AddGlue()
|
||||
)
|
||||
.End()
|
||||
.SetInsets(5, 5, 5, 5)
|
||||
);
|
||||
.End();
|
||||
|
||||
CenterOnScreen();
|
||||
}
|
||||
|
||||
|
||||
|
@ -509,11 +458,11 @@ bool
|
|||
LocaleWindow::QuitRequested()
|
||||
{
|
||||
BMessage update(kMsgSettingsChanged);
|
||||
update.AddRect("window_frame", Frame());
|
||||
update.AddPoint("window_location", Frame().LeftTop());
|
||||
int index = 0;
|
||||
while (index < fPreferredListView->CountItems()) {
|
||||
update.AddString("language", static_cast<LanguageListItem*>
|
||||
(fPreferredListView->ItemAt(index))->getLanguageCode());
|
||||
(fPreferredListView->ItemAt(index))->LanguageCode());
|
||||
index++;
|
||||
}
|
||||
// TODO also save Country tab settings
|
||||
|
@ -547,10 +496,10 @@ LocaleWindow::MessageReceived(BMessage *message)
|
|||
LanguageListItem* lli = static_cast<LanguageListItem*>
|
||||
(countryList->ItemAt(countryList->CurrentSelection()));
|
||||
BMessage* newMessage = new BMessage(kMsgSettingsChanged);
|
||||
newMessage->AddString("country",lli->getLanguageCode());
|
||||
newMessage->AddString("country",lli->LanguageCode());
|
||||
be_app_messenger.SendMessage(newMessage);
|
||||
|
||||
BCountry* country = new BCountry(lli->getLanguageCode());
|
||||
BCountry* country = new BCountry(lli->LanguageCode());
|
||||
fTimeFormatSettings->SetCountry(country);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ class TimeFormatSettingsView;
|
|||
|
||||
class LocaleWindow : public BWindow {
|
||||
public:
|
||||
LocaleWindow(BRect rect);
|
||||
LocaleWindow();
|
||||
|
||||
virtual bool QuitRequested();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
#include "TimeFormatSettingsView.h"
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Box.h>
|
||||
#include <Catalog.h>
|
||||
#include <CheckBox.h>
|
||||
#include <Country.h>
|
||||
#include <GroupLayout.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <Locale.h>
|
||||
#include <LocaleRoster.h>
|
||||
#include <Message.h>
|
||||
|
@ -116,15 +116,12 @@ CreateDateMenu(BMenuField** field, bool longFormat = true)
|
|||
|
||||
|
||||
TimeFormatSettingsView::TimeFormatSettingsView(BCountry* country)
|
||||
: BView("WindowsSettingsView", 0)
|
||||
, fCountry(country)
|
||||
:
|
||||
BView("WindowsSettingsView", B_FRAME_EVENTS),
|
||||
fCountry(country)
|
||||
{
|
||||
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||
|
||||
// Date
|
||||
BSeparatorView* dateHeader = new BSeparatorView(TR("Date"));
|
||||
|
||||
// Long format
|
||||
fLongDateExampleView = new BStringView("", "");
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
@ -135,7 +132,6 @@ TimeFormatSettingsView::TimeFormatSettingsView(BCountry* country)
|
|||
new BMessage(kSettingsContentsModified));
|
||||
}
|
||||
|
||||
// Short format
|
||||
fShortDateExampleView = new BStringView("", "");
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
@ -154,9 +150,6 @@ TimeFormatSettingsView::TimeFormatSettingsView(BCountry* country)
|
|||
|
||||
fSeparatorMenuField = new BMenuField(TR("Separator:"), menu);
|
||||
|
||||
// Time
|
||||
BSeparatorView* timeHeader = new BSeparatorView(TR("Time"));
|
||||
|
||||
BBox *clockBox = new BBox("Clock");
|
||||
clockBox->SetLabel(TR("Clock"));
|
||||
|
||||
|
@ -177,9 +170,6 @@ TimeFormatSettingsView::TimeFormatSettingsView(BCountry* country)
|
|||
fLongTimeExampleView = new BStringView("", "");
|
||||
fShortTimeExampleView = new BStringView("", "");
|
||||
|
||||
// Numbers
|
||||
BSeparatorView* numberHeader = new BSeparatorView(TR("Numbers"));
|
||||
|
||||
fNumberFormatExampleView = new BStringView("", "");
|
||||
|
||||
BTextControl* numberThousand = new BTextControl("",
|
||||
|
@ -193,8 +183,6 @@ TimeFormatSettingsView::TimeFormatSettingsView(BCountry* country)
|
|||
new BMessage(kSettingsContentsModified));
|
||||
// Unit system (US/Metric) (radio)
|
||||
|
||||
// Currency
|
||||
BSeparatorView* currencyHeader = new BSeparatorView(TR("Currency"));
|
||||
BTextControl* currencySymbol = new BTextControl("", TR("Currency symbol:"),
|
||||
"", new BMessage(kSettingsContentsModified));
|
||||
menu = new BPopUpMenu(TR("Negative marker"));
|
||||
|
@ -228,76 +216,120 @@ TimeFormatSettingsView::TimeFormatSettingsView(BCountry* country)
|
|||
_UpdateExamples();
|
||||
_ParseDateFormat();
|
||||
|
||||
AddChild(BGroupLayoutBuilder(B_VERTICAL, 5)
|
||||
.Add(dateHeader)
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 3)
|
||||
fDateBox = new BBox(TR("Date"));
|
||||
fTimeBox = new BBox(TR("Time"));
|
||||
fNumbersBox = new BBox(TR("Numbers"));
|
||||
fCurrencyBox = new BBox(TR("Currency"));
|
||||
|
||||
fDateBox->SetLabel(TR("Date"));
|
||||
fTimeBox->SetLabel(TR("Time"));
|
||||
fNumbersBox->SetLabel(TR("Numbers"));
|
||||
fCurrencyBox->SetLabel(TR("Currency"));
|
||||
|
||||
fDateBox->AddChild(BLayoutBuilder::Group<>(B_HORIZONTAL, 5)
|
||||
.AddGroup(B_VERTICAL, 5)
|
||||
.AddGroup(B_HORIZONTAL, 3)
|
||||
.Add(new BStringView("",TR("Long format:")))
|
||||
.Add(fLongDateExampleView)
|
||||
.AddGlue()
|
||||
)
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 3)
|
||||
.End()
|
||||
.AddGroup(B_HORIZONTAL, 3)
|
||||
.Add(fLongDateMenu[0])
|
||||
.Add(fLongDateSeparator[0])
|
||||
)
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 3)
|
||||
.End()
|
||||
.AddGroup(B_HORIZONTAL, 3)
|
||||
.Add(fLongDateMenu[1])
|
||||
.Add(fLongDateSeparator[1])
|
||||
)
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 3)
|
||||
.End()
|
||||
.AddGroup(B_HORIZONTAL, 3)
|
||||
.Add(fLongDateMenu[2])
|
||||
.Add(fLongDateSeparator[2])
|
||||
)
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 3)
|
||||
.End()
|
||||
.AddGroup(B_HORIZONTAL, 3)
|
||||
.Add(fLongDateMenu[3])
|
||||
.Add(fLongDateSeparator[3])
|
||||
)
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 3)
|
||||
.End()
|
||||
.AddGroup(B_HORIZONTAL, 3)
|
||||
.Add(new BStringView("",TR("Short format:")))
|
||||
.Add(fShortDateExampleView)
|
||||
.AddGlue()
|
||||
)
|
||||
.End()
|
||||
.Add(fDateMenu[0])
|
||||
.Add(fDateMenu[1])
|
||||
.Add(fDateMenu[2])
|
||||
.Add(fSeparatorMenuField)
|
||||
.End()
|
||||
.SetInsets(5, 5, 5, 5)
|
||||
.View()
|
||||
);
|
||||
|
||||
.Add(timeHeader)
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 3)
|
||||
fTimeBox->AddChild(BLayoutBuilder::Group<>(B_HORIZONTAL, 5)
|
||||
.AddGroup(B_VERTICAL, 5)
|
||||
.AddGroup(B_HORIZONTAL, 3)
|
||||
.Add(new BStringView("",TR("Long format:")))
|
||||
.Add(fLongTimeExampleView)
|
||||
.AddGlue()
|
||||
)
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 3)
|
||||
.End()
|
||||
.AddGroup(B_HORIZONTAL, 3)
|
||||
.Add(new BStringView("",TR("Short format:")))
|
||||
.Add(fShortTimeExampleView)
|
||||
.AddGlue()
|
||||
)
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 3)
|
||||
.End()
|
||||
.AddGroup(B_HORIZONTAL, 3)
|
||||
.Add(clockBox)
|
||||
.AddGlue()
|
||||
)
|
||||
.End()
|
||||
.AddGlue()
|
||||
.End()
|
||||
.SetInsets(5, 5, 5, 5)
|
||||
.View()
|
||||
);
|
||||
|
||||
.Add(numberHeader)
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 3)
|
||||
fNumbersBox->AddChild(BLayoutBuilder::Group<>(B_HORIZONTAL, 5)
|
||||
.AddGroup(B_VERTICAL, 5)
|
||||
.AddGroup(B_HORIZONTAL, 3)
|
||||
.Add(new BStringView("",TR("Example:")))
|
||||
.Add(fNumberFormatExampleView)
|
||||
.AddGlue()
|
||||
)
|
||||
.End()
|
||||
.Add(numberThousand)
|
||||
.Add(numberDecimal)
|
||||
.Add(numberLeadingZero)
|
||||
.Add(numberList)
|
||||
.AddGlue()
|
||||
.End()
|
||||
.SetInsets(5, 5, 5, 5)
|
||||
.View()
|
||||
);
|
||||
|
||||
.Add(currencyHeader)
|
||||
fCurrencyBox->AddChild(BLayoutBuilder::Group<>(B_HORIZONTAL, 5)
|
||||
.AddGroup(B_VERTICAL, 5)
|
||||
.Add(currencySymbol)
|
||||
.Add(currencyNegative)
|
||||
.Add(currencyDecimal)
|
||||
.Add(currencyLeadingZero)
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 3)
|
||||
.AddGroup(B_HORIZONTAL, 3)
|
||||
.Add(formatBox)
|
||||
.AddGlue()
|
||||
)
|
||||
.End()
|
||||
.AddGlue()
|
||||
.End()
|
||||
.SetInsets(5, 5, 5, 5)
|
||||
.View()
|
||||
);
|
||||
|
||||
AddChild(BLayoutBuilder::Group<>(B_HORIZONTAL, 5)
|
||||
.AddGroup(B_VERTICAL, 5)
|
||||
.Add(fDateBox)
|
||||
.Add(fTimeBox)
|
||||
.AddGlue()
|
||||
.End()
|
||||
.AddGroup(B_VERTICAL, 5)
|
||||
.Add(fNumbersBox)
|
||||
.Add(fCurrencyBox)
|
||||
.AddGlue()
|
||||
.End()
|
||||
.SetInsets(5, 5, 5, 5)
|
||||
.View()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -689,4 +721,3 @@ TimeFormatSettingsView::_UpdateExamples()
|
|||
fNumberFormatExampleView->SetText(u_errorName((UErrorCode)Error));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
/*
|
||||
** Copyright 2009, Adrien Destugues, pulkomandy@gmail.com. All rights reserved.
|
||||
** Distributed under the terms of the MIT License.
|
||||
* Copyright 2009, Adrien Destugues, pulkomandy@gmail.com. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __TIMEFORMATSETTINGS_H__
|
||||
#define __TIMEFORMATSETTINGS_H__
|
||||
|
||||
|
||||
#include <Box.h>
|
||||
#include <String.h>
|
||||
#include <View.h>
|
||||
|
||||
|
@ -77,8 +76,14 @@ class TimeFormatSettingsView : public BView {
|
|||
|
||||
BCountry* fCountry;
|
||||
|
||||
BBox* fDateBox;
|
||||
BBox* fTimeBox;
|
||||
BBox* fNumbersBox;
|
||||
BBox* fCurrencyBox;
|
||||
|
||||
typedef BView _inherited;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue