Fix a few minor coding style violations.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25410 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2008-05-10 11:12:23 +00:00
parent 8bbf2fc768
commit 572ff7ee4a
+46 -33
View File
@@ -69,20 +69,21 @@ SetLabel(BStringView *label, const char *text)
// #pragma mark - // #pragma mark -
CDPlayer::CDPlayer(BRect frame, const char *name, uint32 resizeMask, uint32 flags) CDPlayer::CDPlayer(BRect frame, const char *name, uint32 resizeMask,
uint32 flags)
: BView(frame, name, resizeMask, flags | B_FRAME_EVENTS), : BView(frame, name, resizeMask, flags | B_FRAME_EVENTS),
fCDQuery("freedb.freedb.org") fCDQuery("freedb.freedb.org")
{ {
SetViewColor(216,216,216); SetViewColor(216, 216, 216);
fVolume = 255; fVolume = 255;
BuildGUI(); BuildGUI();
if (fCDDrive.CountDrives() < 1) { if (fCDDrive.CountDrives() < 1) {
BAlert *alert = new BAlert("CDPlayer", "It appears that there are no CD drives" BAlert *alert = new BAlert("CDPlayer", "It appears that there are no CD"
" on your computer or there is no system software" " drives on your computer or there is no system software to "
" to support one. Sorry.", "OK"); "support one. Sorry.", "OK");
alert->Go(); alert->Go();
be_app->PostMessage(B_QUIT_REQUESTED); be_app->PostMessage(B_QUIT_REQUESTED);
} }
@@ -124,7 +125,8 @@ CDPlayer::BuildGUI()
r.bottom = 25; r.bottom = 25;
float labelWidth, labelHeight; float labelWidth, labelHeight;
fCDTitle = new BStringView(r, "CDTitle", "CD drive is empty", B_FOLLOW_LEFT_RIGHT); fCDTitle = new BStringView(r, "CDTitle", "CD drive is empty",
B_FOLLOW_LEFT_RIGHT);
fCDTitle->GetPreferredSize(&labelWidth, &labelHeight); fCDTitle->GetPreferredSize(&labelWidth, &labelHeight);
fCDTitle->ResizeTo(r.Width(), labelHeight); fCDTitle->ResizeTo(r.Width(), labelHeight);
box->AddChild(fCDTitle); box->AddChild(fCDTitle);
@@ -137,11 +139,13 @@ CDPlayer::BuildGUI()
r.OffsetBy(0, r.Height() + 5); r.OffsetBy(0, r.Height() + 5);
r.right = r.left + (r.Width() / 2); r.right = r.left + (r.Width() / 2);
fTrackTime = new BStringView(r, "TrackTime", "Track: --:-- / --:--", B_FOLLOW_LEFT_RIGHT); fTrackTime = new BStringView(r, "TrackTime", "Track: --:-- / --:--",
B_FOLLOW_LEFT_RIGHT);
box->AddChild(fTrackTime); box->AddChild(fTrackTime);
r.OffsetTo(box->Bounds().right / 2, r.top); r.OffsetTo(box->Bounds().right / 2, r.top);
fDiscTime = new BStringView(r, "DiscTime", "Disc: --:-- / --:--", B_FOLLOW_RIGHT); fDiscTime = new BStringView(r, "DiscTime", "Disc: --:-- / --:--",
B_FOLLOW_RIGHT);
fDiscTime->ResizeToPreferred(); fDiscTime->ResizeToPreferred();
fDiscTime->ResizeBy(10, 0); fDiscTime->ResizeBy(10, 0);
box->AddChild(fDiscTime); box->AddChild(fDiscTime);
@@ -154,7 +158,8 @@ CDPlayer::BuildGUI()
new BMessage(M_STOP), B_FOLLOW_BOTTOM, B_WILL_DRAW); new BMessage(M_STOP), B_FOLLOW_BOTTOM, B_WILL_DRAW);
fStop->ResizeToPreferred(); fStop->ResizeToPreferred();
fStop->MoveTo(10, box->Frame().bottom + 15); fStop->MoveTo(10, box->Frame().bottom + 15);
fStop->SetDisabled(BTranslationUtils::GetBitmap(B_PNG_FORMAT, "stop_disabled")); fStop->SetDisabled(BTranslationUtils::GetBitmap(B_PNG_FORMAT,
"stop_disabled"));
AddChild(fStop); AddChild(fStop);
float stopTop = fStop->Frame().top; float stopTop = fStop->Frame().top;
@@ -254,7 +259,8 @@ CDPlayer::MessageReceived(BMessage *msg)
case M_STOP: case M_STOP:
if (fWindowState == kPaused) { if (fWindowState == kPaused) {
fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_up"), fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT,
"play_up"),
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down")); BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down"));
fPlay->SetState(1); fPlay->SetState(1);
} }
@@ -268,12 +274,14 @@ CDPlayer::MessageReceived(BMessage *msg)
if (fWindowState == kPlaying) { if (fWindowState == kPlaying) {
fWindowState = kPaused; fWindowState = kPaused;
fCDDrive.Pause(); fCDDrive.Pause();
fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT, "paused_up"), fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT,
"paused_up"),
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down")); BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down"));
} else if (fWindowState == kPaused) { } else if (fWindowState == kPaused) {
fWindowState = kPlaying; fWindowState = kPlaying;
fCDDrive.Resume(); fCDDrive.Resume();
fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_up"), fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT,
"play_up"),
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down")); BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down"));
} else { } else {
fWindowState = kPlaying; fWindowState = kPlaying;
@@ -447,7 +455,8 @@ CDPlayer::_WatchCDState()
// We have just discovered that we have no bananas // We have just discovered that we have no bananas
fWindowState = kNoCD; fWindowState = kNoCD;
// Because we are changing play states, we will need to update the GUI // Because we are changing play states, we will need to update
// the GUI
fCDData.SetDiscID(-1); fCDData.SetDiscID(-1);
SetLabel(fCDTitle, "CD drive is empty"); SetLabel(fCDTitle, "CD drive is empty");
@@ -470,8 +479,8 @@ CDPlayer::_WatchCDState()
if (fWindowState == kPlaying) { if (fWindowState == kPlaying) {
internalTrackChange = true; internalTrackChange = true;
// This means that the drive finished playing the song, so get the next one // This means that the drive finished playing the song, so get
// from the list and play it // the next one from the list and play it
int16 next = fPlayList.GetNextTrack(); int16 next = fPlayList.GetNextTrack();
if (next > 0) if (next > 0)
fCDDrive.Play(next); fCDDrive.Play(next);
@@ -485,8 +494,8 @@ CDPlayer::_WatchCDState()
} else if (playState == kPaused) } else if (playState == kPaused)
fPlay->SetState(0); fPlay->SetState(0);
// If we got this far, then there must be a CD in the drive. The next order on the agenda // If we got this far, then there must be a CD in the drive. The next order
// is to find out which CD it is // on the agenda is to find out which CD it is
int32 discId = fCDDrive.GetDiscID(); int32 discId = fCDDrive.GetDiscID();
bool updateTrackGui = false; bool updateTrackGui = false;
@@ -498,8 +507,8 @@ CDPlayer::_WatchCDState()
fCDQuery.SetToCD(fCDDrive.GetDrivePath()); fCDQuery.SetToCD(fCDDrive.GetDrivePath());
if (fCDQuery.Ready()) { if (fCDQuery.Ready()) {
// Note that we only update the CD title for now. We still need a track number // Note that we only update the CD title for now. We still need a
// in order to update the display for the selected track // track number in order to update the display for the selected track
if (fCDQuery.GetData(&fCDData, 1000000)) { if (fCDQuery.GetData(&fCDData, 1000000)) {
BString display(fCDData.Artist()); BString display(fCDData.Artist());
display << " - " << fCDData.Album(); display << " - " << fCDData.Album();
@@ -521,8 +530,9 @@ CDPlayer::_WatchCDState()
playlistTrack = driveTrack; playlistTrack = driveTrack;
if (!internalTrackChange) { if (!internalTrackChange) {
// The main thing is that we need to make sure that the playlist and the drive's track // The main thing is that we need to make sure that the
// stay in sync. The CD's track may have been changed by an outside source, so if // playlist and the drive's track stay in sync. The CD's
// track may have been changed by an outside source, so if
// the drive is playing, check for playlist sync. // the drive is playing, check for playlist sync.
fPlayList.SetTrackCount(driveCount); fPlayList.SetTrackCount(driveCount);
fPlayList.SetCurrentTrack(driveTrack); fPlayList.SetCurrentTrack(driveTrack);
@@ -533,16 +543,16 @@ CDPlayer::_WatchCDState()
if (playlistCount != driveCount) { if (playlistCount != driveCount) {
// This happens only when CDs are changed // This happens only when CDs are changed
if (driveCount < 0) { if (driveCount < 0) {
// There is no CD in the drive. The playlist needs to have its track // There is no CD in the drive. The playlist needs to have its
// count set to 0 and it also needs to be rewound. // track count set to 0 and it also needs to be rewound.
fPlayList.SetStartingTrack(1); fPlayList.SetStartingTrack(1);
fPlayList.SetTrackCount(0); fPlayList.SetTrackCount(0);
playlistTrack = 1; playlistTrack = 1;
playlistCount = 0; playlistCount = 0;
} else { } else {
// Two possible cases here: playlist is empty or playlist has a different // Two possible cases here: playlist is empty or playlist has a
// number of tracks. In either case, the playlist needs to be reinitialized // different number of tracks. In either case, the playlist
// to the current track data // needs to be reinitialized to the current track data
fPlayList.SetStartingTrack(1); fPlayList.SetStartingTrack(1);
fPlayList.SetTrackCount(driveCount); fPlayList.SetTrackCount(driveCount);
playlistTrack = fPlayList.GetCurrentTrack(); playlistTrack = fPlayList.GetCurrentTrack();
@@ -564,7 +574,8 @@ CDPlayer::_WatchCDState()
if (whichTrack == 0) if (whichTrack == 0)
whichTrack++; whichTrack++;
currentTrackName << "Track " << whichTrack << ": " << fCDData.TrackAt(whichTrack - 1); currentTrackName << "Track " << whichTrack << ": "
<< fCDData.TrackAt(whichTrack - 1);
SetLabel(fCurrentTrack, currentTrackName.String()); SetLabel(fCurrentTrack, currentTrackName.String());
@@ -581,13 +592,15 @@ CDPlayer::_WatchCDState()
if (fCDDrive.GetTime(trackTime, discTime)) { if (fCDDrive.GetTime(trackTime, discTime)) {
fCDDrive.GetTimeForDisc(discTotal); fCDDrive.GetTimeForDisc(discTotal);
sprintf(timeString, "Disc: %ld:%.2ld / %ld:%.2ld", discTime.GetMinutes(), sprintf(timeString, "Disc: %ld:%.2ld / %ld:%.2ld",
discTime.GetSeconds(), discTotal.GetMinutes(), discTotal.GetSeconds()); discTime.GetMinutes(), discTime.GetSeconds(),
discTotal.GetMinutes(), discTotal.GetSeconds());
SetLabel(fDiscTime, timeString); SetLabel(fDiscTime, timeString);
fCDDrive.GetTimeForTrack(playlistTrack, trackTotal); fCDDrive.GetTimeForTrack(playlistTrack, trackTotal);
sprintf(timeString, "Track: %ld:%.2ld / %ld:%.2ld", trackTime.GetMinutes(), sprintf(timeString, "Track: %ld:%.2ld / %ld:%.2ld",
trackTime.GetSeconds(), trackTotal.GetMinutes(), trackTotal.GetSeconds()); trackTime.GetMinutes(), trackTime.GetSeconds(),
trackTotal.GetMinutes(), trackTotal.GetSeconds());
SetLabel(fTrackTime, timeString); SetLabel(fTrackTime, timeString);
} else { } else {
SetLabel(fTrackTime, "Track: --:-- / --:--"); SetLabel(fTrackTime, "Track: --:-- / --:--");
@@ -600,8 +613,8 @@ CDPlayer::_WatchCDState()
CDPlayerWindow::CDPlayerWindow() CDPlayerWindow::CDPlayerWindow()
: BWindow(BRect (100, 100, 405, 280), "CDPlayer", B_TITLED_WINDOW, B_NOT_RESIZABLE | : BWindow(BRect (100, 100, 405, 280), "CDPlayer", B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS) B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)
{ {
} }