diff --git a/src/apps/showimage/Filter.cpp b/src/apps/showimage/Filter.cpp index d63a087fcf..ded6dcf609 100644 --- a/src/apps/showimage/Filter.cpp +++ b/src/apps/showimage/Filter.cpp @@ -6,6 +6,7 @@ * * Authors: * Michael Pfeiffer, laplace@haiku-os.org + * Ryan Leavengood, leavengood@gmail.com * yellowTAB GmbH * Bernd Korz */ @@ -939,7 +940,7 @@ ImageProcessor::CreateDestImage(BBitmap* /* srcImage */) fWidth = GetSrcImage()->Bounds().IntegerWidth(); fHeight = GetSrcImage()->Bounds().IntegerHeight(); - if (fOp == kRotateClockwise || fOp == kRotateAntiClockwise) { + if (fOp == kRotateClockwise || fOp == kRotateCounterClockwise) { rect.Set(0, 0, fHeight, fWidth); } else { rect.Set(0, 0, fWidth, fHeight); @@ -1056,7 +1057,7 @@ ImageProcessor::Run(int32 i, int32 n) } } break; - case kRotateAntiClockwise: + case kRotateCounterClockwise: for (y = from; y <= to; y ++) { for (x = 0; x <= fWidth; x ++) { destX = y; diff --git a/src/apps/showimage/Filter.h b/src/apps/showimage/Filter.h index 86b8b89b6d..4419361df5 100644 --- a/src/apps/showimage/Filter.h +++ b/src/apps/showimage/Filter.h @@ -188,7 +188,7 @@ class ImageProcessor : public Filter { public: enum operation { kRotateClockwise, - kRotateAntiClockwise, + kRotateCounterClockwise, kFlipLeftToRight, kFlipTopToBottom, kInvert, diff --git a/src/apps/showimage/Jamfile b/src/apps/showimage/Jamfile index b94afb9344..59cc2b500c 100644 --- a/src/apps/showimage/Jamfile +++ b/src/apps/showimage/Jamfile @@ -5,7 +5,6 @@ UsePrivateHeaders tracker ; SetSubDirSupportedPlatformsBeOSCompatible ; Application ShowImage : ShowImageApp.cpp - ShowImageConstants.cpp ShowImageSettings.cpp ShowImageStatusView.cpp ShowImageUndo.cpp diff --git a/src/apps/showimage/ResizerWindow.cpp b/src/apps/showimage/ResizerWindow.cpp index d4ed7e7077..29fcd595c1 100644 --- a/src/apps/showimage/ResizerWindow.cpp +++ b/src/apps/showimage/ResizerWindow.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2007, 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. @@ -8,26 +8,10 @@ * yellowTAB GmbH * Bernd Korz * Michael Pfeiffer - * - * 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 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 - * DEALINGS IN THE SOFTWARE. + * Ryan Leavengood */ + #include #include #include @@ -41,6 +25,7 @@ #include "ResizerWindow.h" #include "ShowImageConstants.h" + static const char* kWidthLabel = "Width:"; static const char* kHeightLabel = "Height:"; static const char* kKeepAspectRatioLabel = "Keep Original Proportions"; @@ -50,6 +35,7 @@ static const float kLineDistance = 5; static const float kHorizontalIndent = 10; static const float kVerticalIndent = 10; + ResizerWindow::ResizerWindow(BMessenger target, int32 width, int32 height) : BWindow(BRect(100, 100, 300, 300), "Resize", B_FLOATING_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE) , fOriginalWidth(width) @@ -100,6 +86,7 @@ ResizerWindow::ResizerWindow(BMessenger target, int32 width, int32 height) ResizeTo(width2, rect.top); } + void ResizerWindow::AddControl(BView* view, BControl* control, float column2, BRect& rect) { @@ -119,6 +106,7 @@ ResizerWindow::AddControl(BView* view, BControl* control, float column2, BRect& } } + void ResizerWindow::AddSeparatorLine(BView* view, BRect& rect) { @@ -133,6 +121,7 @@ ResizerWindow::AddSeparatorLine(BView* view, BRect& rect) rect.OffsetBy(0, kLineDistance + lineWidth); } + void ResizerWindow::LeftAlign(BControl* control) { @@ -141,6 +130,7 @@ ResizerWindow::LeftAlign(BControl* control) control->MoveTo(left, frame.top); } + void ResizerWindow::MessageReceived(BMessage* message) { @@ -175,7 +165,8 @@ ResizerWindow::MessageReceived(BMessage* message) // private actions case kResolutionMsg: - { fAspectRatio->SetValue(B_CONTROL_OFF); + { + fAspectRatio->SetValue(B_CONTROL_OFF); BString width, height; width << message->FindInt32("w"); height << message->FindInt32("h"); @@ -184,8 +175,7 @@ ResizerWindow::MessageReceived(BMessage* message) break; } case kWidthModifiedMsg: - if (fAspectRatio->Value() == B_CONTROL_ON) - { + if (fAspectRatio->Value() == B_CONTROL_ON) { int w = atoi(fWidth->Text()); int h = (int)((int64)w * (int64) fOriginalHeight / (int64) fOriginalWidth); BString height; @@ -197,8 +187,7 @@ ResizerWindow::MessageReceived(BMessage* message) } break; case kHeightModifiedMsg: - if (fAspectRatio->Value() == B_CONTROL_ON) - { + if (fAspectRatio->Value() == B_CONTROL_ON) { int h = atoi(fHeight->Text()); int w = (int)((int64)h * (int64) fOriginalWidth / (int64) fOriginalHeight); BString width; @@ -223,13 +212,16 @@ ResizerWindow::MessageReceived(BMessage* message) } } + ResizerWindow::~ResizerWindow() { } + bool ResizerWindow::QuitRequested() { - fTarget.SendMessage(MSG_RESIZER_WINDOW_QUITED); + fTarget.SendMessage(MSG_RESIZER_WINDOW_QUIT); return true; } + diff --git a/src/apps/showimage/ResizerWindow.h b/src/apps/showimage/ResizerWindow.h index 2f5820774f..43aace2ebe 100644 --- a/src/apps/showimage/ResizerWindow.h +++ b/src/apps/showimage/ResizerWindow.h @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2007, 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. @@ -8,29 +8,12 @@ * yellowTAB GmbH * Bernd Korz * Michael Pfeiffer - * - * 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 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 - * DEALINGS IN THE SOFTWARE. + * Ryan Leavengood */ - #ifndef _resizer_window_h #define _resizer_window_h + #include #include @@ -38,6 +21,7 @@ class BTextControl; class BCheckBox; + class ResizerWindow : public BWindow { public: diff --git a/src/apps/showimage/ShowImageApp.cpp b/src/apps/showimage/ShowImageApp.cpp index f253fdcba7..0e007d2b4c 100644 --- a/src/apps/showimage/ShowImageApp.cpp +++ b/src/apps/showimage/ShowImageApp.cpp @@ -1,11 +1,12 @@ /* - * Copyright 2003-2006, Haiku, Inc. All Rights Reserved. + * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: * Fernando Francisco de Oliveira * Michael Wilber * Michael Pfeiffer + * Ryan Leavengood */ @@ -228,10 +229,16 @@ ShowImageApp::CheckClipboard() bool ShowImageApp::QuitRequested() { - be_clipboard->StopWatching(be_app_messenger); - // tell clipboard we don't want anymore notification + // Give the windows a chance to prompt the user if there are changes + BMessage msg(B_QUIT_REQUESTED); + BroadcastToWindows(&msg); + if (CountWindows() <= WINDOWS_TO_IGNORE) { + be_clipboard->StopWatching(be_app_messenger); + // tell clipboard we don't want anymore notification - return true; + return true; + } else + return false; } diff --git a/src/apps/showimage/ShowImageConstants.cpp b/src/apps/showimage/ShowImageConstants.cpp deleted file mode 100644 index 9359e714b9..0000000000 --- a/src/apps/showimage/ShowImageConstants.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/*****************************************************************************/ -// ShowImageConstants -// Written by Fernando Francisco de Oliveira, Michael Wilber -// -// ShowImageConstants.cpp -// -// -// Copyright (c) 2003 OpenBeOS Project -// -// 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 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 -// DEALINGS IN THE SOFTWARE. -/*****************************************************************************/ - -#include "ShowImageConstants.h" - diff --git a/src/apps/showimage/ShowImageConstants.h b/src/apps/showimage/ShowImageConstants.h index d2091f31df..5ae6ef08c6 100644 --- a/src/apps/showimage/ShowImageConstants.h +++ b/src/apps/showimage/ShowImageConstants.h @@ -1,11 +1,12 @@ /* - * Copyright 2003-2006, Haiku, Inc. All Rights Reserved. + * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: * Fernando Francisco de Oliveira * Michael Wilber * Michael Pfeiffer + * Ryan Leavengood */ #ifndef SHOW_IMAGE_CONSTANTS_H #define SHOW_IMAGE_CONSTANTS_H @@ -14,51 +15,54 @@ #include -const uint32 MSG_CAPTURE_MOUSE = 'mCPM'; -const uint32 MSG_CHANGE_FOCUS = 'mCFS'; -const uint32 MSG_FILE_OPEN = 'mFOP'; -const uint32 MSG_WINDOW_QUIT = 'mWQT'; -const uint32 MSG_OUTPUT_TYPE = 'BTMN'; -const uint32 MSG_SAVE_PANEL = 'mFSP'; -const uint32 MSG_CLEAR_SELECT = 'mCSL'; -const uint32 MSG_SELECT_ALL = 'mSAL'; -const uint32 MSG_CLIPBOARD_CHANGED = 'mCLP'; -const uint32 MSG_DITHER_IMAGE = 'mDIM'; -const uint32 MSG_MODIFIED = 'mMOD'; -const uint32 MSG_UPDATE_STATUS = 'mUPS'; -const uint32 MSG_UNDO_STATE = 'mUNS'; -const uint32 MSG_SELECTION = 'mSEL'; -const uint32 MSG_SELECTION_BITMAP = 'mSBT'; -const uint32 MSG_PAGE_FIRST = 'mPGF'; -const uint32 MSG_PAGE_LAST = 'mPGL'; -const uint32 MSG_PAGE_NEXT = 'mPGN'; -const uint32 MSG_PAGE_PREV = 'mPGP'; -const uint32 MSG_GOTO_PAGE = 'mGTP'; -const uint32 MSG_FILE_NEXT = 'mFLN'; -const uint32 MSG_FILE_PREV = 'mFLP'; -const uint32 MSG_SHRINK_TO_WINDOW = 'mSTW'; -const uint32 MSG_ZOOM_TO_WINDOW = 'mZTW'; -const uint32 MSG_ROTATE_90 = 'mR90'; -const uint32 MSG_ROTATE_270 = 'mR27'; -const uint32 MSG_FLIP_LEFT_TO_RIGHT = 'mFLR'; -const uint32 MSG_FLIP_TOP_TO_BOTTOM = 'mFTB'; -const uint32 MSG_INVERT = 'mINV'; -const uint32 MSG_SLIDE_SHOW = 'mSSW'; -const uint32 MSG_SLIDE_SHOW_DELAY = 'mSSD'; -const uint32 MSG_FULL_SCREEN = 'mFSC'; -const uint32 MSG_EXIT_FULL_SCREEN = 'mEFS'; -const uint32 MSG_SHOW_CAPTION = 'mSCP'; -const uint32 MSG_PAGE_SETUP = 'mPSU'; -const uint32 MSG_PREPARE_PRINT = 'mPPT'; -const uint32 MSG_PRINT = 'mPRT'; -const uint32 MSG_ZOOM_IN = 'mZIN'; -const uint32 MSG_ZOOM_OUT = 'mZOU'; -const uint32 MSG_ORIGINAL_SIZE = 'mOSZ'; -const uint32 MSG_INVALIDATE = 'mIVD'; -const uint32 MSG_SCALE_BILINEAR = 'mSBL'; -const uint32 MSG_DESKTOP_BACKGROUND = 'mDBG'; -const uint32 MSG_OPEN_RESIZER_WINDOW = 'mORS'; -const uint32 MSG_RESIZER_WINDOW_QUITED = 'mRSQ'; -const uint32 MSG_RESIZE = 'mRSZ'; +enum { + MSG_CAPTURE_MOUSE = 'mCPM', + MSG_CHANGE_FOCUS = 'mCFS', + MSG_FILE_OPEN = 'mFOP', + MSG_WINDOW_QUIT = 'mWQT', + MSG_OUTPUT_TYPE = 'BTMN', + MSG_SAVE_PANEL = 'mFSP', + MSG_CLEAR_SELECT = 'mCSL', + MSG_SELECT_ALL = 'mSAL', + MSG_CLIPBOARD_CHANGED = 'mCLP', + MSG_DITHER_IMAGE = 'mDIM', + MSG_MODIFIED = 'mMOD', + MSG_UPDATE_STATUS = 'mUPS', + MSG_UPDATE_STATUS_TEXT = 'mUPT', + MSG_UNDO_STATE = 'mUNS', + MSG_SELECTION = 'mSEL', + MSG_SELECTION_BITMAP = 'mSBT', + MSG_PAGE_FIRST = 'mPGF', + MSG_PAGE_LAST = 'mPGL', + MSG_PAGE_NEXT = 'mPGN', + MSG_PAGE_PREV = 'mPGP', + MSG_GOTO_PAGE = 'mGTP', + MSG_FILE_NEXT = 'mFLN', + MSG_FILE_PREV = 'mFLP', + MSG_SHRINK_TO_WINDOW = 'mSTW', + MSG_ZOOM_TO_WINDOW = 'mZTW', + MSG_ROTATE_90 = 'mR90', + MSG_ROTATE_270 = 'mR27', + MSG_FLIP_LEFT_TO_RIGHT = 'mFLR', + MSG_FLIP_TOP_TO_BOTTOM = 'mFTB', + MSG_INVERT = 'mINV', + MSG_SLIDE_SHOW = 'mSSW', + MSG_SLIDE_SHOW_DELAY = 'mSSD', + MSG_FULL_SCREEN = 'mFSC', + MSG_EXIT_FULL_SCREEN = 'mEFS', + MSG_SHOW_CAPTION = 'mSCP', + MSG_PAGE_SETUP = 'mPSU', + MSG_PREPARE_PRINT = 'mPPT', + MSG_PRINT = 'mPRT', + MSG_ZOOM_IN = 'mZIN', + MSG_ZOOM_OUT = 'mZOU', + MSG_ORIGINAL_SIZE = 'mOSZ', + MSG_INVALIDATE = 'mIVD', + MSG_SCALE_BILINEAR = 'mSBL', + MSG_DESKTOP_BACKGROUND = 'mDBG', + MSG_OPEN_RESIZER_WINDOW = 'mORS', + MSG_RESIZER_WINDOW_QUIT = 'mRSQ', + MSG_RESIZE = 'mRSZ', +}; #endif // SHOW_IMAGE_CONSTANTS_H diff --git a/src/apps/showimage/ShowImageView.cpp b/src/apps/showimage/ShowImageView.cpp index 84831d2411..8390c04a91 100644 --- a/src/apps/showimage/ShowImageView.cpp +++ b/src/apps/showimage/ShowImageView.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006, Haiku, Inc. All Rights Reserved. + * Copyright 2003-2007, 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. @@ -368,20 +368,34 @@ ShowImageView::SetTrackerMessenger(const BMessenger& trackerMessenger) } +void +ShowImageView::SendMessageToWindow(BMessage *message) +{ + BMessenger msgr(Window()); + msgr.SendMessage(message); +} + + +void +ShowImageView::SendMessageToWindow(uint32 code) +{ + BMessage message(code); + SendMessageToWindow(&message); +} + + //! send message to parent about new image void -ShowImageView::Notify(const char* status) +ShowImageView::Notify() { BMessage msg(MSG_UPDATE_STATUS); - if (status != NULL) { - msg.AddString("status", status); - } + + msg.AddString("status", fImageType.String()); msg.AddInt32("width", fBitmap->Bounds().IntegerWidth() + 1); msg.AddInt32("height", fBitmap->Bounds().IntegerHeight() + 1); msg.AddInt32("colors", fBitmap->ColorSpace()); - BMessenger msgr(Window()); - msgr.SendMessage(&msg); + SendMessageToWindow(&msg); FixupScrollBars(); Invalidate(); @@ -511,7 +525,7 @@ ShowImageView::SetImage(const entry_ref *ref) DoImageOperation(ImageProcessor::kRotateClockwise, true); break; case k270: - DoImageOperation(ImageProcessor::kRotateAntiClockwise, true); + DoImageOperation(ImageProcessor::kRotateCounterClockwise, true); break; case k0V: DoImageOperation(ImageProcessor::ImageProcessor::kFlipTopToBottom, true); @@ -524,7 +538,7 @@ ShowImageView::SetImage(const entry_ref *ref) DoImageOperation(ImageProcessor::ImageProcessor::kFlipLeftToRight, true); break; case k270V: - DoImageOperation(ImageProcessor::kRotateAntiClockwise, true); + DoImageOperation(ImageProcessor::kRotateCounterClockwise, true); DoImageOperation(ImageProcessor::ImageProcessor::kFlipTopToBottom, true); break; } @@ -538,15 +552,17 @@ ShowImageView::SetImage(const entry_ref *ref) else fDocumentCount = 1; + fImageType = info.name; + GetPath(&fCaption); if (fDocumentCount > 1) fCaption << ", " << fDocumentIndex << "/" << fDocumentCount; - fCaption << ", " << info.name; + fCaption << ", " << fImageType; AddToRecentDocuments(); - Notify(info.name); + Notify(); return B_OK; } @@ -1104,7 +1120,7 @@ ShowImageView::BeginDrag(BPoint sourcePoint) drag.AddString("be:types", B_FILE_MIME_TYPE); // avoid flickering of dragged bitmap caused by drawing into the window AnimateSelection(false); - // only use a transparent bitmap on selections less than 400x400 (taking into account scaling) + // 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(); @@ -1352,8 +1368,7 @@ ShowImageView::MergeWithBitmap(BBitmap *merge, BRect selection) DeleteBitmap(); fBitmap = bitmap; - BMessenger msgr(Window()); - msgr.SendMessage(MSG_MODIFIED); + SendMessageToWindow(MSG_MODIFIED); } else delete bitmap; } @@ -1466,6 +1481,7 @@ ShowImageView::UpdateSelectionRect(BPoint point, bool final) if (fCopyFromRect.Width() < 1.0 && fCopyFromRect.Height() < 1.0) SetHasSelection(false); } + if (oldSelection != fCopyFromRect || !HasSelection()) { BRect updateRect; updateRect = oldSelection | fCopyFromRect; @@ -1496,8 +1512,7 @@ ShowImageView::MouseUp(BPoint point) fMakesSelection = false; } else if (fMovesImage) { MoveImage(); - if (fMovesImage) - fMovesImage = false; + fMovesImage = false; } AnimateSelection(true); } @@ -1593,10 +1608,10 @@ ShowImageView::KeyDown(const char* bytes, int32 numBytes) ScrollRestrictedBy(10, 0); break; case B_ENTER: - NextFile(); + SendMessageToWindow(MSG_FILE_NEXT); break; case B_BACKSPACE: - PrevFile(); + SendMessageToWindow(MSG_FILE_PREV); break; case B_HOME: break; @@ -1626,8 +1641,7 @@ ShowImageView::KeyDown(const char* bytes, int32 numBytes) if (!NextFile()) { // This is the last (or only file) in this directory, // close the window - BMessenger msgr(Window()); - msgr.SendMessage(B_QUIT_REQUESTED); + SendMessageToWindow(B_QUIT_REQUESTED); } break; } @@ -1889,8 +1903,7 @@ ShowImageView::AddWhiteRect(BRect &rect) DeleteBitmap(); fBitmap = bitmap; - BMessenger msgr(Window()); - msgr.SendMessage(MSG_MODIFIED); + SendMessageToWindow(MSG_MODIFIED); } else delete bitmap; } @@ -2006,8 +2019,7 @@ ShowImageView::SetHasSelection(bool bHasSelection) BMessage msg(MSG_SELECTION); msg.AddBool("has_selection", fHasSelection); - BMessenger msgr(Window()); - msgr.SendMessage(&msg); + SendMessageToWindow(&msg); } @@ -2377,7 +2389,7 @@ ShowImageView::DoImageOperation(ImageProcessor::operation op, bool quiet) if (op != ImageProcessor::kInvert) { // Note: If one of these fails, check its definition in class ImageProcessor. ASSERT(ImageProcessor::kRotateClockwise < ImageProcessor::kNumberOfAffineTransformations); - ASSERT(ImageProcessor::kRotateAntiClockwise < ImageProcessor::kNumberOfAffineTransformations); + ASSERT(ImageProcessor::kRotateCounterClockwise < ImageProcessor::kNumberOfAffineTransformations); ASSERT(ImageProcessor::kFlipLeftToRight < ImageProcessor::kNumberOfAffineTransformations); ASSERT(ImageProcessor::kFlipTopToBottom < ImageProcessor::kNumberOfAffineTransformations); fImageOrientation = fTransformation[op][fImageOrientation]; @@ -2404,19 +2416,7 @@ ShowImageView::DoImageOperation(ImageProcessor::operation op, bool quiet) if (!quiet) { // remove selection SetHasSelection(false); - // Pull the image type name from fCaption (hackish?) - int32 last_comma_index = fCaption.FindLast(','); - if (last_comma_index != B_ERROR) { - // The -1 at the end is -2 to get rid of the comma and space, +1 for the \0 - int32 name_size = fCaption.CountChars() - last_comma_index - 1; - char *name = new char[name_size]; - fCaption.CopyInto(name, last_comma_index + 2, name_size - 1); - name[name_size - 1] = '\0'; - Notify(name); - delete name; - } - else - Notify(NULL); + Notify(); } } @@ -2436,7 +2436,7 @@ ShowImageView::Rotate(int degree) if (degree == 90) { UserDoImageOperation(ImageProcessor::kRotateClockwise); } else if (degree == 270) { - UserDoImageOperation(ImageProcessor::kRotateAntiClockwise); + UserDoImageOperation(ImageProcessor::kRotateCounterClockwise); } } @@ -2483,10 +2483,9 @@ ShowImageView::ResizeImage(int w, int h) DeleteBitmap(); fBitmap = scaled; - BMessenger msgr(Window()); - msgr.SendMessage(MSG_MODIFIED); + SendMessageToWindow(MSG_MODIFIED); - Notify(NULL); + Notify(); } void @@ -2562,8 +2561,7 @@ ShowImageView::SetIcon(bool clear) void ShowImageView::ToggleSlideShow() { - BMessenger msgr(Window()); - msgr.SendMessage(MSG_SLIDE_SHOW); + SendMessageToWindow(MSG_SLIDE_SHOW); } @@ -2571,8 +2569,7 @@ void ShowImageView::ExitFullScreen() { be_app->ShowCursor(); - BMessenger m(Window()); - m.SendMessage(MSG_EXIT_FULL_SCREEN); + SendMessageToWindow(MSG_EXIT_FULL_SCREEN); } diff --git a/src/apps/showimage/ShowImageView.h b/src/apps/showimage/ShowImageView.h index a38e834317..bb9c87e1d1 100644 --- a/src/apps/showimage/ShowImageView.h +++ b/src/apps/showimage/ShowImageView.h @@ -133,7 +133,9 @@ class ShowImageView : public BView { bool HasSelection() { return fHasSelection; } void SetHasSelection(bool bHasSelection); void AnimateSelection(bool a); - void Notify(const char* status); + void SendMessageToWindow(BMessage *message); + void SendMessageToWindow(uint32 code); + void Notify(); void AddToRecentDocuments(); void AddWhiteRect(BRect &rect); void GetMergeRects(BBitmap *merge, BRect selection, BRect &srcBits, BRect &destRect); @@ -237,6 +239,8 @@ class ShowImageView : public BView { bool fShowCaption; // display caption? BString fCaption; // caption text + BString fImageType; // Type of image, for use in status bar and caption + bool fInverted; bool fShowingPopUpMenu; diff --git a/src/apps/showimage/ShowImageWindow.cpp b/src/apps/showimage/ShowImageWindow.cpp index d86bace683..db9bf7b229 100644 --- a/src/apps/showimage/ShowImageWindow.cpp +++ b/src/apps/showimage/ShowImageWindow.cpp @@ -832,7 +832,7 @@ ShowImageWindow::MessageReceived(BMessage *message) fImageView->ResizeImage(w, h); break; } - case MSG_RESIZER_WINDOW_QUITED: + case MSG_RESIZER_WINDOW_QUIT: fResizerWindowMessenger = NULL; break;