From fd952aef9b43f8631cd97afc27d12b261d68a917 Mon Sep 17 00:00:00 2001 From: Ryan Leavengood Date: Fri, 14 Aug 2009 05:21:14 +0000 Subject: [PATCH] Started cleaning up these monsters: - Add underscore to private methods. - Use class member initializer syntax. - Make sure all class members are initialized, use same order as headers. - Header reordering. - A few other small things. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32342 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/showimage/ShowImageView.cpp | 563 +++++++++++++------------ src/apps/showimage/ShowImageView.h | 138 +++--- src/apps/showimage/ShowImageWindow.cpp | 307 +++++++------- src/apps/showimage/ShowImageWindow.h | 70 +-- 4 files changed, 547 insertions(+), 531 deletions(-) diff --git a/src/apps/showimage/ShowImageView.cpp b/src/apps/showimage/ShowImageView.cpp index 8db6dc33c9..e862eb694f 100644 --- a/src/apps/showimage/ShowImageView.cpp +++ b/src/apps/showimage/ShowImageView.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2003-2009, Haiku, Inc. All Rights Reserved. * Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd. * Copyright 2006 Bernd Korz. All Rights Reserved * Distributed under the terms of the MIT License. @@ -13,12 +13,11 @@ * Bernd Korz */ - -#include "ProgressWindow.h" -#include "ShowImageApp.h" -#include "ShowImageConstants.h" #include "ShowImageView.h" -#include "ShowImageWindow.h" + +#include +#include +#include #include #include @@ -46,9 +45,11 @@ #include -#include -#include -#include +#include "ProgressWindow.h" +#include "ShowImageApp.h" +#include "ShowImageConstants.h" +#include "ShowImageWindow.h" + // TODO: Remove this and use Tracker's Command.h once it is moved into the private headers namespace BPrivate { @@ -158,7 +159,8 @@ compose_checker_background(const BBitmap* bitmap) PopUpMenu::PopUpMenu(const char* name, BMessenger target) - : BPopUpMenu(name, false, false), + : + BPopUpMenu(name, false, false), fTarget(target) { SetAsyncAutoDestruct(true); @@ -176,38 +178,45 @@ PopUpMenu::~PopUpMenu() ShowImageView::ShowImageView(BRect rect, const char *name, uint32 resizingMode, uint32 flags) - : BView(rect, name, resizingMode, flags), + : + BView(rect, name, resizingMode, flags), + fDither(BScreen().ColorSpace() == B_CMAP8), + fDocumentIndex(1), + fDocumentCount(1), + fBitmap(NULL), + fDisplayBitmap(NULL), + fSelBitmap(NULL), + fZoom(1.0), + fScaleBilinear(true), + fScaler(NULL), + fShrinkToBounds(false), + fZoomToBounds(false), + fShrinkOrZoomToBounds(false), + fFullScreen(false), + fLeft(0.0), + fTop(0.0), + fMovesImage(false), + fMakesSelection(false), + fFirstPoint(0.0, 0.0), + fAnimateSelection(true), + fHasSelection(false), + fSlideShow(false), + fSlideShowDelay(3 * 10), // 3 seconds + fSlideShowCountDown(0), +#if DELAYED_SCALING + fScalingCountDown(SCALING_DELAY_TIME), +#endif + fShowCaption(false), + fInverted(false), + fShowingPopUpMenu(false), + fHideCursorCountDown(HIDE_CURSOR_DELAY_TIME), + fIsActiveWin(true), fProgressWindow(NULL) { + _InitPatterns(); + ShowImageSettings* settings; settings = my_app->Settings(); - - InitPatterns(); - fDither = BScreen().ColorSpace() == B_CMAP8; - fBitmap = NULL; - fDisplayBitmap = NULL; - fSelBitmap = NULL; - fDocumentIndex = 1; - fDocumentCount = 1; - fAnimateSelection = true; - fHasSelection = false; - fShrinkToBounds = false; - fZoomToBounds = false; - fFullScreen = false; - fSlideShow = false; - fSlideShowDelay = 3 * 10; // 3 seconds - fShowCaption = false; - fZoom = 1.0; - fMovesImage = false; - fScaleBilinear = true; - fScaler = NULL; -#if DELAYED_SCALING - fScalingCountDown = SCALING_DELAY_TIME; -#endif - fShowingPopUpMenu = false; - fHideCursorCountDown = HIDE_CURSOR_DELAY_TIME; - fIsActiveWin = true; - if (settings->Lock()) { fDither = settings->GetBool("Dither", fDither); fShrinkToBounds = settings->GetBool("ShrinkToBounds", fShrinkToBounds); @@ -226,13 +235,13 @@ ShowImageView::ShowImageView(BRect rect, const char *name, uint32 resizingMode, ShowImageView::~ShowImageView() { - DeleteBitmap(); + _DeleteBitmap(); } //! Use patterns to simulate marching ants for selection void -ShowImageView::InitPatterns() +ShowImageView::_InitPatterns() { uchar p; uchar p1 = 0x33; @@ -252,7 +261,7 @@ ShowImageView::InitPatterns() void -ShowImageView::RotatePatterns() +ShowImageView::_RotatePatterns() { int i; uchar p; @@ -290,7 +299,7 @@ ShowImageView::RotatePatterns() void -ShowImageView::AnimateSelection(bool enabled) +ShowImageView::_AnimateSelection(bool enabled) { fAnimateSelection = enabled; } @@ -300,22 +309,22 @@ void ShowImageView::Pulse() { // animate marching ants - if (HasSelection() && fAnimateSelection && fIsActiveWin) { - RotatePatterns(); - DrawSelectionBox(); + if (_HasSelection() && fAnimateSelection && fIsActiveWin) { + _RotatePatterns(); + _DrawSelectionBox(); } if (fSlideShow) { fSlideShowCountDown --; if (fSlideShowCountDown <= 0) { fSlideShowCountDown = fSlideShowDelay; if (!NextFile()) { - FirstFile(); + _FirstFile(); } } } // Hide cursor in full screen mode - if (fFullScreen && !HasSelection() && !fShowingPopUpMenu && fIsActiveWin) { + if (fFullScreen && !_HasSelection() && !fShowingPopUpMenu && fIsActiveWin) { if (fHideCursorCountDown <= 0) be_app->ObscureCursor(); else @@ -326,7 +335,7 @@ ShowImageView::Pulse() if (fBitmap && (fScaleBilinear || fDither) && fScalingCountDown > 0) { if (fScalingCountDown == 1) { fScalingCountDown = 0; - GetScaler(AlignBitmap()); + _GetScaler(_AlignBitmap()); } else { fScalingCountDown --; } @@ -336,7 +345,7 @@ ShowImageView::Pulse() bool -ShowImageView::IsImage(const entry_ref *ref) +ShowImageView::_IsImage(const entry_ref *ref) { if (ref == NULL || !entry_ref_is_file(ref)) return false; @@ -371,7 +380,7 @@ ShowImageView::SetTrackerMessenger(const BMessenger& trackerMessenger) void -ShowImageView::SendMessageToWindow(BMessage *message) +ShowImageView::_SendMessageToWindow(BMessage *message) { BMessenger msgr(Window()); msgr.SendMessage(message); @@ -379,16 +388,16 @@ ShowImageView::SendMessageToWindow(BMessage *message) void -ShowImageView::SendMessageToWindow(uint32 code) +ShowImageView::_SendMessageToWindow(uint32 code) { BMessage message(code); - SendMessageToWindow(&message); + _SendMessageToWindow(&message); } //! send message to parent about new image void -ShowImageView::Notify() +ShowImageView::_Notify() { BMessage msg(MSG_UPDATE_STATUS); @@ -397,7 +406,7 @@ ShowImageView::Notify() msg.AddInt32("height", fBitmap->Bounds().IntegerHeight() + 1); msg.AddInt32("colors", fBitmap->ColorSpace()); - SendMessageToWindow(&msg); + _SendMessageToWindow(&msg); FixupScrollBars(); Invalidate(); @@ -405,7 +414,7 @@ ShowImageView::Notify() void -ShowImageView::UpdateStatusText() +ShowImageView::_UpdateStatusText() { BMessage msg(MSG_UPDATE_STATUS_TEXT); BString status_to_send = fImageType; @@ -419,19 +428,19 @@ ShowImageView::UpdateStatusText() } msg.AddString("status", status_to_send.String()); - SendMessageToWindow(&msg); + _SendMessageToWindow(&msg); } void -ShowImageView::AddToRecentDocuments() +ShowImageView::_AddToRecentDocuments() { be_roster->AddToRecentDocuments(&fCurrentRef, kApplicationSignature); } void -ShowImageView::DeleteScaler() +ShowImageView::_DeleteScaler() { if (fScaler) { fScaler->Stop(); @@ -445,10 +454,10 @@ ShowImageView::DeleteScaler() void -ShowImageView::DeleteBitmap() +ShowImageView::_DeleteBitmap() { - DeleteScaler(); - DeleteSelBitmap(); + _DeleteScaler(); + _DeleteSelBitmap(); if (fDisplayBitmap != fBitmap) delete fDisplayBitmap; @@ -460,7 +469,7 @@ ShowImageView::DeleteBitmap() void -ShowImageView::DeleteSelBitmap() +ShowImageView::_DeleteSelBitmap() { delete fSelBitmap; fSelBitmap = NULL; @@ -523,9 +532,9 @@ ShowImageView::SetImage(const entry_ref *ref) // I can be sure it is safe to delete the old one, // and clear everything fUndo.Clear(); - SetHasSelection(false); + _SetHasSelection(false); fMakesSelection = false; - DeleteBitmap(); + _DeleteBitmap(); fBitmap = newBitmap; fDisplayBitmap = NULL; newBitmap = NULL; @@ -545,35 +554,35 @@ ShowImageView::SetImage(const entry_ref *ref) if (file.ReadAttr(SHOW_IMAGE_ORIENTATION_ATTRIBUTE, B_INT32_TYPE, 0, &orientation, sizeof(orientation)) == sizeof(orientation)) { if (orientation & 256) - DoImageOperation(ImageProcessor::ImageProcessor::kInvert, true); + _DoImageOperation(ImageProcessor::ImageProcessor::kInvert, true); orientation &= 255; switch (orientation) { case k0: break; case k90: - DoImageOperation(ImageProcessor::kRotateClockwise, true); + _DoImageOperation(ImageProcessor::kRotateClockwise, true); break; case k180: - DoImageOperation(ImageProcessor::kRotateClockwise, true); - DoImageOperation(ImageProcessor::kRotateClockwise, true); + _DoImageOperation(ImageProcessor::kRotateClockwise, true); + _DoImageOperation(ImageProcessor::kRotateClockwise, true); break; case k270: - DoImageOperation(ImageProcessor::kRotateCounterClockwise, true); + _DoImageOperation(ImageProcessor::kRotateCounterClockwise, true); break; case k0V: - DoImageOperation(ImageProcessor::ImageProcessor::kFlipTopToBottom, true); + _DoImageOperation(ImageProcessor::ImageProcessor::kFlipTopToBottom, true); break; case k90V: - DoImageOperation(ImageProcessor::kRotateClockwise, true); - DoImageOperation(ImageProcessor::ImageProcessor::kFlipTopToBottom, true); + _DoImageOperation(ImageProcessor::kRotateClockwise, true); + _DoImageOperation(ImageProcessor::ImageProcessor::kFlipTopToBottom, true); break; case k0H: - DoImageOperation(ImageProcessor::ImageProcessor::kFlipLeftToRight, true); + _DoImageOperation(ImageProcessor::ImageProcessor::kFlipLeftToRight, true); break; case k270V: - DoImageOperation(ImageProcessor::kRotateCounterClockwise, true); - DoImageOperation(ImageProcessor::ImageProcessor::kFlipTopToBottom, true); + _DoImageOperation(ImageProcessor::kRotateCounterClockwise, true); + _DoImageOperation(ImageProcessor::ImageProcessor::kFlipTopToBottom, true); break; } } @@ -595,15 +604,15 @@ ShowImageView::SetImage(const entry_ref *ref) fCaption << ", " << fImageType; fZoom = 1.0; - AddToRecentDocuments(); + _AddToRecentDocuments(); - Notify(); + _Notify(); return B_OK; } status_t -ShowImageView::SetSelection(const entry_ref *ref, BPoint point) +ShowImageView::_SetSelection(const entry_ref *ref, BPoint point) { BTranslatorRoster *roster = BTranslatorRoster::Default(); if (!roster) @@ -626,7 +635,7 @@ ShowImageView::SetSelection(const entry_ref *ref, BPoint point) if (outstream.DetachBitmap(&newBitmap) != B_OK) return B_ERROR; - return PasteBitmap(newBitmap, point); + return _PasteBitmap(newBitmap, point); } @@ -634,7 +643,7 @@ void ShowImageView::SetDither(bool dither) { if (fDither != dither) { - SettingsSetBool("Dither", dither); + _SettingsSetBool("Dither", dither); fDither = dither; Invalidate(); } @@ -646,7 +655,7 @@ ShowImageView::SetShowCaption(bool show) { if (fShowCaption != show) { fShowCaption = show; - UpdateCaption(); + _UpdateCaption(); } } @@ -655,7 +664,7 @@ void ShowImageView::SetShrinkToBounds(bool enable) { if (fShrinkToBounds != enable) { - SettingsSetBool("ShrinkToBounds", enable); + _SettingsSetBool("ShrinkToBounds", enable); fShrinkToBounds = enable; FixupScrollBars(); Invalidate(); @@ -667,7 +676,7 @@ void ShowImageView::SetZoomToBounds(bool enable) { if (fZoomToBounds != enable) { - SettingsSetBool("ZoomToBounds", enable); + _SettingsSetBool("ZoomToBounds", enable); fZoomToBounds = enable; FixupScrollBars(); Invalidate(); @@ -723,7 +732,7 @@ void ShowImageView::SetScaleBilinear(bool enabled) { if (fScaleBilinear != enabled) { - SettingsSetBool("ScaleBilinear", enabled); + _SettingsSetBool("ScaleBilinear", enabled); fScaleBilinear = enabled; Invalidate(); } @@ -749,7 +758,7 @@ ShowImageView::DetachedFromWindow() BRect -ShowImageView::AlignBitmap() +ShowImageView::_AlignBitmap() { BRect rect(fBitmap->Bounds()); @@ -804,7 +813,7 @@ ShowImageView::AlignBitmap() void -ShowImageView::Setup(BRect rect) +ShowImageView::_Setup(BRect rect) { fLeft = floorf(rect.left); fTop = floorf(rect.top); @@ -813,7 +822,7 @@ ShowImageView::Setup(BRect rect) BPoint -ShowImageView::ImageToView(BPoint p) const +ShowImageView::_ImageToView(BPoint p) const { p.x = floorf(fZoom * p.x + fLeft); p.y = floorf(fZoom * p.y + fTop); @@ -822,7 +831,7 @@ ShowImageView::ImageToView(BPoint p) const BPoint -ShowImageView::ViewToImage(BPoint p) const +ShowImageView::_ViewToImage(BPoint p) const { p.x = floorf((p.x - fLeft) / fZoom); p.y = floorf((p.y - fTop) / fZoom); @@ -831,19 +840,19 @@ ShowImageView::ViewToImage(BPoint p) const BRect -ShowImageView::ImageToView(BRect r) const +ShowImageView::_ImageToView(BRect r) const { - BPoint leftTop(ImageToView(BPoint(r.left, r.top))); + BPoint leftTop(_ImageToView(BPoint(r.left, r.top))); BPoint rightBottom(r.right, r.bottom); rightBottom += BPoint(1, 1); - rightBottom = ImageToView(rightBottom); + rightBottom = _ImageToView(rightBottom); rightBottom -= BPoint(1, 1); return BRect(leftTop.x, leftTop.y, rightBottom.x, rightBottom.y); } void -ShowImageView::DrawBorder(BRect border) +ShowImageView::_DrawBorder(BRect border) { BRect bounds(Bounds()); // top @@ -858,7 +867,7 @@ ShowImageView::DrawBorder(BRect border) void -ShowImageView::LayoutCaption(BFont &font, BPoint &pos, BRect &rect) +ShowImageView::_LayoutCaption(BFont &font, BPoint &pos, BRect &rect) { font_height fontHeight; float width, height; @@ -880,12 +889,12 @@ ShowImageView::LayoutCaption(BFont &font, BPoint &pos, BRect &rect) void -ShowImageView::DrawCaption() +ShowImageView::_DrawCaption() { BFont font; BPoint position; BRect rect; - LayoutCaption(font, position, rect); + _LayoutCaption(font, position, rect); PushState(); @@ -906,12 +915,12 @@ ShowImageView::DrawCaption() void -ShowImageView::UpdateCaption() +ShowImageView::_UpdateCaption() { BFont font; BPoint pos; BRect rect; - LayoutCaption(font, pos, rect); + _LayoutCaption(font, pos, rect); // draw over portion of image where caption is located BRegion clip(rect); @@ -923,10 +932,10 @@ ShowImageView::UpdateCaption() Scaler* -ShowImageView::GetScaler(BRect rect) +ShowImageView::_GetScaler(BRect rect) { if (fScaler == NULL || !fScaler->Matches(rect, fDither)) { - DeleteScaler(); + _DeleteScaler(); BMessenger msgr(this, Window()); fScaler = new Scaler(fDisplayBitmap, rect, msgr, MSG_INVALIDATE, fDither); fScaler->Start(); @@ -936,16 +945,16 @@ ShowImageView::GetScaler(BRect rect) void -ShowImageView::DrawImage(BRect rect) +ShowImageView::_DrawImage(BRect rect) { if (fScaleBilinear || fDither) { #if DELAYED_SCALING Scaler* scaler = fScaler; if (scaler != NULL && !scaler->Matches(rect, fDither)) { - DeleteScaler(); scaler = NULL; + _DeleteScaler(); scaler = NULL; } #else - Scaler* scaler = GetScaler(rect); + Scaler* scaler = _GetScaler(rect); #endif if (scaler != NULL && !scaler->IsRunning()) { BBitmap* bitmap = scaler->GetBitmap(); @@ -976,41 +985,41 @@ ShowImageView::Draw(BRect updateRect) return; } - BRect rect = AlignBitmap(); - Setup(rect); + BRect rect = _AlignBitmap(); + _Setup(rect); BRect border(rect); border.InsetBy(-PEN_SIZE, -PEN_SIZE); - DrawBorder(border); + _DrawBorder(border); // Draw black rectangle around image StrokeRect(border); // Draw image - DrawImage(rect); + _DrawImage(rect); if (fShowCaption) - DrawCaption(); + _DrawCaption(); - if (HasSelection()) { + if (_HasSelection()) { if (fSelBitmap) { BRect srcBits, destRect; - GetSelMergeRects(srcBits, destRect); - destRect = ImageToView(destRect); + _GetSelMergeRects(srcBits, destRect); + destRect = _ImageToView(destRect); DrawBitmap(fSelBitmap, srcBits, destRect); } - DrawSelectionBox(); + _DrawSelectionBox(); } } void -ShowImageView::DrawSelectionBox() +ShowImageView::_DrawSelectionBox() { BRect r(fSelectionRect); - ConstrainToImage(r); - r = ImageToView(r); + _ConstrainToImage(r); + r = _ImageToView(r); // draw selection box *around* selection r.InsetBy(-1, -1); PushState(); @@ -1032,21 +1041,21 @@ ShowImageView::FrameResized(float /* width */, float /* height */) void -ShowImageView::ConstrainToImage(BPoint &point) +ShowImageView::_ConstrainToImage(BPoint &point) { point.ConstrainTo(fBitmap->Bounds()); } void -ShowImageView::ConstrainToImage(BRect &rect) +ShowImageView::_ConstrainToImage(BRect &rect) { rect = rect & fBitmap->Bounds(); } BBitmap* -ShowImageView::CopyFromRect(BRect srcRect) +ShowImageView::_CopyFromRect(BRect srcRect) { BRect rect(0, 0, srcRect.Width(), srcRect.Height()); BView view(rect, NULL, B_FOLLOW_NONE, B_WILL_DRAW); @@ -1069,11 +1078,11 @@ ShowImageView::CopyFromRect(BRect srcRect) BBitmap* -ShowImageView::CopySelection(uchar alpha, bool imageSize) +ShowImageView::_CopySelection(uchar alpha, bool imageSize) { bool hasAlpha = alpha != 255; - if (!HasSelection()) + if (!_HasSelection()) return NULL; BRect rect(0, 0, fSelectionRect.Width(), fSelectionRect.Height()); @@ -1110,7 +1119,7 @@ ShowImageView::CopySelection(uchar alpha, bool imageSize) bool -ShowImageView::AddSupportedTypes(BMessage* msg, BBitmap* bitmap) +ShowImageView::_AddSupportedTypes(BMessage* msg, BBitmap* bitmap) { BTranslatorRoster *roster = BTranslatorRoster::Default(); if (roster == NULL) @@ -1145,9 +1154,9 @@ ShowImageView::AddSupportedTypes(BMessage* msg, BBitmap* bitmap) void -ShowImageView::BeginDrag(BPoint sourcePoint) +ShowImageView::_BeginDrag(BPoint sourcePoint) { - BBitmap* bitmap = CopySelection(128, false); + BBitmap* bitmap = _CopySelection(128, false); if (bitmap == NULL) return; @@ -1160,11 +1169,11 @@ ShowImageView::BeginDrag(BPoint sourcePoint) // ShowImage specific fields drag.AddPoint("be:_source_point", sourcePoint); drag.AddRect("be:_frame", fSelectionRect); - if (AddSupportedTypes(&drag, bitmap)) { + if (_AddSupportedTypes(&drag, bitmap)) { // we also support "Passing Data via File" protocol drag.AddString("be:types", B_FILE_MIME_TYPE); // avoid flickering of dragged bitmap caused by drawing into the window - AnimateSelection(false); + _AnimateSelection(false); // only use a transparent bitmap on selections less than 400x400 (taking into account zooming) if ((fSelectionRect.Width() * fZoom) < 400.0 && (fSelectionRect.Height() * fZoom) < 400.0) { sourcePoint -= fSelectionRect.LeftTop(); @@ -1177,7 +1186,7 @@ ShowImageView::BeginDrag(BPoint sourcePoint) delete bitmap; // Offset and scale the rect BRect rect(fSelectionRect); - rect = ImageToView(rect); + rect = _ImageToView(rect); rect.InsetBy(-1, -1); DragMessage(&drag, rect); } @@ -1186,7 +1195,7 @@ ShowImageView::BeginDrag(BPoint sourcePoint) bool -ShowImageView::OutputFormatForType(BBitmap* bitmap, const char* type, +ShowImageView::_OutputFormatForType(BBitmap* bitmap, const char* type, translation_format* format) { bool found = false; @@ -1263,7 +1272,7 @@ ShowImageView::SaveToFile(BDirectory* dir, const char* name, BBitmap* bitmap, void -ShowImageView::SendInMessage(BMessage* msg, BBitmap* bitmap, translation_format* format) +ShowImageView::_SendInMessage(BMessage* msg, BBitmap* bitmap, translation_format* format) { BMessage reply(B_MIME_DATA); BBitmapStream stream(bitmap); // destructor deletes bitmap @@ -1277,7 +1286,7 @@ ShowImageView::SendInMessage(BMessage* msg, BBitmap* bitmap, translation_format* void -ShowImageView::HandleDrop(BMessage* msg) +ShowImageView::_HandleDrop(BMessage* msg) { BMessage data(B_MIME_DATA); entry_ref dirRef; @@ -1292,12 +1301,12 @@ ShowImageView::HandleDrop(BMessage* msg) sendInMessage = (!saveToFile) && msg->FindString("be:types", &type) == B_OK; - bitmap = CopySelection(); + bitmap = _CopySelection(); if (bitmap == NULL) return; translation_format format; - if (!OutputFormatForType(bitmap, type.String(), &format)) { + if (!_OutputFormatForType(bitmap, type.String(), &format)) { delete bitmap; return; } @@ -1307,7 +1316,7 @@ ShowImageView::HandleDrop(BMessage* msg) SaveToFile(&dir, name.String(), bitmap, &format); delete bitmap; } else if (sendInMessage) { - SendInMessage(msg, bitmap, &format); + _SendInMessage(msg, bitmap, &format); } else { delete bitmap; } @@ -1315,7 +1324,7 @@ ShowImageView::HandleDrop(BMessage* msg) void -ShowImageView::MoveImage() +ShowImageView::_MoveImage() { BPoint point, delta; uint32 buttons; @@ -1324,16 +1333,16 @@ ShowImageView::MoveImage() point = ConvertToScreen(point); delta = fFirstPoint - point; fFirstPoint = point; - ScrollRestrictedBy(delta.x, delta.y); + _ScrollRestrictedBy(delta.x, delta.y); // in case we miss MouseUp - if ((GetMouseButtons() & B_TERTIARY_MOUSE_BUTTON) == 0) + if ((_GetMouseButtons() & B_TERTIARY_MOUSE_BUTTON) == 0) fMovesImage = false; } uint32 -ShowImageView::GetMouseButtons() +ShowImageView::_GetMouseButtons() { uint32 buttons; BPoint point; @@ -1350,11 +1359,11 @@ ShowImageView::GetMouseButtons() void -ShowImageView::GetMergeRects(BBitmap *merge, BRect selection, BRect &srcBits, +ShowImageView::_GetMergeRects(BBitmap *merge, BRect selection, BRect &srcBits, BRect &destRect) { destRect = selection; - ConstrainToImage(destRect); + _ConstrainToImage(destRect); srcBits = selection; if (srcBits.left < 0) @@ -1380,14 +1389,14 @@ ShowImageView::GetMergeRects(BBitmap *merge, BRect selection, BRect &srcBits, void -ShowImageView::GetSelMergeRects(BRect &srcBits, BRect &destRect) +ShowImageView::_GetSelMergeRects(BRect &srcBits, BRect &destRect) { - GetMergeRects(fSelBitmap, fSelectionRect, srcBits, destRect); + _GetMergeRects(fSelBitmap, fSelectionRect, srcBits, destRect); } void -ShowImageView::MergeWithBitmap(BBitmap *merge, BRect selection) +ShowImageView::_MergeWithBitmap(BBitmap *merge, BRect selection) { BView view(fBitmap->Bounds(), NULL, B_FOLLOW_NONE, B_WILL_DRAW); BBitmap *bitmap = new(nothrow) BBitmap(fBitmap->Bounds(), fBitmap->ColorSpace(), true); @@ -1400,39 +1409,39 @@ ShowImageView::MergeWithBitmap(BBitmap *merge, BRect selection) bitmap->AddChild(&view); view.DrawBitmap(fBitmap, fBitmap->Bounds()); BRect srcBits, destRect; - GetMergeRects(merge, selection, srcBits, destRect); + _GetMergeRects(merge, selection, srcBits, destRect); view.DrawBitmap(merge, srcBits, destRect); view.Sync(); bitmap->RemoveChild(&view); bitmap->Unlock(); - DeleteBitmap(); + _DeleteBitmap(); fBitmap = bitmap; - SendMessageToWindow(MSG_MODIFIED); + _SendMessageToWindow(MSG_MODIFIED); } else delete bitmap; } void -ShowImageView::MergeSelection() +ShowImageView::_MergeSelection() { - if (!HasSelection()) + if (!_HasSelection()) return; if (!fSelBitmap) { // Even though the merge will not change // the background image, I still need to save // some undo information here - fUndo.SetTo(fSelectionRect, NULL, CopySelection()); + fUndo.SetTo(fSelectionRect, NULL, _CopySelection()); return; } // Merge selection with background - fUndo.SetTo(fSelectionRect, CopyFromRect(fSelectionRect), CopySelection()); - MergeWithBitmap(fSelBitmap, fSelectionRect); + fUndo.SetTo(fSelectionRect, _CopyFromRect(fSelectionRect), _CopySelection()); + _MergeWithBitmap(fSelBitmap, fSelectionRect); } @@ -1443,16 +1452,16 @@ ShowImageView::MouseDown(BPoint position) uint32 buttons; MakeFocus(true); - point = ViewToImage(position); - buttons = GetMouseButtons(); + point = _ViewToImage(position); + buttons = _GetMouseButtons(); - if (HasSelection() && fSelectionRect.Contains(point) + if (_HasSelection() && fSelectionRect.Contains(point) && (buttons & (B_PRIMARY_MOUSE_BUTTON | B_SECONDARY_MOUSE_BUTTON))) { if (!fSelBitmap) - fSelBitmap = CopySelection(); + fSelBitmap = _CopySelection(); BPoint sourcePoint = point; - BeginDrag(sourcePoint); + _BeginDrag(sourcePoint); while (buttons) { // Keep reading mouse movement until @@ -1466,7 +1475,7 @@ ShowImageView::MouseDown(BPoint position) // If selection stayed inside this view // (Some of the selection may be in the border area, which can be OK) BPoint last, diff; - last = ViewToImage(point); + last = _ViewToImage(point); diff = last - sourcePoint; BRect newSelection = fSelectionRect; @@ -1480,23 +1489,23 @@ ShowImageView::MouseDown(BPoint position) } } - AnimateSelection(true); + _AnimateSelection(true); } else if (buttons == B_PRIMARY_MOUSE_BUTTON) { - MergeSelection(); + _MergeSelection(); // If there is an existing selection, // Make it part of the background image // begin new selection - SetHasSelection(true); + _SetHasSelection(true); fMakesSelection = true; SetMouseEventMask(B_POINTER_EVENTS); - ConstrainToImage(point); + _ConstrainToImage(point); fFirstPoint = point; fCopyFromRect.Set(point.x, point.y, point.x, point.y); fSelectionRect = fCopyFromRect; Invalidate(); } else if (buttons == B_SECONDARY_MOUSE_BUTTON) { - ShowPopUpMenu(ConvertToScreen(position)); + _ShowPopUpMenu(ConvertToScreen(position)); } else if (buttons == B_TERTIARY_MOUSE_BUTTON) { // move image in window SetMouseEventMask(B_POINTER_EVENTS); @@ -1507,11 +1516,11 @@ ShowImageView::MouseDown(BPoint position) void -ShowImageView::UpdateSelectionRect(BPoint point, bool final) +ShowImageView::_UpdateSelectionRect(BPoint point, bool final) { BRect oldSelection = fCopyFromRect; - point = ViewToImage(point); - ConstrainToImage(point); + point = _ViewToImage(point); + _ConstrainToImage(point); fCopyFromRect.left = min_c(fFirstPoint.x, point.x); fCopyFromRect.right = max_c(fFirstPoint.x, point.x); fCopyFromRect.top = min_c(fFirstPoint.y, point.y); @@ -1521,14 +1530,14 @@ ShowImageView::UpdateSelectionRect(BPoint point, bool final) if (final) { // selection must be at least 2 pixels wide or 2 pixels tall if (fCopyFromRect.Width() < 1.0 && fCopyFromRect.Height() < 1.0) - SetHasSelection(false); + _SetHasSelection(false); } else - UpdateStatusText(); + _UpdateStatusText(); - if (oldSelection != fCopyFromRect || !HasSelection()) { + if (oldSelection != fCopyFromRect || !_HasSelection()) { BRect updateRect; updateRect = oldSelection | fCopyFromRect; - updateRect = ImageToView(updateRect); + updateRect = _ImageToView(updateRect); updateRect.InsetBy(-PEN_SIZE, -PEN_SIZE); Invalidate(updateRect); } @@ -1540,9 +1549,9 @@ ShowImageView::MouseMoved(BPoint point, uint32 state, const BMessage *message) { fHideCursorCountDown = HIDE_CURSOR_DELAY_TIME; if (fMakesSelection) { - UpdateSelectionRect(point, false); + _UpdateSelectionRect(point, false); } else if (fMovesImage) { - MoveImage(); + _MoveImage(); } } @@ -1551,18 +1560,18 @@ void ShowImageView::MouseUp(BPoint point) { if (fMakesSelection) { - UpdateSelectionRect(point, true); + _UpdateSelectionRect(point, true); fMakesSelection = false; } else if (fMovesImage) { - MoveImage(); + _MoveImage(); fMovesImage = false; } - AnimateSelection(true); + _AnimateSelection(true); } float -ShowImageView::LimitToRange(float v, orientation o, bool absolute) +ShowImageView::_LimitToRange(float v, orientation o, bool absolute) { BScrollBar* psb = ScrollBar(o); if (psb) { @@ -1586,13 +1595,13 @@ ShowImageView::LimitToRange(float v, orientation o, bool absolute) void -ShowImageView::ScrollRestricted(float x, float y, bool absolute) +ShowImageView::_ScrollRestricted(float x, float y, bool absolute) { if (x != 0) - x = LimitToRange(x, B_HORIZONTAL, absolute); + x = _LimitToRange(x, B_HORIZONTAL, absolute); if (y != 0) - y = LimitToRange(y, B_VERTICAL, absolute); + y = _LimitToRange(y, B_VERTICAL, absolute); // hide the caption when using mouse wheel // in full screen mode @@ -1601,7 +1610,7 @@ ShowImageView::ScrollRestricted(float x, float y, bool absolute) bool caption = fShowCaption; if (caption) { fShowCaption = false; - UpdateCaption(); + _UpdateCaption(); } ScrollBy(x, y); @@ -1609,23 +1618,23 @@ ShowImageView::ScrollRestricted(float x, float y, bool absolute) if (caption) { // show the caption again fShowCaption = true; - UpdateCaption(); + _UpdateCaption(); } } // XXX method is not unused void -ShowImageView::ScrollRestrictedTo(float x, float y) +ShowImageView::_ScrollRestrictedTo(float x, float y) { - ScrollRestricted(x, y, true); + _ScrollRestricted(x, y, true); } void -ShowImageView::ScrollRestrictedBy(float x, float y) +ShowImageView::_ScrollRestrictedBy(float x, float y) { - ScrollRestricted(x, y, false); + _ScrollRestricted(x, y, false); } @@ -1639,36 +1648,36 @@ ShowImageView::KeyDown(const char* bytes, int32 numBytes) switch (*bytes) { case B_DOWN_ARROW: - ScrollRestrictedBy(0, 10); + _ScrollRestrictedBy(0, 10); break; case B_UP_ARROW: - ScrollRestrictedBy(0, -10); + _ScrollRestrictedBy(0, -10); break; case B_LEFT_ARROW: - ScrollRestrictedBy(-10, 0); + _ScrollRestrictedBy(-10, 0); break; case B_RIGHT_ARROW: - ScrollRestrictedBy(10, 0); + _ScrollRestrictedBy(10, 0); break; case B_ENTER: - SendMessageToWindow(MSG_FILE_NEXT); + _SendMessageToWindow(MSG_FILE_NEXT); break; case B_BACKSPACE: - SendMessageToWindow(MSG_FILE_PREV); + _SendMessageToWindow(MSG_FILE_PREV); break; case B_HOME: break; case B_END: break; case B_SPACE: - ToggleSlideShow(); + _ToggleSlideShow(); break; case B_ESCAPE: // stop slide show if (fSlideShow) - ToggleSlideShow(); + _ToggleSlideShow(); - ExitFullScreen(); + _ExitFullScreen(); ClearSelection(); break; @@ -1684,7 +1693,7 @@ ShowImageView::KeyDown(const char* bytes, int32 numBytes) if (!NextFile()) { // This is the last (or only file) in this directory, // close the window - SendMessageToWindow(B_QUIT_REQUESTED); + _SendMessageToWindow(B_QUIT_REQUESTED); } break; } @@ -1700,7 +1709,7 @@ ShowImageView::KeyDown(const char* bytes, int32 numBytes) void -ShowImageView::MouseWheelChanged(BMessage *msg) +ShowImageView::_MouseWheelChanged(BMessage *msg) { // The BeOS driver does not currently support // X wheel scrolling, therefore, dx is zero. @@ -1716,12 +1725,12 @@ ShowImageView::MouseWheelChanged(BMessage *msg) if (msg->FindFloat("be:wheel_delta_y", &dy) == B_OK) y = dy * kscrollBy; - ScrollRestrictedBy(x, y); + _ScrollRestrictedBy(x, y); } void -ShowImageView::ShowPopUpMenu(BPoint screen) +ShowImageView::_ShowPopUpMenu(BPoint screen) { BPopUpMenu* menu = new PopUpMenu("PopUpMenu", this); @@ -1736,7 +1745,7 @@ ShowImageView::ShowPopUpMenu(BPoint screen) void -ShowImageView::SettingsSetBool(const char* name, bool value) +ShowImageView::_SettingsSetBool(const char* name, bool value) { ShowImageSettings* settings; settings = my_app->Settings(); @@ -1759,7 +1768,7 @@ ShowImageView::MessageReceived(BMessage *message) // allocates the BBitmap * sent in the reply, it is only // to be used and deleted by the view that is being replied to. BMessage msg; - msg.AddPointer("be:_bitmap_ptr", CopySelection()); + msg.AddPointer("be:_bitmap_ptr", _CopySelection()); message->SendReply(&msg); break; } @@ -1775,8 +1784,8 @@ ShowImageView::MessageReceived(BMessage *message) if (message->FindRef("refs", 0, &ref) == B_OK) { BPoint point = message->DropPoint(); point = ConvertFromScreen(point); - point = ViewToImage(point); - SetSelection(&ref, point); + point = _ViewToImage(point); + _SetSelection(&ref, point); } } else { // If a user drags a clip from another ShowImage window, @@ -1800,9 +1809,9 @@ ShowImageView::MessageReceived(BMessage *message) point.y - (sourcePoint.y - sourceRect.top)); // adjust drop point before scaling is factored in point = ConvertFromScreen(point); - point = ViewToImage(point); + point = _ViewToImage(point); - PasteBitmap(bitmap, point); + _PasteBitmap(bitmap, point); } } } @@ -1810,10 +1819,10 @@ ShowImageView::MessageReceived(BMessage *message) break; case B_COPY_TARGET: - HandleDrop(message); + _HandleDrop(message); break; case B_MOUSE_WHEEL_CHANGED: - MouseWheelChanged(message); + _MouseWheelChanged(message); break; case MSG_INVALIDATE: Invalidate(); @@ -1858,7 +1867,7 @@ ShowImageView::FixupScrollBars() { BRect rctview = Bounds(), rctbitmap(0, 0, 0, 0); if (fBitmap) { - rctbitmap = AlignBitmap(); + rctbitmap = _AlignBitmap(); rctbitmap.OffsetTo(0, 0); } @@ -1892,13 +1901,13 @@ ShowImageView::Undo() BRect undoneSelRect; BBitmap *undoneSelection; undoneSelRect = fSelectionRect; - undoneSelection = CopySelection(); + undoneSelection = _CopySelection(); if (undoType == UNDO_UNDO) { BBitmap *undoRestore; undoRestore = fUndo.GetRestoreBitmap(); if (undoRestore) - MergeWithBitmap(undoRestore, fUndo.GetRect()); + _MergeWithBitmap(undoRestore, fUndo.GetRect()); } // restore previous image/selection @@ -1907,11 +1916,11 @@ ShowImageView::Undo() // NOTE: ShowImageView is responsible for deleting this bitmap // (Which it will, as it would with a fSelBitmap that it allocated itself) if (!undoSelection) - SetHasSelection(false); + _SetHasSelection(false); else { fCopyFromRect = BRect(); fSelectionRect = fUndo.GetRect(); - SetHasSelection(true); + _SetHasSelection(true); fSelBitmap = undoSelection; } @@ -1922,7 +1931,7 @@ ShowImageView::Undo() void -ShowImageView::AddWhiteRect(BRect &rect) +ShowImageView::_AddWhiteRect(BRect &rect) { // Paint white rectangle, using rect, into the background image BView view(fBitmap->Bounds(), NULL, B_FOLLOW_NONE, B_WILL_DRAW); @@ -1943,36 +1952,36 @@ ShowImageView::AddWhiteRect(BRect &rect) bitmap->RemoveChild(&view); bitmap->Unlock(); - DeleteBitmap(); + _DeleteBitmap(); fBitmap = bitmap; - SendMessageToWindow(MSG_MODIFIED); + _SendMessageToWindow(MSG_MODIFIED); } else delete bitmap; } void -ShowImageView::RemoveSelection(bool toClipboard) +ShowImageView::_RemoveSelection(bool toClipboard) { - if (!HasSelection()) + if (!_HasSelection()) return; BRect rect = fSelectionRect; bool cutBackground = (fSelBitmap) ? false : true; BBitmap *selection, *restore = NULL; - selection = CopySelection(); + selection = _CopySelection(); if (toClipboard) CopySelectionToClipboard(); - SetHasSelection(false); + _SetHasSelection(false); if (cutBackground) { // If the user hasn't dragged the selection, // paint a white rectangle where the selection was - restore = CopyFromRect(rect); - AddWhiteRect(rect); + restore = _CopyFromRect(rect); + _AddWhiteRect(rect); } fUndo.SetTo(rect, restore, selection); @@ -1985,19 +1994,19 @@ ShowImageView::Cut() { // Copy the selection to the clipboard, // then remove it - RemoveSelection(true); + _RemoveSelection(true); } status_t -ShowImageView::PasteBitmap(BBitmap *bitmap, BPoint point) +ShowImageView::_PasteBitmap(BBitmap *bitmap, BPoint point) { if (bitmap && bitmap->IsValid()) { - MergeSelection(); + _MergeSelection(); fCopyFromRect = BRect(); fSelectionRect = bitmap->Bounds(); - SetHasSelection(true); + _SetHasSelection(true); fSelBitmap = bitmap; BRect offsetRect = fSelectionRect; @@ -2027,7 +2036,7 @@ ShowImageView::Paste() pclip->FindPoint("be:location", &point); BBitmap *pbits; pbits = dynamic_cast(BBitmap::Instantiate(pclip)); - PasteBitmap(pbits, point); + _PasteBitmap(pbits, point); } be_clipboard->Unlock(); @@ -2038,7 +2047,7 @@ ShowImageView::Paste() void ShowImageView::SelectAll() { - SetHasSelection(true); + _SetHasSelection(true); fCopyFromRect.Set(0, 0, fBitmap->Bounds().Width(), fBitmap->Bounds().Height()); fSelectionRect = fCopyFromRect; Invalidate(); @@ -2050,33 +2059,33 @@ ShowImageView::ClearSelection() { // Remove the selection, // DON'T copy it to the clipboard - RemoveSelection(false); + _RemoveSelection(false); } void -ShowImageView::SetHasSelection(bool bHasSelection) +ShowImageView::_SetHasSelection(bool bHasSelection) { - DeleteSelBitmap(); + _DeleteSelBitmap(); fHasSelection = bHasSelection; - UpdateStatusText(); + _UpdateStatusText(); BMessage msg(MSG_SELECTION); msg.AddBool("has_selection", fHasSelection); - SendMessageToWindow(&msg); + _SendMessageToWindow(&msg); } void ShowImageView::CopySelectionToClipboard() { - if (HasSelection() && be_clipboard->Lock()) { + if (_HasSelection() && be_clipboard->Lock()) { be_clipboard->Clear(); BMessage *clip = NULL; if ((clip = be_clipboard->Data()) != NULL) { BMessage data; - BBitmap* bitmap = CopySelection(); + BBitmap* bitmap = _CopySelection(); if (bitmap != NULL) { #if 0 // According to BeBook and Becasso, Gobe Productive do the following. @@ -2140,7 +2149,7 @@ ShowImageView::PrevPage() int -ShowImageView::CompareEntries(const void* a, const void* b) +ShowImageView::_CompareEntries(const void* a, const void* b) { entry_ref *r1, *r2; r1 = *(entry_ref**)a; @@ -2160,7 +2169,7 @@ ShowImageView::GoToPage(int32 page) void -ShowImageView::FreeEntries(BList* entries) +ShowImageView::_FreeEntries(BList* entries) { const int32 n = entries->CountItems(); for (int32 i = 0; i < n; i ++) { @@ -2172,7 +2181,7 @@ ShowImageView::FreeEntries(BList* entries) void -ShowImageView::SetTrackerSelectionToCurrent() +ShowImageView::_SetTrackerSelectionToCurrent() { BMessage setsel(B_SET_PROPERTY); setsel.AddSpecifier("Selection"); @@ -2182,7 +2191,7 @@ ShowImageView::SetTrackerSelectionToCurrent() bool -ShowImageView::FindNextImageByDir(entry_ref *in_current, entry_ref *out_image, bool next, bool rewind) +ShowImageView::_FindNextImageByDir(entry_ref *in_current, entry_ref *out_image, bool next, bool rewind) { ASSERT(next || !rewind); BEntry curImage(in_current); @@ -2205,19 +2214,19 @@ ShowImageView::FindNextImageByDir(entry_ref *in_current, entry_ref *out_image, b } } - entries.SortItems(CompareEntries); + entries.SortItems(_CompareEntries); cur = entries.IndexOf(in_current); ASSERT(cur >= 0); - // remove it so FreeEntries() does not delete it + // remove it so _FreeEntries() does not delete it entries.RemoveItem(in_current); if (next) { // find the next image in the list if (rewind) cur = 0; // start with first for (; (ref = (entry_ref*)entries.ItemAt(cur)) != NULL; cur ++) { - if (IsImage(ref)) { + if (_IsImage(ref)) { found = true; *out_image = (const entry_ref)*ref; break; @@ -2228,7 +2237,7 @@ ShowImageView::FindNextImageByDir(entry_ref *in_current, entry_ref *out_image, b cur --; for (; cur >= 0; cur --) { ref = (entry_ref*)entries.ItemAt(cur); - if (IsImage(ref)) { + if (_IsImage(ref)) { found = true; *out_image = (const entry_ref)*ref; break; @@ -2236,18 +2245,18 @@ ShowImageView::FindNextImageByDir(entry_ref *in_current, entry_ref *out_image, b } } - FreeEntries(&entries); + _FreeEntries(&entries); return found; } bool -ShowImageView::FindNextImage(entry_ref *in_current, entry_ref *ref, bool next, bool rewind) +ShowImageView::_FindNextImage(entry_ref *in_current, entry_ref *ref, bool next, bool rewind) { // Based on similar function from BeMail! if (!fTrackerMessenger.IsValid()) // If tracker scripting is not available, // fall back on directory searching code - return FindNextImageByDir(in_current, ref, next, rewind); + return _FindNextImageByDir(in_current, ref, next, rewind); // // Ask the Tracker what the next/prev file in the window is. @@ -2277,11 +2286,11 @@ ShowImageView::FindNextImage(entry_ref *in_current, entry_ref *ref, bool next, b BMessage reply; if (fTrackerMessenger.SendMessage(&request, &reply) != B_OK) - return FindNextImageByDir(in_current, ref, next, rewind);; + return _FindNextImageByDir(in_current, ref, next, rewind);; if (reply.FindRef("result", &nextRef) != B_OK) - return FindNextImageByDir(in_current, ref, next, rewind);; + return _FindNextImageByDir(in_current, ref, next, rewind);; - if (IsImage(&nextRef)) + if (_IsImage(&nextRef)) foundRef = true; rewind = false; @@ -2293,24 +2302,24 @@ ShowImageView::FindNextImage(entry_ref *in_current, entry_ref *ref, bool next, b } bool -ShowImageView::ShowNextImage(bool next, bool rewind) +ShowImageView::_ShowNextImage(bool next, bool rewind) { entry_ref curRef = fCurrentRef; entry_ref imgRef; - bool found = FindNextImage(&curRef, &imgRef, next, rewind); + bool found = _FindNextImage(&curRef, &imgRef, next, rewind); if (found) { // Keep trying to load images until: // 1. The image loads successfully // 2. The last file in the directory is found (for find next or find first) // 3. The first file in the directory is found (for find prev) - // 4. The call to FindNextImage fails for any other reason + // 4. The call to _FindNextImage fails for any other reason while (SetImage(&imgRef) != B_OK) { curRef = imgRef; - found = FindNextImage(&curRef, &imgRef, next, false); + found = _FindNextImage(&curRef, &imgRef, next, false); if (!found) return false; } - SetTrackerSelectionToCurrent(); + _SetTrackerSelectionToCurrent(); return true; } return false; @@ -2320,14 +2329,14 @@ ShowImageView::ShowNextImage(bool next, bool rewind) bool ShowImageView::NextFile() { - return ShowNextImage(true, false); + return _ShowNextImage(true, false); } bool ShowImageView::PrevFile() { - return ShowNextImage(false, false); + return _ShowNextImage(false, false); } @@ -2335,7 +2344,7 @@ bool ShowImageView::HasNextFile() { entry_ref ref; - return FindNextImage(&fCurrentRef, &ref, true, false); + return _FindNextImage(&fCurrentRef, &ref, true, false); } @@ -2343,14 +2352,14 @@ bool ShowImageView::HasPrevFile() { entry_ref ref; - return FindNextImage(&fCurrentRef, &ref, false, false); + return _FindNextImage(&fCurrentRef, &ref, false, false); } bool -ShowImageView::FirstFile() +ShowImageView::_FirstFile() { - return ShowNextImage(true, true); + return _ShowNextImage(true, true); } @@ -2358,7 +2367,7 @@ void ShowImageView::SetZoom(float zoom) { if ((fScaleBilinear || fDither) && fZoom != zoom) { - DeleteScaler(); + _DeleteScaler(); } fZoom = zoom; FixupScrollBars(); @@ -2419,7 +2428,7 @@ ShowImageView::StopSlideShow() void -ShowImageView::DoImageOperation(ImageProcessor::operation op, bool quiet) +ShowImageView::_DoImageOperation(ImageProcessor::operation op, bool quiet) { BMessenger msgr; ImageProcessor imageProcessor(op, fBitmap, msgr, 0); @@ -2455,23 +2464,23 @@ ShowImageView::DoImageOperation(ImageProcessor::operation op, bool quiet) } // set new bitmap - DeleteBitmap(); + _DeleteBitmap(); fBitmap = bm; if (!quiet) { // remove selection - SetHasSelection(false); - Notify(); + _SetHasSelection(false); + _Notify(); } } //! image operation initiated by user void -ShowImageView::UserDoImageOperation(ImageProcessor::operation op, bool quiet) +ShowImageView::_UserDoImageOperation(ImageProcessor::operation op, bool quiet) { fUndo.Clear(); - DoImageOperation(op, quiet); + _DoImageOperation(op, quiet); } @@ -2479,9 +2488,9 @@ void ShowImageView::Rotate(int degree) { if (degree == 90) { - UserDoImageOperation(ImageProcessor::kRotateClockwise); + _UserDoImageOperation(ImageProcessor::kRotateClockwise); } else if (degree == 270) { - UserDoImageOperation(ImageProcessor::kRotateCounterClockwise); + _UserDoImageOperation(ImageProcessor::kRotateCounterClockwise); } } @@ -2490,9 +2499,9 @@ void ShowImageView::Flip(bool vertical) { if (vertical) { - UserDoImageOperation(ImageProcessor::kFlipLeftToRight); + _UserDoImageOperation(ImageProcessor::kFlipLeftToRight); } else { - UserDoImageOperation(ImageProcessor::kFlipTopToBottom); + _UserDoImageOperation(ImageProcessor::kFlipTopToBottom); } } @@ -2504,7 +2513,7 @@ ShowImageView::Invert() // Only allow an invert operation if the // bitmap color space is supported by the // invert algorithm - UserDoImageOperation(ImageProcessor::kInvert); + _UserDoImageOperation(ImageProcessor::kInvert); } } @@ -2523,18 +2532,18 @@ ShowImageView::ResizeImage(int w, int h) } // remove selection - SetHasSelection(false); + _SetHasSelection(false); fUndo.Clear(); - DeleteBitmap(); + _DeleteBitmap(); fBitmap = scaled; - SendMessageToWindow(MSG_MODIFIED); + _SendMessageToWindow(MSG_MODIFIED); - Notify(); + _Notify(); } void -ShowImageView::SetIcon(bool clear, icon_size which) +ShowImageView::_SetIcon(bool clear, icon_size which) { int32 size; switch (which) { @@ -2598,23 +2607,23 @@ ShowImageView::SetIcon(bool clear, icon_size which) void ShowImageView::SetIcon(bool clear) { - SetIcon(clear, B_MINI_ICON); - SetIcon(clear, B_LARGE_ICON); + _SetIcon(clear, B_MINI_ICON); + _SetIcon(clear, B_LARGE_ICON); } void -ShowImageView::ToggleSlideShow() +ShowImageView::_ToggleSlideShow() { - SendMessageToWindow(MSG_SLIDE_SHOW); + _SendMessageToWindow(MSG_SLIDE_SHOW); } void -ShowImageView::ExitFullScreen() +ShowImageView::_ExitFullScreen() { be_app->ShowCursor(); - SendMessageToWindow(MSG_EXIT_FULL_SCREEN); + _SendMessageToWindow(MSG_EXIT_FULL_SCREEN); } diff --git a/src/apps/showimage/ShowImageView.h b/src/apps/showimage/ShowImageView.h index 35c9041eaa..43551ccc1d 100644 --- a/src/apps/showimage/ShowImageView.h +++ b/src/apps/showimage/ShowImageView.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2003-2009, Haiku, Inc. All Rights Reserved. * Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd. * Copyright 2006 Bernd Korz. All Rights Reserved * Distributed under the terms of the MIT License. @@ -130,79 +130,79 @@ class ShowImageView : public BView { k270V, // 7 kNumberOfOrientations, }; - void InitPatterns(); - void RotatePatterns(); - void RemoveSelection(bool bToClipboard); - bool HasSelection() { return fHasSelection; } - void SetHasSelection(bool bHasSelection); - void AnimateSelection(bool a); - void SendMessageToWindow(BMessage *message); - void SendMessageToWindow(uint32 code); - void Notify(); - void UpdateStatusText(); - void AddToRecentDocuments(); - void AddWhiteRect(BRect &rect); - void GetMergeRects(BBitmap *merge, BRect selection, BRect &srcBits, BRect &destRect); - void GetSelMergeRects(BRect &srcBits, BRect &destRect); - status_t SetSelection(const entry_ref *pref, BPoint point); - status_t PasteBitmap(BBitmap *bitmap, BPoint point); - void MergeWithBitmap(BBitmap *merge, BRect selection); - void MergeSelection(); - void DeleteScaler(); - void DeleteBitmap(); - void DeleteSelBitmap(); - int32 BytesPerPixel(color_space cs) const; - void CopyPixel(uchar* dest, int32 destX, int32 destY, int32 destBPR, + void _InitPatterns(); + void _RotatePatterns(); + void _RemoveSelection(bool bToClipboard); + bool _HasSelection() { return fHasSelection; } + void _SetHasSelection(bool bHasSelection); + void _AnimateSelection(bool a); + void _SendMessageToWindow(BMessage *message); + void _SendMessageToWindow(uint32 code); + void _Notify(); + void _UpdateStatusText(); + void _AddToRecentDocuments(); + void _AddWhiteRect(BRect &rect); + void _GetMergeRects(BBitmap *merge, BRect selection, BRect &srcBits, BRect &destRect); + void _GetSelMergeRects(BRect &srcBits, BRect &destRect); + status_t _SetSelection(const entry_ref *pref, BPoint point); + status_t _PasteBitmap(BBitmap *bitmap, BPoint point); + void _MergeWithBitmap(BBitmap *merge, BRect selection); + void _MergeSelection(); + void _DeleteScaler(); + void _DeleteBitmap(); + void _DeleteSelBitmap(); + int32 _BytesPerPixel(color_space cs) const; + void _CopyPixel(uchar* dest, int32 destX, int32 destY, int32 destBPR, uchar* src, int32 x, int32 y, int32 bpr, int32 bpp); - void InvertPixel(int32 x, int32 y, uchar* dest, int32 destBPR, uchar* src, + void _InvertPixel(int32 x, int32 y, uchar* dest, int32 destBPR, uchar* src, int32 bpr, int32 bpp); - void DoImageOperation(enum ImageProcessor::operation op, bool quiet = false); - void UserDoImageOperation(enum ImageProcessor::operation op, bool quiet = false); - BRect AlignBitmap(); - void Setup(BRect r); - BPoint ImageToView(BPoint p) const; - BPoint ViewToImage(BPoint p) const; - BRect ImageToView(BRect r) const; - bool IsImage(const entry_ref* pref); - static int CompareEntries(const void* a, const void* b); - void FreeEntries(BList* entries); - void SetTrackerSelectionToCurrent(); - bool FindNextImageByDir(entry_ref *in_current, entry_ref *out_image, + void _DoImageOperation(enum ImageProcessor::operation op, bool quiet = false); + void _UserDoImageOperation(enum ImageProcessor::operation op, bool quiet = false); + BRect _AlignBitmap(); + void _Setup(BRect r); + BPoint _ImageToView(BPoint p) const; + BPoint _ViewToImage(BPoint p) const; + BRect _ImageToView(BRect r) const; + bool _IsImage(const entry_ref* pref); + static int _CompareEntries(const void* a, const void* b); + void _FreeEntries(BList* entries); + void _SetTrackerSelectionToCurrent(); + bool _FindNextImageByDir(entry_ref *in_current, entry_ref *out_image, bool next, bool rewind); - bool FindNextImage(entry_ref *in_current, entry_ref *out_image, + bool _FindNextImage(entry_ref *in_current, entry_ref *out_image, bool next, bool rewind); - bool ShowNextImage(bool next, bool rewind); - bool FirstFile(); - void ConstrainToImage(BPoint &point); - void ConstrainToImage(BRect &rect); - BBitmap* CopyFromRect(BRect srcRect); - BBitmap* CopySelection(uchar alpha = 255, bool imageSize = true); - bool AddSupportedTypes(BMessage* msg, BBitmap* bitmap); - void BeginDrag(BPoint sourcePoint); - void SendInMessage(BMessage* msg, BBitmap* bitmap, translation_format* format); - bool OutputFormatForType(BBitmap* bitmap, const char* type, + bool _ShowNextImage(bool next, bool rewind); + bool _FirstFile(); + void _ConstrainToImage(BPoint &point); + void _ConstrainToImage(BRect &rect); + BBitmap* _CopyFromRect(BRect srcRect); + BBitmap* _CopySelection(uchar alpha = 255, bool imageSize = true); + bool _AddSupportedTypes(BMessage* msg, BBitmap* bitmap); + void _BeginDrag(BPoint sourcePoint); + void _SendInMessage(BMessage* msg, BBitmap* bitmap, translation_format* format); + bool _OutputFormatForType(BBitmap* bitmap, const char* type, translation_format* format); - void HandleDrop(BMessage* msg); - void MoveImage(); - uint32 GetMouseButtons(); - void UpdateSelectionRect(BPoint point, bool final); - void DrawBorder(BRect border); - void LayoutCaption(BFont &font, BPoint &textPos, BRect &background); - void DrawCaption(); - void UpdateCaption(); - void DrawSelectionBox(); - Scaler* GetScaler(BRect rect); - void DrawImage(BRect rect); - float LimitToRange(float v, orientation o, bool absolute); - void ScrollRestricted(float x, float y, bool absolute); - void ScrollRestrictedTo(float x, float y); - void ScrollRestrictedBy(float x, float y); - void MouseWheelChanged(BMessage* msg); - void ShowPopUpMenu(BPoint screen); - void SettingsSetBool(const char* name, bool value); - void SetIcon(bool clear, icon_size which); - void ToggleSlideShow(); - void ExitFullScreen(); + void _HandleDrop(BMessage* msg); + void _MoveImage(); + uint32 _GetMouseButtons(); + void _UpdateSelectionRect(BPoint point, bool final); + void _DrawBorder(BRect border); + void _LayoutCaption(BFont &font, BPoint &textPos, BRect &background); + void _DrawCaption(); + void _UpdateCaption(); + void _DrawSelectionBox(); + Scaler* _GetScaler(BRect rect); + void _DrawImage(BRect rect); + float _LimitToRange(float v, orientation o, bool absolute); + void _ScrollRestricted(float x, float y, bool absolute); + void _ScrollRestrictedTo(float x, float y); + void _ScrollRestrictedBy(float x, float y); + void _MouseWheelChanged(BMessage* msg); + void _ShowPopUpMenu(BPoint screen); + void _SettingsSetBool(const char* name, bool value); + void _SetIcon(bool clear, icon_size which); + void _ToggleSlideShow(); + void _ExitFullScreen(); BMessenger fTrackerMessenger; // of the window that this was launched from entry_ref fCurrentRef; // of the image diff --git a/src/apps/showimage/ShowImageWindow.cpp b/src/apps/showimage/ShowImageWindow.cpp index bb30a81932..ebd275d532 100644 --- a/src/apps/showimage/ShowImageWindow.cpp +++ b/src/apps/showimage/ShowImageWindow.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2008, Haiku, Inc. All Rights Reserved. + * Copyright 2003-2009, Haiku, Inc. All Rights Reserved. * Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd. * Copyright 2006 Bernd Korz. All Rights Reserved * Distributed under the terms of the MIT License. @@ -12,15 +12,10 @@ * Bernd Korz */ -#include "BackgroundImage.h" -#include "EntryMenuItem.h" -#include "ResizerWindow.h" -#include "ShowImageApp.h" -#include "ShowImageConstants.h" -#include "ShowImageStatusView.h" -#include "ShowImageView.h" #include "ShowImageWindow.h" +#include +#include #include #include @@ -44,27 +39,32 @@ #include #include - -#include -#include +#include "BackgroundImage.h" +#include "EntryMenuItem.h" +#include "ResizerWindow.h" +#include "ShowImageApp.h" +#include "ShowImageConstants.h" +#include "ShowImageStatusView.h" +#include "ShowImageView.h" // #pragma mark -- ShowImageWindow::RecentDocumentsMenu class ShowImageWindow::RecentDocumentsMenu : public BMenu { public: - RecentDocumentsMenu(const char *title, - menu_layout layout = B_ITEMS_IN_COLUMN); - bool AddDynamicItem(add_state addState); + RecentDocumentsMenu(const char *title, + menu_layout layout = B_ITEMS_IN_COLUMN); + bool AddDynamicItem(add_state addState); - private: - void UpdateRecentDocumentsMenu(); +private: + void UpdateRecentDocumentsMenu(); }; ShowImageWindow::RecentDocumentsMenu::RecentDocumentsMenu(const char *title, menu_layout layout) - : BMenu(title, layout) + : + BMenu(title, layout) { } @@ -89,7 +89,7 @@ ShowImageWindow::RecentDocumentsMenu::AddDynamicItem(add_state addState) if (entry.Exists() && entry.GetName(name) == B_OK) { msg = new BMessage(B_REFS_RECEIVED); msg->AddRef("refs", &ref); - item = new EntryMenuItem(&ref, name, msg, 0, 0); + item = new EntryMenuItem(&ref, name, msg, 0, 0); AddItem(item); item->SetTarget(be_app, NULL); } @@ -108,20 +108,27 @@ const char* kTranslatorField = "be:translator"; ShowImageWindow::ShowImageWindow(const entry_ref *ref, - const BMessenger& trackerMessenger) - : BWindow(BRect(5, 24, 250, 100), "", B_DOCUMENT_WINDOW, 0) + const BMessenger& trackerMessenger) + : + BWindow(BRect(5, 24, 250, 100), "", B_DOCUMENT_WINDOW, 0), + fSavePanel(NULL), + fBar(NULL), + fOpenMenu(NULL), + fBrowseMenu(NULL), + fGoToPageMenu(NULL), + fSlideShowDelay(NULL), + fImageView(NULL), + fStatusView(NULL), + fModified(false), + fFullScreen(false), + fShowCaption(true), + fPrintSettings(NULL), + fResizerWindowMessenger(NULL), + fResizeItem(NULL), + fHeight(0), + fWidth(0) { - fSavePanel = NULL; - fModified = false; - fFullScreen = false; - fShowCaption = true; - fPrintSettings = NULL; - fImageView = NULL; - fSlideShowDelay = NULL; - fResizerWindowMessenger = NULL; - fHeight = fWidth = 0; - - LoadSettings(); + _LoadSettings(); // create menu bar fBar = new BMenuBar(BRect(0, 0, Bounds().right, 1), "menu_bar"); @@ -160,8 +167,8 @@ ShowImageWindow::ShowImageWindow(const entry_ref *ref, AddChild(fStatusView); rect = Bounds(); - rect.top = viewFrame.top - 1; - rect.left = viewFrame.right + 1; + rect.top = viewFrame.top - 1; + rect.left = viewFrame.right + 1; rect.bottom = viewFrame.bottom + 1; rect.right += 1; BScrollBar *verticalScrollBar = new BScrollBar(rect, "vscroll", fImageView, @@ -188,9 +195,9 @@ ShowImageWindow::ShowImageWindow(const entry_ref *ref, // add View menu here so it can access ShowImageView methods BMenu* menu = new BMenu("View"); - BuildViewMenu(menu, false); + _BuildViewMenu(menu, false); fBar->AddItem(menu); - MarkMenuItem(fBar, MSG_DITHER_IMAGE, fImageView->GetDither()); + _MarkMenuItem(fBar, MSG_DITHER_IMAGE, fImageView->GetDither()); UpdateTitle(); SetPulseRate(100000); @@ -234,15 +241,15 @@ ShowImageWindow::UpdateTitle() void ShowImageWindow::BuildContextMenu(BMenu *menu) { - BuildViewMenu(menu, true); + _BuildViewMenu(menu, true); } void -ShowImageWindow::BuildViewMenu(BMenu *menu, bool popupMenu) +ShowImageWindow::_BuildViewMenu(BMenu *menu, bool popupMenu) { - AddItemMenu(menu, "Slide Show", MSG_SLIDE_SHOW, 0, 0, this); - MarkMenuItem(menu, MSG_SLIDE_SHOW, fImageView->SlideShowStarted()); + _AddItemMenu(menu, "Slide Show", MSG_SLIDE_SHOW, 0, 0, this); + _MarkMenuItem(menu, MSG_SLIDE_SHOW, fImageView->SlideShowStarted()); BMenu* delayMenu = new BMenu("Slide Delay"); if (fSlideShowDelay == NULL) fSlideShowDelay = delayMenu; @@ -252,60 +259,60 @@ ShowImageWindow::BuildViewMenu(BMenu *menu, bool popupMenu) // if slide show delay is too short! (Especially if loading the image // takes as long as or longer than the slide show delay). Should load // in background thread! - AddDelayItem(delayMenu, "Three Seconds", 3); - AddDelayItem(delayMenu, "Four Second", 4); - AddDelayItem(delayMenu, "Five Seconds", 5); - AddDelayItem(delayMenu, "Six Seconds", 6); - AddDelayItem(delayMenu, "Seven Seconds", 7); - AddDelayItem(delayMenu, "Eight Seconds", 8); - AddDelayItem(delayMenu, "Nine Seconds", 9); - AddDelayItem(delayMenu, "Ten Seconds", 10); - AddDelayItem(delayMenu, "Twenty Seconds", 20); + _AddDelayItem(delayMenu, "Three Seconds", 3); + _AddDelayItem(delayMenu, "Four Second", 4); + _AddDelayItem(delayMenu, "Five Seconds", 5); + _AddDelayItem(delayMenu, "Six Seconds", 6); + _AddDelayItem(delayMenu, "Seven Seconds", 7); + _AddDelayItem(delayMenu, "Eight Seconds", 8); + _AddDelayItem(delayMenu, "Nine Seconds", 9); + _AddDelayItem(delayMenu, "Ten Seconds", 10); + _AddDelayItem(delayMenu, "Twenty Seconds", 20); menu->AddItem(delayMenu); menu->AddSeparatorItem(); - AddItemMenu(menu, "Original Size", MSG_ORIGINAL_SIZE, 0, 0, this); - AddItemMenu(menu, "Zoom In", MSG_ZOOM_IN, '+', 0, this); - AddItemMenu(menu, "Zoom Out", MSG_ZOOM_OUT, '-', 0, this); + _AddItemMenu(menu, "Original Size", MSG_ORIGINAL_SIZE, 0, 0, this); + _AddItemMenu(menu, "Zoom In", MSG_ZOOM_IN, '+', 0, this); + _AddItemMenu(menu, "Zoom Out", MSG_ZOOM_OUT, '-', 0, this); menu->AddSeparatorItem(); - AddItemMenu(menu, "High-Quality Zooming", MSG_SCALE_BILINEAR, 0, 0, this); + _AddItemMenu(menu, "High-Quality Zooming", MSG_SCALE_BILINEAR, 0, 0, this); menu->AddSeparatorItem(); - AddItemMenu(menu, "Shrink to Window", MSG_SHRINK_TO_WINDOW, 0, 0, this); - AddItemMenu(menu, "Zoom to Window", MSG_ZOOM_TO_WINDOW, 0, 0, this); + _AddItemMenu(menu, "Shrink to Window", MSG_SHRINK_TO_WINDOW, 0, 0, this); + _AddItemMenu(menu, "Zoom to Window", MSG_ZOOM_TO_WINDOW, 0, 0, this); menu->AddSeparatorItem(); - AddItemMenu(menu, "Full Screen", MSG_FULL_SCREEN, 'F', 0, this); - MarkMenuItem(menu, MSG_FULL_SCREEN, fFullScreen); + _AddItemMenu(menu, "Full Screen", MSG_FULL_SCREEN, 'F', 0, this); + _MarkMenuItem(menu, MSG_FULL_SCREEN, fFullScreen); AddShortcut(B_ENTER, 0, new BMessage(MSG_FULL_SCREEN)); - AddItemMenu(menu, "Show Caption in Full Screen Mode", MSG_SHOW_CAPTION, 0, + _AddItemMenu(menu, "Show Caption in Full Screen Mode", MSG_SHOW_CAPTION, 0, 0, this); - MarkMenuItem(menu, MSG_SHOW_CAPTION, fShowCaption); + _MarkMenuItem(menu, MSG_SHOW_CAPTION, fShowCaption); - MarkMenuItem(menu, MSG_SCALE_BILINEAR, fImageView->GetScaleBilinear()); + _MarkMenuItem(menu, MSG_SCALE_BILINEAR, fImageView->GetScaleBilinear()); bool shrink, zoom, enabled; shrink = fImageView->GetShrinkToBounds(); zoom = fImageView->GetZoomToBounds(); - MarkMenuItem(menu, MSG_SHRINK_TO_WINDOW, shrink); - MarkMenuItem(menu, MSG_ZOOM_TO_WINDOW, zoom); + _MarkMenuItem(menu, MSG_SHRINK_TO_WINDOW, shrink); + _MarkMenuItem(menu, MSG_ZOOM_TO_WINDOW, zoom); enabled = !(shrink || zoom); - EnableMenuItem(menu, MSG_ORIGINAL_SIZE, enabled); - EnableMenuItem(menu, MSG_ZOOM_IN, enabled); - EnableMenuItem(menu, MSG_ZOOM_OUT, enabled); + _EnableMenuItem(menu, MSG_ORIGINAL_SIZE, enabled); + _EnableMenuItem(menu, MSG_ZOOM_IN, enabled); + _EnableMenuItem(menu, MSG_ZOOM_OUT, enabled); if (popupMenu) { menu->AddSeparatorItem(); - AddItemMenu(menu, "As Desktop Background", MSG_DESKTOP_BACKGROUND, 0, 0, + _AddItemMenu(menu, "As Desktop Background", MSG_DESKTOP_BACKGROUND, 0, 0, this); } } @@ -327,61 +334,61 @@ ShowImageWindow::AddMenus(BMenuBar *bar) // Fill Save As submenu with all types that can be converted // to from the Be bitmap image format menu->AddItem(pmenuSaveAs); - AddItemMenu(menu, "Close", B_QUIT_REQUESTED, 'W', 0, this); + _AddItemMenu(menu, "Close", B_QUIT_REQUESTED, 'W', 0, this); menu->AddSeparatorItem(); - AddItemMenu(menu, "Page Setup" B_UTF8_ELLIPSIS, MSG_PAGE_SETUP, 0, 0, this); - AddItemMenu(menu, "Print" B_UTF8_ELLIPSIS, MSG_PREPARE_PRINT, 'P', 0, this); + _AddItemMenu(menu, "Page Setup" B_UTF8_ELLIPSIS, MSG_PAGE_SETUP, 0, 0, this); + _AddItemMenu(menu, "_Print" B_UTF8_ELLIPSIS, MSG_PREPARE_PRINT, 'P', 0, this); menu->AddSeparatorItem(); - AddItemMenu(menu, "About ShowImage" B_UTF8_ELLIPSIS, B_ABOUT_REQUESTED, 0, 0, + _AddItemMenu(menu, "About ShowImage" B_UTF8_ELLIPSIS, B_ABOUT_REQUESTED, 0, 0, be_app); menu->AddSeparatorItem(); - AddItemMenu(menu, "Quit", B_QUIT_REQUESTED, 'Q', 0, be_app); + _AddItemMenu(menu, "Quit", B_QUIT_REQUESTED, 'Q', 0, be_app); bar->AddItem(menu); menu = new BMenu("Edit"); - AddItemMenu(menu, "Undo", B_UNDO, 'Z', 0, this, false); + _AddItemMenu(menu, "Undo", B_UNDO, 'Z', 0, this, false); menu->AddSeparatorItem(); - AddItemMenu(menu, "Cut", B_CUT, 'X', 0, this, false); - AddItemMenu(menu, "Copy", B_COPY, 'C', 0, this, false); - AddItemMenu(menu, "Paste", B_PASTE, 'V', 0, this, false); - AddItemMenu(menu, "Clear", MSG_CLEAR_SELECT, 0, 0, this, false); + _AddItemMenu(menu, "Cut", B_CUT, 'X', 0, this, false); + _AddItemMenu(menu, "Copy", B_COPY, 'C', 0, this, false); + _AddItemMenu(menu, "Paste", B_PASTE, 'V', 0, this, false); + _AddItemMenu(menu, "Clear", MSG_CLEAR_SELECT, 0, 0, this, false); menu->AddSeparatorItem(); - AddItemMenu(menu, "Select All", MSG_SELECT_ALL, 'A', 0, this); + _AddItemMenu(menu, "Select All", MSG_SELECT_ALL, 'A', 0, this); bar->AddItem(menu); menu = fBrowseMenu = new BMenu("Browse"); - AddItemMenu(menu, "First Page", MSG_PAGE_FIRST, B_LEFT_ARROW, B_SHIFT_KEY, this); - AddItemMenu(menu, "Last Page", MSG_PAGE_LAST, B_RIGHT_ARROW, B_SHIFT_KEY, this); - AddItemMenu(menu, "Previous Page", MSG_PAGE_PREV, B_LEFT_ARROW, 0, this); - AddItemMenu(menu, "Next Page", MSG_PAGE_NEXT, B_RIGHT_ARROW, 0, this); + _AddItemMenu(menu, "First Page", MSG_PAGE_FIRST, B_LEFT_ARROW, B_SHIFT_KEY, this); + _AddItemMenu(menu, "Last Page", MSG_PAGE_LAST, B_RIGHT_ARROW, B_SHIFT_KEY, this); + _AddItemMenu(menu, "Previous Page", MSG_PAGE_PREV, B_LEFT_ARROW, 0, this); + _AddItemMenu(menu, "Next Page", MSG_PAGE_NEXT, B_RIGHT_ARROW, 0, this); fGoToPageMenu = new BMenu("Go to Page"); fGoToPageMenu->SetRadioMode(true); menu->AddItem(fGoToPageMenu); menu->AddSeparatorItem(); - AddItemMenu(menu, "Previous File", MSG_FILE_PREV, B_UP_ARROW, 0, this); - AddItemMenu(menu, "Next File", MSG_FILE_NEXT, B_DOWN_ARROW, 0, this); + _AddItemMenu(menu, "Previous File", MSG_FILE_PREV, B_UP_ARROW, 0, this); + _AddItemMenu(menu, "Next File", MSG_FILE_NEXT, B_DOWN_ARROW, 0, this); bar->AddItem(menu); menu = new BMenu("Image"); - AddItemMenu(menu, "Rotate Counterclockwise", MSG_ROTATE_270, '[', 0, this); - AddItemMenu(menu, "Rotate Clockwise", MSG_ROTATE_90, ']', 0, this); + _AddItemMenu(menu, "Rotate Counterclockwise", MSG_ROTATE_270, '[', 0, this); + _AddItemMenu(menu, "Rotate Clockwise", MSG_ROTATE_90, ']', 0, this); menu->AddSeparatorItem(); - AddItemMenu(menu, "Flip Left to Right", MSG_FLIP_LEFT_TO_RIGHT, 0, 0, this); - AddItemMenu(menu, "Flip Top to Bottom", MSG_FLIP_TOP_TO_BOTTOM, 0, 0, this); + _AddItemMenu(menu, "Flip Left to Right", MSG_FLIP_LEFT_TO_RIGHT, 0, 0, this); + _AddItemMenu(menu, "Flip Top to Bottom", MSG_FLIP_TOP_TO_BOTTOM, 0, 0, this); menu->AddSeparatorItem(); - AddItemMenu(menu, "Invert Colors", MSG_INVERT, 0, 0, this); + _AddItemMenu(menu, "Invert Colors", MSG_INVERT, 0, 0, this); menu->AddSeparatorItem(); - fResizeItem = AddItemMenu(menu, "Resize" B_UTF8_ELLIPSIS, + fResizeItem = _AddItemMenu(menu, "Resize" B_UTF8_ELLIPSIS, MSG_OPEN_RESIZER_WINDOW, 0, 0, this); bar->AddItem(menu); menu->AddSeparatorItem(); - AddItemMenu(menu, "Use as Desktop Background", MSG_DESKTOP_BACKGROUND, 0, 0, + _AddItemMenu(menu, "Use as Desktop Background", MSG_DESKTOP_BACKGROUND, 0, 0, this); } BMenuItem* -ShowImageWindow::AddItemMenu(BMenu *menu, const char *label, uint32 what, +ShowImageWindow::_AddItemMenu(BMenu *menu, const char *label, uint32 what, const char shortcut, uint32 modifier, const BHandler *target, bool enabled) { BMenuItem* item = new BMenuItem(label, new BMessage(what), shortcut, modifier); @@ -395,7 +402,7 @@ ShowImageWindow::AddItemMenu(BMenu *menu, const char *label, uint32 what, BMenuItem* -ShowImageWindow::AddDelayItem(BMenu *menu, const char *label, float value) +ShowImageWindow::_AddDelayItem(BMenu *menu, const char *label, float value) { BMessage* message = new BMessage(MSG_SLIDE_SHOW_DELAY); message->AddFloat("value", value); @@ -461,7 +468,7 @@ ShowImageWindow::FrameResized(float width, float height) bool -ShowImageWindow::ToggleMenuItem(uint32 what) +ShowImageWindow::_ToggleMenuItem(uint32 what) { bool marked = false; BMenuItem *item = fBar->FindItem(what); @@ -474,7 +481,7 @@ ShowImageWindow::ToggleMenuItem(uint32 what) void -ShowImageWindow::EnableMenuItem(BMenu *menu, uint32 what, bool enable) +ShowImageWindow::_EnableMenuItem(BMenu *menu, uint32 what, bool enable) { BMenuItem* item = menu->FindItem(what); if (item && item->IsEnabled() != enable) @@ -483,7 +490,7 @@ ShowImageWindow::EnableMenuItem(BMenu *menu, uint32 what, bool enable) void -ShowImageWindow::MarkMenuItem(BMenu *menu, uint32 what, bool marked) +ShowImageWindow::_MarkMenuItem(BMenu *menu, uint32 what, bool marked) { BMenuItem* item = menu->FindItem(what); if (item && item->IsMarked() != marked) @@ -492,7 +499,7 @@ ShowImageWindow::MarkMenuItem(BMenu *menu, uint32 what, bool marked) void -ShowImageWindow::MarkSlideShowDelay(float value) +ShowImageWindow::_MarkSlideShowDelay(float value) { const int32 n = fSlideShowDelay->CountItems(); float v; @@ -510,18 +517,18 @@ ShowImageWindow::MarkSlideShowDelay(float value) void -ShowImageWindow::ResizeToWindow(bool shrink, uint32 what) +ShowImageWindow::_ResizeToWindow(bool shrink, uint32 what) { - bool enabled = ToggleMenuItem(what); + bool enabled = _ToggleMenuItem(what); if (shrink) fImageView->SetShrinkToBounds(enabled); else fImageView->SetZoomToBounds(enabled); enabled = !(fImageView->GetShrinkToBounds() || fImageView->GetZoomToBounds()); - EnableMenuItem(fBar, MSG_ORIGINAL_SIZE, enabled); - EnableMenuItem(fBar, MSG_ZOOM_IN, enabled); - EnableMenuItem(fBar, MSG_ZOOM_OUT, enabled); + _EnableMenuItem(fBar, MSG_ORIGINAL_SIZE, enabled); + _EnableMenuItem(fBar, MSG_ZOOM_IN, enabled); + _EnableMenuItem(fBar, MSG_ZOOM_OUT, enabled); } @@ -538,12 +545,12 @@ ShowImageWindow::MessageReceived(BMessage *message) // User clicked Save As then choose an output format if (!fSavePanel) // If user doesn't already have a save panel open - SaveAs(message); + _SaveAs(message); break; case MSG_SAVE_PANEL: // User specified where to save the output image - SaveToFile(message); + _SaveToFile(message); break; case B_CANCEL: @@ -556,13 +563,13 @@ ShowImageWindow::MessageReceived(BMessage *message) int32 curPage = fImageView->CurrentPage(); bool benable = (pages > 1) ? true : false; - EnableMenuItem(fBar, MSG_PAGE_FIRST, benable); - EnableMenuItem(fBar, MSG_PAGE_LAST, benable); - EnableMenuItem(fBar, MSG_PAGE_NEXT, benable); - EnableMenuItem(fBar, MSG_PAGE_PREV, benable); + _EnableMenuItem(fBar, MSG_PAGE_FIRST, benable); + _EnableMenuItem(fBar, MSG_PAGE_LAST, benable); + _EnableMenuItem(fBar, MSG_PAGE_NEXT, benable); + _EnableMenuItem(fBar, MSG_PAGE_PREV, benable); - EnableMenuItem(fBar, MSG_FILE_NEXT, fImageView->HasNextFile()); - EnableMenuItem(fBar, MSG_FILE_PREV, fImageView->HasPrevFile()); + _EnableMenuItem(fBar, MSG_FILE_NEXT, fImageView->HasNextFile()); + _EnableMenuItem(fBar, MSG_FILE_PREV, fImageView->HasPrevFile()); if (fGoToPageMenu->CountItems() != pages) { // Only rebuild the submenu if the number of @@ -607,7 +614,7 @@ ShowImageWindow::MessageReceived(BMessage *message) // invert algorithm) color_space colors = B_NO_COLOR_SPACE; message->FindInt32("colors", reinterpret_cast(&colors)); - EnableMenuItem(fBar, MSG_INVERT, (colors != B_CMAP8)); + _EnableMenuItem(fBar, MSG_INVERT, (colors != B_CMAP8)); BString status; bool messageProvidesSize = false; @@ -625,7 +632,7 @@ ShowImageWindow::MessageReceived(BMessage *message) } if (messageProvidesSize) { - UpdateResizerWindow(fWidth, fHeight); + _UpdateResizerWindow(fWidth, fHeight); } fStatusView->SetText(status); @@ -649,16 +656,16 @@ ShowImageWindow::MessageReceived(BMessage *message) // can update the state of the appropriate menu items bool benable; if (message->FindBool("has_selection", &benable) == B_OK) { - EnableMenuItem(fBar, B_CUT, benable); - EnableMenuItem(fBar, B_COPY, benable); - EnableMenuItem(fBar, MSG_CLEAR_SELECT, benable); + _EnableMenuItem(fBar, B_CUT, benable); + _EnableMenuItem(fBar, B_COPY, benable); + _EnableMenuItem(fBar, MSG_CLEAR_SELECT, benable); } } break; case MSG_UNDO_STATE: { bool benable; if (message->FindBool("can_undo", &benable) == B_OK) - EnableMenuItem(fBar, B_UNDO, benable); + _EnableMenuItem(fBar, B_UNDO, benable); } break; case MSG_CLIPBOARD_CHANGED: { @@ -666,7 +673,7 @@ ShowImageWindow::MessageReceived(BMessage *message) // response to a B_CLIPBOARD_CHANGED message bool bdata; if (message->FindBool("data_available", &bdata) == B_OK) - EnableMenuItem(fBar, B_PASTE, bdata); + _EnableMenuItem(fBar, B_PASTE, bdata); } break; case B_UNDO: @@ -694,27 +701,27 @@ ShowImageWindow::MessageReceived(BMessage *message) break; case MSG_PAGE_FIRST: - if (ClosePrompt()) + if (_ClosePrompt()) fImageView->FirstPage(); break; case MSG_PAGE_LAST: - if (ClosePrompt()) + if (_ClosePrompt()) fImageView->LastPage(); break; case MSG_PAGE_NEXT: - if (ClosePrompt()) + if (_ClosePrompt()) fImageView->NextPage(); break; case MSG_PAGE_PREV: - if (ClosePrompt()) + if (_ClosePrompt()) fImageView->PrevPage(); break; case MSG_GOTO_PAGE: { - if (!ClosePrompt()) + if (!_ClosePrompt()) break; int32 newPage; @@ -736,24 +743,24 @@ ShowImageWindow::MessageReceived(BMessage *message) } break; case MSG_DITHER_IMAGE: - fImageView->SetDither(ToggleMenuItem(message->what)); + fImageView->SetDither(_ToggleMenuItem(message->what)); break; case MSG_SHRINK_TO_WINDOW: - ResizeToWindow(true, message->what); + _ResizeToWindow(true, message->what); break; case MSG_ZOOM_TO_WINDOW: - ResizeToWindow(false, message->what); + _ResizeToWindow(false, message->what); break; case MSG_FILE_PREV: - if (ClosePrompt()) + if (_ClosePrompt()) fImageView->PrevFile(); break; case MSG_FILE_NEXT: - if (ClosePrompt()) + if (_ClosePrompt()) fImageView->NextFile(); break; @@ -785,7 +792,7 @@ ShowImageWindow::MessageReceived(BMessage *message) item->SetMarked(false); fResizeItem->SetEnabled(true); fImageView->StopSlideShow(); - } else if (ClosePrompt()) { + } else if (_ClosePrompt()) { item->SetMarked(true); fResizeItem->SetEnabled(false); fImageView->StartSlideShow(); @@ -797,21 +804,21 @@ ShowImageWindow::MessageReceived(BMessage *message) if (message->FindFloat("value", &value) == B_OK) { fImageView->SetSlideShowDelay(value); // in case message is sent from popup menu - MarkSlideShowDelay(value); + _MarkSlideShowDelay(value); } } break; case MSG_FULL_SCREEN: - ToggleFullScreen(); + _ToggleFullScreen(); break; case MSG_EXIT_FULL_SCREEN: if (fFullScreen) - ToggleFullScreen(); + _ToggleFullScreen(); break; case MSG_SHOW_CAPTION: { - fShowCaption = ToggleMenuItem(message->what); + fShowCaption = _ToggleMenuItem(message->what); ShowImageSettings* settings = my_app->Settings(); if (settings->Lock()) { @@ -823,15 +830,15 @@ ShowImageWindow::MessageReceived(BMessage *message) } break; case MSG_PAGE_SETUP: - PageSetup(); + _PageSetup(); break; case MSG_PREPARE_PRINT: - PrepareForPrint(); + _PrepareForPrint(); break; case MSG_PRINT: - Print(message); + _Print(message); break; case MSG_ZOOM_IN: @@ -847,13 +854,13 @@ ShowImageWindow::MessageReceived(BMessage *message) break; case MSG_SCALE_BILINEAR: - fImageView->SetScaleBilinear(ToggleMenuItem(message->what)); + fImageView->SetScaleBilinear(_ToggleMenuItem(message->what)); break; case MSG_OPEN_RESIZER_WINDOW: { if (fImageView->GetBitmap() != NULL) { BRect rect = fImageView->GetBitmap()->Bounds(); - OpenResizerWindow(rect.IntegerWidth()+1, rect.IntegerHeight()+1); + _OpenResizerWindow(rect.IntegerWidth()+1, rect.IntegerHeight()+1); } } break; @@ -885,7 +892,7 @@ ShowImageWindow::MessageReceived(BMessage *message) void -ShowImageWindow::SaveAs(BMessage *message) +ShowImageWindow::_SaveAs(BMessage *message) { // Read the translator and output type the user chose translator_id outTranslator; @@ -915,7 +922,7 @@ ShowImageWindow::SaveAs(BMessage *message) void -ShowImageWindow::SaveToFile(BMessage *message) +ShowImageWindow::_SaveToFile(BMessage *message) { // Read in where the file should be saved entry_ref dirRef; @@ -960,7 +967,7 @@ ShowImageWindow::SaveToFile(BMessage *message) bool -ShowImageWindow::ClosePrompt() +ShowImageWindow::_ClosePrompt() { if (!fModified) return true; @@ -990,7 +997,7 @@ ShowImageWindow::ClosePrompt() void -ShowImageWindow::ToggleFullScreen() +ShowImageWindow::_ToggleFullScreen() { BRect frame; fFullScreen = !fFullScreen; @@ -1021,7 +1028,7 @@ ShowImageWindow::ToggleFullScreen() void -ShowImageWindow::LoadSettings() +ShowImageWindow::_LoadSettings() { ShowImageSettings* settings = my_app->Settings(); @@ -1050,7 +1057,7 @@ ShowImageWindow::LoadSettings() void -ShowImageWindow::SavePrintOptions() +ShowImageWindow::_SavePrintOptions() { ShowImageSettings* settings = my_app->Settings(); @@ -1066,7 +1073,7 @@ ShowImageWindow::SavePrintOptions() bool -ShowImageWindow::PageSetup() +ShowImageWindow::_PageSetup() { BString name; fImageView->GetName(&name); @@ -1085,7 +1092,7 @@ ShowImageWindow::PageSetup() void -ShowImageWindow::PrepareForPrint() +ShowImageWindow::_PrepareForPrint() { if (fPrintSettings == NULL) { BString name; @@ -1105,13 +1112,13 @@ ShowImageWindow::PrepareForPrint() void -ShowImageWindow::Print(BMessage *msg) +ShowImageWindow::_Print(BMessage *msg) { status_t st; if (msg->FindInt32("status", &st) != B_OK || st != B_OK) return; - SavePrintOptions(); + _SavePrintOptions(); BString name; fImageView->GetName(&name); @@ -1178,7 +1185,7 @@ ShowImageWindow::Print(BMessage *msg) void -ShowImageWindow::OpenResizerWindow(int32 width, int32 height) +ShowImageWindow::_OpenResizerWindow(int32 width, int32 height) { if (fResizerWindowMessenger == NULL) { // open window if it is not already opened @@ -1192,7 +1199,7 @@ ShowImageWindow::OpenResizerWindow(int32 width, int32 height) void -ShowImageWindow::UpdateResizerWindow(int32 width, int32 height) +ShowImageWindow::_UpdateResizerWindow(int32 width, int32 height) { if (fResizerWindowMessenger == NULL) return; @@ -1205,7 +1212,7 @@ ShowImageWindow::UpdateResizerWindow(int32 width, int32 height) void -ShowImageWindow::CloseResizerWindow() +ShowImageWindow::_CloseResizerWindow() { if (fResizerWindowMessenger == NULL) return; @@ -1224,10 +1231,10 @@ ShowImageWindow::QuitRequested() return false; } - bool quit = ClosePrompt(); + bool quit = _ClosePrompt(); if (quit) { - CloseResizerWindow(); + _CloseResizerWindow(); // tell the app to forget about this window be_app->PostMessage(MSG_WINDOW_QUIT); diff --git a/src/apps/showimage/ShowImageWindow.h b/src/apps/showimage/ShowImageWindow.h index 0f42772966..44a28d8fd4 100644 --- a/src/apps/showimage/ShowImageWindow.h +++ b/src/apps/showimage/ShowImageWindow.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2008, Haiku, Inc. All Rights Reserved. + * Copyright 2003-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -34,10 +34,9 @@ class ShowImageWindow : public BWindow { virtual void MessageReceived(BMessage *message); virtual bool QuitRequested(); virtual void ScreenChanged(BRect frame, color_space mode); - // virtual void Zoom(BPoint origin, float width, float height); status_t InitCheck(); - ShowImageView *GetShowImageView() const { return fImageView; } + ShowImageView* GetShowImageView() const { return fImageView; } void UpdateTitle(); void AddMenus(BMenuBar *bar); @@ -47,51 +46,52 @@ class ShowImageWindow : public BWindow { private: class RecentDocumentsMenu; - void BuildViewMenu(BMenu *menu, bool popupMenu); - BMenuItem *AddItemMenu(BMenu *menu, const char *label, + void _BuildViewMenu(BMenu *menu, bool popupMenu); + BMenuItem* _AddItemMenu(BMenu *menu, const char *label, uint32 what, const char shortcut, uint32 modifier, const BHandler *target, bool enabled = true); - BMenuItem* AddDelayItem(BMenu *menu, const char *label, float value); + BMenuItem* _AddDelayItem(BMenu *menu, const char *label, float value); - bool ToggleMenuItem(uint32 what); - void EnableMenuItem(BMenu *menu, uint32 what, bool enable); - void MarkMenuItem(BMenu *menu, uint32 what, bool marked); - void MarkSlideShowDelay(float value); - void ResizeToWindow(bool shrink, uint32 what); + bool _ToggleMenuItem(uint32 what); + void _EnableMenuItem(BMenu *menu, uint32 what, bool enable); + void _MarkMenuItem(BMenu *menu, uint32 what, bool marked); + void _MarkSlideShowDelay(float value); + void _ResizeToWindow(bool shrink, uint32 what); - void SaveAs(BMessage *message); + void _SaveAs(BMessage *message); // Handle Save As submenu choice - void SaveToFile(BMessage *message); + void _SaveToFile(BMessage *message); // Handle save file panel message - bool ClosePrompt(); - void ToggleFullScreen(); - void LoadSettings(); - void SavePrintOptions(); - bool PageSetup(); - void PrepareForPrint(); - void Print(BMessage *msg); + bool _ClosePrompt(); + void _ToggleFullScreen(); + void _LoadSettings(); + void _SavePrintOptions(); + bool _PageSetup(); + void _PrepareForPrint(); + void _Print(BMessage *msg); - void OpenResizerWindow(int32 width, int32 height); - void UpdateResizerWindow(int32 width, int32 height); - void CloseResizerWindow(); + void _OpenResizerWindow(int32 width, int32 height); + void _UpdateResizerWindow(int32 width, int32 height); + void _CloseResizerWindow(); - BFilePanel *fSavePanel; - BMenuBar *fBar; - BMenu *fOpenMenu; - BMenu *fBrowseMenu; - BMenu *fGoToPageMenu; - BMenu *fSlideShowDelay; - ShowImageView *fImageView; - ShowImageStatusView *fStatusView; + BFilePanel* fSavePanel; + BMenuBar* fBar; + BMenu* fOpenMenu; + BMenu* fBrowseMenu; + BMenu* fGoToPageMenu; + BMenu* fSlideShowDelay; + ShowImageView* fImageView; + ShowImageStatusView* fStatusView; bool fModified; bool fFullScreen; BRect fWindowFrame; bool fShowCaption; - BMessage *fPrintSettings; + BMessage* fPrintSettings; PrintOptions fPrintOptions; - BMessenger *fResizerWindowMessenger; - BMenuItem *fResizeItem; - int32 fHeight, fWidth; + BMessenger* fResizerWindowMessenger; + BMenuItem* fResizeItem; + int32 fHeight; + int32 fWidth; }; #endif // SHOW_IMAGE_WINDOW_H