diff --git a/src/apps/soundrecorder/RecorderWindow.cpp b/src/apps/soundrecorder/RecorderWindow.cpp index 3235d53b23..f9e12df32c 100644 --- a/src/apps/soundrecorder/RecorderWindow.cpp +++ b/src/apps/soundrecorder/RecorderWindow.cpp @@ -55,7 +55,7 @@ #define CONNECT FPRINTF #define WINDOW FPRINTF -// default window positioning +// default window positioning static const float MIN_WIDTH = 400.0f; static const float MIN_HEIGHT = 336.0f; static const float XPOS = 100.0f; @@ -64,27 +64,27 @@ static const float YPOS = 200.0f; #define FOURCC(a,b,c,d) ((((uint32)(d)) << 24) | (((uint32)(c)) << 16) | (((uint32)(b)) << 8) | ((uint32)(a))) struct riff_struct -{ +{ uint32 riff_id; // 'RIFF' uint32 len; uint32 wave_id; // 'WAVE' -}; +}; -struct chunk_struct -{ +struct chunk_struct +{ uint32 fourcc; uint32 len; }; -struct format_struct -{ - uint16 format_tag; - uint16 channels; - uint32 samples_per_sec; - uint32 avg_bytes_per_sec; - uint16 block_align; +struct format_struct +{ + uint16 format_tag; + uint16 channels; + uint32 samples_per_sec; + uint32 avg_bytes_per_sec; + uint16 block_align; uint16 bits_per_sample; -}; +}; struct wave_struct @@ -97,7 +97,7 @@ struct wave_struct RecorderWindow::RecorderWindow() : - BWindow(BRect(XPOS,YPOS,XPOS+MIN_WIDTH,YPOS+MIN_HEIGHT), "SoundRecorder", B_TITLED_WINDOW, + BWindow(BRect(XPOS,YPOS,XPOS+MIN_WIDTH,YPOS+MIN_HEIGHT), "SoundRecorder", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_V_RESIZABLE), fPlayer(NULL), fSoundList(NULL), @@ -122,7 +122,7 @@ RecorderWindow::RecorderWindow() : fButtonState = btnPaused; CalcSizes(MIN_WIDTH, MIN_HEIGHT); - + fInitCheck = InitWindow(); if (fInitCheck != B_OK) { ErrorAlert("connect to media server", fInitCheck); @@ -141,14 +141,14 @@ RecorderWindow::~RecorderWindow() if (fPlayer) { delete fPlayer; } - + if (fPlayTrack && fPlayFile) fPlayFile->ReleaseTrack(fPlayTrack); if (fPlayFile) delete fPlayFile; fPlayTrack = NULL; fPlayFile = NULL; - + // Clean up items in list view. if (fSoundList) { fSoundList->DeselectAll(); @@ -200,7 +200,7 @@ RecorderWindow::InitWindow() { BPopUpMenu * popup = 0; status_t error; - + try { // Find temp directory for recorded sounds. BPath path; @@ -241,21 +241,21 @@ RecorderWindow::InitWindow() B_WILL_DRAW|B_FRAME_EVENTS|B_NAVIGABLE_JUMP, B_PLAIN_BORDER); AddChild(background); - - + + r = background->Bounds(); r.left = 2; r.right = r.left + 37; r.bottom = r.top + 104; fVUView = new VUView(r, B_FOLLOW_LEFT|B_FOLLOW_TOP); background->AddChild(fVUView); - + r = background->Bounds(); r.left = r.left + 40; r.bottom = r.top + 104; fScopeView = new ScopeView(r, B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP); background->AddChild(fScopeView); - + r = background->Bounds(); r.left = 2; r.right -= 26; @@ -263,89 +263,89 @@ RecorderWindow::InitWindow() r.bottom = r.top + 30; fTrackSlider = new TrackSlider(r, "trackSlider", new BMessage(POSITION_CHANGED), B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP); background->AddChild(fTrackSlider); - + BRect buttonRect; - + // Button for rewinding buttonRect = BRect(BPoint(0,0), kSkipButtonSize); buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-7, 25)); - fRewindButton = new TransportButton(buttonRect, "Rewind", - kSkipBackBitmapBits, kPressedSkipBackBitmapBits, kDisabledSkipBackBitmapBits, + fRewindButton = new TransportButton(buttonRect, "Rewind", + kSkipBackBitmapBits, kPressedSkipBackBitmapBits, kDisabledSkipBackBitmapBits, new BMessage(REWIND)); background->AddChild(fRewindButton); - + // Button for stopping recording or playback buttonRect = BRect(BPoint(0,0), kStopButtonSize); buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-48, 25)); - fStopButton = new TransportButton(buttonRect, "Stop", - kStopButtonBitmapBits, kPressedStopButtonBitmapBits, kDisabledStopButtonBitmapBits, + fStopButton = new TransportButton(buttonRect, "Stop", + kStopButtonBitmapBits, kPressedStopButtonBitmapBits, kDisabledStopButtonBitmapBits, new BMessage(STOP)); background->AddChild(fStopButton); - + // Button for starting playback of selected sound BRect playRect(BPoint(0,0), kPlayButtonSize); playRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-82, 25)); - fPlayButton = new PlayPauseButton(playRect, "Play", + fPlayButton = new PlayPauseButton(playRect, "Play", new BMessage(PLAY), new BMessage(PLAY_PERIOD), ' ', 0); background->AddChild(fPlayButton); - + // Button for forwarding buttonRect = BRect(BPoint(0,0), kSkipButtonSize); buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-133, 25)); - fForwardButton = new TransportButton(buttonRect, "Forward", - kSkipForwardBitmapBits, kPressedSkipForwardBitmapBits, kDisabledSkipForwardBitmapBits, + fForwardButton = new TransportButton(buttonRect, "Forward", + kSkipForwardBitmapBits, kPressedSkipForwardBitmapBits, kDisabledSkipForwardBitmapBits, new BMessage(FORWARD)); background->AddChild(fForwardButton); - + // Button to start recording (or waiting for sound) buttonRect = BRect(BPoint(0,0), kRecordButtonSize); buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-174, 25)); - fRecordButton = new RecordButton(buttonRect, "Record", + fRecordButton = new RecordButton(buttonRect, "Record", new BMessage(RECORD), new BMessage(RECORD_PERIOD)); background->AddChild(fRecordButton); // Button for saving selected sound buttonRect = BRect(BPoint(0,0), kDiskButtonSize); buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-250, 21)); - fSaveButton = new TransportButton(buttonRect, "Save", + fSaveButton = new TransportButton(buttonRect, "Save", kDiskButtonBitmapsBits, kPressedDiskButtonBitmapsBits, kDisabledDiskButtonBitmapsBits, new BMessage(SAVE)); fSaveButton->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP); background->AddChild(fSaveButton); - + // Button Loop buttonRect = BRect(BPoint(0,0), kArrowSize); buttonRect.OffsetTo(background->Bounds().RightBottom() - BPoint(23, 48)); - fLoopButton = new DrawButton(buttonRect, "Loop", + fLoopButton = new DrawButton(buttonRect, "Loop", kLoopArrowBits, kArrowBits, new BMessage(LOOP)); fLoopButton->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP); fLoopButton->SetTarget(this); background->AddChild(fLoopButton); - + buttonRect = BRect(BPoint(0,0), kSpeakerIconBitmapSize); buttonRect.OffsetTo(background->Bounds().RightBottom() - BPoint(121, 17)); SpeakerView *speakerView = new SpeakerView(buttonRect, B_FOLLOW_LEFT | B_FOLLOW_TOP); speakerView->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP); background->AddChild(speakerView); - + buttonRect = BRect(BPoint(0,0), BPoint(84, 19)); buttonRect.OffsetTo(background->Bounds().RightBottom() - BPoint(107, 20)); fVolumeSlider = new VolumeSlider(buttonRect, "volumeSlider", B_FOLLOW_LEFT | B_FOLLOW_TOP); fVolumeSlider->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP); background->AddChild(fVolumeSlider); - + // Button to mask/see sounds list buttonRect = BRect(BPoint(0,0), kUpDownButtonSize); buttonRect.OffsetTo(background->Bounds().RightBottom() - BPoint(21, 25)); fUpDownButton = new UpDownButton(buttonRect, new BMessage(VIEW_LIST)); fUpDownButton->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP); background->AddChild(fUpDownButton); - + r = Bounds(); r.top = background->Bounds().bottom + 1; fBottomBox = new BBox(r, "bottomBox", B_FOLLOW_ALL); fBottomBox->SetBorder(B_NO_BORDER); AddChild(fBottomBox); - + // The actual list of recorded sounds (initially empty) sits // below the header with the controls. r = fBottomBox->Bounds(); @@ -361,7 +361,7 @@ RecorderWindow::InitWindow() BScrollView *scroller = new BScrollView("scroller", fSoundList, B_FOLLOW_ALL, 0, false, true, B_FANCY_BORDER); fBottomBox->AddChild(scroller); - + r = fBottomBox->Bounds(); r.right = r.left + 190; r.bottom -= 25; @@ -369,7 +369,7 @@ RecorderWindow::InitWindow() r.top -= 1; fFileInfoBox = new BBox(r, "fileinfo", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); fFileInfoBox->SetLabel("File Info"); - + r = fFileInfoBox->Bounds(); r.left = 8; r.top = 13; @@ -401,13 +401,13 @@ RecorderWindow::InitWindow() r.bottom = r.top + 15; fDuration = new BStringView(r, "duration", "Duration:"); fFileInfoBox->AddChild(fDuration); - + // Input selection lists all available physical inputs that produce // buffers with B_MEDIA_RAW_AUDIO format data. popup = new BPopUpMenu("Input"); int max_input_count = 64; dormant_node_info dni[max_input_count]; - + int32 real_count = max_input_count; media_format output_format; output_format.type = B_MEDIA_RAW_AUDIO; @@ -436,7 +436,7 @@ RecorderWindow::InitWindow() break; } } - + // Create the actual widget BRect frame(fBottomBox->Bounds()); r = frame; @@ -463,16 +463,16 @@ RecorderWindow::InitWindow() r.bottom -= 1; BStringView* lenUnits = new BStringView(r, "Seconds", "seconds"); fBottomBox->AddChild(lenUnits); - + fBottomBox->AddChild(fFileInfoBox); - + fBottomBox->Hide(); CalcSizes(Frame().Width(), MIN_HEIGHT-161); ResizeTo(Frame().Width(), MIN_HEIGHT-161); - + popup->Superitem()->SetLabel(selected_name); - + // Make sure the save panel is happy. fSavePanel = new BFilePanel(B_SAVE_PANEL); fSavePanel->SetTarget(this); @@ -491,7 +491,7 @@ bad_mojo: if (fRecordNode) { fRecordNode->Release(); } - + delete fPlayer; if (!fInputField) { delete popup; @@ -565,7 +565,7 @@ RecorderWindow::MessageReceived(BMessage * message) fBottomBox->Hide(); CalcSizes(Frame().Width(), MIN_HEIGHT-161); ResizeTo(Frame().Width(), MIN_HEIGHT-161); - + } break; case UPDATE_TRACKSLIDER: @@ -613,7 +613,7 @@ RecorderWindow::MessageReceived(BMessage * message) void RecorderWindow::Record(BMessage * message) -{ +{ // User pressed Record button fRecording = true; int seconds = atoi(fLengthControl->Text()); @@ -693,29 +693,29 @@ RecorderWindow::Play(BMessage * message) fPlayer->SetHasData(!fPlayer->HasData()); return; } - + SetButtonState(btnPlaying); fPlayButton->SetPlaying(); - + if (!fPlayTrack) { ErrorAlert("get the file to play", B_ERROR); return; } - + fPlayLimit = MIN(fPlayFrames, (off_t)(fTrackSlider->RightTime()*fPlayFormat.u.raw_audio.frame_rate/1000000LL)); fPlayTrack->SeekToTime(fTrackSlider->MainTime()); fPlayFrame = fPlayTrack->CurrentFrame(); - + // Create our internal Node which plays sound, and register it. fPlayer = new BSoundPlayer(fAudioMixerNode, &fPlayFormat.u.raw_audio, "Sound Player"); status_t err = fPlayer->InitCheck(); if (err < B_OK) { return; } - + fVolumeSlider->SetSoundPlayer(fPlayer); fPlayer->SetCallbacks(PlayFile, NotifyPlayFile, this); - + // And get it going... fPlayer->Start(); fPlayer->SetHasData(true); @@ -741,14 +741,14 @@ RecorderWindow::Save(BMessage * message) if ((! pItem) || (pItem->Entry().InitCheck() != B_OK)) { return; } - + // Update the save panel and show it. char filename[B_FILE_NAME_LENGTH]; pItem->Entry().GetName(filename); BMessage saveMsg(B_SAVE_REQUESTED); entry_ref ref; pItem->Entry().GetRef(&ref); - + saveMsg.AddPointer("sound list item", pItem); fSavePanel->SetSaveText(filename); fSavePanel->SetMessage(&saveMsg); @@ -765,7 +765,7 @@ RecorderWindow::DoSave(BMessage * message) entry_ref old_ref, new_dir_ref; const char* new_name; SoundListItem* pItem; - + if ((message->FindPointer("sound list item", (void**) &pItem) == B_OK) && (message->FindRef("directory", &new_dir_ref) == B_OK) && (message->FindString("name", &new_name) == B_OK)) @@ -778,15 +778,15 @@ RecorderWindow::DoSave(BMessage * message) BDirectory newDir(&new_dir_ref); if (newDir.InitCheck() != B_OK) return; - - BFile newFile; - newDir.CreateFile(new_name, &newFile); - + + BFile newFile; + newDir.CreateFile(new_name, &newFile); + if (newFile.InitCheck() != B_OK) return; - + status_t err = CopyFile(newFile, oldFile); - + if (err == B_OK) { // clean up the sound list and item if (pItem->IsTemp()) @@ -840,7 +840,7 @@ RecorderWindow::Input(BMessage * message) if (message->FindData("node", B_RAW_TYPE, (const void **)&dni, &size)) { return; // bad input selection message } - + media_node_id node_id; status_t error = fRoster->GetInstancesFor(dni->addon, dni->flavor_id, &node_id); if (error != B_OK) { @@ -862,7 +862,7 @@ status_t RecorderWindow::MakeRecordConnection(const media_node & input) { CONNECT((stderr, "RecorderWindow::MakeRecordConnection()\n")); - + // Find an available output for the given input node. int32 count = 0; status_t err = fRoster->GetFreeOutputsFor(input, &fAudioOutput, 1, &count, B_MEDIA_RAW_AUDIO); @@ -968,7 +968,7 @@ RecorderWindow::StopRecording() BreakRecordConnection(); fRecordNode->SetHooks(NULL,NULL,NULL); if (fRecSize > 0) { - + wave_struct header; header.riff.riff_id = FOURCC('R','I','F','F'); header.riff.len = fRecSize + 36; @@ -985,7 +985,7 @@ RecorderWindow::StopRecording() header.data_chunk.len = fRecSize; fRecFile.Seek(0, SEEK_SET); fRecFile.Write(&header, sizeof(header)); - + fRecFile.SetSize(fRecSize + sizeof(header)); // We reserve space; make sure we cut off any excess at the end. AddSoundItem(fRecEntry, true); } @@ -1001,7 +1001,7 @@ RecorderWindow::StopRecording() fRecSize = 0; SetButtonState(btnPaused); fRecordButton->SetStopped(); - + return B_OK; } @@ -1020,7 +1020,7 @@ RecorderWindow::StopPlaying() fPlayButton->SetStopped(); fTrackSlider->ResetMainTime(); fScopeView->SetMainTime(*fTrackSlider->MainTime()); - return B_OK; + return B_OK; } @@ -1050,7 +1050,7 @@ RecorderWindow::UpdateButtons() extern "C" status_t DecodedFormat__11BMediaTrackP12media_format(BMediaTrack *self, media_format *inout_format); #endif -void +void RecorderWindow::UpdatePlayFile() { // Get selection. @@ -1059,7 +1059,7 @@ RecorderWindow::UpdatePlayFile() if (! pItem) { return; } - + if (fPlayTrack && fPlayFile) fPlayFile->ReleaseTrack(fPlayTrack); if (fPlayFile) @@ -1077,12 +1077,12 @@ RecorderWindow::UpdatePlayFile() delete fPlayFile; return; } - + for (int ix=0; ixCountTracks(); ix++) { BMediaTrack * track = fPlayFile->TrackAt(ix); fPlayFormat.type = B_MEDIA_RAW_AUDIO; #ifdef __HAIKU__ - if ((track->DecodedFormat(&fPlayFormat) == B_OK) + if ((track->DecodedFormat(&fPlayFormat) == B_OK) #else if ((DecodedFormat__11BMediaTrackP12media_format(track, &fPlayFormat) == B_OK) #endif @@ -1093,13 +1093,13 @@ RecorderWindow::UpdatePlayFile() if (track) fPlayFile->ReleaseTrack(track); } - + if (!fPlayTrack) { ErrorAlert("get the file to play", err); delete fPlayFile; return; } - + BString filename = "File Name: "; filename << ref.name; fFilename->SetText(filename.String()); @@ -1124,22 +1124,22 @@ RecorderWindow::UpdatePlayFile() samplerate << (int)fPlayFormat.u.raw_audio.frame_rate; BString durationString = "Duration: "; bigtime_t duration = fPlayTrack->Duration(); - durationString << (float)(duration / 1000000.0) << " seconds"; - + durationString << (float)(duration / 1000000.0) << " seconds"; + fFormat->SetText(format.String()); fCompression->SetText(compression.String()); fChannels->SetText(channels.String()); fSampleSize->SetText(samplesize.String()); fSampleRate->SetText(samplerate.String()); fDuration->SetText(durationString.String()); - + fTrackSlider->SetTotalTime(duration, true); fScopeView->SetMainTime(fTrackSlider->LeftTime()); fScopeView->SetTotalTime(duration); fScopeView->SetRightTime(fTrackSlider->RightTime()); fScopeView->SetLeftTime(fTrackSlider->LeftTime()); fScopeView->RenderTrack(fPlayTrack, fPlayFormat); - + fPlayFrames = fPlayTrack->CountFrames(); } @@ -1204,7 +1204,7 @@ RecorderWindow::RecordFile(void * cookie, bigtime_t timestamp, void * data, size // Callback called from the SoundConsumer when receiving buffers. assert((format.format & 0x02) && format.channel_count); RecorderWindow * window = (RecorderWindow *)cookie; - + if (window->fRecording) { // Write the data to file (we don't buffer or guard file access // or anything) @@ -1234,12 +1234,12 @@ RecorderWindow::NotifyRecordFile(void * cookie, int32 code, ...) void RecorderWindow::PlayFile(void * cookie, void * data, size_t size, const media_raw_audio_format & format) -{ +{ // Callback called from the SoundProducer when producing buffers. RecorderWindow * window = (RecorderWindow *)cookie; int32 frame_size = (window->fPlayFormat.u.raw_audio.format & 0xf) * window->fPlayFormat.u.raw_audio.channel_count; - + if ((window->fPlayFrame < window->fPlayLimit) || window->fLooping) { if (window->fPlayFrame >= window->fPlayLimit) { bigtime_t left = window->fTrackSlider->LeftTime(); @@ -1269,22 +1269,22 @@ RecorderWindow::NotifyPlayFile(void * cookie, BSoundPlayer::sound_player_notific } -void +void RecorderWindow::RefsReceived(BMessage *msg) { entry_ref ref; int32 i = 0; - + while (msg->FindRef("refs", i++, &ref) == B_OK) { - + BEntry entry(&ref, true); BPath path(&entry); BNode node(&entry); - + if (node.IsFile()) { AddSoundItem(entry, false); } else if(node.IsDirectory()) { - + } } } diff --git a/src/apps/text_search/GrepWindow.cpp b/src/apps/text_search/GrepWindow.cpp index 41c261f853..4a4dee5de3 100644 --- a/src/apps/text_search/GrepWindow.cpp +++ b/src/apps/text_search/GrepWindow.cpp @@ -1,22 +1,22 @@ /* * Copyright (c) 1998-2007 Matthijs Hollemans - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in + * + * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #include "GrepWindow.h" @@ -141,7 +141,7 @@ GrepWindow::GrepWindow(BMessage* message) _LoadPrefs(); _TileIfMultipleWindows(); - Show(); + Show(); } @@ -404,7 +404,7 @@ GrepWindow::_SetWindowTitle() if (!title.Length()) title = APP_NAME; - + SetTitle(title.String()); } @@ -419,34 +419,34 @@ GrepWindow::_CreateMenus() fPreferencesMenu = new BMenu(_T("Preferences")); fHistoryMenu = new BMenu(_T("History")); fEncodingMenu = new BMenu(_T("Encoding")); - + fNew = new BMenuItem( _T("New Window"), new BMessage(MSG_NEW_WINDOW), 'N'); - + fOpen = new BMenuItem( _T("Set Which Files to Search"), new BMessage(MSG_OPEN_PANEL), 'F'); fClose = new BMenuItem( _T("Close"), new BMessage(B_QUIT_REQUESTED), 'W'); - + fAbout = new BMenuItem( _T("About"), new BMessage(B_ABOUT_REQUESTED)); fQuit = new BMenuItem( _T("Quit"), new BMessage(MSG_QUIT_NOW), 'Q'); - + fSearch = new BMenuItem( _T("Search"), new BMessage(MSG_START_CANCEL), 'S'); - + fSelectAll = new BMenuItem( _T("Select All"), new BMessage(MSG_SELECT_ALL), 'A'); - + fTrimSelection = new BMenuItem( _T("Trim to Selection"), new BMessage(MSG_TRIM_SELECTION), 'T'); - + fOpenSelection = new BMenuItem( _T("Open Selection"), new BMessage(MSG_OPEN_SELECTION), 'O'); - + fSelectInTracker = new BMenuItem( _T("Show Files in Tracker"), new BMessage(MSG_SELECT_IN_TRACKER), 'K'); @@ -477,12 +477,12 @@ GrepWindow::_CreateMenus() fShowLinesMenuitem = new BMenuItem( _T("Show Lines"), new BMessage(MSG_MENU_SHOW_LINES), 'L'); fShowLinesMenuitem->SetMarked(true); - + fUTF8 = new BMenuItem("UTF8", new BMessage('utf8')); fShiftJIS = new BMenuItem("ShiftJIS", new BMessage(B_SJIS_CONVERSION)); fEUC = new BMenuItem("EUC", new BMessage(B_EUC_CONVERSION)); fJIS = new BMenuItem("JIS", new BMessage(B_JIS_CONVERSION)); - + fFileMenu->AddItem(fNew); fFileMenu->AddSeparatorItem(); fFileMenu->AddItem(fOpen); @@ -491,7 +491,7 @@ GrepWindow::_CreateMenus() fFileMenu->AddItem(fAbout); fFileMenu->AddSeparatorItem(); fFileMenu->AddItem(fQuit); - + fActionMenu->AddItem(fSearch); fActionMenu->AddSeparatorItem(); fActionMenu->AddItem(fSelectAll); @@ -500,7 +500,7 @@ GrepWindow::_CreateMenus() fActionMenu->AddItem(fOpenSelection); fActionMenu->AddItem(fSelectInTracker); fActionMenu->AddItem(fCopyText); - + fPreferencesMenu->AddItem(fRecurseLinks); fPreferencesMenu->AddItem(fRecurseDirs); fPreferencesMenu->AddItem(fSkipDotDirs); @@ -510,7 +510,7 @@ GrepWindow::_CreateMenus() fPreferencesMenu->AddItem(fInvokePe); fPreferencesMenu->AddSeparatorItem(); fPreferencesMenu->AddItem(fShowLinesMenuitem); - + fEncodingMenu->AddItem(fUTF8); fEncodingMenu->AddItem(fShiftJIS); fEncodingMenu->AddItem(fEUC); @@ -526,10 +526,10 @@ GrepWindow::_CreateMenus() fMenuBar->AddItem(fPreferencesMenu); fMenuBar->AddItem(fHistoryMenu); fMenuBar->AddItem(fEncodingMenu); - + AddChild(fMenuBar); SetKeyMenuBar(fMenuBar); - + fSearch->SetEnabled(false); } @@ -537,16 +537,16 @@ GrepWindow::_CreateMenus() void GrepWindow::_CreateViews() { - // The search pattern entry field does not send a message when - // is pressed, because the "Search/Cancel" button already + // The search pattern entry field does not send a message when + // is pressed, because the "Search/Cancel" button already // does this and we don't want to send the same message twice. fSearchText = new BTextControl( BRect(0, 0, 0, 1), "SearchText", NULL, NULL, NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, - B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_NAVIGABLE); - - fSearchText->TextView()->SetMaxBytes(1000); + B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_NAVIGABLE); + + fSearchText->TextView()->SetMaxBytes(1000); fSearchText->ResizeToPreferred(); // because it doesn't have a label @@ -555,23 +555,23 @@ GrepWindow::_CreateViews() fButton = new BButton( BRect(0, 1, 80, 1), "Button", _T("Search"), new BMessage(MSG_START_CANCEL), B_FOLLOW_RIGHT); - + fButton->MakeDefault(true); fButton->ResizeToPreferred(); fButton->SetEnabled(false); - + fShowLinesCheckbox = new BCheckBox( BRect(0, 0, 1, 1), "ShowLines", _T("Show Lines"), new BMessage(MSG_CHECKBOX_SHOW_LINES), B_FOLLOW_LEFT); - + fShowLinesCheckbox->SetValue(B_CONTROL_ON); fShowLinesCheckbox->ResizeToPreferred(); - - fSearchResults = new GrepListView(); + + fSearchResults = new GrepListView(); fSearchResults->SetInvocationMessage(new BMessage(MSG_INVOKE_ITEM)); fSearchResults->ResizeToPreferred(); -} +} void @@ -581,13 +581,13 @@ GrepWindow::_LayoutViews() fMenuBar->GetPreferredSize(&menubarWidth, &menubarHeight); BBox *background = new BBox( - BRect(0, menubarHeight + 1, 2, menubarHeight + 2), B_EMPTY_STRING, - B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, - B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, - B_PLAIN_BORDER); + BRect(0, menubarHeight + 1, 2, menubarHeight + 2), B_EMPTY_STRING, + B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, + B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, + B_PLAIN_BORDER); BScrollView *scroller = new BScrollView( - "ScrollSearchResults", fSearchResults, B_FOLLOW_ALL_SIDES, + "ScrollSearchResults", fSearchResults, B_FOLLOW_ALL_SIDES, B_FULL_UPDATE_ON_RESIZE, true, true, B_NO_BORDER); scroller->ResizeToPreferred(); @@ -601,7 +601,7 @@ GrepWindow::_LayoutViews() float backgroundHeight = 8 + fSearchText->Frame().Height() + 8 + fButton->Frame().Height() + 8; - ResizeTo(width, height); + ResizeTo(width, height); AddChild(background); background->ResizeTo(width, backgroundHeight); @@ -641,15 +641,15 @@ GrepWindow::_TileIfMultipleWindows() if (be_app->Lock()) { int32 windowCount = be_app->CountWindows(); be_app->Unlock(); - + if (windowCount > 1) - MoveBy(20,20); + MoveBy(20,20); } - + BScreen screen(this); BRect screenFrame = screen.Frame(); BRect windowFrame = Frame(); - + if (windowFrame.left > screenFrame.right || windowFrame.top > screenFrame.bottom || windowFrame.right < screenFrame.left @@ -788,16 +788,16 @@ GrepWindow::_OnStartCancel() fPreferencesMenu->SetEnabled(false); fHistoryMenu->SetEnabled(false); fEncodingMenu->SetEnabled(false); - + fSearchText->SetEnabled(false); fButton->MakeFocus(true); fButton->SetLabel(_T("Cancel")); fSearch->SetEnabled(false); - // We need to remember the search pattern, because during - // the grepping, the text control's text will be replaced - // by the name of the file that's currently being grepped. + // We need to remember the search pattern, because during + // the grepping, the text control's text will be replaced + // by the name of the file that's currently being grepped. // When the grepping finishes, we need to restore the old // search pattern. @@ -1102,7 +1102,7 @@ GrepWindow::_OnRecurseDirs() _ModelChanged(); } - + void GrepWindow::_OnSkipDotDirs() { @@ -1120,7 +1120,7 @@ GrepWindow::_OnEscapeText() _ModelChanged(); } - + void GrepWindow::_OnCaseSensitive() { @@ -1154,30 +1154,30 @@ GrepWindow::_OnCheckboxShowLines() // toggle checkbox and menuitem fModel->fShowContents = !fModel->fShowContents; fShowLinesMenuitem->SetMarked(!fShowLinesMenuitem->IsMarked()); - + // Selection in BOutlineListView in multiple selection mode // gets weird when collapsing. I've tried all sorts of things. // It seems impossible to make it behave just right. - + // Going from collapsed to expande mode, the superitems - // keep their selection, the subitems don't (yet) have + // keep their selection, the subitems don't (yet) have // a selection. This works as expected, AFAIK. - + // Going from expanded to collapsed mode, I would like // for a selected subitem (line) to select its superitem, - // (its file) and the subitem be unselected. - + // (its file) and the subitem be unselected. + // I've successfully tried code patches that apply the // selection pattern that I want, but with weird effects - // on subsequent manual selection. + // on subsequent manual selection. // Lines stay selected while the user tries to select - // some other line. It just gets weird. - - // It's as though listItem->Select() and Deselect() + // some other line. It just gets weird. + + // It's as though listItem->Select() and Deselect() // put the items in some semi-selected state. // Or maybe I've got it all wrong. - - // So, here's the plain basic collapse/expand. + + // So, here's the plain basic collapse/expand. // I think it's the least bad of what's possible on BeOS R5, // but perhaps someone comes along with a patch of magic. @@ -1214,7 +1214,7 @@ void GrepWindow::_OnInvokeItem() { for (int32 selectionIndex = 0; ; selectionIndex++) { - int32 itemIndex = fSearchResults->CurrentSelection(selectionIndex); + int32 itemIndex = fSearchResults->CurrentSelection(selectionIndex); BListItem* item = fSearchResults->ItemAt(itemIndex); if (item == NULL) break; @@ -1298,7 +1298,7 @@ GrepWindow::_OnTrimSelection() fSearchResults->ItemAt(index)); if (item == NULL) break; - + if (!item->IsSelected() || item->OutlineLevel() != 0) continue; @@ -1327,7 +1327,7 @@ void GrepWindow::_OnCopyText() { bool onlyCopySelection = true; - + if (fSearchResults->CurrentSelection() < 0) onlyCopySelection = false; @@ -1352,11 +1352,11 @@ GrepWindow::_OnCopyText() if (be_clipboard->Lock()) { be_clipboard->Clear(); - + clip = be_clipboard->Data(); clip->AddData("text/plain", B_MIME_TYPE, buffer.String(), - buffer.Length()); + buffer.Length()); status = be_clipboard->Commit(); @@ -1408,7 +1408,7 @@ GrepWindow::_OnSelectInTracker() continue; message.AddRef("refs", &file_ref); - + // add parent folder to list of folders to open folderPath.SetTo(filePath.String()); if (folderPath.GetParent(&folderPath) == B_OK) { @@ -1434,7 +1434,7 @@ GrepWindow::_OnSelectInTracker() snooze(aShortWhile); _OpenFoldersInTracker(&folderList); } - } + } if (!_AreAllFoldersOpenInTracker(&folderList)) { BAlert* alert = new BAlert(NULL, @@ -1448,7 +1448,7 @@ GrepWindow::_OnSelectInTracker() _SelectFilesInTracker(&folderList, &message); -out: +out: // delete folderList contents int32 folderCount = folderList.CountItems(); for (int32 x = 0; x < folderCount; x++) @@ -1476,7 +1476,7 @@ GrepWindow::_OnAboutRequested() BString fAppVersion; if (be_app->Lock()) { - be_app->GetAppInfo(&appInfo); + be_app->GetAppInfo(&appInfo); appFile.SetTo(&appInfo.ref, B_READ_ONLY); appFileInfo.SetTo(&appFile); if (appFileInfo.GetVersionInfo(&vInfo, B_APP_VERSION_KIND) == B_OK) @@ -1484,7 +1484,7 @@ GrepWindow::_OnAboutRequested() be_app->Unlock(); } - BString text; + BString text; text << APP_NAME << " " << fAppVersion << "\n"; int32 titleLength = text.Length(); text << _T("Get a grip on grep.") << "\n\n"; @@ -1498,10 +1498,10 @@ GrepWindow::_OnAboutRequested() text << _T("Peter Hinely, Serge Fantino, Hideki Naito, Oscar Lesta, " "Oliver Tappe, Luc Schrijvers and momoziro."); text << "\n"; - + BAlert* alert = new BAlert("Tracker Grep", text.String(), _T("Ok"), NULL, NULL, B_WIDTH_AS_USUAL, B_INFO_ALERT); - + BTextView* view = alert->TextView(); BFont font; view->SetStylable(true); @@ -1558,7 +1558,7 @@ GrepWindow::_OnOpenPanel() return; fFilePanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(NULL, this), - &path, B_FILE_NODE|B_DIRECTORY_NODE|B_SYMLINK_NODE, + &path, B_FILE_NODE|B_DIRECTORY_NODE|B_SYMLINK_NODE, true, new BMessage(MSG_REFS_RECEIVED), NULL, true, true); fFilePanel->Show(); @@ -1660,7 +1660,7 @@ GrepWindow::_RemoveFolderListDuplicates(BList* folderList) y--; } } - } + } } @@ -1669,11 +1669,11 @@ GrepWindow::_OpenFoldersInTracker(BList* folderList) { status_t status = B_OK; BMessage refsMsg(B_REFS_RECEIVED); - + int32 folderCount = folderList->CountItems(); for (int32 index = 0; index < folderCount; index++) { BPath* path = static_cast(folderList->ItemAt(index)); - + entry_ref folderRef; status = get_ref_for_path(path->Path(), &folderRef); if (status != B_OK) @@ -1682,7 +1682,7 @@ GrepWindow::_OpenFoldersInTracker(BList* folderList) status = refsMsg.AddRef("refs", &folderRef); if (status != B_OK) return status; - } + } status = be_roster->Launch(TRACKER_SIGNATURE, &refsMsg); if (status != B_OK && status != B_ALREADY_RUNNING) @@ -1695,7 +1695,7 @@ GrepWindow::_OpenFoldersInTracker(BList* folderList) bool GrepWindow::_AreAllFoldersOpenInTracker(BList *folderList) { - // Compare the folders we want open in Tracker to + // Compare the folders we want open in Tracker to // the actual Tracker windows currently open. // We build a list of open Tracker windows, and compare @@ -1711,12 +1711,12 @@ GrepWindow::_AreAllFoldersOpenInTracker(BList *folderList) BList windowList; if (!trackerMessenger.IsValid()) - return false; + return false; for (int32 count = 1; ; count++) { sendMessage.MakeEmpty(); replyMessage.MakeEmpty(); - + sendMessage.what = B_GET_PROPERTY; sendMessage.AddSpecifier("Path"); sendMessage.AddSpecifier("Poses"); @@ -1725,7 +1725,7 @@ GrepWindow::_AreAllFoldersOpenInTracker(BList *folderList) status = trackerMessenger.SendMessage(&sendMessage, &replyMessage); if (status != B_OK) return false; - + entry_ref* trackerRef = new (nothrow) entry_ref; status = replyMessage.FindRef("result", trackerRef); if (status != B_OK || !windowList.AddItem(trackerRef)) { @@ -1752,18 +1752,18 @@ GrepWindow::_AreAllFoldersOpenInTracker(BList *folderList) // Loop over the two lists and see if all folders exist as window for (int32 x = 0; x < folderCount; x++) { for (int32 y = 0; y < windowCount; y++) { - + folderPath = static_cast(folderList->ItemAt(x)); windowRef = static_cast(windowList.ItemAt(y)); - + if (folderPath == NULL) break; - + if (windowRef == NULL) break; - + folderString = folderPath->Path(); - + BEntry entry; BPath path; @@ -1803,16 +1803,16 @@ GrepWindow::_SelectFilesInTracker(BList* folderList, BMessage* refsMessage) BMessage windowReplyMessage; BMessage selectionSendMessage; BMessage selectionReplyMessage; - + if (!trackerMessenger.IsValid()) - return status; - + return status; + // loop over Tracker windows for (int32 windowCount = 1; ; windowCount++) { - + windowSendMessage.MakeEmpty(); windowReplyMessage.MakeEmpty(); - + windowSendMessage.what = B_GET_PROPERTY; windowSendMessage.AddSpecifier("Path"); windowSendMessage.AddSpecifier("Poses"); @@ -1861,7 +1861,7 @@ GrepWindow::_SelectFilesInTracker(BList* folderList, BMessage* refsMessage) selectionSendMessage.MakeEmpty(); selectionSendMessage.what = B_SET_PROPERTY; selectionReplyMessage.MakeEmpty(); - + // loop over refs and add to message entry_ref ref; for (int32 index = 0; ; index++) { @@ -1877,11 +1877,11 @@ GrepWindow::_SelectFilesInTracker(BList* folderList, BMessage* refsMessage) // finish selection message selectionSendMessage.AddSpecifier("Selection"); - selectionSendMessage.AddSpecifier("Poses"); - selectionSendMessage.AddSpecifier("Window", windowCount); + selectionSendMessage.AddSpecifier("Poses"); + selectionSendMessage.AddSpecifier("Window", windowCount); trackerMessenger.SendMessage(&selectionSendMessage, - &selectionReplyMessage); + &selectionReplyMessage); } } } diff --git a/src/kits/tracker/InfoWindow.cpp b/src/kits/tracker/InfoWindow.cpp index 6673e0cd7e..84c987e82a 100644 --- a/src/kits/tracker/InfoWindow.cpp +++ b/src/kits/tracker/InfoWindow.cpp @@ -99,7 +99,7 @@ class TrackingView : public BControl { bool fMouseInView; }; -class AttributeView : public BView { +class AttributeView : public BView { public: AttributeView(BRect, Model *); ~AttributeView(); @@ -229,7 +229,7 @@ OpenParentAndSelectOriginal(const entry_ref *ref) BEntry entry(ref); node_ref node; entry.GetNodeRef(&node); - + BEntry parent; entry.GetParent(&parent); entry_ref parentRef; @@ -238,7 +238,7 @@ OpenParentAndSelectOriginal(const entry_ref *ref) BMessage message(B_REFS_RECEIVED); message.AddRef("refs", &parentRef); message.AddData("nodeRefToSelect", B_RAW_TYPE, &node, sizeof(node_ref)); - + be_app->PostMessage(&message); } @@ -413,7 +413,7 @@ void BInfoWindow::MessageReceived(BMessage *message) { switch (message->what) { - case kRestoreState: + case kRestoreState: Show(); break; @@ -421,7 +421,7 @@ BInfoWindow::MessageReceived(BMessage *message) { BMessage refsMessage(B_REFS_RECEIVED); refsMessage.AddRef("refs", fModel->EntryRef()); - + // add a messenger to the launch message that will be used to // dispatch scripting calls from apps to the PoseView refsMessage.AddMessenger("TrackerViewToken", BMessenger(this)); @@ -443,7 +443,7 @@ BInfoWindow::MessageReceived(BMessage *message) BEntry entry; if (entry.SetTo(fModel->EntryRef(), true) == B_OK) { BPath path; - if (entry.GetPath(&path) == B_OK) + if (entry.GetPath(&path) == B_OK) update_mime_info(path.Path(), true, false, force ? 2 : 1); } break; @@ -452,29 +452,29 @@ BInfoWindow::MessageReceived(BMessage *message) case kRecalculateSize: { fStopCalc = true; - + // Wait until any current CalcSize thread has terminated before // starting a new one status_t result; wait_for_thread(fCalcThreadID, &result); - - // Start recalculating.. + + // Start recalculating.. fStopCalc = false; SetSizeStr("calculating" B_UTF8_ELLIPSIS); fCalcThreadID = spawn_thread(BInfoWindow::CalcSize, "CalcSize", B_NORMAL_PRIORITY, this); resume_thread(fCalcThreadID); - + break; } - case kSetLinkTarget: + case kSetLinkTarget: OpenFilePanel(fModel->EntryRef()); break; // An item was dropped into the window case B_SIMPLE_DATA: // If we are not a SymLink, just ignore the request - if (!fModel->IsSymLink()) + if (!fModel->IsSymLink()) break; // supposed to fall through @@ -537,16 +537,16 @@ BInfoWindow::MessageReceived(BMessage *message) AttributeStreamFileNode newNode(TargetModel()->Node()); newNode << memoryNode; - // Start watching this again + // Start watching this again TTracker::WatchNode(TargetModel()->NodeRef(), B_WATCH_ALL | B_WATCH_MOUNT, this); - // Tell the attribute view about this new model + // Tell the attribute view about this new model fAttributeView->ReLinkTargetModel(TargetModel()); } break; } - case B_CANCEL: + case B_CANCEL: // File panel window has closed delete fFilePanel; fFilePanel = NULL; @@ -572,7 +572,7 @@ BInfoWindow::MessageReceived(BMessage *message) } break; - case kEmptyTrash: + case kEmptyTrash: FSEmptyTrash(); break; @@ -584,14 +584,14 @@ BInfoWindow::MessageReceived(BMessage *message) message->FindInt32("device", &itemNode.device); message->FindInt64("node", &itemNode.node); // our window itself may be deleted - if (*TargetModel()->NodeRef() == itemNode) + if (*TargetModel()->NodeRef() == itemNode) Close(); break; } case B_ENTRY_MOVED: case B_STAT_CHANGED: - case B_ATTR_CHANGED: + case B_ATTR_CHANGED: fAttributeView->ModelChanged(TargetModel(), message); // must be called before the FilePermissionView::ModelChanged() // call, because it changes the model... (bad style!) @@ -613,7 +613,7 @@ BInfoWindow::MessageReceived(BMessage *message) break; } - default: + default: break; } break; @@ -623,7 +623,7 @@ BInfoWindow::MessageReceived(BMessage *message) // Only true on first call. fPermissionsView = new FilePermissionsView(BRect(kBorderWidth + 1, fAttributeView->Bounds().bottom, fAttributeView->Bounds().right, - fAttributeView->Bounds().bottom+80), fModel); + fAttributeView->Bounds().bottom+80), fModel); ResizeBy(0, fPermissionsView->Bounds().Height()); fAttributeView->AddChild(fPermissionsView); @@ -661,7 +661,7 @@ BInfoWindow::GetSizeString(BString &result, off_t size, int32 fileCount) charsTillComma = 3; uint32 numberIndex = 0; - + while (numStr[numberIndex]) { bytes += numStr[numberIndex++]; if (--charsTillComma == 0 && numStr[numberIndex]) { @@ -671,8 +671,8 @@ BInfoWindow::GetSizeString(BString &result, off_t size, int32 fileCount) } } else bytes = numStr; - - if (size >= kGBSize) + + if (size >= kGBSize) PrintFloat(result, (float)size / kGBSize) << " GB"; else if (size >= kMBSize) PrintFloat(result, (float)size / kMBSize) << " MB"; @@ -700,7 +700,7 @@ BInfoWindow::CalcSize(void *castToWindow) BInfoWindow *window = static_cast(castToWindow); BDirectory dir(window->TargetModel()->EntryRef()); BDirectory trashDir; - FSGetTrashDir(&trashDir, window->TargetModel()->EntryRef()->device); + FSGetTrashDir(&trashDir, window->TargetModel()->EntryRef()->device); if (dir.InitCheck() != B_OK) { if (window->StopCalc()) return B_ERROR; @@ -749,13 +749,13 @@ BInfoWindow::CalcSize(void *castToWindow) BDirectory trashDir; if (FSGetTrashDir(&trashDir, volume.Device()) == B_OK) { - FSRecursiveCalcSize(window, &trashDir, ¤tSize, + FSRecursiveCalcSize(window, &trashDir, ¤tSize, ¤tFileCount, ¤tDirCount); totalSize += currentSize; totalFileCount += currentFileCount; totalDirCount += currentDirCount; } - } + } GetSizeString(sizeString, totalSize, totalFileCount); } @@ -764,7 +764,7 @@ BInfoWindow::CalcSize(void *castToWindow) return B_OK; AutoLock lock(window); - if (lock.IsLocked()) + if (lock.IsLocked()) window->SetSizeStr(sizeString.String()); return B_OK; @@ -850,7 +850,7 @@ AttributeView::AttributeView(BRect rect, Model *model) // The title rect // The magic numbers are used to properly calculate the rect so that // when the editing text view is displayed, the position of the text - // does not change. + // does not change. BFont currentFont; font_height fontMetrics; GetFont(¤tFont); @@ -931,7 +931,7 @@ AttributeView::AttributeView(BRect rect, Model *model) if (err != B_OK) result = new BMenuItem(signature, itemMessage); - else + else result = new BMenuItem(entry.name, itemMessage); result->SetTarget(this); @@ -981,7 +981,7 @@ AttributeView::~AttributeView() if (fModel->IsSymLink() && fIconModel != fModel) delete fIconModel; } - + void AttributeView::InitStrings(const Model *model) @@ -1019,7 +1019,7 @@ AttributeView::InitStrings(const Model *model) BEntry entry(traversedPath.Path(), false); // look at the target itself if (entry.InitCheck() == B_OK && entry.Exists()) linked = true; - } + } } // always show the target as it is: absolute or relative! @@ -1109,7 +1109,7 @@ AttributeView::ModelChanged(Model *model, BMessage *message) break; } - case B_STAT_CHANGED: + case B_STAT_CHANGED: if (model->OpenNode() == B_OK) { WidgetAttributeText::AttrAsString(model, &fCreatedStr, kAttrStatCreated, B_TIME_TYPE, drawBounds.Width() - kBorderMargin, this); @@ -1298,21 +1298,21 @@ AttributeView::MouseMoved(BPoint point, uint32, const BMessage *message) } switch (fTrackingState) { - case link_track: + case link_track: if (fLinkRect.Contains(point) != fMouseDown) { fMouseDown = !fMouseDown; InvertRect(fLinkRect); } break; - case path_track: + case path_track: if (fPathRect.Contains(point) != fMouseDown) { fMouseDown = !fMouseDown; InvertRect(fPathRect); } break; - case size_track: + case size_track: if (fSizeRect.Contains(point) != fMouseDown) { fMouseDown = !fMouseDown; InvertRect(fSizeRect); @@ -1354,7 +1354,7 @@ AttributeView::MouseMoved(BPoint point, uint32, const BMessage *message) // See if we need to truncate the string BString nameString(fModel->Name()); - if (view->StringWidth(fModel->Name()) > rect.Width()) + if (view->StringWidth(fModel->Name()) > rect.Width()) view->TruncateString(&nameString, B_TRUNCATE_END, rect.Width() - 5); // Draw the label @@ -1367,7 +1367,7 @@ AttributeView::MouseMoved(BPoint point, uint32, const BMessage *message) view->Sync(); dragBitmap->Unlock(); - + BMessage message(B_REFS_RECEIVED); message.AddPoint("click_pt", fClickPoint); BPoint tmpLoc; @@ -1452,7 +1452,7 @@ AttributeView::MouseMoved(BPoint point, uint32, const BMessage *message) void AttributeView::OpenLinkSource() { - OpenParentAndSelectOriginal(fModel->EntryRef()); + OpenParentAndSelectOriginal(fModel->EntryRef()); } @@ -1473,14 +1473,14 @@ AttributeView::OpenLinkTarget() if (entry.InitCheck() != B_OK || !entry.Exists()) { // Open a file dialog panel to allow the user to relink. BInfoWindow *window = dynamic_cast(Window()); - if (window) + if (window) window->OpenFilePanel(fModel->EntryRef()); } else { entry_ref ref; entry.GetRef(&ref); BPath path(&ref); printf("Opening link target: %s\n", path.Path()); - OpenParentAndSelectOriginal(&ref); + OpenParentAndSelectOriginal(&ref); } } @@ -1520,7 +1520,7 @@ AttributeView::MouseUp(BPoint point) fMouseDown = false; fDragging = false; fTrackingState = no_track; - + } @@ -1654,7 +1654,7 @@ AttributeView::Draw(BRect) float lineHeight = 0; float lineBase = 0; // Draw the main title if the user is not currently editing it - if (fTitleEditView == NULL) { + if (fTitleEditView == NULL) { SetFont(be_bold_font); SetFontSize(kTitleFontHeight); GetFont(¤tFont); @@ -1715,7 +1715,7 @@ AttributeView::Draw(BRect) lineBase += lineHeight; // Created - SetHighColor(kAttrTitleColor); + SetHighColor(kAttrTitleColor); MovePenTo(BPoint(fDivider - (StringWidth("Created:")), lineBase)); SetHighColor(kAttrTitleColor); DrawString("Created:"); @@ -1759,7 +1759,7 @@ AttributeView::Draw(BRect) TruncateString(&nameString, B_TRUNCATE_MIDDLE, Bounds().Width() - (fDivider + kBorderMargin)); DrawString(nameString.String()); - } else + } else DrawString(fPathStr.String()); // Cache the position of the path @@ -1781,7 +1781,7 @@ AttributeView::Draw(BRect) // Check for truncation if (StringWidth(fLinkToStr.String()) > (Bounds().Width() - (fDivider + kBorderMargin))) { BString nameString(fLinkToStr.String()); - TruncateString(&nameString, B_TRUNCATE_MIDDLE, + TruncateString(&nameString, B_TRUNCATE_MIDDLE, Bounds().Width() - (fDivider + kBorderMargin)); DrawString(nameString.String()); } else @@ -1818,10 +1818,10 @@ AttributeView::Draw(BRect) // Check for truncation if (StringWidth(fDescStr.String()) > (Bounds().Width() - (fDivider + kBorderMargin))) { BString nameString(fDescStr.String()); - TruncateString(&nameString, B_TRUNCATE_MIDDLE, + TruncateString(&nameString, B_TRUNCATE_MIDDLE, Bounds().Width() - (fDivider + kBorderMargin)); DrawString(nameString.String()); - } else + } else DrawString(fDescStr.String()); // Cache the position of the description field @@ -1868,9 +1868,9 @@ AttributeView::BeginEditingTitle() BScrollView *scrollView = new BScrollView("BorderView", fTitleEditView, 0, 0, false, false, B_PLAIN_BORDER); - AddChild(scrollView); + AddChild(scrollView); fTitleEditView->SelectAll(); - fTitleEditView->MakeFocus(); + fTitleEditView->MakeFocus(); Window()->UpdateIfNeeded(); } @@ -1925,7 +1925,7 @@ AttributeView::FinishEditingTitle(bool commit) delete scrollView; fTitleEditView = NULL; - if (reopen) + if (reopen) BeginEditingTitle(); } @@ -1995,10 +1995,10 @@ AttributeView::BuildContextMenu(BMenu *parent) navigate = entry.IsDirectory(); entry.GetRef(&ref); } - } else if (model.IsDirectory() || model.IsVolume()) + } else if (model.IsDirectory() || model.IsVolume()) navigate = true; } - ModelMenuItem *navigationItem = NULL; + ModelMenuItem *navigationItem = NULL; if (navigate) { navigationItem = new ModelMenuItem(new Model(model), new BNavMenu(model.Name(), B_REFS_RECEIVED, be_app, Window())); @@ -2036,7 +2036,7 @@ AttributeView::BuildContextMenu(BMenu *parent) item->SetEnabled(false); } else parent->AddItem(new BMenuItem("Identify", new BMessage(kIdentifyEntry))); - } else if (FSIsTrashDir(&entry)) + } else if (FSIsTrashDir(&entry)) parent->AddItem(new BMenuItem("Empty Trash", new BMessage(kEmptyTrash))); BMenuItem *sizeItem = NULL; @@ -2087,7 +2087,7 @@ AttributeView::TextViewFilter(BMessage *message, BHandler **, BMessageFilter *fi attribView->TextView()->SetTextRect(nuRect); // Make sure the cursor is in view - attribView->TextView()->ScrollToSelection(); + attribView->TextView()->ScrollToSelection(); if (message->FindInt8("byte", (int8 *)&key) != B_OK) return B_DISPATCH_MESSAGE; @@ -2100,25 +2100,25 @@ AttributeView::TextViewFilter(BMessage *message, BHandler **, BMessageFilter *fi } -off_t +off_t AttributeView::LastSize() const { return fLastSize; } -void +void AttributeView::SetLastSize(off_t lastSize) { fLastSize = lastSize; } -void +void AttributeView::SetSizeStr(const char *sizeStr) { fSizeStr = sizeStr; - + BRect bounds(Bounds()); float lineHeight = CurrentFontHeight(kAttribFontHeight) + 6; bounds.Set(fDivider, fIconRect.bottom, bounds.right, fIconRect.bottom + lineHeight);