* some more cleanup
* pass the target directly to AddItemMenu * use default paramter to enable the menu item * fixed messenger leaks for file panel and resizer window messenger * show the job config panel when the 'Print' menu item is invoked + shortcut git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27204 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
9837b719af
commit
6163f3334b
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2006, Haiku, Inc. All Rights Reserved.
|
* Copyright 2003-2008, Haiku, Inc. All Rights Reserved.
|
||||||
* Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd.
|
* Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd.
|
||||||
* Copyright 2006 Bernd Korz. All Rights Reserved
|
* Copyright 2006 Bernd Korz. All Rights Reserved
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
@ -12,7 +12,6 @@
|
|||||||
* Bernd Korz
|
* Bernd Korz
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "BackgroundImage.h"
|
#include "BackgroundImage.h"
|
||||||
#include "EntryMenuItem.h"
|
#include "EntryMenuItem.h"
|
||||||
#include "ResizerWindow.h"
|
#include "ResizerWindow.h"
|
||||||
@ -22,6 +21,7 @@
|
|||||||
#include "ShowImageView.h"
|
#include "ShowImageView.h"
|
||||||
#include "ShowImageWindow.h"
|
#include "ShowImageWindow.h"
|
||||||
|
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
@ -29,6 +29,7 @@
|
|||||||
#include <Clipboard.h>
|
#include <Clipboard.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
|
#include <FilePanel.h>
|
||||||
#include <Menu.h>
|
#include <Menu.h>
|
||||||
#include <MenuBar.h>
|
#include <MenuBar.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
@ -37,35 +38,51 @@
|
|||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
#include <ScrollView.h>
|
#include <ScrollView.h>
|
||||||
|
#include <String.h>
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
#include <TranslationDefs.h>
|
||||||
#include <TranslationUtils.h>
|
#include <TranslationUtils.h>
|
||||||
#include <TranslatorRoster.h>
|
#include <TranslatorRoster.h>
|
||||||
|
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
RecentDocumentsMenu::RecentDocumentsMenu(const char *title, menu_layout layout)
|
// #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);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void UpdateRecentDocumentsMenu();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ShowImageWindow::RecentDocumentsMenu::RecentDocumentsMenu(const char *title,
|
||||||
|
menu_layout layout)
|
||||||
: BMenu(title, layout)
|
: BMenu(title, layout)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
RecentDocumentsMenu::AddDynamicItem(add_state addState)
|
ShowImageWindow::RecentDocumentsMenu::AddDynamicItem(add_state addState)
|
||||||
{
|
{
|
||||||
if (addState != B_INITIAL_ADD)
|
if (addState != B_INITIAL_ADD)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
while (CountItems() > 0)
|
||||||
|
delete RemoveItem(0L);
|
||||||
|
|
||||||
BMenuItem *item;
|
BMenuItem *item;
|
||||||
BMessage list, *msg;
|
BMessage list, *msg;
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
char name[B_FILE_NAME_LENGTH];
|
char name[B_FILE_NAME_LENGTH];
|
||||||
|
|
||||||
while ((item = RemoveItem((int32)0)) != NULL) {
|
|
||||||
delete item;
|
|
||||||
}
|
|
||||||
|
|
||||||
be_roster->GetRecentDocuments(&list, 20, NULL, kApplicationSignature);
|
be_roster->GetRecentDocuments(&list, 20, NULL, kApplicationSignature);
|
||||||
for (int i = 0; list.FindRef("refs", i, &ref) == B_OK; i++) {
|
for (int i = 0; list.FindRef("refs", i, &ref) == B_OK; i++) {
|
||||||
BEntry entry(&ref);
|
BEntry entry(&ref);
|
||||||
@ -82,7 +99,12 @@ RecentDocumentsMenu::AddDynamicItem(add_state addState)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -- ShowImageWindow
|
||||||
|
|
||||||
|
|
||||||
|
// BMessage field names used in Save messages
|
||||||
|
const char* kTypeField = "be:type";
|
||||||
|
const char* kTranslatorField = "be:translator";
|
||||||
|
|
||||||
|
|
||||||
ShowImageWindow::ShowImageWindow(const entry_ref *ref,
|
ShowImageWindow::ShowImageWindow(const entry_ref *ref,
|
||||||
@ -186,6 +208,7 @@ ShowImageWindow::ShowImageWindow(const entry_ref *ref,
|
|||||||
|
|
||||||
ShowImageWindow::~ShowImageWindow()
|
ShowImageWindow::~ShowImageWindow()
|
||||||
{
|
{
|
||||||
|
delete fResizerWindowMessenger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -218,7 +241,7 @@ ShowImageWindow::BuildContextMenu(BMenu *menu)
|
|||||||
void
|
void
|
||||||
ShowImageWindow::BuildViewMenu(BMenu *menu, bool popupMenu)
|
ShowImageWindow::BuildViewMenu(BMenu *menu, bool popupMenu)
|
||||||
{
|
{
|
||||||
AddItemMenu(menu, "Slide Show", MSG_SLIDE_SHOW, 0, 0, 'W', true);
|
AddItemMenu(menu, "Slide Show", MSG_SLIDE_SHOW, 0, 0, this);
|
||||||
MarkMenuItem(menu, MSG_SLIDE_SHOW, fImageView->SlideShowStarted());
|
MarkMenuItem(menu, MSG_SLIDE_SHOW, fImageView->SlideShowStarted());
|
||||||
BMenu* delayMenu = new BMenu("Slide Delay");
|
BMenu* delayMenu = new BMenu("Slide Delay");
|
||||||
if (fSlideShowDelay == NULL)
|
if (fSlideShowDelay == NULL)
|
||||||
@ -242,28 +265,28 @@ ShowImageWindow::BuildViewMenu(BMenu *menu, bool popupMenu)
|
|||||||
|
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
|
|
||||||
AddItemMenu(menu, "Original Size", MSG_ORIGINAL_SIZE, 0, 0, 'W', true);
|
AddItemMenu(menu, "Original Size", MSG_ORIGINAL_SIZE, 0, 0, this);
|
||||||
AddItemMenu(menu, "Zoom In", MSG_ZOOM_IN, '+', 0, 'W', true);
|
AddItemMenu(menu, "Zoom In", MSG_ZOOM_IN, '+', 0, this);
|
||||||
AddItemMenu(menu, "Zoom Out", MSG_ZOOM_OUT, '-', 0, 'W', true);
|
AddItemMenu(menu, "Zoom Out", MSG_ZOOM_OUT, '-', 0, this);
|
||||||
|
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
|
|
||||||
AddItemMenu(menu, "High-Quality Zooming", MSG_SCALE_BILINEAR, 0, 0, 'W', true);
|
AddItemMenu(menu, "High-Quality Zooming", MSG_SCALE_BILINEAR, 0, 0, this);
|
||||||
|
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
|
|
||||||
AddItemMenu(menu, "Shrink to Window", MSG_SHRINK_TO_WINDOW, 0, 0, 'W', true);
|
AddItemMenu(menu, "Shrink to Window", MSG_SHRINK_TO_WINDOW, 0, 0, this);
|
||||||
AddItemMenu(menu, "Zoom to Window", MSG_ZOOM_TO_WINDOW, 0, 0, 'W', true);
|
AddItemMenu(menu, "Zoom to Window", MSG_ZOOM_TO_WINDOW, 0, 0, this);
|
||||||
|
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
|
|
||||||
AddItemMenu(menu, "Full Screen", MSG_FULL_SCREEN, 'F', 0, 'W', true);
|
AddItemMenu(menu, "Full Screen", MSG_FULL_SCREEN, 'F', 0, this);
|
||||||
MarkMenuItem(menu, MSG_FULL_SCREEN, fFullScreen);
|
MarkMenuItem(menu, MSG_FULL_SCREEN, fFullScreen);
|
||||||
|
|
||||||
AddShortcut(B_ENTER, 0, new BMessage(MSG_FULL_SCREEN));
|
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, 'W', true);
|
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());
|
||||||
@ -283,7 +306,7 @@ ShowImageWindow::BuildViewMenu(BMenu *menu, bool popupMenu)
|
|||||||
if (popupMenu) {
|
if (popupMenu) {
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
AddItemMenu(menu, "As Desktop Background", MSG_DESKTOP_BACKGROUND, 0, 0,
|
AddItemMenu(menu, "As Desktop Background", MSG_DESKTOP_BACKGROUND, 0, 0,
|
||||||
'W', true);
|
this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,85 +327,80 @@ ShowImageWindow::AddMenus(BMenuBar *bar)
|
|||||||
// Fill Save As submenu with all types that can be converted
|
// Fill Save As submenu with all types that can be converted
|
||||||
// to from the Be bitmap image format
|
// to from the Be bitmap image format
|
||||||
menu->AddItem(pmenuSaveAs);
|
menu->AddItem(pmenuSaveAs);
|
||||||
AddItemMenu(menu, "Close", B_QUIT_REQUESTED, 'W', 0, 'W', true);
|
AddItemMenu(menu, "Close", B_QUIT_REQUESTED, 'W', 0, this);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
AddItemMenu(menu, "Page Setup" B_UTF8_ELLIPSIS, MSG_PAGE_SETUP, 0, 0, 'W', true);
|
AddItemMenu(menu, "Page Setup" B_UTF8_ELLIPSIS, MSG_PAGE_SETUP, 0, 0, this);
|
||||||
AddItemMenu(menu, "Print" B_UTF8_ELLIPSIS, MSG_PREPARE_PRINT, 0, 0, 'W', true);
|
AddItemMenu(menu, "Print" B_UTF8_ELLIPSIS, MSG_PREPARE_PRINT, 'P', 0, this);
|
||||||
menu->AddSeparatorItem();
|
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,
|
||||||
'A', true);
|
be_app);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
AddItemMenu(menu, "Quit", B_QUIT_REQUESTED, 'Q', 0, 'A', true);
|
AddItemMenu(menu, "Quit", B_QUIT_REQUESTED, 'Q', 0, be_app);
|
||||||
bar->AddItem(menu);
|
bar->AddItem(menu);
|
||||||
|
|
||||||
menu = new BMenu("Edit");
|
menu = new BMenu("Edit");
|
||||||
AddItemMenu(menu, "Undo", B_UNDO, 'Z', 0, 'W', false);
|
AddItemMenu(menu, "Undo", B_UNDO, 'Z', 0, this, false);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
AddItemMenu(menu, "Cut", B_CUT, 'X', 0, 'W', false);
|
AddItemMenu(menu, "Cut", B_CUT, 'X', 0, this, false);
|
||||||
AddItemMenu(menu, "Copy", B_COPY, 'C', 0, 'W', false);
|
AddItemMenu(menu, "Copy", B_COPY, 'C', 0, this, false);
|
||||||
AddItemMenu(menu, "Paste", B_PASTE, 'V', 0, 'W', false);
|
AddItemMenu(menu, "Paste", B_PASTE, 'V', 0, this, false);
|
||||||
AddItemMenu(menu, "Clear", MSG_CLEAR_SELECT, 0, 0, 'W', false);
|
AddItemMenu(menu, "Clear", MSG_CLEAR_SELECT, 0, 0, this, false);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
AddItemMenu(menu, "Select All", MSG_SELECT_ALL, 'A', 0, 'W', true);
|
AddItemMenu(menu, "Select All", MSG_SELECT_ALL, 'A', 0, this);
|
||||||
bar->AddItem(menu);
|
bar->AddItem(menu);
|
||||||
|
|
||||||
menu = fBrowseMenu = new BMenu("Browse");
|
menu = fBrowseMenu = new BMenu("Browse");
|
||||||
AddItemMenu(menu, "First Page", MSG_PAGE_FIRST, B_LEFT_ARROW, B_SHIFT_KEY, 'W', true);
|
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, 'W', true);
|
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, 'W', true);
|
AddItemMenu(menu, "Previous Page", MSG_PAGE_PREV, B_LEFT_ARROW, 0, this);
|
||||||
AddItemMenu(menu, "Next Page", MSG_PAGE_NEXT, B_RIGHT_ARROW, 0, 'W', true);
|
AddItemMenu(menu, "Next Page", MSG_PAGE_NEXT, B_RIGHT_ARROW, 0, this);
|
||||||
fGoToPageMenu = new BMenu("Go to Page");
|
fGoToPageMenu = new BMenu("Go to Page");
|
||||||
fGoToPageMenu->SetRadioMode(true);
|
fGoToPageMenu->SetRadioMode(true);
|
||||||
menu->AddItem(fGoToPageMenu);
|
menu->AddItem(fGoToPageMenu);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
AddItemMenu(menu, "Previous File", MSG_FILE_PREV, B_UP_ARROW, 0, 'W', true);
|
AddItemMenu(menu, "Previous File", MSG_FILE_PREV, B_UP_ARROW, 0, this);
|
||||||
AddItemMenu(menu, "Next File", MSG_FILE_NEXT, B_DOWN_ARROW, 0, 'W', true);
|
AddItemMenu(menu, "Next File", MSG_FILE_NEXT, B_DOWN_ARROW, 0, this);
|
||||||
bar->AddItem(menu);
|
bar->AddItem(menu);
|
||||||
|
|
||||||
menu = new BMenu("Image");
|
menu = new BMenu("Image");
|
||||||
AddItemMenu(menu, "Rotate Counterclockwise", MSG_ROTATE_270, '[', 0, 'W', true);
|
AddItemMenu(menu, "Rotate Counterclockwise", MSG_ROTATE_270, '[', 0, this);
|
||||||
AddItemMenu(menu, "Rotate Clockwise", MSG_ROTATE_90, ']', 0, 'W', true);
|
AddItemMenu(menu, "Rotate Clockwise", MSG_ROTATE_90, ']', 0, this);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
AddItemMenu(menu, "Flip Left to Right", MSG_FLIP_LEFT_TO_RIGHT, 0, 0, 'W', true);
|
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, 'W', true);
|
AddItemMenu(menu, "Flip Top to Bottom", MSG_FLIP_TOP_TO_BOTTOM, 0, 0, this);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
AddItemMenu(menu, "Invert Colors", MSG_INVERT, 0, 0, 'W', true);
|
AddItemMenu(menu, "Invert Colors", MSG_INVERT, 0, 0, this);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
fResizeItem = AddItemMenu(menu, "Resize" B_UTF8_ELLIPSIS,
|
fResizeItem = AddItemMenu(menu, "Resize" B_UTF8_ELLIPSIS,
|
||||||
MSG_OPEN_RESIZER_WINDOW, 0, 0, 'W', true);
|
MSG_OPEN_RESIZER_WINDOW, 0, 0, this);
|
||||||
bar->AddItem(menu);
|
bar->AddItem(menu);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
AddItemMenu(menu, "Use as Desktop Background", MSG_DESKTOP_BACKGROUND, 0, 0,
|
AddItemMenu(menu, "Use as Desktop Background", MSG_DESKTOP_BACKGROUND, 0, 0,
|
||||||
'W', true);
|
this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMenuItem *
|
BMenuItem*
|
||||||
ShowImageWindow::AddItemMenu(BMenu *menu, char *caption, uint32 command,
|
ShowImageWindow::AddItemMenu(BMenu *menu, const char *label, uint32 what,
|
||||||
char shortcut, uint32 modifier, char target, bool enabled)
|
const char shortcut, uint32 modifier, const BHandler *target, bool enabled)
|
||||||
{
|
{
|
||||||
BMenuItem* item =
|
BMenuItem* item = new BMenuItem(label, new BMessage(what), shortcut, modifier);
|
||||||
new BMenuItem(caption, new BMessage(command), shortcut, modifier);
|
|
||||||
|
|
||||||
if (target == 'A')
|
|
||||||
item->SetTarget(be_app);
|
|
||||||
else
|
|
||||||
item->SetTarget(this);
|
|
||||||
|
|
||||||
item->SetEnabled(enabled);
|
|
||||||
menu->AddItem(item);
|
menu->AddItem(item);
|
||||||
|
|
||||||
|
item->SetTarget(target);
|
||||||
|
item->SetEnabled(enabled);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMenuItem*
|
BMenuItem*
|
||||||
ShowImageWindow::AddDelayItem(BMenu *menu, char *caption, float value)
|
ShowImageWindow::AddDelayItem(BMenu *menu, const char *label, float value)
|
||||||
{
|
{
|
||||||
BMessage* message = new BMessage(MSG_SLIDE_SHOW_DELAY);
|
BMessage* message = new BMessage(MSG_SLIDE_SHOW_DELAY);
|
||||||
message->AddFloat("value", value);
|
message->AddFloat("value", value);
|
||||||
|
|
||||||
BMenuItem* item = new BMenuItem(caption, message, 0);
|
BMenuItem* item = new BMenuItem(label, message, 0);
|
||||||
item->SetTarget(this);
|
item->SetTarget(this);
|
||||||
|
|
||||||
bool marked = fImageView->GetSlideShowDelay() == value;
|
bool marked = fImageView->GetSlideShowDelay() == value;
|
||||||
@ -402,16 +420,15 @@ ShowImageWindow::WindowRedimension(BBitmap *pbitmap)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
BRect r(pbitmap->Bounds());
|
BRect r(pbitmap->Bounds());
|
||||||
const float windowBorderWidth = 5;
|
|
||||||
const float windowBorderHeight = 5;
|
|
||||||
|
|
||||||
float width = r.Width() + 2 * PEN_SIZE + B_V_SCROLL_BAR_WIDTH;
|
float width = r.Width() + 2 * PEN_SIZE + B_V_SCROLL_BAR_WIDTH;
|
||||||
float height = r.Height() + 2 * PEN_SIZE + 1 + fBar->Frame().Height() +
|
float height = r.Height() + 2 * PEN_SIZE + 1 + fBar->Frame().Height() +
|
||||||
B_H_SCROLL_BAR_HEIGHT;
|
B_H_SCROLL_BAR_HEIGHT;
|
||||||
|
|
||||||
|
BRect frame = screen.Frame();
|
||||||
|
const float windowBorder = 5;
|
||||||
// dimensions so that window does not reach outside of screen
|
// dimensions so that window does not reach outside of screen
|
||||||
float maxWidth = screen.Frame().Width() + 1 - windowBorderWidth - Frame().left;
|
float maxWidth = frame.Width() + 1 - windowBorder - Frame().left;
|
||||||
float maxHeight = screen.Frame().Height() + 1 - windowBorderHeight - Frame().top;
|
float maxHeight = frame.Height() + 1 - windowBorder - Frame().top;
|
||||||
|
|
||||||
// We have to check size limits manually, otherwise
|
// We have to check size limits manually, otherwise
|
||||||
// menu bar will be too short for small images.
|
// menu bar will be too short for small images.
|
||||||
@ -439,15 +456,15 @@ ShowImageWindow::WindowRedimension(BBitmap *pbitmap)
|
|||||||
void
|
void
|
||||||
ShowImageWindow::FrameResized(float width, float height)
|
ShowImageWindow::FrameResized(float width, float height)
|
||||||
{
|
{
|
||||||
|
BWindow::FrameResized(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ShowImageWindow::ToggleMenuItem(uint32 what)
|
ShowImageWindow::ToggleMenuItem(uint32 what)
|
||||||
{
|
{
|
||||||
BMenuItem *item;
|
|
||||||
bool marked = false;
|
bool marked = false;
|
||||||
item = fBar->FindItem(what);
|
BMenuItem *item = fBar->FindItem(what);
|
||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
marked = !item->IsMarked();
|
marked = !item->IsMarked();
|
||||||
item->SetMarked(marked);
|
item->SetMarked(marked);
|
||||||
@ -459,22 +476,18 @@ ShowImageWindow::ToggleMenuItem(uint32 what)
|
|||||||
void
|
void
|
||||||
ShowImageWindow::EnableMenuItem(BMenu *menu, uint32 what, bool enable)
|
ShowImageWindow::EnableMenuItem(BMenu *menu, uint32 what, bool enable)
|
||||||
{
|
{
|
||||||
BMenuItem* item;
|
BMenuItem* item = menu->FindItem(what);
|
||||||
item = menu->FindItem(what);
|
if (item && item->IsEnabled() != enable)
|
||||||
if (item && item->IsEnabled() != enable) {
|
|
||||||
item->SetEnabled(enable);
|
item->SetEnabled(enable);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageWindow::MarkMenuItem(BMenu *menu, uint32 what, bool marked)
|
ShowImageWindow::MarkMenuItem(BMenu *menu, uint32 what, bool marked)
|
||||||
{
|
{
|
||||||
BMenuItem* item;
|
BMenuItem* item = menu->FindItem(what);
|
||||||
item = menu->FindItem(what);
|
if (item && item->IsMarked() != marked)
|
||||||
if (item && item->IsMarked() != marked) {
|
|
||||||
item->SetMarked(marked);
|
item->SetMarked(marked);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -487,9 +500,8 @@ ShowImageWindow::MarkSlideShowDelay(float value)
|
|||||||
BMenuItem* item = fSlideShowDelay->ItemAt(i);
|
BMenuItem* item = fSlideShowDelay->ItemAt(i);
|
||||||
if (item) {
|
if (item) {
|
||||||
if (item->Message()->FindFloat("value", &v) == B_OK && v == value) {
|
if (item->Message()->FindFloat("value", &v) == B_OK && v == value) {
|
||||||
if (!item->IsMarked()) {
|
if (!item->IsMarked())
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -500,13 +512,12 @@ ShowImageWindow::MarkSlideShowDelay(float value)
|
|||||||
void
|
void
|
||||||
ShowImageWindow::ResizeToWindow(bool shrink, uint32 what)
|
ShowImageWindow::ResizeToWindow(bool shrink, uint32 what)
|
||||||
{
|
{
|
||||||
bool enabled;
|
bool enabled = ToggleMenuItem(what);
|
||||||
enabled = ToggleMenuItem(what);
|
if (shrink)
|
||||||
if (shrink) {
|
|
||||||
fImageView->SetShrinkToBounds(enabled);
|
fImageView->SetShrinkToBounds(enabled);
|
||||||
} else {
|
else
|
||||||
fImageView->SetZoomToBounds(enabled);
|
fImageView->SetZoomToBounds(enabled);
|
||||||
}
|
|
||||||
enabled = !(fImageView->GetShrinkToBounds() || fImageView->GetZoomToBounds());
|
enabled = !(fImageView->GetShrinkToBounds() || fImageView->GetZoomToBounds());
|
||||||
EnableMenuItem(fBar, MSG_ORIGINAL_SIZE, enabled);
|
EnableMenuItem(fBar, MSG_ORIGINAL_SIZE, enabled);
|
||||||
EnableMenuItem(fBar, MSG_ZOOM_IN, enabled);
|
EnableMenuItem(fBar, MSG_ZOOM_IN, enabled);
|
||||||
@ -540,11 +551,9 @@ ShowImageWindow::MessageReceived(BMessage *message)
|
|||||||
fSavePanel = NULL;
|
fSavePanel = NULL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_UPDATE_STATUS:
|
case MSG_UPDATE_STATUS: {
|
||||||
{
|
int32 pages = fImageView->PageCount();
|
||||||
int32 pages, curPage;
|
int32 curPage = fImageView->CurrentPage();
|
||||||
pages = fImageView->PageCount();
|
|
||||||
curPage = fImageView->CurrentPage();
|
|
||||||
|
|
||||||
bool benable = (pages > 1) ? true : false;
|
bool benable = (pages > 1) ? true : false;
|
||||||
EnableMenuItem(fBar, MSG_PAGE_FIRST, benable);
|
EnableMenuItem(fBar, MSG_PAGE_FIRST, benable);
|
||||||
@ -565,19 +574,21 @@ ShowImageWindow::MessageReceived(BMessage *message)
|
|||||||
|
|
||||||
for (int32 i = 1; i <= pages; i++) {
|
for (int32 i = 1; i <= pages; i++) {
|
||||||
// Fill Go To page submenu with an entry for each page
|
// Fill Go To page submenu with an entry for each page
|
||||||
BMessage *pgomsg;
|
BMessage *pgomsg = new BMessage(MSG_GOTO_PAGE);
|
||||||
char shortcut = 0;
|
|
||||||
pgomsg = new BMessage(MSG_GOTO_PAGE);
|
|
||||||
pgomsg->AddInt32("page", i);
|
pgomsg->AddInt32("page", i);
|
||||||
BString strCaption;
|
|
||||||
strCaption << i;
|
char shortcut = 0;
|
||||||
BMenuItem *item;
|
|
||||||
if (i < 10) {
|
if (i < 10) {
|
||||||
shortcut = '0' + i;
|
shortcut = '0' + i;
|
||||||
} else if (i == 10) {
|
} else if (i == 10) {
|
||||||
shortcut = '0';
|
shortcut = '0';
|
||||||
}
|
}
|
||||||
item = new BMenuItem(strCaption.String(), pgomsg, shortcut);
|
|
||||||
|
BString strCaption;
|
||||||
|
strCaption << i;
|
||||||
|
|
||||||
|
BMenuItem *item = new BMenuItem(strCaption.String(), pgomsg,
|
||||||
|
shortcut);
|
||||||
if (curPage == i)
|
if (curPage == i)
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
fGoToPageMenu->AddItem(item);
|
fGoToPageMenu->AddItem(item);
|
||||||
@ -620,11 +631,9 @@ ShowImageWindow::MessageReceived(BMessage *message)
|
|||||||
fStatusView->SetText(status);
|
fStatusView->SetText(status);
|
||||||
|
|
||||||
UpdateTitle();
|
UpdateTitle();
|
||||||
break;
|
} break;
|
||||||
}
|
|
||||||
|
|
||||||
case MSG_UPDATE_STATUS_TEXT:
|
case MSG_UPDATE_STATUS_TEXT: {
|
||||||
{
|
|
||||||
BString status;
|
BString status;
|
||||||
status << fWidth << "x" << fHeight;
|
status << fWidth << "x" << fHeight;
|
||||||
BString str;
|
BString str;
|
||||||
@ -632,11 +641,9 @@ ShowImageWindow::MessageReceived(BMessage *message)
|
|||||||
status << ", " << str;
|
status << ", " << str;
|
||||||
fStatusView->SetText(status);
|
fStatusView->SetText(status);
|
||||||
}
|
}
|
||||||
break;
|
} break;
|
||||||
}
|
|
||||||
|
|
||||||
case MSG_SELECTION:
|
case MSG_SELECTION: {
|
||||||
{
|
|
||||||
// The view sends this message when a selection is
|
// The view sends this message when a selection is
|
||||||
// made or the selection is cleared so that the window
|
// made or the selection is cleared so that the window
|
||||||
// can update the state of the appropriate menu items
|
// can update the state of the appropriate menu items
|
||||||
@ -646,43 +653,42 @@ ShowImageWindow::MessageReceived(BMessage *message)
|
|||||||
EnableMenuItem(fBar, B_COPY, benable);
|
EnableMenuItem(fBar, B_COPY, benable);
|
||||||
EnableMenuItem(fBar, MSG_CLEAR_SELECT, benable);
|
EnableMenuItem(fBar, MSG_CLEAR_SELECT, benable);
|
||||||
}
|
}
|
||||||
break;
|
} break;
|
||||||
}
|
|
||||||
|
|
||||||
case MSG_UNDO_STATE:
|
case MSG_UNDO_STATE: {
|
||||||
{
|
|
||||||
bool benable;
|
bool benable;
|
||||||
if (message->FindBool("can_undo", &benable) == B_OK)
|
if (message->FindBool("can_undo", &benable) == B_OK)
|
||||||
EnableMenuItem(fBar, B_UNDO, benable);
|
EnableMenuItem(fBar, B_UNDO, benable);
|
||||||
break;
|
} break;
|
||||||
}
|
|
||||||
|
|
||||||
case MSG_CLIPBOARD_CHANGED:
|
case MSG_CLIPBOARD_CHANGED: {
|
||||||
{
|
// The app sends this message after it examines the clipboard in
|
||||||
// The app sends this message after it examines
|
// response to a B_CLIPBOARD_CHANGED message
|
||||||
// the clipboard in response to a B_CLIPBOARD_CHANGED
|
|
||||||
// message
|
|
||||||
bool bdata;
|
bool bdata;
|
||||||
if (message->FindBool("data_available", &bdata) == B_OK)
|
if (message->FindBool("data_available", &bdata) == B_OK)
|
||||||
EnableMenuItem(fBar, B_PASTE, bdata);
|
EnableMenuItem(fBar, B_PASTE, bdata);
|
||||||
break;
|
} break;
|
||||||
}
|
|
||||||
|
|
||||||
case B_UNDO:
|
case B_UNDO:
|
||||||
fImageView->Undo();
|
fImageView->Undo();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_CUT:
|
case B_CUT:
|
||||||
fImageView->Cut();
|
fImageView->Cut();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_COPY:
|
case B_COPY:
|
||||||
fImageView->CopySelectionToClipboard();
|
fImageView->CopySelectionToClipboard();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_PASTE:
|
case B_PASTE:
|
||||||
fImageView->Paste();
|
fImageView->Paste();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_CLEAR_SELECT:
|
case MSG_CLEAR_SELECT:
|
||||||
fImageView->ClearSelection();
|
fImageView->ClearSelection();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_SELECT_ALL:
|
case MSG_SELECT_ALL:
|
||||||
fImageView->SelectAll();
|
fImageView->SelectAll();
|
||||||
break;
|
break;
|
||||||
@ -707,29 +713,27 @@ ShowImageWindow::MessageReceived(BMessage *message)
|
|||||||
fImageView->PrevPage();
|
fImageView->PrevPage();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_GOTO_PAGE:
|
case MSG_GOTO_PAGE: {
|
||||||
{
|
|
||||||
if (!ClosePrompt())
|
if (!ClosePrompt())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
int32 curPage, newPage, pages;
|
int32 newPage;
|
||||||
if (message->FindInt32("page", &newPage) == B_OK) {
|
if (message->FindInt32("page", &newPage) != B_OK)
|
||||||
curPage = fImageView->CurrentPage();
|
break;
|
||||||
pages = fImageView->PageCount();
|
|
||||||
|
|
||||||
if (newPage > 0 && newPage <= pages) {
|
int32 curPage = fImageView->CurrentPage();
|
||||||
BMenuItem *pcurItem, *pnewItem;
|
int32 pages = fImageView->PageCount();
|
||||||
pcurItem = fGoToPageMenu->ItemAt(curPage - 1);
|
|
||||||
pnewItem = fGoToPageMenu->ItemAt(newPage - 1);
|
if (newPage > 0 && newPage <= pages) {
|
||||||
if (!pcurItem || !pnewItem)
|
BMenuItem* pcurItem = fGoToPageMenu->ItemAt(curPage - 1);
|
||||||
break;
|
BMenuItem* pnewItem = fGoToPageMenu->ItemAt(newPage - 1);
|
||||||
|
if (pcurItem && pnewItem) {
|
||||||
pcurItem->SetMarked(false);
|
pcurItem->SetMarked(false);
|
||||||
pnewItem->SetMarked(true);
|
pnewItem->SetMarked(true);
|
||||||
fImageView->GoToPage(newPage);
|
fImageView->GoToPage(newPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
} break;
|
||||||
}
|
|
||||||
|
|
||||||
case MSG_DITHER_IMAGE:
|
case MSG_DITHER_IMAGE:
|
||||||
fImageView->SetDither(ToggleMenuItem(message->what));
|
fImageView->SetDither(ToggleMenuItem(message->what));
|
||||||
@ -738,6 +742,7 @@ ShowImageWindow::MessageReceived(BMessage *message)
|
|||||||
case MSG_SHRINK_TO_WINDOW:
|
case MSG_SHRINK_TO_WINDOW:
|
||||||
ResizeToWindow(true, message->what);
|
ResizeToWindow(true, message->what);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_ZOOM_TO_WINDOW:
|
case MSG_ZOOM_TO_WINDOW:
|
||||||
ResizeToWindow(false, message->what);
|
ResizeToWindow(false, message->what);
|
||||||
break;
|
break;
|
||||||
@ -755,22 +760,25 @@ ShowImageWindow::MessageReceived(BMessage *message)
|
|||||||
case MSG_ROTATE_90:
|
case MSG_ROTATE_90:
|
||||||
fImageView->Rotate(90);
|
fImageView->Rotate(90);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_ROTATE_270:
|
case MSG_ROTATE_270:
|
||||||
fImageView->Rotate(270);
|
fImageView->Rotate(270);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_FLIP_LEFT_TO_RIGHT:
|
case MSG_FLIP_LEFT_TO_RIGHT:
|
||||||
fImageView->Flip(true);
|
fImageView->Flip(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_FLIP_TOP_TO_BOTTOM:
|
case MSG_FLIP_TOP_TO_BOTTOM:
|
||||||
fImageView->Flip(false);
|
fImageView->Flip(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_INVERT:
|
case MSG_INVERT:
|
||||||
fImageView->Invert();
|
fImageView->Invert();
|
||||||
break;
|
break;
|
||||||
case MSG_SLIDE_SHOW:
|
|
||||||
{
|
case MSG_SLIDE_SHOW: {
|
||||||
BMenuItem *item;
|
BMenuItem *item = fBar->FindItem(message->what);
|
||||||
item = fBar->FindItem(message->what);
|
|
||||||
if (!item)
|
if (!item)
|
||||||
break;
|
break;
|
||||||
if (item->IsMarked()) {
|
if (item->IsMarked()) {
|
||||||
@ -782,29 +790,27 @@ ShowImageWindow::MessageReceived(BMessage *message)
|
|||||||
fResizeItem->SetEnabled(false);
|
fResizeItem->SetEnabled(false);
|
||||||
fImageView->StartSlideShow();
|
fImageView->StartSlideShow();
|
||||||
}
|
}
|
||||||
break;
|
} break;
|
||||||
}
|
|
||||||
|
|
||||||
case MSG_SLIDE_SHOW_DELAY:
|
case MSG_SLIDE_SHOW_DELAY: {
|
||||||
{
|
|
||||||
float value;
|
float value;
|
||||||
if (message->FindFloat("value", &value) == B_OK) {
|
if (message->FindFloat("value", &value) == B_OK) {
|
||||||
fImageView->SetSlideShowDelay(value);
|
fImageView->SetSlideShowDelay(value);
|
||||||
// in case message is sent from popup menu
|
// in case message is sent from popup menu
|
||||||
MarkSlideShowDelay(value);
|
MarkSlideShowDelay(value);
|
||||||
}
|
}
|
||||||
break;
|
} break;
|
||||||
}
|
|
||||||
|
|
||||||
case MSG_FULL_SCREEN:
|
case MSG_FULL_SCREEN:
|
||||||
ToggleFullScreen();
|
ToggleFullScreen();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_EXIT_FULL_SCREEN:
|
case MSG_EXIT_FULL_SCREEN:
|
||||||
if (fFullScreen)
|
if (fFullScreen)
|
||||||
ToggleFullScreen();
|
ToggleFullScreen();
|
||||||
break;
|
break;
|
||||||
case MSG_SHOW_CAPTION:
|
|
||||||
{
|
case MSG_SHOW_CAPTION: {
|
||||||
fShowCaption = ToggleMenuItem(message->what);
|
fShowCaption = ToggleMenuItem(message->what);
|
||||||
ShowImageSettings* settings = my_app->Settings();
|
ShowImageSettings* settings = my_app->Settings();
|
||||||
|
|
||||||
@ -814,15 +820,16 @@ ShowImageWindow::MessageReceived(BMessage *message)
|
|||||||
}
|
}
|
||||||
if (fFullScreen)
|
if (fFullScreen)
|
||||||
fImageView->SetShowCaption(fShowCaption);
|
fImageView->SetShowCaption(fShowCaption);
|
||||||
break;
|
} break;
|
||||||
}
|
|
||||||
|
|
||||||
case MSG_PAGE_SETUP:
|
case MSG_PAGE_SETUP:
|
||||||
PageSetup();
|
PageSetup();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_PREPARE_PRINT:
|
case MSG_PREPARE_PRINT:
|
||||||
PrepareForPrint();
|
PrepareForPrint();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_PRINT:
|
case MSG_PRINT:
|
||||||
Print(message);
|
Print(message);
|
||||||
break;
|
break;
|
||||||
@ -830,44 +837,45 @@ ShowImageWindow::MessageReceived(BMessage *message)
|
|||||||
case MSG_ZOOM_IN:
|
case MSG_ZOOM_IN:
|
||||||
fImageView->ZoomIn();
|
fImageView->ZoomIn();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_ZOOM_OUT:
|
case MSG_ZOOM_OUT:
|
||||||
fImageView->ZoomOut();
|
fImageView->ZoomOut();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_ORIGINAL_SIZE:
|
case MSG_ORIGINAL_SIZE:
|
||||||
fImageView->SetZoom(1.0);
|
fImageView->SetZoom(1.0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_SCALE_BILINEAR:
|
case MSG_SCALE_BILINEAR:
|
||||||
fImageView->SetScaleBilinear(ToggleMenuItem(message->what));
|
fImageView->SetScaleBilinear(ToggleMenuItem(message->what));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_OPEN_RESIZER_WINDOW:
|
case MSG_OPEN_RESIZER_WINDOW: {
|
||||||
if (fImageView->GetBitmap() != NULL)
|
if (fImageView->GetBitmap() != NULL) {
|
||||||
{
|
|
||||||
BRect rect = fImageView->GetBitmap()->Bounds();
|
BRect rect = fImageView->GetBitmap()->Bounds();
|
||||||
OpenResizerWindow(rect.IntegerWidth()+1, rect.IntegerHeight()+1);
|
OpenResizerWindow(rect.IntegerWidth()+1, rect.IntegerHeight()+1);
|
||||||
}
|
}
|
||||||
break;
|
} break;
|
||||||
case MSG_RESIZE:
|
|
||||||
{
|
case MSG_RESIZE: {
|
||||||
int w = message->FindInt32("w");
|
int w = message->FindInt32("w");
|
||||||
int h = message->FindInt32("h");
|
int h = message->FindInt32("h");
|
||||||
fImageView->ResizeImage(w, h);
|
fImageView->ResizeImage(w, h);
|
||||||
break;
|
} break;
|
||||||
}
|
|
||||||
case MSG_RESIZER_WINDOW_QUIT:
|
case MSG_RESIZER_WINDOW_QUIT:
|
||||||
|
delete fResizerWindowMessenger;
|
||||||
fResizerWindowMessenger = NULL;
|
fResizerWindowMessenger = NULL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_DESKTOP_BACKGROUND:
|
case MSG_DESKTOP_BACKGROUND: {
|
||||||
{
|
|
||||||
BPath path;
|
BPath path;
|
||||||
if (path.SetTo(fImageView->Image()) == B_OK) {
|
if (path.SetTo(fImageView->Image()) == B_OK) {
|
||||||
BackgroundImage::SetDesktopImage(B_CURRENT_WORKSPACE,
|
BackgroundImage::SetDesktopImage(B_CURRENT_WORKSPACE,
|
||||||
path.Path(), BackgroundImage::kScaledToFit,
|
path.Path(), BackgroundImage::kScaledToFit,
|
||||||
BPoint(0, 0), false);
|
BPoint(0, 0), false);
|
||||||
}
|
}
|
||||||
break;
|
} break;
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(message);
|
BWindow::MessageReceived(message);
|
||||||
@ -882,21 +890,22 @@ ShowImageWindow::SaveAs(BMessage *message)
|
|||||||
// Read the translator and output type the user chose
|
// Read the translator and output type the user chose
|
||||||
translator_id outTranslator;
|
translator_id outTranslator;
|
||||||
uint32 outType;
|
uint32 outType;
|
||||||
if (message->FindInt32(TRANSLATOR_FLD,
|
if (message->FindInt32(kTranslatorField,
|
||||||
reinterpret_cast<int32 *>(&outTranslator)) != B_OK
|
reinterpret_cast<int32 *>(&outTranslator)) != B_OK
|
||||||
|| message->FindInt32(TYPE_FLD,
|
|| message->FindInt32(kTypeField,
|
||||||
reinterpret_cast<int32 *>(&outType)) != B_OK)
|
reinterpret_cast<int32 *>(&outType)) != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Add the chosen translator and output type to the
|
// Add the chosen translator and output type to the
|
||||||
// message that the save panel will send back
|
// message that the save panel will send back
|
||||||
BMessage *panelMsg = new BMessage(MSG_SAVE_PANEL);
|
BMessage *panelMsg = new BMessage(MSG_SAVE_PANEL);
|
||||||
panelMsg->AddInt32(TRANSLATOR_FLD, outTranslator);
|
panelMsg->AddInt32(kTranslatorField, outTranslator);
|
||||||
panelMsg->AddInt32(TYPE_FLD, outType);
|
panelMsg->AddInt32(kTypeField, outType);
|
||||||
|
|
||||||
// Create save panel and show it
|
// Create save panel and show it
|
||||||
|
BMessenger target(this);
|
||||||
fSavePanel = new (std::nothrow) BFilePanel(B_SAVE_PANEL,
|
fSavePanel = new (std::nothrow) BFilePanel(B_SAVE_PANEL,
|
||||||
new BMessenger(this), NULL, 0, false, panelMsg);
|
&target, NULL, 0, false, panelMsg);
|
||||||
if (!fSavePanel)
|
if (!fSavePanel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -921,9 +930,9 @@ ShowImageWindow::SaveToFile(BMessage *message)
|
|||||||
// to save the output image
|
// to save the output image
|
||||||
translator_id outTranslator;
|
translator_id outTranslator;
|
||||||
uint32 outType;
|
uint32 outType;
|
||||||
if (message->FindInt32(TRANSLATOR_FLD,
|
if (message->FindInt32(kTranslatorField,
|
||||||
reinterpret_cast<int32 *>(&outTranslator)) != B_OK
|
reinterpret_cast<int32 *>(&outTranslator)) != B_OK
|
||||||
|| message->FindInt32(TYPE_FLD,
|
|| message->FindInt32(kTypeField,
|
||||||
reinterpret_cast<int32 *>(&outType)) != B_OK)
|
reinterpret_cast<int32 *>(&outType)) != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1059,28 +1068,33 @@ ShowImageWindow::SavePrintOptions()
|
|||||||
bool
|
bool
|
||||||
ShowImageWindow::PageSetup()
|
ShowImageWindow::PageSetup()
|
||||||
{
|
{
|
||||||
status_t st;
|
|
||||||
BString name;
|
BString name;
|
||||||
fImageView->GetName(&name);
|
fImageView->GetName(&name);
|
||||||
BPrintJob printJob(name.String());
|
BPrintJob printJob(name.String());
|
||||||
if (fPrintSettings != NULL)
|
if (fPrintSettings != NULL)
|
||||||
printJob.SetSettings(new BMessage(*fPrintSettings));
|
printJob.SetSettings(new BMessage(*fPrintSettings));
|
||||||
|
|
||||||
st = printJob.ConfigPage();
|
status_t status = printJob.ConfigPage();
|
||||||
if (st == B_OK) {
|
if (status == B_OK) {
|
||||||
delete fPrintSettings;
|
delete fPrintSettings;
|
||||||
fPrintSettings = printJob.Settings();
|
fPrintSettings = printJob.Settings();
|
||||||
}
|
}
|
||||||
|
|
||||||
return st == B_OK;
|
return status == B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageWindow::PrepareForPrint()
|
ShowImageWindow::PrepareForPrint()
|
||||||
{
|
{
|
||||||
if (fPrintSettings == NULL && !PageSetup())
|
if (fPrintSettings == NULL) {
|
||||||
return;
|
BString name;
|
||||||
|
fImageView->GetName(&name);
|
||||||
|
|
||||||
|
BPrintJob printJob("");
|
||||||
|
if (printJob.ConfigJob() == B_OK)
|
||||||
|
fPrintSettings = printJob.Settings();
|
||||||
|
}
|
||||||
|
|
||||||
fPrintOptions.SetBounds(fImageView->GetBitmap()->Bounds());
|
fPrintOptions.SetBounds(fImageView->GetBitmap()->Bounds());
|
||||||
fPrintOptions.SetWidth(fImageView->GetBitmap()->Bounds().Width()+1);
|
fPrintOptions.SetWidth(fImageView->GetBitmap()->Bounds().Width()+1);
|
||||||
@ -1100,17 +1114,21 @@ ShowImageWindow::Print(BMessage *msg)
|
|||||||
SavePrintOptions();
|
SavePrintOptions();
|
||||||
|
|
||||||
BString name;
|
BString name;
|
||||||
fPrintOptions.SetBounds(fImageView->GetBitmap()->Bounds());
|
|
||||||
fImageView->GetName(&name);
|
fImageView->GetName(&name);
|
||||||
|
|
||||||
BPrintJob printJob(name.String());
|
BPrintJob printJob(name.String());
|
||||||
printJob.SetSettings(new BMessage(*fPrintSettings));
|
if (fPrintSettings)
|
||||||
|
printJob.SetSettings(new BMessage(*fPrintSettings));
|
||||||
|
|
||||||
if (printJob.ConfigJob() == B_OK) {
|
if (printJob.ConfigJob() == B_OK) {
|
||||||
BRect printableRect = printJob.PrintableRect();
|
delete fPrintSettings;
|
||||||
float width, w1, w2;
|
fPrintSettings = printJob.Settings();
|
||||||
|
|
||||||
// first/lastPage is unused for now
|
// first/lastPage is unused for now
|
||||||
int32 firstPage = printJob.FirstPage();
|
int32 firstPage = printJob.FirstPage();
|
||||||
int32 lastPage = printJob.LastPage();
|
int32 lastPage = printJob.LastPage();
|
||||||
|
BRect printableRect = printJob.PrintableRect();
|
||||||
|
|
||||||
if (firstPage < 1)
|
if (firstPage < 1)
|
||||||
firstPage = 1;
|
firstPage = 1;
|
||||||
if (lastPage < firstPage)
|
if (lastPage < firstPage)
|
||||||
@ -1120,15 +1138,16 @@ ShowImageWindow::Print(BMessage *msg)
|
|||||||
float imageWidth = bitmap->Bounds().Width() + 1.0;
|
float imageWidth = bitmap->Bounds().Width() + 1.0;
|
||||||
float imageHeight = bitmap->Bounds().Height() + 1.0;
|
float imageHeight = bitmap->Bounds().Height() + 1.0;
|
||||||
|
|
||||||
|
float width;
|
||||||
switch (fPrintOptions.Option()) {
|
switch (fPrintOptions.Option()) {
|
||||||
case PrintOptions::kFitToPage:
|
case PrintOptions::kFitToPage: {
|
||||||
w1 = printableRect.Width()+1;
|
float w1 = printableRect.Width()+1;
|
||||||
w2 = imageWidth * (printableRect.Height() + 1) / imageHeight;
|
float w2 = imageWidth * (printableRect.Height() + 1) / imageHeight;
|
||||||
if (w2 < w1)
|
if (w2 < w1)
|
||||||
width = w2;
|
width = w2;
|
||||||
else
|
else
|
||||||
width = w1;
|
width = w1;
|
||||||
break;
|
} break;
|
||||||
case PrintOptions::kZoomFactor:
|
case PrintOptions::kZoomFactor:
|
||||||
width = imageWidth * fPrintOptions.ZoomFactor();
|
width = imageWidth * fPrintOptions.ZoomFactor();
|
||||||
break;
|
break;
|
||||||
@ -1166,18 +1185,17 @@ ShowImageWindow::OpenResizerWindow(int32 width, int32 height)
|
|||||||
BWindow* window = new ResizerWindow(this, width, height);
|
BWindow* window = new ResizerWindow(this, width, height);
|
||||||
fResizerWindowMessenger = new BMessenger(window);
|
fResizerWindowMessenger = new BMessenger(window);
|
||||||
window->Show();
|
window->Show();
|
||||||
} else
|
} else {
|
||||||
fResizerWindowMessenger->SendMessage(ResizerWindow::kActivateMsg);
|
fResizerWindowMessenger->SendMessage(ResizerWindow::kActivateMsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageWindow::UpdateResizerWindow(int32 width, int32 height)
|
ShowImageWindow::UpdateResizerWindow(int32 width, int32 height)
|
||||||
{
|
{
|
||||||
if (fResizerWindowMessenger == NULL) {
|
if (fResizerWindowMessenger == NULL)
|
||||||
// window not opened
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
BMessage updateMsg(ResizerWindow::kUpdateMsg);
|
BMessage updateMsg(ResizerWindow::kUpdateMsg);
|
||||||
updateMsg.AddInt32("width", width);
|
updateMsg.AddInt32("width", width);
|
||||||
@ -1189,11 +1207,11 @@ ShowImageWindow::UpdateResizerWindow(int32 width, int32 height)
|
|||||||
void
|
void
|
||||||
ShowImageWindow::CloseResizerWindow()
|
ShowImageWindow::CloseResizerWindow()
|
||||||
{
|
{
|
||||||
if (fResizerWindowMessenger == NULL) {
|
if (fResizerWindowMessenger == NULL)
|
||||||
// window not opened
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
fResizerWindowMessenger->SendMessage(B_QUIT_REQUESTED);
|
fResizerWindowMessenger->SendMessage(B_QUIT_REQUESTED);
|
||||||
|
delete fResizerWindowMessenger;
|
||||||
fResizerWindowMessenger = NULL;
|
fResizerWindowMessenger = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2006, Haiku, Inc. All Rights Reserved.
|
* Copyright 2003-2008, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@ -13,27 +13,17 @@
|
|||||||
|
|
||||||
#include "PrintOptionsWindow.h"
|
#include "PrintOptionsWindow.h"
|
||||||
|
|
||||||
#include <FilePanel.h>
|
|
||||||
#include <Menu.h>
|
|
||||||
#include <String.h>
|
|
||||||
#include <TranslationDefs.h>
|
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
|
class BFilePanel;
|
||||||
|
class BMenu;
|
||||||
|
class BMenuBar;
|
||||||
|
class BMenuItem;
|
||||||
class ShowImageView;
|
class ShowImageView;
|
||||||
class ShowImageStatusView;
|
class ShowImageStatusView;
|
||||||
|
|
||||||
// BMessage field names used in Save messages
|
|
||||||
#define TRANSLATOR_FLD "be:translator"
|
|
||||||
#define TYPE_FLD "be:type"
|
|
||||||
|
|
||||||
class RecentDocumentsMenu : public BMenu {
|
|
||||||
public:
|
|
||||||
RecentDocumentsMenu(const char *title, menu_layout layout = B_ITEMS_IN_COLUMN);
|
|
||||||
bool AddDynamicItem(add_state addState);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void UpdateRecentDocumentsMenu();
|
|
||||||
};
|
|
||||||
|
|
||||||
class ShowImageWindow : public BWindow {
|
class ShowImageWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
@ -55,18 +45,20 @@ class ShowImageWindow : public BWindow {
|
|||||||
void WindowRedimension(BBitmap *bitmap);
|
void WindowRedimension(BBitmap *bitmap);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
class RecentDocumentsMenu;
|
||||||
|
|
||||||
void BuildViewMenu(BMenu *menu, bool popupMenu);
|
void BuildViewMenu(BMenu *menu, bool popupMenu);
|
||||||
BMenuItem *AddItemMenu(BMenu *menu, char *caption,
|
BMenuItem *AddItemMenu(BMenu *menu, const char *label,
|
||||||
uint32 command, char shortcut, uint32 modifier,
|
uint32 what, const char shortcut, uint32 modifier,
|
||||||
char target, bool enabled);
|
const BHandler *target, bool enabled = true);
|
||||||
BMenuItem* AddDelayItem(BMenu *menu, char *caption, float value);
|
BMenuItem* AddDelayItem(BMenu *menu, const char *label, float value);
|
||||||
|
|
||||||
bool ToggleMenuItem(uint32 what);
|
bool ToggleMenuItem(uint32 what);
|
||||||
void EnableMenuItem(BMenu *menu, uint32 what, bool enable);
|
void EnableMenuItem(BMenu *menu, uint32 what, bool enable);
|
||||||
void MarkMenuItem(BMenu *menu, uint32 what, bool marked);
|
void MarkMenuItem(BMenu *menu, uint32 what, bool marked);
|
||||||
void MarkSlideShowDelay(float value);
|
void MarkSlideShowDelay(float value);
|
||||||
void ResizeToWindow(bool shrink, uint32 what);
|
void ResizeToWindow(bool shrink, uint32 what);
|
||||||
|
|
||||||
void SaveAs(BMessage *message);
|
void SaveAs(BMessage *message);
|
||||||
// Handle Save As submenu choice
|
// Handle Save As submenu choice
|
||||||
void SaveToFile(BMessage *message);
|
void SaveToFile(BMessage *message);
|
||||||
@ -78,7 +70,7 @@ class ShowImageWindow : public BWindow {
|
|||||||
bool PageSetup();
|
bool PageSetup();
|
||||||
void PrepareForPrint();
|
void PrepareForPrint();
|
||||||
void Print(BMessage *msg);
|
void Print(BMessage *msg);
|
||||||
|
|
||||||
void OpenResizerWindow(int32 width, int32 height);
|
void OpenResizerWindow(int32 width, int32 height);
|
||||||
void UpdateResizerWindow(int32 width, int32 height);
|
void UpdateResizerWindow(int32 width, int32 height);
|
||||||
void CloseResizerWindow();
|
void CloseResizerWindow();
|
||||||
|
Loading…
Reference in New Issue
Block a user