* Added a "Set as desktop background" option with an easy to use engine based

on the OpenTracker's BackgroundImage implementation.
* It's currently placed in the "View" menu, even though it doesn't fit that
  good, I think it should definitely be part of the right click menu.
* Some more cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16273 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-02-07 10:28:27 +00:00
parent 240b1766ff
commit a60adbf9b4
7 changed files with 592 additions and 249 deletions
+256
View File
@@ -0,0 +1,256 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
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 applies to all licensees
and 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 TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED 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.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include "BackgroundImage.h"
#include <Background.h>
#include <Directory.h>
#include <Entry.h>
#include <Message.h>
#include <Path.h>
#include <Window.h>
#include <fs_attr.h>
#include <new>
#include <stdlib.h>
const char *kBackgroundImageInfoSet = "be:bgndimginfoset";
/*static*/
status_t
BackgroundImage::_NotifyTracker(BDirectory& directory, bool desktop)
{
BMessenger tracker("application/x-vnd.Be-TRAK");
if (desktop) {
tracker.SendMessage(new BMessage(B_RESTORE_BACKGROUND_IMAGE));
} else {
BEntry entry;
status_t status = directory.GetEntry(&entry);
if (status < B_OK)
return status;
BPath folderPath(&entry);
int32 i = -1;
while (true) {
BMessage msg(B_GET_PROPERTY);
BMessage reply;
i++;
// look at the "Poses" in every Tracker window
msg.AddSpecifier("Poses");
msg.AddSpecifier("Window", i);
reply.MakeEmpty();
tracker.SendMessage(&msg, &reply);
// break out of the loop when we're at the end of
// the windows
int32 err;
if (reply.what == B_MESSAGE_NOT_UNDERSTOOD
&& reply.FindInt32("error", &err) == B_OK
&& err == B_BAD_INDEX)
break;
// don't stop for windows that don't understand
// a request for "Poses"; they're not displaying
// folders
if (reply.what == B_MESSAGE_NOT_UNDERSTOOD
&& reply.FindInt32("error", &err) == B_OK
&& err != B_BAD_SCRIPT_SYNTAX)
continue;
BMessenger trackerWindow;
if (reply.FindMessenger("result", &trackerWindow) != B_OK)
continue;
// found a window with poses, ask for its path
msg.MakeEmpty();
msg.what = B_GET_PROPERTY;
msg.AddSpecifier("Path");
msg.AddSpecifier("Poses");
msg.AddSpecifier("Window", i);
reply.MakeEmpty();
tracker.SendMessage(&msg, &reply);
// go on with the next if this din't have a path
if (reply.what == B_MESSAGE_NOT_UNDERSTOOD)
continue;
entry_ref ref;
if (reply.FindRef("result", &ref) == B_OK) {
BEntry entry(&ref);
BPath path(&entry);
// these are not the paths you're looking for
if (folderPath != path)
continue;
}
trackerWindow.SendMessage(B_RESTORE_BACKGROUND_IMAGE);
}
}
return B_OK;
}
/*static*/
status_t
BackgroundImage::_GetImages(BDirectory& directory, BMessage& container)
{
attr_info info;
status_t status = directory.GetAttrInfo(B_BACKGROUND_INFO, &info);
if (status != B_OK)
return status;
char *buffer = new (nothrow) char [info.size];
if (buffer == NULL)
return NULL;
status = directory.ReadAttr(B_BACKGROUND_INFO, info.type,
0, buffer, (size_t)info.size);
if (status == info.size)
status = container.Unflatten(buffer);
else
status = B_ERROR;
delete[] buffer;
return status;
}
/*static*/
status_t
BackgroundImage::_SetImage(BDirectory& directory, bool desktop, uint32 workspaces,
const char* path, Mode mode, BPoint offset, bool eraseIconBackground)
{
BMessage images;
if (desktop) {
status_t status = _GetImages(directory, images);
if (status != B_OK)
return status;
if (workspaces == B_CURRENT_WORKSPACE)
workspaces = 1UL << current_workspace();
// Find old image and replace it
uint32 imageWorkspaces;
int32 found = -1;
int32 i = 0;
while (images.FindInt32(B_BACKGROUND_WORKSPACES, i,
(int32 *)&imageWorkspaces) == B_OK) {
// we don't care about masks that are similar to ours
if (imageWorkspaces == workspaces) {
found = i;
break;
}
i++;
}
// Remove old image, if any
if (found == i) {
images.RemoveData(B_BACKGROUND_ERASE_TEXT, i);
images.RemoveData(B_BACKGROUND_IMAGE, i);
images.RemoveData(B_BACKGROUND_WORKSPACES, i);
images.RemoveData(B_BACKGROUND_ORIGIN, i);
images.RemoveData(B_BACKGROUND_MODE, i);
if (desktop)
images.RemoveData(kBackgroundImageInfoSet, i);
}
}
// Insert new image
images.AddBool(B_BACKGROUND_ERASE_TEXT, eraseIconBackground);
images.AddString(B_BACKGROUND_IMAGE, path);
images.AddInt32(B_BACKGROUND_WORKSPACES, workspaces);
images.AddPoint(B_BACKGROUND_ORIGIN, offset);
images.AddInt32(B_BACKGROUND_MODE, mode);
if (desktop)
images.AddInt32(kBackgroundImageInfoSet, 0);
// Write back new image info
size_t flattenedSize = images.FlattenedSize();
char* buffer = new (std::nothrow) char[flattenedSize];
if (buffer == NULL)
return B_NO_MEMORY;
status_t status = images.Flatten(buffer, flattenedSize);
if (status != B_OK)
return status;
ssize_t written = directory.WriteAttr(B_BACKGROUND_INFO, B_MESSAGE_TYPE,
0, buffer, flattenedSize);
delete[] buffer;
if (written < B_OK)
return written;
if ((size_t)written != flattenedSize)
return B_ERROR;
_NotifyTracker(directory, desktop);
return B_OK;
}
/*static*/
status_t
BackgroundImage::SetImage(BDirectory& directory, const char* path, Mode mode,
BPoint offset, bool eraseIconBackground)
{
return _SetImage(directory, false, 0, path, mode, offset, eraseIconBackground);
}
/*static*/
status_t
BackgroundImage::SetDesktopImage(BDirectory& directory, uint32 workspaces, const char* path,
Mode mode, BPoint offset, bool eraseIconBackground)
{
return _SetImage(directory, true, workspaces, path, mode, offset, eraseIconBackground);
}
+70
View File
@@ -0,0 +1,70 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
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 applies to all licensees
and 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 TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED 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.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef BACKGROUND_IMAGE_H
#define BACKGROUND_IMAGE_H
#include <SupportDefs.h>
class BDirectory;
class BackgroundImage {
// This class knows everything about which bitmap to use for a given
// view and how.
// Unlike other windows, the Desktop window can have different backgrounds
// for each workspace
public:
enum Mode {
kAtOffset,
kCentered, // only works on Desktop
kScaledToFit, // only works on Desktop
kTiled
};
static status_t SetImage(BDirectory& directory, const char* path, Mode mode,
BPoint offset, bool eraseIconBackground = false);
static status_t SetDesktopImage(BDirectory& directory, uint32 workspaces,
const char* path, Mode mode, BPoint offset,
bool eraseIconBackground = false);
private:
static status_t _SetImage(BDirectory& directory, bool desktop, uint32 workspaces,
const char* path, Mode mode, BPoint offset,
bool eraseIconBackground);
static status_t _GetImages(BDirectory& directory, BMessage& images);
static status_t _NotifyTracker(BDirectory& directory, bool desktop);
};
#endif // BACKGROUND_IMAGE_H
+1
View File
@@ -12,6 +12,7 @@ Application ShowImage : ShowImageApp.cpp
PrintOptionsWindow.cpp PrintOptionsWindow.cpp
Filter.cpp Filter.cpp
EntryMenuItem.cpp EntryMenuItem.cpp
BackgroundImage.cpp
: be tracker translation : be tracker translation
: ShowImage.rdef : ShowImage.rdef
; ;
+1
View File
@@ -56,5 +56,6 @@ const uint32 MSG_ZOOM_OUT = 'mZOU';
const uint32 MSG_ORIGINAL_SIZE = 'mOSZ'; const uint32 MSG_ORIGINAL_SIZE = 'mOSZ';
const uint32 MSG_INVALIDATE = 'mIVD'; const uint32 MSG_INVALIDATE = 'mIVD';
const uint32 MSG_SCALE_BILINEAR = 'mSBL'; const uint32 MSG_SCALE_BILINEAR = 'mSBL';
const uint32 MSG_DESKTOP_BACKGROUND = 'mDBG';
#endif // SHOW_IMAGE_CONSTANTS_H #endif // SHOW_IMAGE_CONSTANTS_H
+46 -55
View File
@@ -1,43 +1,26 @@
/*****************************************************************************/ /*
// ShowImageView * Copyright 2003-2006, Haiku, Inc. All Rights Reserved.
// Written by Fernando Francisco de Oliveira, Michael Wilber, Michael Pfeiffer * Distributed under the terms of the MIT License.
// *
// ShowImageView.h * Authors:
// * Fernando Francisco de Oliveira
// * Michael Wilber
// Copyright (c) 2003 OpenBeOS Project * Michael Pfeiffer
// */
// Permission is hereby granted, free of charge, to any person obtaining a #ifndef SHOW_IMAGE_VIEW_H
// copy of this software and associated documentation files (the "Software"), #define SHOW_IMAGE_VIEW_H
// 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.
/*****************************************************************************/
#ifndef _ShowImageView_h
#define _ShowImageView_h
#include <View.h> #include "Filter.h"
#include "ShowImageUndo.h"
#include <Bitmap.h> #include <Bitmap.h>
#include <Entry.h> #include <Entry.h>
#include <NodeInfo.h> #include <NodeInfo.h>
#include <String.h> #include <String.h>
#include <TranslatorRoster.h> #include <TranslatorRoster.h>
#include <View.h>
#include "Filter.h"
#include "ShowImageUndo.h"
// delay scaling operation, so that a sequence of zoom in/out operations works smoother // delay scaling operation, so that a sequence of zoom in/out operations works smoother
#define DELAYED_SCALING 1 #define DELAYED_SCALING 1
@@ -48,13 +31,25 @@ class ShowImageView : public BView {
public: public:
ShowImageView(BRect rect, const char *name, uint32 resizingMode, ShowImageView(BRect rect, const char *name, uint32 resizingMode,
uint32 flags); uint32 flags);
~ShowImageView(); virtual ~ShowImageView();
void Pulse(); virtual void AttachedToWindow();
virtual void Draw(BRect updateRect);
virtual void FrameResized(float width, float height);
virtual void MouseDown(BPoint point);
virtual void MouseMoved(BPoint point, uint32 state, const BMessage *pmsg);
virtual void MouseUp(BPoint point);
virtual void KeyDown(const char *bytes, int32 numBytes);
virtual void Pulse();
virtual void MessageReceived(BMessage *pmsg);
void SetTrackerMessenger(const BMessenger& trackerMessenger); void SetTrackerMessenger(const BMessenger& trackerMessenger);
status_t SetImage(const entry_ref *pref); status_t SetImage(const entry_ref *ref);
void SaveToFile(BDirectory* dir, const char* name, BBitmap* bitmap, const translation_format* format); const entry_ref* Image() const { return &fCurrentRef; }
void SaveToFile(BDirectory* dir, const char* name, BBitmap* bitmap,
const translation_format* format);
void SetDither(bool dither); void SetDither(bool dither);
bool GetDither() const { return fDither; } bool GetDither() const { return fDither; }
void SetShowCaption(bool show); void SetShowCaption(bool show);
@@ -72,16 +67,6 @@ public:
void SetScaleBilinear(bool b); void SetScaleBilinear(bool b);
bool GetScaleBilinear() { return fScaleBilinear; } bool GetScaleBilinear() { return fScaleBilinear; }
virtual void AttachedToWindow();
virtual void Draw(BRect updateRect);
virtual void FrameResized(float width, float height);
virtual void MouseDown(BPoint point);
virtual void MouseMoved(BPoint point, uint32 state, const BMessage *pmsg);
virtual void MouseUp(BPoint point);
virtual void KeyDown(const char *bytes, int32 numBytes);
virtual void MessageReceived(BMessage *pmsg);
void FixupScrollBar(orientation o, float bitmapLength, float viewLength); void FixupScrollBar(orientation o, float bitmapLength, float viewLength);
void FixupScrollBars(); void FixupScrollBars();
@@ -153,8 +138,10 @@ private:
void DeleteBitmap(); void DeleteBitmap();
void DeleteSelBitmap(); void DeleteSelBitmap();
int32 BytesPerPixel(color_space cs) const; int32 BytesPerPixel(color_space cs) const;
inline void CopyPixel(uchar* dest, int32 destX, int32 destY, int32 destBPR, uchar* src, int32 x, int32 y, int32 bpr, int32 bpp); void CopyPixel(uchar* dest, int32 destX, int32 destY, int32 destBPR,
inline void InvertPixel(int32 x, int32 y, uchar* dest, int32 destBPR, uchar* src, int32 bpr, int32 bpp); uchar* src, int32 x, int32 y, int32 bpr, int32 bpp);
void InvertPixel(int32 x, int32 y, uchar* dest, int32 destBPR, uchar* src,
int32 bpr, int32 bpp);
void DoImageOperation(enum ImageProcessor::operation op, bool quiet = false); void DoImageOperation(enum ImageProcessor::operation op, bool quiet = false);
void UserDoImageOperation(enum ImageProcessor::operation op, bool quiet = false); void UserDoImageOperation(enum ImageProcessor::operation op, bool quiet = false);
BRect AlignBitmap(); BRect AlignBitmap();
@@ -166,8 +153,10 @@ private:
static int CompareEntries(const void* a, const void* b); static int CompareEntries(const void* a, const void* b);
void FreeEntries(BList* entries); void FreeEntries(BList* entries);
void SetTrackerSelectionToCurrent(); void SetTrackerSelectionToCurrent();
bool FindNextImageByDir(entry_ref *in_current, entry_ref *out_image, bool next, bool rewind); bool FindNextImageByDir(entry_ref *in_current, entry_ref *out_image,
bool FindNextImage(entry_ref *in_current, entry_ref *out_image, bool next, bool rewind); bool next, bool rewind);
bool FindNextImage(entry_ref *in_current, entry_ref *out_image,
bool next, bool rewind);
bool ShowNextImage(bool next, bool rewind); bool ShowNextImage(bool next, bool rewind);
bool FirstFile(); bool FirstFile();
void ConstrainToImage(BPoint &point); void ConstrainToImage(BPoint &point);
@@ -177,7 +166,8 @@ private:
bool AddSupportedTypes(BMessage* msg, BBitmap* bitmap); bool AddSupportedTypes(BMessage* msg, BBitmap* bitmap);
void BeginDrag(BPoint sourcePoint); void BeginDrag(BPoint sourcePoint);
void SendInMessage(BMessage* msg, BBitmap* bitmap, translation_format* format); void SendInMessage(BMessage* msg, BBitmap* bitmap, translation_format* format);
bool OutputFormatForType(BBitmap* bitmap, const char* type, translation_format* format); bool OutputFormatForType(BBitmap* bitmap, const char* type,
translation_format* format);
void HandleDrop(BMessage* msg); void HandleDrop(BMessage* msg);
void MoveImage(); void MoveImage();
uint32 GetMouseButtons(); uint32 GetMouseButtons();
@@ -206,14 +196,15 @@ private:
int32 fDocumentIndex; // of the image in the file int32 fDocumentIndex; // of the image in the file
int32 fDocumentCount; // number of images in the file int32 fDocumentCount; // number of images in the file
BBitmap *fBitmap; // the original image BBitmap *fBitmap; // the original image
BBitmap *fDisplayBitmap; // the image to be displayed BBitmap *fDisplayBitmap;
// the image to be displayed
// (== fBitmap if the bitmap can be displayed as is) // (== fBitmap if the bitmap can be displayed as is)
BBitmap *fSelBitmap; // the bitmap in the selection BBitmap *fSelBitmap; // the bitmap in the selection
float fZoom; // factor to be used to display the image float fZoom; // factor to be used to display the image
bool fScaleBilinear; // use bilinear scaling? bool fScaleBilinear; // use bilinear scaling?
Scaler* fScaler; // holds the scaled image if bilinear scaling is enabled Scaler* fScaler; // holds the scaled image if bilinear scaling is enabled
bool fShrinkToBounds; // shrink images to view bounds that are larger than the view bool fShrinkToBounds;
bool fZoomToBounds; // zoom images to view bounds that are smaller than the view bool fZoomToBounds;
bool fShrinkOrZoomToBounds; bool fShrinkOrZoomToBounds;
bool fHasBorder; // should the image have a border? bool fHasBorder; // should the image have a border?
alignment fHAlignment; // horizontal alignment (left and centered only) alignment fHAlignment; // horizontal alignment (left and centered only)
@@ -247,4 +238,4 @@ private:
static enum image_orientation fTransformation[ImageProcessor::kNumberOfAffineTransformations][kNumberOfOrientations]; static enum image_orientation fTransformation[ImageProcessor::kNumberOfAffineTransformations][kNumberOfOrientations];
}; };
#endif /* _ShowImageView_h */ #endif // SHOW_IMAGE_VIEW_H
+32 -8
View File
@@ -9,6 +9,7 @@
*/ */
#include "BackgroundImage.h"
#include "EntryMenuItem.h" #include "EntryMenuItem.h"
#include "ShowImageApp.h" #include "ShowImageApp.h"
#include "ShowImageConstants.h" #include "ShowImageConstants.h"
@@ -23,6 +24,7 @@
#include <Clipboard.h> #include <Clipboard.h>
#include <Entry.h> #include <Entry.h>
#include <File.h> #include <File.h>
#include <FindDirectory.h>
#include <Menu.h> #include <Menu.h>
#include <MenuBar.h> #include <MenuBar.h>
#include <MenuItem.h> #include <MenuItem.h>
@@ -46,9 +48,9 @@ RecentDocumentsMenu::RecentDocumentsMenu(const char *title, menu_layout layout)
bool bool
RecentDocumentsMenu::AddDynamicItem(add_state s) RecentDocumentsMenu::AddDynamicItem(add_state addState)
{ {
if (s != B_INITIAL_ADD) if (addState != B_INITIAL_ADD)
return false; return false;
BMenuItem *item; BMenuItem *item;
@@ -264,6 +266,11 @@ ShowImageWindow::BuildViewMenu(BMenu *menu)
EnableMenuItem(menu, MSG_ORIGINAL_SIZE, enabled); EnableMenuItem(menu, MSG_ORIGINAL_SIZE, enabled);
EnableMenuItem(menu, MSG_ZOOM_IN, enabled); EnableMenuItem(menu, MSG_ZOOM_IN, enabled);
EnableMenuItem(menu, MSG_ZOOM_OUT, enabled); EnableMenuItem(menu, MSG_ZOOM_OUT, enabled);
menu->AddSeparatorItem();
AddItemMenu(menu, "As Desktop Background", MSG_DESKTOP_BACKGROUND, 0, 0, 'W',
true);
} }
@@ -332,10 +339,10 @@ ShowImageWindow::AddMenus(BMenuBar *bar)
BMenuItem * BMenuItem *
ShowImageWindow::AddItemMenu(BMenu *menu, char *caption, long unsigned int msg, ShowImageWindow::AddItemMenu(BMenu *menu, char *caption, uint32 command,
char shortcut, uint32 modifier, char target, bool enabled) char shortcut, uint32 modifier, char target, bool enabled)
{ {
BMenuItem* item = new BMenuItem(caption, new BMessage(msg), shortcut, modifier); BMenuItem* item = new BMenuItem(caption, new BMessage(command), shortcut, modifier);
if (target == 'A') if (target == 'A')
item->SetTarget(be_app); item->SetTarget(be_app);
@@ -791,6 +798,22 @@ ShowImageWindow::MessageReceived(BMessage *message)
fImageView->SetScaleBilinear(ToggleMenuItem(message->what)); fImageView->SetScaleBilinear(ToggleMenuItem(message->what));
break; break;
case MSG_DESKTOP_BACKGROUND:
{
BPath path;
if (find_directory(B_DESKTOP_DIRECTORY, &path) == B_OK) {
BDirectory directory(path.Path());
if (directory.InitCheck() == B_OK) {
if (path.SetTo(fImageView->Image()) == B_OK) {
BackgroundImage::SetDesktopImage(directory, B_CURRENT_WORKSPACE,
path.Path(), BackgroundImage::kScaledToFit, BPoint(0, 0),
false);
}
}
}
break;
}
default: default:
BWindow::MessageReceived(message); BWindow::MessageReceived(message);
break; break;
@@ -812,15 +835,16 @@ ShowImageWindow::SaveAs(BMessage *message)
// 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 *ppanelMsg = new BMessage(MSG_SAVE_PANEL); BMessage *panelMsg = new BMessage(MSG_SAVE_PANEL);
ppanelMsg->AddInt32(TRANSLATOR_FLD, outTranslator); panelMsg->AddInt32(TRANSLATOR_FLD, outTranslator);
ppanelMsg->AddInt32(TYPE_FLD, outType); panelMsg->AddInt32(TYPE_FLD, outType);
// Create save panel and show it // Create save panel and show it
fSavePanel = new (std::nothrow) BFilePanel(B_SAVE_PANEL, fSavePanel = new (std::nothrow) BFilePanel(B_SAVE_PANEL,
new BMessenger(this), NULL, 0, false, ppanelMsg); new BMessenger(this), NULL, 0, false, panelMsg);
if (!fSavePanel) if (!fSavePanel)
return; return;
fSavePanel->Window()->SetWorkspaces(B_CURRENT_WORKSPACE); fSavePanel->Window()->SetWorkspaces(B_CURRENT_WORKSPACE);
fSavePanel->Show(); fSavePanel->Show();
} }
+10 -10
View File
@@ -29,7 +29,7 @@ class ShowImageStatusView;
class RecentDocumentsMenu : public BMenu { class RecentDocumentsMenu : public BMenu {
public: public:
RecentDocumentsMenu(const char *title, menu_layout layout = B_ITEMS_IN_COLUMN); RecentDocumentsMenu(const char *title, menu_layout layout = B_ITEMS_IN_COLUMN);
bool AddDynamicItem(add_state s); bool AddDynamicItem(add_state addState);
private: private:
void UpdateRecentDocumentsMenu(); void UpdateRecentDocumentsMenu();
@@ -37,11 +37,11 @@ class RecentDocumentsMenu : public BMenu {
class ShowImageWindow : public BWindow { class ShowImageWindow : public BWindow {
public: public:
ShowImageWindow(const entry_ref *pref, const BMessenger& trackerMessenger); ShowImageWindow(const entry_ref *ref, const BMessenger& trackerMessenger);
virtual ~ShowImageWindow(); virtual ~ShowImageWindow();
virtual void FrameResized(float width, float height); virtual void FrameResized(float width, float height);
virtual void MessageReceived(BMessage *pmsg); virtual void MessageReceived(BMessage *message);
virtual bool QuitRequested(); virtual bool QuitRequested();
virtual void Zoom(BPoint origin, float width, float height); virtual void Zoom(BPoint origin, float width, float height);
@@ -50,14 +50,14 @@ class ShowImageWindow : public BWindow {
void UpdateTitle(); void UpdateTitle();
void BuildViewMenu(BMenu *menu); void BuildViewMenu(BMenu *menu);
void AddMenus(BMenuBar *pbar); void AddMenus(BMenuBar *bar);
void WindowRedimension(BBitmap *pbitmap); void WindowRedimension(BBitmap *bitmap);
private: private:
BMenuItem *AddItemMenu(BMenu *pmenu, char *caption, BMenuItem *AddItemMenu(BMenu *menu, char *caption,
long unsigned int msg, char shortcut, uint32 modifier, uint32 command, char shortcut, uint32 modifier,
char target, bool enabled); char target, bool enabled);
BMenuItem* AddDelayItem(BMenu *pmenu, char *caption, float value); BMenuItem* AddDelayItem(BMenu *menu, char *caption, 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);
@@ -65,9 +65,9 @@ class ShowImageWindow : public BWindow {
void MarkSlideShowDelay(float value); void MarkSlideShowDelay(float value);
void ResizeToWindow(bool shrink, uint32 what); void ResizeToWindow(bool shrink, uint32 what);
void SaveAs(BMessage *pmsg); void SaveAs(BMessage *message);
// Handle Save As submenu choice // Handle Save As submenu choice
void SaveToFile(BMessage *pmsg); void SaveToFile(BMessage *message);
// Handle save file panel message // Handle save file panel message
bool ClosePrompt(); bool ClosePrompt();
void ToggleFullScreen(); void ToggleFullScreen();