* 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
+12 -9
View File
@@ -16,13 +16,14 @@
HApp::HApp() HApp::HApp()
: BApplication("application/x-vnd.Haiku-Sounds") :
BApplication("application/x-vnd.Haiku-Sounds")
{ {
BRect rect; BRect rect;
rect.Set(200, 150, 590, 570); rect.Set(200, 150, 590, 570);
HWindow *win = new HWindow(rect, "Sounds"); HWindow* window = new HWindow(rect, "Sounds");
win->Show(); window->Show();
} }
@@ -34,12 +35,14 @@ HApp::~HApp()
void void
HApp::AboutRequested() HApp::AboutRequested()
{ {
(new BAlert("About Sounds", "Sounds\n" BAlert* alert = new BAlert("About Sounds",
" Brought to you by :\n" "Sounds\n"
" Oliver Ruiz Dorantes\n" " Brought to you by :\n"
" Jérôme DUVAL.\n" " Oliver Ruiz Dorantes\n"
" Original work from Atsushi Takamatsu.\n" " Jérôme DUVAL.\n"
"Copyright " B_UTF8_COPYRIGHT "2003-2006 Haiku", "OK"))->Go(); " Original work from Atsushi Takamatsu.\n"
"Copyright " B_UTF8_COPYRIGHT "2003-2006 Haiku", "OK");
alert->Go();
} }
+6 -7
View File
@@ -14,13 +14,12 @@
#include <Application.h> #include <Application.h>
class HApp :public BApplication { class HApp : public BApplication {
public: public:
HApp(); HApp();
virtual ~HApp(); virtual ~HApp();
virtual void AboutRequested();
protected:
virtual void AboutRequested();
}; };
#endif // HAPP_H #endif // HAPP_H
+21 -13
View File
@@ -18,7 +18,8 @@
HEventRow::HEventRow(const char* name, const char* path) HEventRow::HEventRow(const char* name, const char* path)
: BRow(), :
BRow(),
fName(name) fName(name)
{ {
SetField(new BStringField(name), kEventColumn); SetField(new BStringField(name), kEventColumn);
@@ -41,18 +42,21 @@ HEventRow::SetPath(const char* _path)
void void
HEventRow::Remove(const char *type) HEventRow::Remove(const char* type)
{ {
BMediaFiles().RemoveItem(type, Name()); BMediaFiles().RemoveItem(type, Name());
} }
HEventList::HEventList(BRect rect, const char* name) HEventList::HEventList(BRect rect, const char* name)
: BColumnListView(rect, name, B_FOLLOW_ALL, 0, B_PLAIN_BORDER, true), :
fType(NULL) 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("Event", 150, 50, 500, B_TRUNCATE_MIDDLE),
AddColumn(new BStringColumn("Sound", 150, 50, 500, B_TRUNCATE_END), kSoundColumn); kEventColumn);
AddColumn(new BStringColumn("Sound", 150, 50, 500, B_TRUNCATE_END),
kSoundColumn);
} }
@@ -76,7 +80,8 @@ HEventList::SetType(const char* type)
entry_ref ref; entry_ref ref;
while (mfiles.GetNextRef(&name,&ref) == B_OK) { while (mfiles.GetNextRef(&name,&ref) == B_OK) {
BPath path(&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)
AddRow(new HEventRow(name.String(), NULL)); AddRow(new HEventRow(name.String(), NULL));
else else
AddRow(new HEventRow(name.String(), path.Path())); AddRow(new HEventRow(name.String(), path.Path()));
@@ -87,8 +92,8 @@ HEventList::SetType(const char* type)
void void
HEventList::RemoveAll() HEventList::RemoveAll()
{ {
BRow *row; BRow* row;
while ((row = RowAt((int32)0, NULL))!=NULL) { while ((row = RowAt((int32)0, NULL)) != NULL) {
RemoveRow(row); RemoveRow(row);
delete row; delete row;
} }
@@ -100,19 +105,22 @@ HEventList::SelectionChanged()
{ {
BColumnListView::SelectionChanged(); BColumnListView::SelectionChanged();
HEventRow* row = (HEventRow *)CurrentSelection(); HEventRow* row = (HEventRow*)CurrentSelection();
if (row != NULL) { if (row != NULL) {
entry_ref ref; entry_ref ref;
BMediaFiles().GetRefFor(fType, row->Name(), &ref); BMediaFiles().GetRefFor(fType, row->Name(), &ref);
BPath path(&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()); row->SetPath(path.Path());
UpdateRow(row); UpdateRow(row);
} else { } else {
printf("name %s\n", ref.name); printf("name %s\n", ref.name);
BMediaFiles().RemoveRefFor(fType, row->Name(), ref); 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; return;
} }
BMessage msg(M_EVENT_CHANGED); BMessage msg(M_EVENT_CHANGED);
@@ -126,7 +134,7 @@ HEventList::SelectionChanged()
void void
HEventList::SetPath(const char* path) HEventList::SetPath(const char* path)
{ {
HEventRow* row = (HEventRow *)CurrentSelection(); HEventRow* row = (HEventRow*)CurrentSelection();
if (row != NULL) { if (row != NULL) {
entry_ref ref; entry_ref ref;
BEntry entry(path); BEntry entry(path);
+24 -19
View File
@@ -10,9 +10,11 @@
#ifndef __HEVENTLIST_H__ #ifndef __HEVENTLIST_H__
#define __HEVENTLIST_H__ #define __HEVENTLIST_H__
#include <ColumnListView.h> #include <ColumnListView.h>
#include <String.h> #include <String.h>
enum { enum {
kEventColumn, kEventColumn,
kSoundColumn, kSoundColumn,
@@ -21,19 +23,18 @@ enum {
class HEventRow : public BRow { class HEventRow : public BRow {
public: public:
HEventRow(const char* event_name, HEventRow(const char* event_name,
const char* path); const char* path);
virtual ~HEventRow(); virtual ~HEventRow();
const char* Name() const { return fName.String();} const char* Name() const { return fName.String(); }
const char* Path() const { return fPath.String();} const char* Path() const { return fPath.String(); }
void Remove(const char *type); void Remove(const char* type);
void SetPath(const char* path); void SetPath(const char* path);
protected:
private: private:
BString fName; BString fName;
BString fPath; BString fPath;
}; };
@@ -44,15 +45,19 @@ enum {
class HEventList : public BColumnListView { class HEventList : public BColumnListView {
public: public:
HEventList(BRect rect, HEventList(BRect rect,
const char* name = "EventList"); const char* name = "EventList");
virtual ~HEventList(); virtual ~HEventList();
void RemoveAll(); void RemoveAll();
void SetType(const char* type); void SetType(const char* type);
void SetPath(const char* path); void SetPath(const char* path);
protected: protected:
virtual void SelectionChanged(); virtual void SelectionChanged();
private: private:
char *fType; char* fType;
}; };
#endif
#endif // __HEVENTLIST_H__
+73 -64
View File
@@ -38,8 +38,9 @@
static const char kSettingsFile[] = "Sounds_Settings"; static const char kSettingsFile[] = "Sounds_Settings";
HWindow::HWindow(BRect rect, const char *name) HWindow::HWindow(BRect rect, const char* name)
: _inherited(rect, name, B_TITLED_WINDOW, 0), :
BWindow(rect, name, B_TITLED_WINDOW, 0),
fFilePanel(NULL), fFilePanel(NULL),
fPlayer(NULL) fPlayer(NULL)
{ {
@@ -78,7 +79,7 @@ HWindow::~HWindow()
BMessage msg; BMessage msg;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
path.Append(kSettingsFile); path.Append(kSettingsFile);
BFile file(path.Path(), B_WRITE_ONLY|B_CREATE_FILE); BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE);
if (file.InitCheck() == B_OK) { if (file.InitCheck() == B_OK) {
msg.AddRect("frame", fFrame); msg.AddRect("frame", fFrame);
@@ -93,7 +94,8 @@ HWindow::InitGUI()
{ {
BRect rect = Bounds(); BRect rect = Bounds();
rect.bottom -= 106; 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)); listView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(listView); AddChild(listView);
@@ -108,34 +110,37 @@ HWindow::InitGUI()
rect = Bounds(); rect = Bounds();
rect.top = rect.bottom - 105; 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)); view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(view); AddChild(view);
rect = view->Bounds().InsetBySelf(12, 12); rect = view->Bounds().InsetBySelf(12, 12);
BBox *box = new BBox(rect, "", B_FOLLOW_ALL); BBox* box = new BBox(rect, "", B_FOLLOW_ALL);
view->AddChild(box); view->AddChild(box);
rect = box->Bounds(); rect = box->Bounds();
rect.top += 10; rect.top += 10;
rect.left += 15; rect.left += 15;
rect.right -= 10; rect.right -= 10;
rect.bottom = rect.top + 20; rect.bottom = rect.top + 20;
BMenu *menu = new BMenu("file"); BMenu* menu = new BMenu("file");
menu->SetRadioMode(true); menu->SetRadioMode(true);
menu->SetLabelFromMarked(true); menu->SetLabelFromMarked(true);
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("<none>", new BMessage(M_NONE_MESSAGE))); menu->AddItem(new BMenuItem("<none>", new BMessage(M_NONE_MESSAGE)));
menu->AddItem(new BMenuItem("Other" B_UTF8_ELLIPSIS, new BMessage(M_OTHER_MESSAGE))); menu->AddItem(new BMenuItem("Other" B_UTF8_ELLIPSIS,
BMenuField *menuField = new BMenuField(rect, "filemenu", "Sound file:", menu, new BMessage(M_OTHER_MESSAGE)));
B_FOLLOW_TOP | B_FOLLOW_LEFT); BMenuField* menuField = new BMenuField(rect, "filemenu", "Sound file:",
menu, B_FOLLOW_TOP | B_FOLLOW_LEFT);
menuField->SetDivider(menuField->StringWidth("Sound file:") + 10); menuField->SetDivider(menuField->StringWidth("Sound file:") + 10);
box->AddChild(menuField); box->AddChild(menuField);
rect.OffsetBy(-2, menuField->Bounds().Height() + 15); rect.OffsetBy(-2, menuField->Bounds().Height() + 15);
BButton *button = new BButton(rect, "stop", "Stop", new BMessage(M_STOP_MESSAGE), BButton* button = new BButton(rect, "stop", "Stop",
B_FOLLOW_RIGHT | B_FOLLOW_TOP); new BMessage(M_STOP_MESSAGE), B_FOLLOW_RIGHT | B_FOLLOW_TOP);
button->ResizeToPreferred(); button->ResizeToPreferred();
button->SetEnabled(false); 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); box->AddChild(button);
rect = button->Frame(); rect = button->Frame();
@@ -151,7 +156,8 @@ HWindow::InitGUI()
box->AddChild(button); box->AddChild(button);
view->MoveTo(0, listView->Frame().bottom); 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); listView->SetResizingMode(B_FOLLOW_ALL);
view->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM); view->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);
@@ -162,24 +168,24 @@ HWindow::InitGUI()
void void
HWindow::MessageReceived(BMessage *message) HWindow::MessageReceived(BMessage* message)
{ {
switch (message->what) { switch (message->what) {
case M_OTHER_MESSAGE: case M_OTHER_MESSAGE:
{ {
BMenuField *menufield = cast_as(FindView("filemenu"), BMenuField); BMenuField* menufield = cast_as(FindView("filemenu"), BMenuField);
BMenu *menu = menufield->Menu(); BMenu* menu = menufield->Menu();
HEventRow* row = (HEventRow *)fEventList->CurrentSelection(); HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
if (row != NULL) { if (row != NULL) {
BPath path(row->Path()); BPath path(row->Path());
if (path.InitCheck() != B_OK) { if (path.InitCheck() != B_OK) {
BMenuItem *item = menu->FindItem("<none>"); BMenuItem* item = menu->FindItem("<none>");
if (item) if (item != NULL)
item->SetMarked(true); item->SetMarked(true);
} else { } else {
BMenuItem *item = menu->FindItem(path.Leaf()); BMenuItem* item = menu->FindItem(path.Leaf());
if (item) if (item != NULL)
item->SetMarked(true); item->SetMarked(true);
} }
} }
@@ -191,10 +197,11 @@ HWindow::MessageReceived(BMessage *message)
case B_REFS_RECEIVED: case B_REFS_RECEIVED:
{ {
entry_ref ref; entry_ref ref;
HEventRow* row = (HEventRow *)fEventList->CurrentSelection(); HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
if (message->FindRef("refs", &ref) == B_OK && row != NULL) { if (message->FindRef("refs", &ref) == B_OK && row != NULL) {
BMenuField *menufield = cast_as(FindView("filemenu"), BMenuField); BMenuField* menufield = cast_as(FindView("filemenu"),
BMenu *menu = menufield->Menu(); BMenuField);
BMenu* menu = menufield->Menu();
// check audio file // check audio file
BNode node(&ref); BNode node(&ref);
@@ -204,24 +211,26 @@ HWindow::MessageReceived(BMessage *message)
BMimeType mtype(type); BMimeType mtype(type);
BMimeType superType; BMimeType superType;
mtype.GetSupertype(&superType); mtype.GetSupertype(&superType);
if (superType.Type() == NULL || strcmp(superType.Type(), "audio") != 0) { if (superType.Type() == NULL
|| strcmp(superType.Type(), "audio") != 0) {
beep(); beep();
(new BAlert("", "This is not a audio file.", "OK", NULL, NULL, BAlert* alert = new BAlert("", "This is not a audio file.",
B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go(); "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->Go();
break; break;
} }
// add file item // add file item
BMessage *msg = new BMessage(M_ITEM_MESSAGE); BMessage* msg = new BMessage(M_ITEM_MESSAGE);
BPath path(&ref); BPath path(&ref);
msg->AddRef("refs", &ref); msg->AddRef("refs", &ref);
BMenuItem *menuitem = menu->FindItem(path.Leaf()); BMenuItem* menuitem = menu->FindItem(path.Leaf());
if (!menuitem) if (menuitem == NULL)
menu->AddItem(menuitem = new BMenuItem(path.Leaf(), msg), 0); menu->AddItem(menuitem = new BMenuItem(path.Leaf(), msg), 0);
// refresh item // refresh item
fEventList->SetPath(BPath(&ref).Path()); fEventList->SetPath(BPath(&ref).Path());
// check file menu // check file menu
if (menuitem) if (menuitem != NULL)
menuitem->SetMarked(true); menuitem->SetMarked(true);
} }
break; break;
@@ -229,10 +238,10 @@ HWindow::MessageReceived(BMessage *message)
case M_PLAY_MESSAGE: case M_PLAY_MESSAGE:
{ {
HEventRow* row = (HEventRow *)fEventList->CurrentSelection(); HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
if (row != NULL) { if (row != NULL) {
const char *path = row->Path(); const char* path = row->Path();
if (path) { if (path != NULL) {
entry_ref ref; entry_ref ref;
::get_ref_for_path(path, &ref); ::get_ref_for_path(path, &ref);
delete fPlayer; delete fPlayer;
@@ -245,7 +254,7 @@ HWindow::MessageReceived(BMessage *message)
case M_STOP_MESSAGE: case M_STOP_MESSAGE:
{ {
if (!fPlayer) if (fPlayer == NULL)
break; break;
if (fPlayer->IsPlaying()) { if (fPlayer->IsPlaying()) {
fPlayer->StopPlaying(); fPlayer->StopPlaying();
@@ -257,19 +266,19 @@ HWindow::MessageReceived(BMessage *message)
case M_EVENT_CHANGED: case M_EVENT_CHANGED:
{ {
const char *path; const char* path;
BMenuField *menufield = cast_as(FindView("filemenu"), BMenuField); BMenuField* menufield = cast_as(FindView("filemenu"), BMenuField);
BMenu *menu = menufield->Menu(); BMenu* menu = menufield->Menu();
if (message->FindString("path", &path) == B_OK) { if (message->FindString("path", &path) == B_OK) {
BPath path(path); BPath path(path);
if (path.InitCheck() != B_OK) { if (path.InitCheck() != B_OK) {
BMenuItem *item = menu->FindItem("<none>"); BMenuItem* item = menu->FindItem("<none>");
if (item) if (item != NULL)
item->SetMarked(true); item->SetMarked(true);
} else { } else {
BMenuItem *item = menu->FindItem(path.Leaf()); BMenuItem* item = menu->FindItem(path.Leaf());
if (item) if (item != NULL)
item->SetMarked(true); item->SetMarked(true);
} }
} }
@@ -291,7 +300,7 @@ HWindow::MessageReceived(BMessage *message)
} }
default: default:
_inherited::MessageReceived(message); BWindow::MessageReceived(message);
} }
} }
@@ -299,12 +308,12 @@ HWindow::MessageReceived(BMessage *message)
void void
HWindow::SetupMenuField() HWindow::SetupMenuField()
{ {
BMenuField *menufield = cast_as(FindView("filemenu"), BMenuField); BMenuField* menufield = cast_as(FindView("filemenu"), BMenuField);
BMenu *menu = menufield->Menu(); BMenu* menu = menufield->Menu();
int32 count = fEventList->CountRows(); int32 count = fEventList->CountRows();
for (int32 i = 0; i < count; i++) { for (int32 i = 0; i < count; i++) {
HEventRow *row = (HEventRow *)fEventList->RowAt(i); HEventRow* row = (HEventRow*)fEventList->RowAt(i);
if (!row) if (row == NULL)
continue; continue;
BPath path(row->Path()); BPath path(row->Path());
@@ -313,7 +322,7 @@ HWindow::SetupMenuField()
if (menu->FindItem(path.Leaf())) if (menu->FindItem(path.Leaf()))
continue; continue;
BMessage *msg = new BMessage(M_ITEM_MESSAGE); BMessage* msg = new BMessage(M_ITEM_MESSAGE);
entry_ref ref; entry_ref ref;
::get_ref_for_path(path.Path(), &ref); ::get_ref_for_path(path.Path(), &ref);
msg->AddRef("refs", &ref); msg->AddRef("refs", &ref);
@@ -329,7 +338,7 @@ HWindow::SetupMenuField()
if (err == B_OK) if (err == B_OK)
err = dir.SetTo(path.Path()); err = dir.SetTo(path.Path());
while (err == B_OK) { while (err == B_OK) {
err = dir.GetNextEntry((BEntry*)&entry, true); err = dir.GetNextEntry(&entry, true);
if (entry.InitCheck() != B_NO_ERROR) if (entry.InitCheck() != B_NO_ERROR)
break; break;
@@ -338,7 +347,7 @@ HWindow::SetupMenuField()
if (menu->FindItem(item_path.Leaf())) if (menu->FindItem(item_path.Leaf()))
continue; continue;
BMessage *msg = new BMessage(M_ITEM_MESSAGE); BMessage* msg = new BMessage(M_ITEM_MESSAGE);
entry_ref ref; entry_ref ref;
::get_ref_for_path(item_path.Path(), &ref); ::get_ref_for_path(item_path.Path(), &ref);
msg->AddRef("refs", &ref); msg->AddRef("refs", &ref);
@@ -349,7 +358,7 @@ HWindow::SetupMenuField()
if (err == B_OK) if (err == B_OK)
err = dir.SetTo(path.Path()); err = dir.SetTo(path.Path());
while (err == B_OK) { while (err == B_OK) {
err = dir.GetNextEntry((BEntry*)&entry, true); err = dir.GetNextEntry(&entry, true);
if (entry.InitCheck() != B_NO_ERROR) if (entry.InitCheck() != B_NO_ERROR)
break; break;
@@ -358,7 +367,7 @@ HWindow::SetupMenuField()
if (menu->FindItem(item_path.Leaf())) if (menu->FindItem(item_path.Leaf()))
continue; continue;
BMessage *msg = new BMessage(M_ITEM_MESSAGE); BMessage* msg = new BMessage(M_ITEM_MESSAGE);
entry_ref ref; entry_ref ref;
::get_ref_for_path(item_path.Path(), &ref); ::get_ref_for_path(item_path.Path(), &ref);
@@ -370,7 +379,7 @@ HWindow::SetupMenuField()
if (err == B_OK) if (err == B_OK)
err = dir.SetTo(path.Path()); err = dir.SetTo(path.Path());
while (err == B_OK) { while (err == B_OK) {
err = dir.GetNextEntry((BEntry*)&entry, true); err = dir.GetNextEntry(&entry, true);
if (entry.InitCheck() != B_NO_ERROR) if (entry.InitCheck() != B_NO_ERROR)
break; break;
@@ -379,7 +388,7 @@ HWindow::SetupMenuField()
if (menu->FindItem(item_path.Leaf())) if (menu->FindItem(item_path.Leaf()))
continue; continue;
BMessage *msg = new BMessage(M_ITEM_MESSAGE); BMessage* msg = new BMessage(M_ITEM_MESSAGE);
entry_ref ref; entry_ref ref;
::get_ref_for_path(item_path.Path(), &ref); ::get_ref_for_path(item_path.Path(), &ref);
@@ -393,19 +402,19 @@ HWindow::SetupMenuField()
void void
HWindow::Pulse() HWindow::Pulse()
{ {
HEventRow* row = (HEventRow *)fEventList->CurrentSelection(); HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
BMenuField *menufield = cast_as(FindView("filemenu"), BMenuField); BMenuField* menufield = cast_as(FindView("filemenu"), BMenuField);
BButton *button = cast_as(FindView("play"), BButton); BButton* button = cast_as(FindView("play"), BButton);
BButton *stop = cast_as(FindView("stop"), BButton); BButton* stop = cast_as(FindView("stop"), BButton);
if (!menufield) if (menufield == NULL)
return; return;
if (row != NULL) { if (row != NULL) {
menufield->SetEnabled(true); menufield->SetEnabled(true);
const char *path = row->Path(); const char* path = row->Path();
if (path && strcmp(path, "")) if (path != NULL && strcmp(path, ""))
button->SetEnabled(true); button->SetEnabled(true);
else else
button->SetEnabled(false); button->SetEnabled(false);
@@ -414,7 +423,7 @@ HWindow::Pulse()
button->SetEnabled(false); button->SetEnabled(false);
} }
if (fPlayer) { if (fPlayer != NULL) {
if (fPlayer->IsPlaying()) if (fPlayer->IsPlaying())
stop->SetEnabled(true); stop->SetEnabled(true);
else else
@@ -425,7 +434,7 @@ HWindow::Pulse()
void void
HWindow::DispatchMessage(BMessage *message, BHandler *handler) HWindow::DispatchMessage(BMessage* message, BHandler* handler)
{ {
if (message->what == B_PULSE) if (message->what == B_PULSE)
Pulse(); Pulse();
+16 -15
View File
@@ -35,22 +35,23 @@ enum{
class HWindow : public BWindow { class HWindow : public BWindow {
public: public:
HWindow(BRect rect, const char* name); HWindow(BRect rect, const char* name);
protected: virtual ~HWindow();
virtual ~HWindow();
virtual void MessageReceived(BMessage *message); virtual void MessageReceived(BMessage* message);
virtual bool QuitRequested(); virtual bool QuitRequested();
virtual void DispatchMessage(BMessage *message, virtual void DispatchMessage(BMessage* message,
BHandler *handler); BHandler* handler);
void InitGUI(); void InitGUI();
void SetupMenuField(); void SetupMenuField();
void Pulse(); void Pulse();
private: private:
typedef BWindow _inherited; HEventList* fEventList;
HEventList* fEventList; BFilePanel* fFilePanel;
BFilePanel* fFilePanel; BFileGameSound* fPlayer;
BFileGameSound* fPlayer; BRect fFrame;
BRect fFrame;
}; };
#endif // __HWINDOW_H__ #endif // __HWINDOW_H__