Clean-up.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33576 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jonas Sundström
2009-10-14 00:14:34 +00:00
parent 41426d9bac
commit 3363f0c5bd
6 changed files with 85 additions and 83 deletions
+10 -10
View File
@@ -24,7 +24,7 @@
#define TR_CONTEXT "Locale Preflet"
const char *kSignature = "application/x-vnd.Haiku-Locale";
const char* kSignature = "application/x-vnd.Haiku-Locale";
static const uint32 kMsgLocaleSettings = 'LCst';
@@ -35,10 +35,10 @@ public:
~Settings();
const BMessage& Message() const { return fMessage; }
void UpdateFrom(BMessage *message);
void UpdateFrom(BMessage* message);
private:
status_t Open(BFile *file, int32 mode);
status_t _Open(BFile* file, int32 mode);
BMessage fMessage;
bool fUpdated;
@@ -50,7 +50,7 @@ public:
LocalePreflet();
virtual ~LocalePreflet();
virtual void MessageReceived(BMessage *message);
virtual void MessageReceived(BMessage* message);
virtual void AboutRequested();
virtual bool QuitRequested();
@@ -70,7 +70,7 @@ Settings::Settings()
fUpdated(false)
{
BFile file;
if (Open(&file, B_READ_ONLY) != B_OK
if (_Open(&file, B_READ_ONLY) != B_OK
|| fMessage.Unflatten(&file) != B_OK) {
// set default prefs
fMessage.AddString("language", "en");
@@ -86,7 +86,7 @@ Settings::~Settings()
return;
BFile file;
if (Open(&file, B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY) != B_OK)
if (_Open(&file, B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY) != B_OK)
return;
fMessage.Flatten(&file);
@@ -94,7 +94,7 @@ Settings::~Settings()
status_t
Settings::Open(BFile *file, int32 mode)
Settings::_Open(BFile* file, int32 mode)
{
BPath path;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
@@ -107,7 +107,7 @@ Settings::Open(BFile *file, int32 mode)
void
Settings::UpdateFrom(BMessage *message)
Settings::UpdateFrom(BMessage* message)
{
BPoint point;
if (message->FindPoint("window_location", &point) == B_OK) {
@@ -162,7 +162,7 @@ LocalePreflet::~LocalePreflet()
void
LocalePreflet::MessageReceived(BMessage *message)
LocalePreflet::MessageReceived(BMessage* message)
{
switch (message->what) {
case kMsgSettingsChanged:
@@ -198,7 +198,7 @@ LocalePreflet::QuitRequested()
int
main(int argc, char **argv)
main(int argc, char** argv)
{
LocalePreflet app;
app.Run();
+2
View File
@@ -11,9 +11,11 @@
extern const char* kSignature;
static const uint32 kMsgCountrySelection = 'csel';
static const uint32 kMsgSettingsChanged = 'SeCh';
static const uint32 kMsgSelectLanguage = 'slng';
static const uint32 kMsgDefaults = 'dflt';
static const uint32 kMsgRevert = 'revt';
#endif /* LOCALE_H */
+24 -25
View File
@@ -62,7 +62,7 @@ class LanguageListView: public BListView
{}
bool InitiateDrag(BPoint point, int32 index, bool wasSelected);
void MouseMoved(BPoint where, uint32 transit, const BMessage *msg);
void MouseMoved(BPoint where, uint32 transit, const BMessage* msg);
void MoveItems(BList& items, int32 index);
void AttachedToWindow()
{
@@ -73,8 +73,8 @@ class LanguageListView: public BListView
void MessageReceived (BMessage* message)
{
if (message->what == 'DRAG') {
LanguageListView *list = NULL;
if (message->FindPointer("list", (void **)&list) == B_OK) {
LanguageListView* list = NULL;
if (message->FindPointer("list", (void**)&list) == B_OK) {
if (list == this) {
int32 count = CountItems();
if (fDropIndex < 0 || fDropIndex > count)
@@ -180,7 +180,7 @@ LanguageListView::InitiateDrag(BPoint point, int32 index, bool)
}
BBitmap* dragBitmap = new BBitmap(dragRect, B_RGB32, true);
if (dragBitmap && dragBitmap->IsValid()) {
if (BView *v = new BView(dragBitmap->Bounds(), "helper",
if (BView* v = new BView(dragBitmap->Bounds(), "helper",
B_FOLLOW_NONE, B_WILL_DRAW)) {
dragBitmap->AddChild(v);
dragBitmap->Lock();
@@ -202,7 +202,7 @@ LanguageListView::InitiateDrag(BPoint point, int32 index, bool)
v->StrokeRect(v->Bounds());
v->Sync();
uint8 *bits = (uint8 *)dragBitmap->Bits();
uint8* bits = (uint8*)dragBitmap->Bits();
int32 height = (int32)dragBitmap->Bounds().Height() + 1;
int32 width = (int32)dragBitmap->Bounds().Width() + 1;
int32 bpr = dragBitmap->BytesPerRow();
@@ -210,22 +210,22 @@ LanguageListView::InitiateDrag(BPoint point, int32 index, bool)
if (fade) {
for (int32 y = 0; y < height - ALPHA / 2;
y++, bits += bpr) {
uint8 *line = bits + 3;
for (uint8 *end = line + 4 * width; line < end;
uint8* line = bits + 3;
for (uint8* end = line + 4 * width; line < end;
line += 4)
*line = ALPHA;
}
for (int32 y = height - ALPHA / 2; y < height;
y++, bits += bpr) {
uint8 *line = bits + 3;
for (uint8 *end = line + 4 * width; line < end;
uint8* line = bits + 3;
for (uint8* end = line + 4 * width; line < end;
line += 4)
*line = (height - y) << 1;
}
} else {
for (int32 y = 0; y < height; y++, bits += bpr) {
uint8 *line = bits + 3;
for (uint8 *end = line + 4 * width; line < end;
uint8* line = bits + 3;
for (uint8* end = line + 4 * width; line < end;
line += 4)
*line = ALPHA;
}
@@ -248,7 +248,7 @@ LanguageListView::InitiateDrag(BPoint point, int32 index, bool)
void
LanguageListView::MouseMoved(BPoint where, uint32 transit, const BMessage *msg)
LanguageListView::MouseMoved(BPoint where, uint32 transit, const BMessage* msg)
{
if (msg && (msg->what == 'DRAG')) {
switch (transit) {
@@ -315,9 +315,9 @@ LocaleWindow::LocaleWindow()
{
// first list: available languages
LanguageListView *listView = new LanguageListView("available",
LanguageListView* listView = new LanguageListView("available",
B_MULTIPLE_SELECTION_LIST);
BScrollView *scrollView = new BScrollView("scroller", listView,
BScrollView* scrollView = new BScrollView("scroller", listView,
B_WILL_DRAW | B_FRAME_EVENTS, false, true);
// Fill the language list from the LocaleRoster data
@@ -355,7 +355,7 @@ LocaleWindow::LocaleWindow()
// Second list: active languages
fPreferredListView = new LanguageListView("preferred",
B_MULTIPLE_SELECTION_LIST);
BScrollView *scrollViewEnabled = new BScrollView("scroller",
BScrollView* scrollViewEnabled = new BScrollView("scroller",
fPreferredListView, B_WILL_DRAW | B_FRAME_EVENTS, false, true);
// get the preferred languages from the Settings. Move them here from
@@ -393,10 +393,9 @@ LocaleWindow::LocaleWindow()
{
BListView* listView = new BListView("country", B_SINGLE_SELECTION_LIST);
BScrollView *scrollView = new BScrollView("scroller",
BScrollView* scrollView = new BScrollView("scroller",
listView, B_WILL_DRAW | B_FRAME_EVENTS, false, true);
BMessage* msg = new BMessage('csel');
listView->SetSelectionMessage(msg);
listView->SetSelectionMessage(new BMessage(kMsgCountrySelection));
// get all available countries from ICU
// Use DateFormat::getAvailableLocale so we get only the one we can
@@ -423,13 +422,13 @@ LocaleWindow::LocaleWindow()
// TODO: find a real solution intead of this hack
listView->SetExplicitMinSize(BSize(300, B_SIZE_UNSET));
fTimeFormatSettings = new TimeFormatSettingsView(defaultCountry);
fFormatView = new FormatView(defaultCountry);
countryTab->AddChild(BLayoutBuilder::Group<>(B_HORIZONTAL, 5)
.AddGroup(B_VERTICAL, 3)
.Add(scrollView)
.End()
.Add(fTimeFormatSettings)
.Add(fFormatView)
.View()
);
@@ -474,18 +473,18 @@ LocaleWindow::QuitRequested()
void
LocaleWindow::MessageReceived(BMessage *message)
LocaleWindow::MessageReceived(BMessage* message)
{
switch (message->what) {
case kMsgDefaults:
// reset default settings
// TODO
break;
case kMsgRevert:
// revert to last settings
// TODO
break;
case 'csel':
case kMsgCountrySelection:
{
// Country selection changed.
// Get the new selected country from the ListView and send it to the
@@ -500,7 +499,7 @@ LocaleWindow::MessageReceived(BMessage *message)
be_app_messenger.SendMessage(newMessage);
BCountry* country = new BCountry(lli->LanguageCode());
fTimeFormatSettings->SetCountry(country);
fFormatView->SetCountry(country);
break;
}
+13 -12
View File
@@ -1,6 +1,6 @@
/*
* Copyright 2005, Axel Dörfler, [email protected]. All rights reserved.
* Distributed under the terms of the MIT License.
* Copyright 2005-2009, Axel Dörfler, [email protected].
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef LOCALE_WINDOW_H
#define LOCALE_WINDOW_H
@@ -10,20 +10,21 @@
class BButton;
class BListView;
class TimeFormatSettingsView;
class FormatView;
class LocaleWindow : public BWindow {
public:
LocaleWindow();
public:
LocaleWindow();
virtual bool QuitRequested();
virtual void MessageReceived(BMessage *message);
virtual bool QuitRequested();
virtual void MessageReceived(BMessage* message);
private:
BButton* fRevertButton;
BListView* fPreferredListView;
TimeFormatSettingsView* fTimeFormatSettings;
private:
BButton* fRevertButton;
BListView* fPreferredListView;
FormatView* fFormatView;
};
#endif /* LOCALE_WINDOW_H */
#endif // LOCALE_WINDOW_H
@@ -38,7 +38,7 @@
BMessage*
MenuMessage(const char* format, BMenuField* field)
{
BMessage* msg = new BMessage('FRMT');
BMessage* msg = new BMessage(kMenuMessage);
msg->AddPointer("dest", field);
msg->AddString("format", format);
@@ -47,22 +47,23 @@ MenuMessage(const char* format, BMenuField* field)
class DateMenuItem: public BMenuItem {
public:
DateMenuItem(const char* label, const char* code, BMenuField* field)
:
BMenuItem(label, MenuMessage(code, field))
{
icuCode = code;
}
public:
DateMenuItem(const char* label, const char* code,
BMenuField* field)
:
BMenuItem(label, MenuMessage(code, field))
{
fIcuCode = code;
}
BString icuCode;
BString fIcuCode;
};
void
CreateDateMenu(BMenuField** field, bool longFormat = true)
{
BMenu *menu = new BMenu("");
BMenu* menu = new BMenu("");
*field = new BMenuField("", menu);
BPopUpMenu* dayMenu = new BPopUpMenu(TR("Day"));
@@ -115,7 +116,7 @@ CreateDateMenu(BMenuField** field, bool longFormat = true)
}
TimeFormatSettingsView::TimeFormatSettingsView(BCountry* country)
FormatView::FormatView(BCountry* country)
:
BView("WindowsSettingsView", B_FRAME_EVENTS),
fCountry(country)
@@ -150,7 +151,7 @@ TimeFormatSettingsView::TimeFormatSettingsView(BCountry* country)
fSeparatorMenuField = new BMenuField(TR("Separator:"), menu);
BBox *clockBox = new BBox("Clock");
BBox* clockBox = new BBox("Clock");
clockBox->SetLabel(TR("Clock"));
{
@@ -196,7 +197,7 @@ TimeFormatSettingsView::TimeFormatSettingsView(BCountry* country)
BCheckBox* currencyLeadingZero = new BCheckBox("", TR("Leading 0"),
new BMessage(kSettingsContentsModified));
BBox *formatBox = new BBox("Symbol position");
BBox* formatBox = new BBox("Symbol position");
formatBox->SetLabel(TR("Symbol position"));
{
@@ -346,7 +347,7 @@ bool IsSpecialDateChar(char charToTest)
// Get the date format from ICU and set the date fields accordingly
void
TimeFormatSettingsView::_ParseDateFormat()
FormatView::_ParseDateFormat()
{
// TODO parse the short date too
BString dateFormatString;
@@ -374,7 +375,7 @@ TimeFormatSettingsView::_ParseDateFormat()
BMenuItem* item;
for (int itemIndex = 0; (item = subMenu->ItemAt(itemIndex)) != NULL;
itemIndex++) {
if (static_cast<DateMenuItem*>(item)->icuCode == str) {
if (static_cast<DateMenuItem*>(item)->fIcuCode == str) {
item->SetMarked(true);
fLongDateMenu[i]->MenuItem()->SetLabel(item->Label());
isFound = true;
@@ -426,7 +427,7 @@ TimeFormatSettingsView::_ParseDateFormat()
BMenuItem* item;
for (int itemIndex = 0; (item = subMenu->ItemAt(itemIndex)) != NULL;
itemIndex++) {
if (static_cast<DateMenuItem*>(item)->icuCode == str) {
if (static_cast<DateMenuItem*>(item)->fIcuCode == str) {
item->SetMarked(true);
fDateMenu[i]->MenuItem()->SetLabel(item->Label());
isFound = true;
@@ -459,7 +460,7 @@ TimeFormatSettingsView::_ParseDateFormat()
void
TimeFormatSettingsView::AttachedToWindow()
FormatView::AttachedToWindow()
{
f24HrRadioButton->SetTarget(this);
f12HrRadioButton->SetTarget(this);
@@ -480,7 +481,7 @@ TimeFormatSettingsView::AttachedToWindow()
void
TimeFormatSettingsView::_UpdateLongDateFormatString()
FormatView::_UpdateLongDateFormatString()
{
BString newDateFormat;
@@ -506,10 +507,10 @@ TimeFormatSettingsView::_UpdateLongDateFormatString()
void
TimeFormatSettingsView::MessageReceived(BMessage *message)
FormatView::MessageReceived(BMessage* message)
{
switch (message->what) {
case 'FRMT':
case kMenuMessage:
{
// Update one of the dropdown menus
void* pointerFromMessage;
@@ -544,7 +545,7 @@ TimeFormatSettingsView::MessageReceived(BMessage *message)
case kSettingsContentsModified:
{
int32 separator = 0;
BMenuItem *item = fSeparatorMenuField->Menu()->FindMarked();
BMenuItem* item = fSeparatorMenuField->Menu()->FindMarked();
if (item) {
separator = fSeparatorMenuField->Menu()->IndexOf(item);
if (separator >= 0)
@@ -570,13 +571,13 @@ TimeFormatSettingsView::MessageReceived(BMessage *message)
}
default:
_inherited::MessageReceived(message);
BView::MessageReceived(message);
}
}
void
TimeFormatSettingsView::SetDefaults()
FormatView::SetDefaults()
{
/*
TrackerSettings settings;
@@ -594,7 +595,7 @@ TimeFormatSettingsView::SetDefaults()
bool
TimeFormatSettingsView::IsDefaultable() const
FormatView::IsDefaultable() const
{
/*
TrackerSettings settings;
@@ -608,7 +609,7 @@ TimeFormatSettingsView::IsDefaultable() const
void
TimeFormatSettingsView::Revert()
FormatView::Revert()
{
/*
TrackerSettings settings;
@@ -624,7 +625,7 @@ TimeFormatSettingsView::Revert()
void
TimeFormatSettingsView::_SendNotices()
FormatView::_SendNotices()
{
// Make the notification message and send it to the tracker:
/*
@@ -638,7 +639,7 @@ TimeFormatSettingsView::_SendNotices()
void
TimeFormatSettingsView::SetCountry(BCountry* country)
FormatView::SetCountry(BCountry* country)
{
delete fCountry;
fCountry = country;
@@ -658,7 +659,7 @@ TimeFormatSettingsView::SetCountry(BCountry* country)
void
TimeFormatSettingsView::RecordRevertSettings()
FormatView::RecordRevertSettings()
{
/*
f24HrClock = settings.ClockIs24Hr();
@@ -671,11 +672,11 @@ TimeFormatSettingsView::RecordRevertSettings()
// Return true if the Revert button should be enabled (ie some setting was
// changed)
bool
TimeFormatSettingsView::IsRevertable() const
FormatView::IsRevertable() const
{
FormatSeparator separator;
BMenuItem *item = fSeparatorMenuField->Menu()->FindMarked();
BMenuItem* item = fSeparatorMenuField->Menu()->FindMarked();
if (item) {
int32 index = fSeparatorMenuField->Menu()->IndexOf(item);
if (index >= 0)
@@ -697,7 +698,7 @@ TimeFormatSettingsView::IsRevertable() const
void
TimeFormatSettingsView::_UpdateExamples()
FormatView::_UpdateExamples()
{
time_t timeValue = (time_t)time(NULL);
BString timeFormat;
@@ -30,13 +30,14 @@ enum FormatSeparator {
};
const uint32 kSettingsContentsModified = 'Scmo';
const uint32 kMenuMessage = 'FRMT';
class TimeFormatSettingsView : public BView {
class FormatView : public BView {
public:
TimeFormatSettingsView(BCountry* country);
FormatView(BCountry* country);
virtual void MessageReceived(BMessage *message);
virtual void MessageReceived(BMessage* message);
virtual void AttachedToWindow();
virtual void SetDefaults();
@@ -80,8 +81,6 @@ private:
BBox* fTimeBox;
BBox* fNumbersBox;
BBox* fCurrencyBox;
typedef BView _inherited;
};