* Removed resizing ability.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39262 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
0d16ad4437
commit
04f965443f
@ -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
|
||||
|
@ -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 <stdlib.h>
|
||||
|
||||
#include <Box.h>
|
||||
#include <Button.h>
|
||||
#include <Catalog.h>
|
||||
#include <CheckBox.h>
|
||||
#include <ControlLook.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
#include <GridLayoutBuilder.h>
|
||||
#include <Locale.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <RadioButton.h>
|
||||
#include <Rect.h>
|
||||
#include <String.h>
|
||||
#include <TextControl.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
@ -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 <Messenger.h>
|
||||
#include <Window.h>
|
||||
|
||||
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
|
@ -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
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include <new>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Application.h>
|
||||
@ -41,10 +42,8 @@
|
||||
#include <TranslationDefs.h>
|
||||
#include <TranslationUtils.h>
|
||||
#include <TranslatorRoster.h>
|
||||
#include <stdlib.h> // 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);
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user