From 04f965443f1a5792f4f397fb870bbb03303aba3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 1 Nov 2010 21:26:53 +0000 Subject: [PATCH] * Removed resizing ability. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39262 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/showimage/Jamfile | 2 - src/apps/showimage/ResizerWindow.cpp | 187 ------------------------ src/apps/showimage/ResizerWindow.h | 65 -------- src/apps/showimage/ShowImageConstants.h | 4 +- src/apps/showimage/ShowImageWindow.cpp | 63 +------- src/apps/showimage/ShowImageWindow.h | 6 - 6 files changed, 5 insertions(+), 322 deletions(-) delete mode 100644 src/apps/showimage/ResizerWindow.cpp delete mode 100644 src/apps/showimage/ResizerWindow.h diff --git a/src/apps/showimage/Jamfile b/src/apps/showimage/Jamfile index 47034b0593..cfc695f2ff 100644 --- a/src/apps/showimage/Jamfile +++ b/src/apps/showimage/Jamfile @@ -10,7 +10,6 @@ Application ShowImage : ImageFileNavigator.cpp PrintOptionsWindow.cpp ProgressWindow.cpp - ResizerWindow.cpp SelectionBox.cpp ShowImageApp.cpp ShowImageSettings.cpp @@ -28,7 +27,6 @@ DoCatalogs ShowImage : : PrintOptionsWindow.cpp ProgressWindow.cpp - ResizerWindow.cpp ShowImageApp.cpp ShowImageView.cpp ShowImageWindow.cpp diff --git a/src/apps/showimage/ResizerWindow.cpp b/src/apps/showimage/ResizerWindow.cpp deleted file mode 100644 index ee81f341f5..0000000000 --- a/src/apps/showimage/ResizerWindow.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright 2006-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. - * - * Authors: - * yellowTAB GmbH - * Bernd Korz - * Michael Pfeiffer - * Ryan Leavengood - */ - -#include "ResizerWindow.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ShowImageConstants.h" - - -#undef B_TRANSLATE_CONTEXT -#define B_TRANSLATE_CONTEXT "ResizerWindow" - -ResizerWindow::ResizerWindow(BMessenger target, int32 width, int32 height) - : - BWindow(BRect(100, 100, 300, 300), B_TRANSLATE("Resize"), - B_FLOATING_WINDOW, - B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS), - fOriginalWidth(width), - fOriginalHeight(height), - fTarget(target) -{ - BString widthValue; - widthValue << width; - fWidth = new BTextControl("width", B_TRANSLATE("Width:"), - widthValue.String(), NULL); - fWidth->SetModificationMessage(new BMessage(kWidthModifiedMsg)); - - BString heightValue; - heightValue << height; - fHeight = new BTextControl("height", - B_TRANSLATE("Height:"), heightValue.String(), NULL); - fHeight->SetModificationMessage(new BMessage(kHeightModifiedMsg)); - - fAspectRatio = new BCheckBox("Ratio", - B_TRANSLATE("Keep original proportions"), - new BMessage(kWidthModifiedMsg)); - fAspectRatio->SetValue(B_CONTROL_ON); - - fApply = new BButton("apply", B_TRANSLATE("Apply"), - new BMessage(kApplyMsg)); - fApply->MakeDefault(true); - - const float spacing = be_control_look->DefaultItemSpacing(); - const float labelspacing = be_control_look->DefaultLabelSpacing(); - - SetLayout(new BGroupLayout(B_HORIZONTAL)); - AddChild(BGroupLayoutBuilder(B_VERTICAL, 0) - .Add(BGridLayoutBuilder(labelspacing, 0) - .Add(fWidth->CreateLabelLayoutItem(), 0, 0) - .Add(fWidth->CreateTextViewLayoutItem(), 1, 0) - .Add(fHeight->CreateLabelLayoutItem(), 0, 1) - .Add(fHeight->CreateTextViewLayoutItem(), 1, 1) - ) - .Add(fAspectRatio) - .AddGroup(B_HORIZONTAL, 0) - .AddGlue() - .Add(fApply) - .End() - .SetInsets(spacing, spacing, spacing, spacing) - ); - - fWidth->MakeFocus(); - -} - - -ResizerWindow::~ResizerWindow() -{ -} - - -void -ResizerWindow::MessageReceived(BMessage* message) -{ - switch (message->what) - { - // public actions - case kActivateMsg: - Activate(); - break; - - case kUpdateMsg: - { - // update aspect ratio, width and height - int32 width, height; - if (message->FindInt32("width", &width) == B_OK && - message->FindInt32("height", &height) == B_OK) { - - fOriginalWidth = width; - fOriginalHeight = height; - - BString widthText, heightText; - widthText << width; - heightText << height; - // here the statement order is important: - // in case keep aspect ratio is enabled, - // the width should determine the height - fHeight->SetText(heightText.String()); - fWidth->SetText(widthText.String()); - } - break; - } - - // private actions - case kResolutionMsg: - { - fAspectRatio->SetValue(B_CONTROL_OFF); - BString width, height; - width << message->FindInt32("w"); - height << message->FindInt32("h"); - fWidth->SetText(width.String()); - fHeight->SetText(height.String()); - break; - } - case kWidthModifiedMsg: - if (fAspectRatio->Value() == B_CONTROL_ON) { - int w = atoi(fWidth->Text()); - int h = (int)((int64)w * (int64) fOriginalHeight - / (int64) fOriginalWidth); - BString height; - height << h; - BMessage* msg = new BMessage(*fHeight->ModificationMessage()); - fHeight->SetModificationMessage(NULL); - fHeight->SetText(height.String()); - fHeight->SetModificationMessage(msg); - } - break; - case kHeightModifiedMsg: - if (fAspectRatio->Value() == B_CONTROL_ON) { - int h = atoi(fHeight->Text()); - int w = (int)((int64)h * (int64) fOriginalWidth - / (int64) fOriginalHeight); - BString width; - width << w; - BMessage* msg = new BMessage(*fWidth->ModificationMessage()); - fWidth->SetModificationMessage(NULL); - fWidth->SetText(width.String()); - fWidth->SetModificationMessage(msg); - } - break; - case kApplyMsg: - { - BMessage resizeRequest(MSG_RESIZE); - resizeRequest.AddInt32("h", atoi(fHeight->Text())); - resizeRequest.AddInt32("w", atoi(fWidth->Text())); - fTarget.SendMessage(&resizeRequest); - PostMessage(B_QUIT_REQUESTED); - break; - } - default: - BWindow::MessageReceived(message); - } -} - - -bool -ResizerWindow::QuitRequested() -{ - fTarget.SendMessage(MSG_RESIZER_WINDOW_QUIT); - return true; -} - diff --git a/src/apps/showimage/ResizerWindow.h b/src/apps/showimage/ResizerWindow.h deleted file mode 100644 index 599d36d561..0000000000 --- a/src/apps/showimage/ResizerWindow.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2006-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. - * - * Authors: - * yellowTAB GmbH - * Bernd Korz - * Michael Pfeiffer - * Ryan Leavengood - */ -#ifndef RESIZER_WINDOW_H -#define RESIZER_WINDOW_H - - -#include -#include - -class BCheckBox; -class BControl; -class BTextControl; - - -class ResizerWindow : public BWindow { - public: - ResizerWindow(BMessenger target, int32 width, - int32 height ); - - virtual void MessageReceived(BMessage* msg); - virtual bool QuitRequested(); - - virtual ~ResizerWindow(); - - // the public message command constants ('what') - enum { - kActivateMsg = 'RSRa', - // activates the window - kUpdateMsg, - // provides the new size of the image in two "int32" fields - // "width" and "height" - }; - - private: - enum { - kResolutionMsg = 'Rszr', - kWidthModifiedMsg, - kHeightModifiedMsg, - kApplyMsg, - }; - - - BTextControl* fWidth; - BTextControl* fHeight; - BCheckBox* fAspectRatio; - BButton* fApply; - // the original size of the image use for aspect ratio calculation - // to avoid rounding errors - int32 fOriginalWidth; - int32 fOriginalHeight; - BMessenger fTarget; -}; - - -#endif // RESIZER_WINDOW_H diff --git a/src/apps/showimage/ShowImageConstants.h b/src/apps/showimage/ShowImageConstants.h index b9e3294fd8..7ccac044d7 100644 --- a/src/apps/showimage/ShowImageConstants.h +++ b/src/apps/showimage/ShowImageConstants.h @@ -57,10 +57,8 @@ enum { MSG_ORIGINAL_SIZE = 'mOSZ', MSG_SCALE_BILINEAR = 'mSBL', MSG_DESKTOP_BACKGROUND = 'mDBG', - MSG_OPEN_RESIZER_WINDOW = 'mORS', - MSG_RESIZER_WINDOW_QUIT = 'mRSQ', - MSG_RESIZE = 'mRSZ', kMsgProgressStatusUpdate = 'SIup' }; + #endif // SHOW_IMAGE_CONSTANTS_H diff --git a/src/apps/showimage/ShowImageWindow.cpp b/src/apps/showimage/ShowImageWindow.cpp index 9a1604c355..941af6ff49 100644 --- a/src/apps/showimage/ShowImageWindow.cpp +++ b/src/apps/showimage/ShowImageWindow.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -41,10 +42,8 @@ #include #include #include -#include // for bs_printf() #include "EntryMenuItem.h" -#include "ResizerWindow.h" #include "ShowImageApp.h" #include "ShowImageConstants.h" #include "ShowImageStatusView.h" @@ -143,9 +142,7 @@ ShowImageWindow::ShowImageWindow(const entry_ref* ref, fModified(false), fFullScreen(false), fShowCaption(true), - fPrintSettings(NULL), - fResizerWindowMessenger(NULL), - fResizeItem(NULL) + fPrintSettings(NULL) { _LoadSettings(); @@ -225,7 +222,6 @@ ShowImageWindow::ShowImageWindow(const entry_ref* ref, ShowImageWindow::~ShowImageWindow() { - delete fResizerWindowMessenger; } @@ -389,12 +385,10 @@ ShowImageWindow::AddMenus(BMenuBar* bar) _AddItemMenu(menu, B_TRANSLATE("Flip top to bottom"), MSG_FLIP_TOP_TO_BOTTOM, 0, 0, this); menu->AddSeparatorItem(); - fResizeItem = _AddItemMenu(menu, B_TRANSLATE("Resize" B_UTF8_ELLIPSIS), - MSG_OPEN_RESIZER_WINDOW, 0, 0, this); - bar->AddItem(menu); - menu->AddSeparatorItem(); _AddItemMenu(menu, B_TRANSLATE("Use as background" B_UTF8_ELLIPSIS), MSG_DESKTOP_BACKGROUND, 0, 0, this); + + bar->AddItem(menu); } @@ -787,11 +781,9 @@ ShowImageWindow::MessageReceived(BMessage* message) break; if (item->IsMarked()) { item->SetMarked(false); - fResizeItem->SetEnabled(true); fImageView->StopSlideShow(); } else if (_ClosePrompt()) { item->SetMarked(true); - fResizeItem->SetEnabled(false); fImageView->StartSlideShow(); } break; @@ -857,11 +849,6 @@ ShowImageWindow::MessageReceived(BMessage* message) fImageView->SetScaleBilinear(_ToggleMenuItem(message->what)); break; - case MSG_RESIZER_WINDOW_QUIT: - delete fResizerWindowMessenger; - fResizerWindowMessenger = NULL; - break; - case MSG_DESKTOP_BACKGROUND: { BMessage message(B_REFS_RECEIVED); @@ -1207,45 +1194,6 @@ ShowImageWindow::_Print(BMessage* msg) } -void -ShowImageWindow::_OpenResizerWindow(int32 width, int32 height) -{ - if (fResizerWindowMessenger == NULL) { - // open window if it is not already opened - BWindow* window = new ResizerWindow(this, width, height); - fResizerWindowMessenger = new BMessenger(window); - window->Show(); - } else { - fResizerWindowMessenger->SendMessage(ResizerWindow::kActivateMsg); - } -} - - -void -ShowImageWindow::_UpdateResizerWindow(int32 width, int32 height) -{ - if (fResizerWindowMessenger == NULL) - return; - - BMessage updateMsg(ResizerWindow::kUpdateMsg); - updateMsg.AddInt32("width", width); - updateMsg.AddInt32("height", height); - fResizerWindowMessenger->SendMessage(&updateMsg); -} - - -void -ShowImageWindow::_CloseResizerWindow() -{ - if (fResizerWindowMessenger == NULL) - return; - - fResizerWindowMessenger->SendMessage(B_QUIT_REQUESTED); - delete fResizerWindowMessenger; - fResizerWindowMessenger = NULL; -} - - bool ShowImageWindow::QuitRequested() { @@ -1255,10 +1203,7 @@ ShowImageWindow::QuitRequested() } bool quit = _ClosePrompt(); - if (quit) { - _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 4690d64f0c..0bb632c5a8 100644 --- a/src/apps/showimage/ShowImageWindow.h +++ b/src/apps/showimage/ShowImageWindow.h @@ -75,10 +75,6 @@ private: void _PrepareForPrint(); void _Print(BMessage* msg); - void _OpenResizerWindow(int32 width, int32 height); - void _UpdateResizerWindow(int32 width, int32 height); - void _CloseResizerWindow(); - private: ImageFileNavigator fNavigator; BFilePanel* fSavePanel; @@ -95,8 +91,6 @@ private: BRect fWindowFrame; BMessage* fPrintSettings; PrintOptions fPrintOptions; - BMessenger* fResizerWindowMessenger; - BMenuItem* fResizeItem; BString fImageType; };