* style cleanup, no functional change

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35596 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Alexandre Deckner 2010-02-24 13:34:36 +00:00
parent 8480d72320
commit bf7db4bb7e
6 changed files with 152 additions and 127 deletions

View File

@ -16,13 +16,14 @@
HApp::HApp()
: BApplication("application/x-vnd.Haiku-Sounds")
:
BApplication("application/x-vnd.Haiku-Sounds")
{
BRect rect;
rect.Set(200, 150, 590, 570);
HWindow *win = new HWindow(rect, "Sounds");
win->Show();
HWindow* window = new HWindow(rect, "Sounds");
window->Show();
}
@ -34,12 +35,14 @@ HApp::~HApp()
void
HApp::AboutRequested()
{
(new BAlert("About Sounds", "Sounds\n"
BAlert* alert = new BAlert("About Sounds",
"Sounds\n"
" Brought to you by :\n"
" Oliver Ruiz Dorantes\n"
" Jérôme DUVAL.\n"
" Original work from Atsushi Takamatsu.\n"
"Copyright " B_UTF8_COPYRIGHT "2003-2006 Haiku", "OK"))->Go();
"Copyright " B_UTF8_COPYRIGHT "2003-2006 Haiku", "OK");
alert->Go();
}

View File

@ -18,9 +18,8 @@ class HApp :public BApplication {
public:
HApp();
virtual ~HApp();
protected:
virtual void AboutRequested();
};
#endif // HAPP_H

View File

@ -18,7 +18,8 @@
HEventRow::HEventRow(const char* name, const char* path)
: BRow(),
:
BRow(),
fName(name)
{
SetField(new BStringField(name), kEventColumn);
@ -48,11 +49,14 @@ HEventRow::Remove(const char *type)
HEventList::HEventList(BRect rect, const char* name)
: BColumnListView(rect, name, B_FOLLOW_ALL, 0, B_PLAIN_BORDER, true),
:
BColumnListView(rect, name, B_FOLLOW_ALL, 0, B_PLAIN_BORDER, true),
fType(NULL)
{
AddColumn(new BStringColumn("Event", 150, 50, 500, B_TRUNCATE_MIDDLE), kEventColumn);
AddColumn(new BStringColumn("Sound", 150, 50, 500, B_TRUNCATE_END), kSoundColumn);
AddColumn(new BStringColumn("Event", 150, 50, 500, B_TRUNCATE_MIDDLE),
kEventColumn);
AddColumn(new BStringColumn("Sound", 150, 50, 500, B_TRUNCATE_END),
kSoundColumn);
}
@ -76,7 +80,8 @@ HEventList::SetType(const char* type)
entry_ref ref;
while (mfiles.GetNextRef(&name,&ref) == B_OK) {
BPath path(&ref);
if ((path.InitCheck() != B_OK) || (ref.name == NULL) || (strcmp(ref.name, "") == 0))
if (path.InitCheck() != B_OK || ref.name == NULL
|| strcmp(ref.name, "") == 0)
AddRow(new HEventRow(name.String(), NULL));
else
AddRow(new HEventRow(name.String(), path.Path()));
@ -106,13 +111,16 @@ HEventList::SelectionChanged()
BMediaFiles().GetRefFor(fType, row->Name(), &ref);
BPath path(&ref);
if ((path.InitCheck()==B_OK) || (ref.name == NULL) || (strcmp(ref.name, "") == 0)) {
if (path.InitCheck() == B_OK || ref.name == NULL
|| strcmp(ref.name, "") == 0) {
row->SetPath(path.Path());
UpdateRow(row);
} else {
printf("name %s\n", ref.name);
BMediaFiles().RemoveRefFor(fType, row->Name(), ref);
(new BAlert("alert", "No such file or directory", "OK"))->Go();
BAlert* alert = new BAlert("alert",
"No such file or directory", "OK");
alert->Go();
return;
}
BMessage msg(M_EVENT_CHANGED);

View File

@ -10,9 +10,11 @@
#ifndef __HEVENTLIST_H__
#define __HEVENTLIST_H__
#include <ColumnListView.h>
#include <String.h>
enum {
kEventColumn,
kSoundColumn,
@ -29,7 +31,6 @@ public:
const char* Path() const { return fPath.String(); }
void Remove(const char* type);
void SetPath(const char* path);
protected:
private:
BString fName;
@ -50,9 +51,13 @@ public:
void RemoveAll();
void SetType(const char* type);
void SetPath(const char* path);
protected:
virtual void SelectionChanged();
private:
char* fType;
};
#endif
#endif // __HEVENTLIST_H__

View File

@ -39,7 +39,8 @@ static const char kSettingsFile[] = "Sounds_Settings";
HWindow::HWindow(BRect rect, const char* name)
: _inherited(rect, name, B_TITLED_WINDOW, 0),
:
BWindow(rect, name, B_TITLED_WINDOW, 0),
fFilePanel(NULL),
fPlayer(NULL)
{
@ -93,7 +94,8 @@ HWindow::InitGUI()
{
BRect rect = Bounds();
rect.bottom -= 106;
BView *listView = new BView(rect, "", B_FOLLOW_NONE, B_WILL_DRAW | B_PULSE_NEEDED);
BView* listView = new BView(rect, "", B_FOLLOW_NONE,
B_WILL_DRAW | B_PULSE_NEEDED);
listView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(listView);
@ -108,7 +110,8 @@ HWindow::InitGUI()
rect = Bounds();
rect.top = rect.bottom - 105;
BView *view = new BView(rect, "", B_FOLLOW_NONE, B_WILL_DRAW | B_PULSE_NEEDED);
BView* view = new BView(rect, "", B_FOLLOW_NONE,
B_WILL_DRAW | B_PULSE_NEEDED);
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(view);
rect = view->Bounds().InsetBySelf(12, 12);
@ -125,17 +128,19 @@ HWindow::InitGUI()
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("<none>", new BMessage(M_NONE_MESSAGE)));
menu->AddItem(new BMenuItem("Other" B_UTF8_ELLIPSIS, new BMessage(M_OTHER_MESSAGE)));
BMenuField *menuField = new BMenuField(rect, "filemenu", "Sound file:", menu,
B_FOLLOW_TOP | B_FOLLOW_LEFT);
menu->AddItem(new BMenuItem("Other" B_UTF8_ELLIPSIS,
new BMessage(M_OTHER_MESSAGE)));
BMenuField* menuField = new BMenuField(rect, "filemenu", "Sound file:",
menu, B_FOLLOW_TOP | B_FOLLOW_LEFT);
menuField->SetDivider(menuField->StringWidth("Sound file:") + 10);
box->AddChild(menuField);
rect.OffsetBy(-2, menuField->Bounds().Height() + 15);
BButton *button = new BButton(rect, "stop", "Stop", new BMessage(M_STOP_MESSAGE),
B_FOLLOW_RIGHT | B_FOLLOW_TOP);
BButton* button = new BButton(rect, "stop", "Stop",
new BMessage(M_STOP_MESSAGE), B_FOLLOW_RIGHT | B_FOLLOW_TOP);
button->ResizeToPreferred();
button->SetEnabled(false);
button->MoveTo(box->Bounds().right - button->Bounds().Width() - 15, rect.top);
button->MoveTo(box->Bounds().right - button->Bounds().Width() - 15,
rect.top);
box->AddChild(button);
rect = button->Frame();
@ -151,7 +156,8 @@ HWindow::InitGUI()
box->AddChild(button);
view->MoveTo(0, listView->Frame().bottom);
ResizeTo(Bounds().Width(), listView->Frame().bottom + view->Bounds().Height());
ResizeTo(Bounds().Width(),
listView->Frame().bottom + view->Bounds().Height());
listView->SetResizingMode(B_FOLLOW_ALL);
view->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);
@ -175,11 +181,11 @@ HWindow::MessageReceived(BMessage *message)
BPath path(row->Path());
if (path.InitCheck() != B_OK) {
BMenuItem* item = menu->FindItem("<none>");
if (item)
if (item != NULL)
item->SetMarked(true);
} else {
BMenuItem* item = menu->FindItem(path.Leaf());
if (item)
if (item != NULL)
item->SetMarked(true);
}
}
@ -193,7 +199,8 @@ HWindow::MessageReceived(BMessage *message)
entry_ref ref;
HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
if (message->FindRef("refs", &ref) == B_OK && row != NULL) {
BMenuField *menufield = cast_as(FindView("filemenu"), BMenuField);
BMenuField* menufield = cast_as(FindView("filemenu"),
BMenuField);
BMenu* menu = menufield->Menu();
// check audio file
@ -204,10 +211,12 @@ HWindow::MessageReceived(BMessage *message)
BMimeType mtype(type);
BMimeType superType;
mtype.GetSupertype(&superType);
if (superType.Type() == NULL || strcmp(superType.Type(), "audio") != 0) {
if (superType.Type() == NULL
|| strcmp(superType.Type(), "audio") != 0) {
beep();
(new BAlert("", "This is not a audio file.", "OK", NULL, NULL,
B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go();
BAlert* alert = new BAlert("", "This is not a audio file.",
"OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->Go();
break;
}
@ -216,12 +225,12 @@ HWindow::MessageReceived(BMessage *message)
BPath path(&ref);
msg->AddRef("refs", &ref);
BMenuItem* menuitem = menu->FindItem(path.Leaf());
if (!menuitem)
if (menuitem == NULL)
menu->AddItem(menuitem = new BMenuItem(path.Leaf(), msg), 0);
// refresh item
fEventList->SetPath(BPath(&ref).Path());
// check file menu
if (menuitem)
if (menuitem != NULL)
menuitem->SetMarked(true);
}
break;
@ -232,7 +241,7 @@ HWindow::MessageReceived(BMessage *message)
HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
if (row != NULL) {
const char* path = row->Path();
if (path) {
if (path != NULL) {
entry_ref ref;
::get_ref_for_path(path, &ref);
delete fPlayer;
@ -245,7 +254,7 @@ HWindow::MessageReceived(BMessage *message)
case M_STOP_MESSAGE:
{
if (!fPlayer)
if (fPlayer == NULL)
break;
if (fPlayer->IsPlaying()) {
fPlayer->StopPlaying();
@ -265,11 +274,11 @@ HWindow::MessageReceived(BMessage *message)
BPath path(path);
if (path.InitCheck() != B_OK) {
BMenuItem* item = menu->FindItem("<none>");
if (item)
if (item != NULL)
item->SetMarked(true);
} else {
BMenuItem* item = menu->FindItem(path.Leaf());
if (item)
if (item != NULL)
item->SetMarked(true);
}
}
@ -291,7 +300,7 @@ HWindow::MessageReceived(BMessage *message)
}
default:
_inherited::MessageReceived(message);
BWindow::MessageReceived(message);
}
}
@ -304,7 +313,7 @@ HWindow::SetupMenuField()
int32 count = fEventList->CountRows();
for (int32 i = 0; i < count; i++) {
HEventRow* row = (HEventRow*)fEventList->RowAt(i);
if (!row)
if (row == NULL)
continue;
BPath path(row->Path());
@ -329,7 +338,7 @@ HWindow::SetupMenuField()
if (err == B_OK)
err = dir.SetTo(path.Path());
while (err == B_OK) {
err = dir.GetNextEntry((BEntry*)&entry, true);
err = dir.GetNextEntry(&entry, true);
if (entry.InitCheck() != B_NO_ERROR)
break;
@ -349,7 +358,7 @@ HWindow::SetupMenuField()
if (err == B_OK)
err = dir.SetTo(path.Path());
while (err == B_OK) {
err = dir.GetNextEntry((BEntry*)&entry, true);
err = dir.GetNextEntry(&entry, true);
if (entry.InitCheck() != B_NO_ERROR)
break;
@ -370,7 +379,7 @@ HWindow::SetupMenuField()
if (err == B_OK)
err = dir.SetTo(path.Path());
while (err == B_OK) {
err = dir.GetNextEntry((BEntry*)&entry, true);
err = dir.GetNextEntry(&entry, true);
if (entry.InitCheck() != B_NO_ERROR)
break;
@ -398,14 +407,14 @@ HWindow::Pulse()
BButton* button = cast_as(FindView("play"), BButton);
BButton* stop = cast_as(FindView("stop"), BButton);
if (!menufield)
if (menufield == NULL)
return;
if (row != NULL) {
menufield->SetEnabled(true);
const char* path = row->Path();
if (path && strcmp(path, ""))
if (path != NULL && strcmp(path, ""))
button->SetEnabled(true);
else
button->SetEnabled(false);
@ -414,7 +423,7 @@ HWindow::Pulse()
button->SetEnabled(false);
}
if (fPlayer) {
if (fPlayer != NULL) {
if (fPlayer->IsPlaying())
stop->SetEnabled(true);
else

View File

@ -36,8 +36,8 @@ enum{
class HWindow : public BWindow {
public:
HWindow(BRect rect, const char* name);
protected:
virtual ~HWindow();
virtual void MessageReceived(BMessage* message);
virtual bool QuitRequested();
virtual void DispatchMessage(BMessage* message,
@ -45,12 +45,13 @@ protected:
void InitGUI();
void SetupMenuField();
void Pulse();
private:
typedef BWindow _inherited;
HEventList* fEventList;
BFilePanel* fFilePanel;
BFileGameSound* fPlayer;
BRect fFrame;
};
#endif // __HWINDOW_H__