- Made some settings persistent: Slide Show Delay, Scale Bilinear, Shrink/Zoom to Window, Show Caption in Full Screen Mode and PrintOptions persistent.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5415 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -38,6 +38,8 @@ FilterThread::FilterThread(Filter* filter, int i)
|
|||||||
fWorkerThread = spawn_thread(worker_thread, "filter", suggest_thread_priority(B_STATUS_RENDERING), this);
|
fWorkerThread = spawn_thread(worker_thread, "filter", suggest_thread_priority(B_STATUS_RENDERING), this);
|
||||||
if (fWorkerThread >= 0) {
|
if (fWorkerThread >= 0) {
|
||||||
resume_thread(fWorkerThread);
|
resume_thread(fWorkerThread);
|
||||||
|
} else {
|
||||||
|
delete this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +124,7 @@ Filter::Stop()
|
|||||||
// tell FilterThreads to stop calculations
|
// tell FilterThreads to stop calculations
|
||||||
fIsRunning = false;
|
fIsRunning = false;
|
||||||
// wait for threads to exit
|
// wait for threads to exit
|
||||||
acquire_sem_etc(fWaitForThreads, fCPUCount, 0, 0);
|
while (acquire_sem_etc(fWaitForThreads, fCPUCount, 0, 0) == B_INTERRUPTED);
|
||||||
// ready to start again
|
// ready to start again
|
||||||
fStarted = false;
|
fStarted = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ AddResources ShowImage : ShowImage.rdef ;
|
|||||||
|
|
||||||
App ShowImage : ShowImageApp.cpp
|
App ShowImage : ShowImageApp.cpp
|
||||||
ShowImageConstants.cpp
|
ShowImageConstants.cpp
|
||||||
|
ShowImageSettings.cpp
|
||||||
ShowImageStatusView.cpp
|
ShowImageStatusView.cpp
|
||||||
ShowImageView.cpp
|
ShowImageView.cpp
|
||||||
ShowImageWindow.cpp
|
ShowImageWindow.cpp
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ public:
|
|||||||
kZoomFactor,
|
kZoomFactor,
|
||||||
kDPI,
|
kDPI,
|
||||||
kWidth,
|
kWidth,
|
||||||
kHeight
|
kHeight,
|
||||||
|
kNumberOfOptions
|
||||||
};
|
};
|
||||||
|
|
||||||
PrintOptions();
|
PrintOptions();
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ int main(int, char **)
|
|||||||
ShowImageApp::ShowImageApp()
|
ShowImageApp::ShowImageApp()
|
||||||
: BApplication(APP_SIG)
|
: BApplication(APP_SIG)
|
||||||
{
|
{
|
||||||
fbPulseStarted = false;
|
fPulseStarted = false;
|
||||||
fpOpenPanel = new BFilePanel(B_OPEN_PANEL);
|
fOpenPanel = new BFilePanel(B_OPEN_PANEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -64,7 +64,7 @@ void
|
|||||||
ShowImageApp::ReadyToRun()
|
ShowImageApp::ReadyToRun()
|
||||||
{
|
{
|
||||||
if (CountWindows() == WINDOWS_TO_IGNORE)
|
if (CountWindows() == WINDOWS_TO_IGNORE)
|
||||||
fpOpenPanel->Show();
|
fOpenPanel->Show();
|
||||||
else
|
else
|
||||||
// If image windows are already open
|
// If image windows are already open
|
||||||
// (paths supplied on the command line)
|
// (paths supplied on the command line)
|
||||||
@@ -78,10 +78,10 @@ ShowImageApp::ReadyToRun()
|
|||||||
void
|
void
|
||||||
ShowImageApp::StartPulse()
|
ShowImageApp::StartPulse()
|
||||||
{
|
{
|
||||||
if (!fbPulseStarted) {
|
if (!fPulseStarted) {
|
||||||
// Tell the app to begin checking
|
// Tell the app to begin checking
|
||||||
// for the number of open windows
|
// for the number of open windows
|
||||||
fbPulseStarted = true;
|
fPulseStarted = true;
|
||||||
SetPulseRate(250000);
|
SetPulseRate(250000);
|
||||||
// Set pulse to every 1/4 second
|
// Set pulse to every 1/4 second
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ ShowImageApp::MessageReceived(BMessage *pmsg)
|
|||||||
{
|
{
|
||||||
switch (pmsg->what) {
|
switch (pmsg->what) {
|
||||||
case MSG_FILE_OPEN:
|
case MSG_FILE_OPEN:
|
||||||
fpOpenPanel->Show();
|
fOpenPanel->Show();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_WINDOW_QUIT:
|
case MSG_WINDOW_QUIT:
|
||||||
|
|||||||
@@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
|
|
||||||
|
#include "ShowImageSettings.h"
|
||||||
|
|
||||||
class ShowImageApp : public BApplication {
|
class ShowImageApp : public BApplication {
|
||||||
public:
|
public:
|
||||||
ShowImageApp();
|
ShowImageApp();
|
||||||
@@ -44,6 +46,8 @@ public:
|
|||||||
virtual void RefsReceived(BMessage *pmsg);
|
virtual void RefsReceived(BMessage *pmsg);
|
||||||
virtual void Quit();
|
virtual void Quit();
|
||||||
|
|
||||||
|
ShowImageSettings* Settings() { return &fSettings; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void StartPulse();
|
void StartPulse();
|
||||||
void Open(const entry_ref *pref);
|
void Open(const entry_ref *pref);
|
||||||
@@ -51,8 +55,11 @@ private:
|
|||||||
void BroadcastToWindows(BMessage *pmsg);
|
void BroadcastToWindows(BMessage *pmsg);
|
||||||
void CheckClipboard();
|
void CheckClipboard();
|
||||||
|
|
||||||
BFilePanel *fpOpenPanel;
|
BFilePanel *fOpenPanel;
|
||||||
bool fbPulseStarted;
|
bool fPulseStarted;
|
||||||
|
ShowImageSettings fSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define my_app dynamic_cast<ShowImageApp*>(be_app)
|
||||||
|
|
||||||
#endif /* _ShowImageApp_h */
|
#endif /* _ShowImageApp_h */
|
||||||
|
|||||||
@@ -0,0 +1,201 @@
|
|||||||
|
/*****************************************************************************/
|
||||||
|
// ShowImageSettings
|
||||||
|
// Written by Michael Pfeiffer
|
||||||
|
//
|
||||||
|
// ShowImageSettings.cpp
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Copyright (c) 2003 OpenBeOS Project
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
// and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#include <File.h>
|
||||||
|
#include <FindDirectory.h>
|
||||||
|
#include <Path.h>
|
||||||
|
|
||||||
|
#include "ShowImageSettings.h"
|
||||||
|
|
||||||
|
ShowImageSettings::ShowImageSettings()
|
||||||
|
{
|
||||||
|
Load();
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowImageSettings::~ShowImageSettings()
|
||||||
|
{
|
||||||
|
if (Lock()) {
|
||||||
|
Save();
|
||||||
|
Unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ShowImageSettings::Lock()
|
||||||
|
{
|
||||||
|
return fLock.Lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ShowImageSettings::Unlock()
|
||||||
|
{
|
||||||
|
fLock.Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ShowImageSettings::GetBool(const char* name, bool defaultValue)
|
||||||
|
{
|
||||||
|
bool value;
|
||||||
|
if (fSettings.FindBool(name, &value) == B_OK) {
|
||||||
|
return value;
|
||||||
|
} else {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32
|
||||||
|
ShowImageSettings::GetInt32(const char* name, int32 defaultValue)
|
||||||
|
{
|
||||||
|
int32 value;
|
||||||
|
if (fSettings.FindInt32(name, &value) == B_OK) {
|
||||||
|
return value;
|
||||||
|
} else {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float
|
||||||
|
ShowImageSettings::GetFloat(const char* name, float defaultValue)
|
||||||
|
{
|
||||||
|
float value;
|
||||||
|
if (fSettings.FindFloat(name, &value) == B_OK) {
|
||||||
|
return value;
|
||||||
|
} else {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BRect
|
||||||
|
ShowImageSettings::GetRect(const char* name, BRect defaultValue)
|
||||||
|
{
|
||||||
|
BRect value;
|
||||||
|
if (fSettings.FindRect(name, &value) == B_OK) {
|
||||||
|
return value;
|
||||||
|
} else {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char*
|
||||||
|
ShowImageSettings::GetString(const char* name, const char* defaultValue)
|
||||||
|
{
|
||||||
|
const char* value;
|
||||||
|
if (fSettings.FindString(name, &value) == B_OK) {
|
||||||
|
return value;
|
||||||
|
} else {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ShowImageSettings::SetBool(const char* name, bool value)
|
||||||
|
{
|
||||||
|
if (fSettings.HasBool(name)) {
|
||||||
|
fSettings.ReplaceBool(name, value);
|
||||||
|
} else {
|
||||||
|
fSettings.AddBool(name, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ShowImageSettings::SetInt32(const char* name, int32 value)
|
||||||
|
{
|
||||||
|
if (fSettings.HasInt32(name)) {
|
||||||
|
fSettings.ReplaceInt32(name, value);
|
||||||
|
} else {
|
||||||
|
fSettings.AddInt32(name, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ShowImageSettings::SetFloat(const char* name, float value)
|
||||||
|
{
|
||||||
|
if (fSettings.HasFloat(name)) {
|
||||||
|
fSettings.ReplaceFloat(name, value);
|
||||||
|
} else {
|
||||||
|
fSettings.AddFloat(name, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ShowImageSettings::SetRect(const char* name, BRect value)
|
||||||
|
{
|
||||||
|
if (fSettings.HasRect(name)) {
|
||||||
|
fSettings.ReplaceRect(name, value);
|
||||||
|
} else {
|
||||||
|
fSettings.AddRect(name, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ShowImageSettings::SetString(const char* name, const char* value)
|
||||||
|
{
|
||||||
|
if (fSettings.HasString(name)) {
|
||||||
|
fSettings.ReplaceString(name, value);
|
||||||
|
} else {
|
||||||
|
fSettings.AddString(name, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ShowImageSettings::OpenSettingsFile(BFile* file, bool forReading)
|
||||||
|
{
|
||||||
|
status_t st;
|
||||||
|
BPath path;
|
||||||
|
uint32 openMode;
|
||||||
|
|
||||||
|
st = find_directory(B_COMMON_SETTINGS_DIRECTORY, &path);
|
||||||
|
if (st != B_OK) return false;
|
||||||
|
|
||||||
|
path.Append("ShowImage_settings");
|
||||||
|
if (forReading) {
|
||||||
|
openMode = B_READ_ONLY;
|
||||||
|
} else {
|
||||||
|
openMode = B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE;
|
||||||
|
}
|
||||||
|
st = file->SetTo(path.Path(), openMode);
|
||||||
|
return st == B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ShowImageSettings::Load()
|
||||||
|
{
|
||||||
|
BFile file;
|
||||||
|
if (OpenSettingsFile(&file, true)) {
|
||||||
|
fSettings.Unflatten(&file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ShowImageSettings::Save()
|
||||||
|
{
|
||||||
|
BFile file;
|
||||||
|
if (OpenSettingsFile(&file, false)) {
|
||||||
|
fSettings.Flatten(&file);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/*****************************************************************************/
|
||||||
|
// ShowImageSettings
|
||||||
|
// Written by Michael Pfeiffer
|
||||||
|
//
|
||||||
|
// ShowImageSettings.cpp
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Copyright (c) 2003 OpenBeOS Project
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
// and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _ShowImageSettings_H
|
||||||
|
#define _ShowImageSettings_H
|
||||||
|
|
||||||
|
#include <Message.h>
|
||||||
|
#include <Locker.h>
|
||||||
|
|
||||||
|
class ShowImageSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ShowImageSettings();
|
||||||
|
~ShowImageSettings();
|
||||||
|
|
||||||
|
bool Lock();
|
||||||
|
bool GetBool(const char* name, bool defaultValue);
|
||||||
|
int32 GetInt32(const char* name, int32 defaultValue);
|
||||||
|
float GetFloat(const char* name, float defaultValue);
|
||||||
|
BRect GetRect(const char* name, BRect defaultValue);
|
||||||
|
const char* GetString(const char* name, const char* defaultValue);
|
||||||
|
void SetBool(const char* name, bool value);
|
||||||
|
void SetInt32(const char* name, int32 value);
|
||||||
|
void SetFloat(const char* name, float value);
|
||||||
|
void SetRect(const char* name, BRect value);
|
||||||
|
void SetString(const char* name, const char* value);
|
||||||
|
void Unlock();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool OpenSettingsFile(BFile* file, bool forReading);
|
||||||
|
void Load();
|
||||||
|
void Save();
|
||||||
|
|
||||||
|
BLocker fLock;
|
||||||
|
BMessage fSettings;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -49,6 +49,7 @@
|
|||||||
#include <PopUpMenu.h>
|
#include <PopUpMenu.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include "ShowImageApp.h"
|
||||||
#include "ShowImageConstants.h"
|
#include "ShowImageConstants.h"
|
||||||
#include "ShowImageView.h"
|
#include "ShowImageView.h"
|
||||||
#include "ShowImageWindow.h"
|
#include "ShowImageWindow.h"
|
||||||
@@ -151,8 +152,10 @@ ShowImageView::ShowImageView(BRect rect, const char *name, uint32 resizingMode,
|
|||||||
uint32 flags)
|
uint32 flags)
|
||||||
: BView(rect, name, resizingMode, flags)
|
: BView(rect, name, resizingMode, flags)
|
||||||
{
|
{
|
||||||
InitPatterns();
|
ShowImageSettings* settings;
|
||||||
|
settings = my_app->Settings();
|
||||||
|
|
||||||
|
InitPatterns();
|
||||||
fBitmap = NULL;
|
fBitmap = NULL;
|
||||||
fSelBitmap = NULL;
|
fSelBitmap = NULL;
|
||||||
fDocumentIndex = 1;
|
fDocumentIndex = 1;
|
||||||
@@ -165,13 +168,21 @@ ShowImageView::ShowImageView(BRect rect, const char *name, uint32 resizingMode,
|
|||||||
fHAlignment = B_ALIGN_LEFT;
|
fHAlignment = B_ALIGN_LEFT;
|
||||||
fVAlignment = B_ALIGN_TOP;
|
fVAlignment = B_ALIGN_TOP;
|
||||||
fSlideShow = false;
|
fSlideShow = false;
|
||||||
SetSlideShowDelay(3); // 3 seconds
|
fSlideShowDelay = 3 * 10; // 3 seconds
|
||||||
fShowCaption = false;
|
fShowCaption = false;
|
||||||
fZoom = 1.0;
|
fZoom = 1.0;
|
||||||
fMovesImage = false;
|
fMovesImage = false;
|
||||||
fScaleBilinear = false;
|
fScaleBilinear = false;
|
||||||
fScaler = NULL;
|
fScaler = NULL;
|
||||||
|
|
||||||
|
if (settings->Lock()) {
|
||||||
|
fShrinkToBounds = settings->GetBool("ShrinkToBounds", fShrinkToBounds);
|
||||||
|
fZoomToBounds = settings->GetBool("ZoomToBounds", fZoomToBounds);
|
||||||
|
fSlideShowDelay = settings->GetInt32("SlideShowDelay", fSlideShowDelay);
|
||||||
|
fScaleBilinear = settings->GetBool("ScaleBilinear", fScaleBilinear);
|
||||||
|
settings->Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
SetViewColor(B_TRANSPARENT_COLOR);
|
SetViewColor(B_TRANSPARENT_COLOR);
|
||||||
SetHighColor(kborderColor);
|
SetHighColor(kborderColor);
|
||||||
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
@@ -322,6 +333,7 @@ void
|
|||||||
ShowImageView::SetShrinkToBounds(bool enable)
|
ShowImageView::SetShrinkToBounds(bool enable)
|
||||||
{
|
{
|
||||||
if (fShrinkToBounds != enable) {
|
if (fShrinkToBounds != enable) {
|
||||||
|
SettingsSetBool("ShrinkToBounds", enable);
|
||||||
fShrinkToBounds = enable;
|
fShrinkToBounds = enable;
|
||||||
FixupScrollBars();
|
FixupScrollBars();
|
||||||
Invalidate();
|
Invalidate();
|
||||||
@@ -332,6 +344,7 @@ void
|
|||||||
ShowImageView::SetZoomToBounds(bool enable)
|
ShowImageView::SetZoomToBounds(bool enable)
|
||||||
{
|
{
|
||||||
if (fZoomToBounds != enable) {
|
if (fZoomToBounds != enable) {
|
||||||
|
SettingsSetBool("ZoomToBounds", enable);
|
||||||
fZoomToBounds = enable;
|
fZoomToBounds = enable;
|
||||||
FixupScrollBars();
|
FixupScrollBars();
|
||||||
Invalidate();
|
Invalidate();
|
||||||
@@ -406,6 +419,7 @@ void
|
|||||||
ShowImageView::SetScaleBilinear(bool s)
|
ShowImageView::SetScaleBilinear(bool s)
|
||||||
{
|
{
|
||||||
if (fScaleBilinear != s) {
|
if (fScaleBilinear != s) {
|
||||||
|
SettingsSetBool("ScaleBilinear", s);
|
||||||
fScaleBilinear = s; Invalidate();
|
fScaleBilinear = s; Invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1247,6 +1261,17 @@ ShowImageView::ShowPopUpMenu(BPoint screen)
|
|||||||
menu->Go(screen, true, false, true);
|
menu->Go(screen, true, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ShowImageView::SettingsSetBool(const char* name, bool value)
|
||||||
|
{
|
||||||
|
ShowImageSettings* settings;
|
||||||
|
settings = my_app->Settings();
|
||||||
|
if (settings->Lock()) {
|
||||||
|
settings->SetBool(name, value);
|
||||||
|
settings->Unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageView::MessageReceived(BMessage *pmsg)
|
ShowImageView::MessageReceived(BMessage *pmsg)
|
||||||
{
|
{
|
||||||
@@ -1595,7 +1620,13 @@ ShowImageView::ZoomOut()
|
|||||||
void
|
void
|
||||||
ShowImageView::SetSlideShowDelay(float seconds)
|
ShowImageView::SetSlideShowDelay(float seconds)
|
||||||
{
|
{
|
||||||
|
ShowImageSettings* settings;
|
||||||
fSlideShowDelay = (int)(seconds * 10.0);
|
fSlideShowDelay = (int)(seconds * 10.0);
|
||||||
|
settings = my_app->Settings();
|
||||||
|
if (settings->Lock()) {
|
||||||
|
settings->SetInt32("SlideShowDelay", fSlideShowDelay);
|
||||||
|
settings->Unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ public:
|
|||||||
bool NextFile();
|
bool NextFile();
|
||||||
bool PrevFile();
|
bool PrevFile();
|
||||||
void SetSlideShowDelay(float seconds);
|
void SetSlideShowDelay(float seconds);
|
||||||
|
float GetSlideShowDelay() const { return fSlideShowDelay / 10.0; }
|
||||||
bool SlideShowStarted() const { return fSlideShow; }
|
bool SlideShowStarted() const { return fSlideShow; }
|
||||||
void StartSlideShow();
|
void StartSlideShow();
|
||||||
void StopSlideShow();
|
void StopSlideShow();
|
||||||
@@ -163,6 +164,7 @@ private:
|
|||||||
void ScrollRestrictedBy(float x, float y);
|
void ScrollRestrictedBy(float x, float y);
|
||||||
void MouseWheelChanged(BMessage* msg);
|
void MouseWheelChanged(BMessage* msg);
|
||||||
void ShowPopUpMenu(BPoint screen);
|
void ShowPopUpMenu(BPoint screen);
|
||||||
|
void SettingsSetBool(const char* name, bool value);
|
||||||
|
|
||||||
entry_ref fCurrentRef; // of the image
|
entry_ref fCurrentRef; // of the image
|
||||||
int32 fDocumentIndex; // of the image in the file
|
int32 fDocumentIndex; // of the image in the file
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <PrintJob.h>
|
#include <PrintJob.h>
|
||||||
|
|
||||||
|
#include "ShowImageApp.h"
|
||||||
#include "ShowImageConstants.h"
|
#include "ShowImageConstants.h"
|
||||||
#include "ShowImageWindow.h"
|
#include "ShowImageWindow.h"
|
||||||
#include "ShowImageView.h"
|
#include "ShowImageView.h"
|
||||||
@@ -54,27 +55,30 @@
|
|||||||
ShowImageWindow::ShowImageWindow(const entry_ref *pref)
|
ShowImageWindow::ShowImageWindow(const entry_ref *pref)
|
||||||
: BWindow(BRect(50, 50, 350, 250), "", B_DOCUMENT_WINDOW, 0)
|
: BWindow(BRect(50, 50, 350, 250), "", B_DOCUMENT_WINDOW, 0)
|
||||||
{
|
{
|
||||||
fpSavePanel = NULL;
|
fSavePanel = NULL;
|
||||||
fFullScreen = false;
|
fFullScreen = false;
|
||||||
fShowCaption = true; // XXX what is best for default?
|
fShowCaption = true;
|
||||||
fPrintSettings = NULL;
|
fPrintSettings = NULL;
|
||||||
fpImageView = NULL;
|
fImageView = NULL;
|
||||||
|
fSlideShowDelay = NULL;
|
||||||
|
|
||||||
|
LoadSettings();
|
||||||
|
|
||||||
// create menu bar
|
// create menu bar
|
||||||
fpBar = new BMenuBar(BRect(0, 0, Bounds().right, 20), "menu_bar");
|
fBar = new BMenuBar(BRect(0, 0, Bounds().right, 20), "menu_bar");
|
||||||
LoadMenus(fpBar);
|
LoadMenus(fBar);
|
||||||
AddChild(fpBar);
|
AddChild(fBar);
|
||||||
|
|
||||||
BRect viewFrame = Bounds();
|
BRect viewFrame = Bounds();
|
||||||
viewFrame.top = fpBar->Bounds().bottom + 1;
|
viewFrame.top = fBar->Bounds().bottom + 1;
|
||||||
viewFrame.right -= B_V_SCROLL_BAR_WIDTH;
|
viewFrame.right -= B_V_SCROLL_BAR_WIDTH;
|
||||||
viewFrame.bottom -= B_H_SCROLL_BAR_HEIGHT;
|
viewFrame.bottom -= B_H_SCROLL_BAR_HEIGHT;
|
||||||
|
|
||||||
// create the image view
|
// create the image view
|
||||||
fpImageView = new ShowImageView(viewFrame, "image_view", B_FOLLOW_ALL,
|
fImageView = new ShowImageView(viewFrame, "image_view", B_FOLLOW_ALL,
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED);
|
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED);
|
||||||
// wrap a scroll view around the view
|
// wrap a scroll view around the view
|
||||||
BScrollView *pscrollView = new BScrollView("image_scroller", fpImageView,
|
BScrollView *pscrollView = new BScrollView("image_scroller", fImageView,
|
||||||
B_FOLLOW_ALL, 0, false, false, B_PLAIN_BORDER);
|
B_FOLLOW_ALL, 0, false, false, B_PLAIN_BORDER);
|
||||||
AddChild(pscrollView);
|
AddChild(pscrollView);
|
||||||
|
|
||||||
@@ -85,38 +89,43 @@ ShowImageWindow::ShowImageWindow(const entry_ref *pref)
|
|||||||
rect.left = viewFrame.left + kstatusWidth;
|
rect.left = viewFrame.left + kstatusWidth;
|
||||||
rect.right = viewFrame.right;
|
rect.right = viewFrame.right;
|
||||||
BScrollBar *phscroll;
|
BScrollBar *phscroll;
|
||||||
phscroll = new BScrollBar(rect, "hscroll", fpImageView, 0, 150,
|
phscroll = new BScrollBar(rect, "hscroll", fImageView, 0, 150,
|
||||||
B_HORIZONTAL);
|
B_HORIZONTAL);
|
||||||
AddChild(phscroll);
|
AddChild(phscroll);
|
||||||
|
|
||||||
rect.left = 0;
|
rect.left = 0;
|
||||||
rect.right = kstatusWidth - 1;
|
rect.right = kstatusWidth - 1;
|
||||||
fpStatusView = new ShowImageStatusView(rect, "status_view", B_FOLLOW_BOTTOM,
|
fStatusView = new ShowImageStatusView(rect, "status_view", B_FOLLOW_BOTTOM,
|
||||||
B_WILL_DRAW);
|
B_WILL_DRAW);
|
||||||
fpStatusView->SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR));
|
fStatusView->SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR));
|
||||||
AddChild(fpStatusView);
|
AddChild(fStatusView);
|
||||||
|
|
||||||
rect = Bounds();
|
rect = Bounds();
|
||||||
rect.top = viewFrame.top;
|
rect.top = viewFrame.top;
|
||||||
rect.left = viewFrame.right + 1;
|
rect.left = viewFrame.right + 1;
|
||||||
rect.bottom = viewFrame.bottom;
|
rect.bottom = viewFrame.bottom;
|
||||||
BScrollBar *pvscroll;
|
BScrollBar *pvscroll;
|
||||||
pvscroll = new BScrollBar(rect, "vscroll", fpImageView, 0, 150, B_VERTICAL);
|
pvscroll = new BScrollBar(rect, "vscroll", fImageView, 0, 150, B_VERTICAL);
|
||||||
AddChild(pvscroll);
|
AddChild(pvscroll);
|
||||||
|
|
||||||
SetSizeLimits(250, 100000, 100, 100000);
|
SetSizeLimits(250, 100000, 100, 100000);
|
||||||
|
|
||||||
// finish creating window
|
// finish creating window
|
||||||
fpImageView->SetImage(pref);
|
fImageView->SetImage(pref);
|
||||||
|
|
||||||
if (InitCheck() == B_OK) {
|
if (InitCheck() == B_OK) {
|
||||||
|
// add View menu here so it can access ShowImageView methods
|
||||||
|
BMenu* pmenu = new BMenu("View");
|
||||||
|
BuildViewMenu(pmenu);
|
||||||
|
fBar->AddItem(pmenu);
|
||||||
|
|
||||||
UpdateTitle();
|
UpdateTitle();
|
||||||
|
|
||||||
SetPulseRate(100000); // every 1/10 second; ShowImageView needs it for marching ants
|
SetPulseRate(100000); // every 1/10 second; ShowImageView needs it for marching ants
|
||||||
|
|
||||||
fpImageView->FlushToLeftTop();
|
fImageView->FlushToLeftTop();
|
||||||
WindowRedimension(fpImageView->GetBitmap());
|
WindowRedimension(fImageView->GetBitmap());
|
||||||
fpImageView->MakeFocus(true); // to receive KeyDown messages
|
fImageView->MakeFocus(true); // to receive KeyDown messages
|
||||||
Show();
|
Show();
|
||||||
} else {
|
} else {
|
||||||
BAlert* alert;
|
BAlert* alert;
|
||||||
@@ -141,7 +150,7 @@ ShowImageWindow::~ShowImageWindow()
|
|||||||
status_t
|
status_t
|
||||||
ShowImageWindow::InitCheck()
|
ShowImageWindow::InitCheck()
|
||||||
{
|
{
|
||||||
if (!fpImageView || fpImageView->GetBitmap() == NULL)
|
if (!fImageView || fImageView->GetBitmap() == NULL)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
else
|
else
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -151,7 +160,7 @@ void
|
|||||||
ShowImageWindow::UpdateTitle()
|
ShowImageWindow::UpdateTitle()
|
||||||
{
|
{
|
||||||
BString path;
|
BString path;
|
||||||
fpImageView->GetPath(&path);
|
fImageView->GetPath(&path);
|
||||||
SetTitle(path.String());
|
SetTitle(path.String());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +172,7 @@ ShowImageWindow::UpdateRecentDocumentsMenu()
|
|||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
char name[B_FILE_NAME_LENGTH];
|
char name[B_FILE_NAME_LENGTH];
|
||||||
|
|
||||||
while ((item = fpOpenMenu->RemoveItem((int32)0)) != NULL) {
|
while ((item = fOpenMenu->RemoveItem((int32)0)) != NULL) {
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,7 +183,7 @@ ShowImageWindow::UpdateRecentDocumentsMenu()
|
|||||||
msg = new BMessage(B_REFS_RECEIVED);
|
msg = new BMessage(B_REFS_RECEIVED);
|
||||||
msg->AddRef("refs", &ref);
|
msg->AddRef("refs", &ref);
|
||||||
item = new BMenuItem(name, msg, 0, 0);
|
item = new BMenuItem(name, msg, 0, 0);
|
||||||
fpOpenMenu->AddItem(item);
|
fOpenMenu->AddItem(item);
|
||||||
item->SetTarget(be_app, NULL);
|
item->SetTarget(be_app, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -184,14 +193,10 @@ void
|
|||||||
ShowImageWindow::BuildViewMenu(BMenu *pmenu)
|
ShowImageWindow::BuildViewMenu(BMenu *pmenu)
|
||||||
{
|
{
|
||||||
AddItemMenu(pmenu, "Slide Show", MSG_SLIDE_SHOW, 0, 0, 'W', true);
|
AddItemMenu(pmenu, "Slide Show", MSG_SLIDE_SHOW, 0, 0, 'W', true);
|
||||||
if (fpImageView) {
|
MarkMenuItem(pmenu, MSG_SLIDE_SHOW, fImageView->SlideShowStarted());
|
||||||
// when invoked from SlideShowView
|
|
||||||
MarkMenuItem(pmenu, MSG_SLIDE_SHOW, fpImageView->SlideShowStarted());
|
|
||||||
}
|
|
||||||
BMenu* pDelay = new BMenu("Slide Delay");
|
BMenu* pDelay = new BMenu("Slide Delay");
|
||||||
if (fpImageView == NULL) {
|
if (fSlideShowDelay == NULL) {
|
||||||
// when invoked from this window
|
fSlideShowDelay = pDelay;
|
||||||
fpSlideShowDelay = pDelay;
|
|
||||||
}
|
}
|
||||||
pDelay->SetRadioMode(true);
|
pDelay->SetRadioMode(true);
|
||||||
// Note: ShowImage loades images in window thread so it becomes unresponsive if
|
// Note: ShowImage loades images in window thread so it becomes unresponsive if
|
||||||
@@ -200,53 +205,53 @@ ShowImageWindow::BuildViewMenu(BMenu *pmenu)
|
|||||||
// AddDelayItem(pDelay, "Half a Second", 0.5, false);
|
// AddDelayItem(pDelay, "Half a Second", 0.5, false);
|
||||||
// AddDelayItem(pDelay, "One Second", 1, false);
|
// AddDelayItem(pDelay, "One Second", 1, false);
|
||||||
// AddDelayItem(pDelay, "Two Second", 2, false);
|
// AddDelayItem(pDelay, "Two Second", 2, false);
|
||||||
AddDelayItem(pDelay, "Three Seconds", 3, true);
|
AddDelayItem(pDelay, "Three Seconds", 3);
|
||||||
AddDelayItem(pDelay, "Four Second", 4, false);
|
AddDelayItem(pDelay, "Four Second", 4);
|
||||||
AddDelayItem(pDelay, "Five Seconds", 5, false);
|
AddDelayItem(pDelay, "Five Seconds", 5);
|
||||||
AddDelayItem(pDelay, "Six Seconds", 6, false);
|
AddDelayItem(pDelay, "Six Seconds", 6);
|
||||||
AddDelayItem(pDelay, "Seven Seconds", 7, false);
|
AddDelayItem(pDelay, "Seven Seconds", 7);
|
||||||
AddDelayItem(pDelay, "Eight Seconds", 8, false);
|
AddDelayItem(pDelay, "Eight Seconds", 8);
|
||||||
AddDelayItem(pDelay, "Nine Seconds", 9, false);
|
AddDelayItem(pDelay, "Nine Seconds", 9);
|
||||||
AddDelayItem(pDelay, "Ten Seconds", 10, false);
|
AddDelayItem(pDelay, "Ten Seconds", 10);
|
||||||
AddDelayItem(pDelay, "Twenty Seconds", 20, false);
|
AddDelayItem(pDelay, "Twenty Seconds", 20);
|
||||||
pmenu->AddItem(pDelay);
|
pmenu->AddItem(pDelay);
|
||||||
pmenu->AddSeparatorItem();
|
pmenu->AddSeparatorItem();
|
||||||
AddItemMenu(pmenu, "Original Size", MSG_ORIGINAL_SIZE, 0, 0, 'W', true);
|
AddItemMenu(pmenu, "Original Size", MSG_ORIGINAL_SIZE, 0, 0, 'W', true);
|
||||||
AddItemMenu(pmenu, "Zoom In", MSG_ZOOM_IN, '+', 0, 'W', true);
|
AddItemMenu(pmenu, "Zoom In", MSG_ZOOM_IN, '+', 0, 'W', true);
|
||||||
AddItemMenu(pmenu, "Zoom Out", MSG_ZOOM_OUT, '-', 0, 'W', true);
|
AddItemMenu(pmenu, "Zoom Out", MSG_ZOOM_OUT, '-', 0, 'W', true);
|
||||||
|
pmenu->AddSeparatorItem();
|
||||||
AddItemMenu(pmenu, "Scale Bilinear", MSG_SCALE_BILINEAR, 0, 0, 'W', true);
|
AddItemMenu(pmenu, "Scale Bilinear", MSG_SCALE_BILINEAR, 0, 0, 'W', true);
|
||||||
pmenu->AddSeparatorItem();
|
pmenu->AddSeparatorItem();
|
||||||
AddItemMenu(pmenu, "Shrink to Window", MSG_SHRINK_TO_WINDOW, 0, 0, 'W', true);
|
AddItemMenu(pmenu, "Shrink to Window", MSG_SHRINK_TO_WINDOW, 0, 0, 'W', true);
|
||||||
AddItemMenu(pmenu, "Zoom to Window", MSG_ZOOM_TO_WINDOW, 0, 0, 'W', true);
|
AddItemMenu(pmenu, "Zoom to Window", MSG_ZOOM_TO_WINDOW, 0, 0, 'W', true);
|
||||||
|
pmenu->AddSeparatorItem();
|
||||||
AddItemMenu(pmenu, "Full Screen", MSG_FULL_SCREEN, B_ENTER, 0, 'W', true);
|
AddItemMenu(pmenu, "Full Screen", MSG_FULL_SCREEN, B_ENTER, 0, 'W', true);
|
||||||
MarkMenuItem(pmenu, MSG_FULL_SCREEN, fFullScreen);
|
MarkMenuItem(pmenu, MSG_FULL_SCREEN, fFullScreen);
|
||||||
AddItemMenu(pmenu, "Show Caption in Full Screen Mode", MSG_SHOW_CAPTION, 0, 0, 'W', true);
|
AddItemMenu(pmenu, "Show Caption in Full Screen Mode", MSG_SHOW_CAPTION, 0, 0, 'W', true);
|
||||||
MarkMenuItem(pmenu, MSG_SHOW_CAPTION, fShowCaption);
|
MarkMenuItem(pmenu, MSG_SHOW_CAPTION, fShowCaption);
|
||||||
|
|
||||||
if (fpImageView) {
|
bool shrink, zoom, enabled;
|
||||||
bool shrink, zoom, enabled;
|
MarkMenuItem(pmenu, MSG_SCALE_BILINEAR, fImageView->GetScaleBilinear());
|
||||||
MarkMenuItem(pmenu, MSG_SCALE_BILINEAR, fpImageView->GetScaleBilinear());
|
shrink = fImageView->GetShrinkToBounds();
|
||||||
shrink = fpImageView->GetShrinkToBounds();
|
zoom = fImageView->GetZoomToBounds();
|
||||||
zoom = fpImageView->GetZoomToBounds();
|
MarkMenuItem(pmenu, MSG_SHRINK_TO_WINDOW, shrink);
|
||||||
MarkMenuItem(pmenu, MSG_SHRINK_TO_WINDOW, shrink);
|
MarkMenuItem(pmenu, MSG_ZOOM_TO_WINDOW, zoom);
|
||||||
MarkMenuItem(pmenu, MSG_ZOOM_TO_WINDOW, zoom);
|
enabled = !(shrink || zoom);
|
||||||
enabled = !(shrink || zoom);
|
EnableMenuItem(pmenu, MSG_ORIGINAL_SIZE, enabled);
|
||||||
EnableMenuItem(pmenu, MSG_ORIGINAL_SIZE, enabled);
|
EnableMenuItem(pmenu, MSG_ZOOM_IN, enabled);
|
||||||
EnableMenuItem(pmenu, MSG_ZOOM_IN, enabled);
|
EnableMenuItem(pmenu, MSG_ZOOM_OUT, enabled);
|
||||||
EnableMenuItem(pmenu, MSG_ZOOM_OUT, enabled);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageWindow::LoadMenus(BMenuBar *pbar)
|
ShowImageWindow::LoadMenus(BMenuBar *pbar)
|
||||||
{
|
{
|
||||||
BMenu *pmenu = new BMenu("File");
|
BMenu *pmenu = new BMenu("File");
|
||||||
fpOpenMenu = new BMenu("Open");
|
fOpenMenu = new BMenu("Open");
|
||||||
pmenu->AddItem(fpOpenMenu);
|
pmenu->AddItem(fOpenMenu);
|
||||||
fpOpenMenu->Superitem()->SetTrigger('O');
|
fOpenMenu->Superitem()->SetTrigger('O');
|
||||||
fpOpenMenu->Superitem()->SetMessage(new BMessage(MSG_FILE_OPEN));
|
fOpenMenu->Superitem()->SetMessage(new BMessage(MSG_FILE_OPEN));
|
||||||
fpOpenMenu->Superitem()->SetTarget(be_app);
|
fOpenMenu->Superitem()->SetTarget(be_app);
|
||||||
fpOpenMenu->Superitem()->SetShortcut('O', 0);
|
fOpenMenu->Superitem()->SetShortcut('O', 0);
|
||||||
pmenu->AddSeparatorItem();
|
pmenu->AddSeparatorItem();
|
||||||
BMenu *pmenuSaveAs = new BMenu("Save As" B_UTF8_ELLIPSIS, B_ITEMS_IN_COLUMN);
|
BMenu *pmenuSaveAs = new BMenu("Save As" B_UTF8_ELLIPSIS, B_ITEMS_IN_COLUMN);
|
||||||
BTranslationUtils::AddTranslationItems(pmenuSaveAs, B_TRANSLATOR_BITMAP);
|
BTranslationUtils::AddTranslationItems(pmenuSaveAs, B_TRANSLATOR_BITMAP);
|
||||||
@@ -274,13 +279,13 @@ ShowImageWindow::LoadMenus(BMenuBar *pbar)
|
|||||||
AddItemMenu(pmenu, "Select All", MSG_SELECT_ALL, 'A', 0, 'W', true);
|
AddItemMenu(pmenu, "Select All", MSG_SELECT_ALL, 'A', 0, 'W', true);
|
||||||
pbar->AddItem(pmenu);
|
pbar->AddItem(pmenu);
|
||||||
|
|
||||||
pmenu = fpBrowseMenu = new BMenu("Browse");
|
pmenu = fBrowseMenu = new BMenu("Browse");
|
||||||
AddItemMenu(pmenu, "First Page", MSG_PAGE_FIRST, B_LEFT_ARROW, B_SHIFT_KEY, 'W', true);
|
AddItemMenu(pmenu, "First Page", MSG_PAGE_FIRST, B_LEFT_ARROW, B_SHIFT_KEY, 'W', true);
|
||||||
AddItemMenu(pmenu, "Last Page", MSG_PAGE_LAST, B_RIGHT_ARROW, B_SHIFT_KEY, 'W', true);
|
AddItemMenu(pmenu, "Last Page", MSG_PAGE_LAST, B_RIGHT_ARROW, B_SHIFT_KEY, 'W', true);
|
||||||
AddItemMenu(pmenu, "Next Page", MSG_PAGE_NEXT, B_RIGHT_ARROW, 0, 'W', true);
|
AddItemMenu(pmenu, "Next Page", MSG_PAGE_NEXT, B_RIGHT_ARROW, 0, 'W', true);
|
||||||
AddItemMenu(pmenu, "Previous Page", MSG_PAGE_PREV, B_LEFT_ARROW, 0, 'W', true);
|
AddItemMenu(pmenu, "Previous Page", MSG_PAGE_PREV, B_LEFT_ARROW, 0, 'W', true);
|
||||||
fpGoToPageMenu = new BMenu("Go To Page");
|
fGoToPageMenu = new BMenu("Go To Page");
|
||||||
pmenu->AddItem(fpGoToPageMenu);
|
pmenu->AddItem(fGoToPageMenu);
|
||||||
pmenu->AddSeparatorItem();
|
pmenu->AddSeparatorItem();
|
||||||
AddItemMenu(pmenu, "Next File", MSG_FILE_NEXT, B_DOWN_ARROW, 0, 'W', true);
|
AddItemMenu(pmenu, "Next File", MSG_FILE_NEXT, B_DOWN_ARROW, 0, 'W', true);
|
||||||
AddItemMenu(pmenu, "Previous File", MSG_FILE_PREV, B_UP_ARROW, 0, 'W', true);
|
AddItemMenu(pmenu, "Previous File", MSG_FILE_PREV, B_UP_ARROW, 0, 'W', true);
|
||||||
@@ -298,10 +303,6 @@ ShowImageWindow::LoadMenus(BMenuBar *pbar)
|
|||||||
AddItemMenu(pmenu, "Invert", MSG_INVERT, 0, 0, 'W', true);
|
AddItemMenu(pmenu, "Invert", MSG_INVERT, 0, 0, 'W', true);
|
||||||
pbar->AddItem(pmenu);
|
pbar->AddItem(pmenu);
|
||||||
|
|
||||||
pmenu = new BMenu("View");
|
|
||||||
BuildViewMenu(pmenu);
|
|
||||||
pbar->AddItem(pmenu);
|
|
||||||
|
|
||||||
UpdateRecentDocumentsMenu();
|
UpdateRecentDocumentsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,7 +324,7 @@ ShowImageWindow::AddItemMenu(BMenu *pmenu, char *caption, long unsigned int msg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
BMenuItem*
|
BMenuItem*
|
||||||
ShowImageWindow::AddDelayItem(BMenu *pmenu, char *caption, float value, bool marked)
|
ShowImageWindow::AddDelayItem(BMenu *pmenu, char *caption, float value)
|
||||||
{
|
{
|
||||||
BMenuItem* pitem;
|
BMenuItem* pitem;
|
||||||
BMessage* pmsg;
|
BMessage* pmsg;
|
||||||
@@ -333,6 +334,7 @@ ShowImageWindow::AddDelayItem(BMenu *pmenu, char *caption, float value, bool mar
|
|||||||
pitem = new BMenuItem(caption, pmsg, 0);
|
pitem = new BMenuItem(caption, pmsg, 0);
|
||||||
pitem->SetTarget(this);
|
pitem->SetTarget(this);
|
||||||
|
|
||||||
|
bool marked = fImageView->GetSlideShowDelay() == value;
|
||||||
if (marked) pitem->SetMarked(true);
|
if (marked) pitem->SetMarked(true);
|
||||||
pmenu->AddItem(pitem);
|
pmenu->AddItem(pitem);
|
||||||
|
|
||||||
@@ -354,7 +356,7 @@ ShowImageWindow::WindowRedimension(BBitmap *pbitmap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
width = r.Width() + B_V_SCROLL_BAR_WIDTH;
|
width = r.Width() + B_V_SCROLL_BAR_WIDTH;
|
||||||
height = r.Height() + 1 + fpBar->Frame().Height() + B_H_SCROLL_BAR_HEIGHT;
|
height = r.Height() + 1 + fBar->Frame().Height() + B_H_SCROLL_BAR_HEIGHT;
|
||||||
|
|
||||||
// dimensions so that window does not reach outside of screen
|
// dimensions so that window does not reach outside of screen
|
||||||
maxWidth = screen.Frame().Width() + 1 - windowBorderWidth - Frame().left;
|
maxWidth = screen.Frame().Width() + 1 - windowBorderWidth - Frame().left;
|
||||||
@@ -376,7 +378,7 @@ ShowImageWindow::ToggleMenuItem(uint32 what)
|
|||||||
{
|
{
|
||||||
BMenuItem *item;
|
BMenuItem *item;
|
||||||
bool marked = false;
|
bool marked = false;
|
||||||
item = fpBar->FindItem(what);
|
item = fBar->FindItem(what);
|
||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
marked = !item->IsMarked();
|
marked = !item->IsMarked();
|
||||||
item->SetMarked(marked);
|
item->SetMarked(marked);
|
||||||
@@ -407,10 +409,10 @@ ShowImageWindow::MarkMenuItem(BMenu *menu, uint32 what, bool marked)
|
|||||||
void
|
void
|
||||||
ShowImageWindow::MarkSlideShowDelay(float value)
|
ShowImageWindow::MarkSlideShowDelay(float value)
|
||||||
{
|
{
|
||||||
const int32 n = fpSlideShowDelay->CountItems();
|
const int32 n = fSlideShowDelay->CountItems();
|
||||||
float v;
|
float v;
|
||||||
for (int32 i = 0; i < n; i ++) {
|
for (int32 i = 0; i < n; i ++) {
|
||||||
BMenuItem* item = fpSlideShowDelay->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()) {
|
||||||
@@ -429,23 +431,24 @@ ShowImageWindow::ResizeToWindow(bool shrink, uint32 what)
|
|||||||
bool enabled;
|
bool enabled;
|
||||||
enabled = ToggleMenuItem(what);
|
enabled = ToggleMenuItem(what);
|
||||||
if (shrink) {
|
if (shrink) {
|
||||||
fpImageView->SetShrinkToBounds(enabled);
|
fImageView->SetShrinkToBounds(enabled);
|
||||||
} else {
|
} else {
|
||||||
fpImageView->SetZoomToBounds(enabled);
|
fImageView->SetZoomToBounds(enabled);
|
||||||
}
|
}
|
||||||
enabled = !(fpImageView->GetShrinkToBounds() || fpImageView->GetZoomToBounds());
|
enabled = !(fImageView->GetShrinkToBounds() || fImageView->GetZoomToBounds());
|
||||||
EnableMenuItem(fpBar, MSG_ORIGINAL_SIZE, enabled);
|
EnableMenuItem(fBar, MSG_ORIGINAL_SIZE, enabled);
|
||||||
EnableMenuItem(fpBar, MSG_ZOOM_IN, enabled);
|
EnableMenuItem(fBar, MSG_ZOOM_IN, enabled);
|
||||||
EnableMenuItem(fpBar, MSG_ZOOM_OUT, enabled);
|
EnableMenuItem(fBar, MSG_ZOOM_OUT, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageWindow::MessageReceived(BMessage *pmsg)
|
ShowImageWindow::MessageReceived(BMessage *pmsg)
|
||||||
{
|
{
|
||||||
|
ShowImageSettings* settings;
|
||||||
switch (pmsg->what) {
|
switch (pmsg->what) {
|
||||||
case MSG_OUTPUT_TYPE:
|
case MSG_OUTPUT_TYPE:
|
||||||
// User clicked Save As then choose an output format
|
// User clicked Save As then choose an output format
|
||||||
if (!fpSavePanel)
|
if (!fSavePanel)
|
||||||
// If user doesn't already have a save panel open
|
// If user doesn't already have a save panel open
|
||||||
SaveAs(pmsg);
|
SaveAs(pmsg);
|
||||||
break;
|
break;
|
||||||
@@ -461,29 +464,29 @@ ShowImageWindow::MessageReceived(BMessage *pmsg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case B_CANCEL:
|
case B_CANCEL:
|
||||||
delete fpSavePanel;
|
delete fSavePanel;
|
||||||
fpSavePanel = NULL;
|
fSavePanel = NULL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_UPDATE_STATUS:
|
case MSG_UPDATE_STATUS:
|
||||||
{
|
{
|
||||||
int32 pages, curPage;
|
int32 pages, curPage;
|
||||||
pages = fpImageView->PageCount();
|
pages = fImageView->PageCount();
|
||||||
curPage = fpImageView->CurrentPage();
|
curPage = fImageView->CurrentPage();
|
||||||
|
|
||||||
bool benable = (pages > 1) ? true : false;
|
bool benable = (pages > 1) ? true : false;
|
||||||
EnableMenuItem(fpBar, MSG_PAGE_FIRST, benable);
|
EnableMenuItem(fBar, MSG_PAGE_FIRST, benable);
|
||||||
EnableMenuItem(fpBar, MSG_PAGE_LAST, benable);
|
EnableMenuItem(fBar, MSG_PAGE_LAST, benable);
|
||||||
EnableMenuItem(fpBar, MSG_PAGE_NEXT, benable);
|
EnableMenuItem(fBar, MSG_PAGE_NEXT, benable);
|
||||||
EnableMenuItem(fpBar, MSG_PAGE_PREV, benable);
|
EnableMenuItem(fBar, MSG_PAGE_PREV, benable);
|
||||||
|
|
||||||
if (fpGoToPageMenu->CountItems() != pages) {
|
if (fGoToPageMenu->CountItems() != pages) {
|
||||||
// Only rebuild the submenu if the number of
|
// Only rebuild the submenu if the number of
|
||||||
// pages is different
|
// pages is different
|
||||||
|
|
||||||
while (fpGoToPageMenu->CountItems() > 0)
|
while (fGoToPageMenu->CountItems() > 0)
|
||||||
// Remove all page numbers
|
// Remove all page numbers
|
||||||
delete fpGoToPageMenu->RemoveItem(0L);
|
delete fGoToPageMenu->RemoveItem(0L);
|
||||||
|
|
||||||
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
|
||||||
@@ -502,25 +505,25 @@ ShowImageWindow::MessageReceived(BMessage *pmsg)
|
|||||||
pitem = new BMenuItem(strCaption.String(), pgomsg, shortcut);
|
pitem = new BMenuItem(strCaption.String(), pgomsg, shortcut);
|
||||||
if (curPage == i)
|
if (curPage == i)
|
||||||
pitem->SetMarked(true);
|
pitem->SetMarked(true);
|
||||||
fpGoToPageMenu->AddItem(pitem);
|
fGoToPageMenu->AddItem(pitem);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Make sure the correct page is marked
|
// Make sure the correct page is marked
|
||||||
BMenuItem *pcurItem;
|
BMenuItem *pcurItem;
|
||||||
pcurItem = fpGoToPageMenu->ItemAt(curPage - 1);
|
pcurItem = fGoToPageMenu->ItemAt(curPage - 1);
|
||||||
if (!pcurItem->IsMarked()) {
|
if (!pcurItem->IsMarked()) {
|
||||||
// If the current page isn't marked, unmark everything
|
// If the current page isn't marked, unmark everything
|
||||||
// then mark the current page
|
// then mark the current page
|
||||||
int32 items = fpGoToPageMenu->CountItems();
|
int32 items = fGoToPageMenu->CountItems();
|
||||||
for (int32 i = 0; i < items; i++)
|
for (int32 i = 0; i < items; i++)
|
||||||
fpGoToPageMenu->ItemAt(i)->SetMarked(false);
|
fGoToPageMenu->ItemAt(i)->SetMarked(false);
|
||||||
pcurItem->SetMarked(true);
|
pcurItem->SetMarked(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BString str;
|
BString str;
|
||||||
if (pmsg->FindString("status", &str) == B_OK)
|
if (pmsg->FindString("status", &str) == B_OK)
|
||||||
fpStatusView->SetText(str);
|
fStatusView->SetText(str);
|
||||||
|
|
||||||
UpdateTitle();
|
UpdateTitle();
|
||||||
break;
|
break;
|
||||||
@@ -533,9 +536,9 @@ ShowImageWindow::MessageReceived(BMessage *pmsg)
|
|||||||
// can update the state of the appropriate menu items
|
// can update the state of the appropriate menu items
|
||||||
bool benable;
|
bool benable;
|
||||||
if (pmsg->FindBool("has_selection", &benable) == B_OK) {
|
if (pmsg->FindBool("has_selection", &benable) == B_OK) {
|
||||||
EnableMenuItem(fpBar, B_CUT, benable);
|
EnableMenuItem(fBar, B_CUT, benable);
|
||||||
EnableMenuItem(fpBar, B_COPY, benable);
|
EnableMenuItem(fBar, B_COPY, benable);
|
||||||
EnableMenuItem(fpBar, MSG_CLEAR_SELECT, benable);
|
EnableMenuItem(fBar, MSG_CLEAR_SELECT, benable);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -547,60 +550,60 @@ ShowImageWindow::MessageReceived(BMessage *pmsg)
|
|||||||
// message
|
// message
|
||||||
bool bdata;
|
bool bdata;
|
||||||
if (pmsg->FindBool("data_available", &bdata) == B_OK)
|
if (pmsg->FindBool("data_available", &bdata) == B_OK)
|
||||||
EnableMenuItem(fpBar, B_PASTE, bdata);
|
EnableMenuItem(fBar, B_PASTE, bdata);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_UNDO:
|
case B_UNDO:
|
||||||
break;
|
break;
|
||||||
case B_CUT:
|
case B_CUT:
|
||||||
fpImageView->Cut();
|
fImageView->Cut();
|
||||||
break;
|
break;
|
||||||
case B_COPY:
|
case B_COPY:
|
||||||
fpImageView->CopySelectionToClipboard();
|
fImageView->CopySelectionToClipboard();
|
||||||
break;
|
break;
|
||||||
case B_PASTE:
|
case B_PASTE:
|
||||||
fpImageView->Paste();
|
fImageView->Paste();
|
||||||
break;
|
break;
|
||||||
case MSG_CLEAR_SELECT:
|
case MSG_CLEAR_SELECT:
|
||||||
fpImageView->ClearSelection();
|
fImageView->ClearSelection();
|
||||||
break;
|
break;
|
||||||
case MSG_SELECT_ALL:
|
case MSG_SELECT_ALL:
|
||||||
fpImageView->SelectAll();
|
fImageView->SelectAll();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_PAGE_FIRST:
|
case MSG_PAGE_FIRST:
|
||||||
fpImageView->FirstPage();
|
fImageView->FirstPage();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_PAGE_LAST:
|
case MSG_PAGE_LAST:
|
||||||
fpImageView->LastPage();
|
fImageView->LastPage();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_PAGE_NEXT:
|
case MSG_PAGE_NEXT:
|
||||||
fpImageView->NextPage();
|
fImageView->NextPage();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_PAGE_PREV:
|
case MSG_PAGE_PREV:
|
||||||
fpImageView->PrevPage();
|
fImageView->PrevPage();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_GOTO_PAGE:
|
case MSG_GOTO_PAGE:
|
||||||
{
|
{
|
||||||
int32 curPage, newPage, pages;
|
int32 curPage, newPage, pages;
|
||||||
if (pmsg->FindInt32("page", &newPage) == B_OK) {
|
if (pmsg->FindInt32("page", &newPage) == B_OK) {
|
||||||
curPage = fpImageView->CurrentPage();
|
curPage = fImageView->CurrentPage();
|
||||||
pages = fpImageView->PageCount();
|
pages = fImageView->PageCount();
|
||||||
|
|
||||||
if (newPage > 0 && newPage <= pages) {
|
if (newPage > 0 && newPage <= pages) {
|
||||||
BMenuItem *pcurItem, *pnewItem;
|
BMenuItem *pcurItem, *pnewItem;
|
||||||
pcurItem = fpGoToPageMenu->ItemAt(curPage - 1);
|
pcurItem = fGoToPageMenu->ItemAt(curPage - 1);
|
||||||
pnewItem = fpGoToPageMenu->ItemAt(newPage - 1);
|
pnewItem = fGoToPageMenu->ItemAt(newPage - 1);
|
||||||
if (!pcurItem || !pnewItem)
|
if (!pcurItem || !pnewItem)
|
||||||
break;
|
break;
|
||||||
pcurItem->SetMarked(false);
|
pcurItem->SetMarked(false);
|
||||||
pnewItem->SetMarked(true);
|
pnewItem->SetMarked(true);
|
||||||
fpImageView->GoToPage(newPage);
|
fImageView->GoToPage(newPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -618,39 +621,39 @@ ShowImageWindow::MessageReceived(BMessage *pmsg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_FILE_PREV:
|
case MSG_FILE_PREV:
|
||||||
fpImageView->PrevFile();
|
fImageView->PrevFile();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_FILE_NEXT:
|
case MSG_FILE_NEXT:
|
||||||
fpImageView->NextFile();
|
fImageView->NextFile();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_ROTATE_90:
|
case MSG_ROTATE_90:
|
||||||
fpImageView->Rotate(90);
|
fImageView->Rotate(90);
|
||||||
break;
|
break;
|
||||||
case MSG_ROTATE_270:
|
case MSG_ROTATE_270:
|
||||||
fpImageView->Rotate(270);
|
fImageView->Rotate(270);
|
||||||
break;
|
break;
|
||||||
case MSG_MIRROR_VERTICAL:
|
case MSG_MIRROR_VERTICAL:
|
||||||
fpImageView->Mirror(true);
|
fImageView->Mirror(true);
|
||||||
break;
|
break;
|
||||||
case MSG_MIRROR_HORIZONTAL:
|
case MSG_MIRROR_HORIZONTAL:
|
||||||
fpImageView->Mirror(false);
|
fImageView->Mirror(false);
|
||||||
break;
|
break;
|
||||||
case MSG_INVERT:
|
case MSG_INVERT:
|
||||||
fpImageView->Invert();
|
fImageView->Invert();
|
||||||
break;
|
break;
|
||||||
case MSG_SLIDE_SHOW:
|
case MSG_SLIDE_SHOW:
|
||||||
if (ToggleMenuItem(pmsg->what)) {
|
if (ToggleMenuItem(pmsg->what)) {
|
||||||
fpImageView->StartSlideShow();
|
fImageView->StartSlideShow();
|
||||||
} else {
|
} else {
|
||||||
fpImageView->StopSlideShow();
|
fImageView->StopSlideShow();
|
||||||
}
|
}
|
||||||
case MSG_SLIDE_SHOW_DELAY:
|
case MSG_SLIDE_SHOW_DELAY:
|
||||||
{
|
{
|
||||||
float value;
|
float value;
|
||||||
if (pmsg->FindFloat("value", &value) == B_OK) {
|
if (pmsg->FindFloat("value", &value) == B_OK) {
|
||||||
fpImageView->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);
|
||||||
}
|
}
|
||||||
@@ -662,8 +665,13 @@ ShowImageWindow::MessageReceived(BMessage *pmsg)
|
|||||||
break;
|
break;
|
||||||
case MSG_SHOW_CAPTION:
|
case MSG_SHOW_CAPTION:
|
||||||
fShowCaption = ToggleMenuItem(pmsg->what);
|
fShowCaption = ToggleMenuItem(pmsg->what);
|
||||||
|
settings = my_app->Settings();
|
||||||
|
if (settings->Lock()) {
|
||||||
|
settings->SetBool("ShowCaption", fShowCaption);
|
||||||
|
settings->Unlock();
|
||||||
|
}
|
||||||
if (fFullScreen) {
|
if (fFullScreen) {
|
||||||
fpImageView->SetShowCaption(fShowCaption);
|
fImageView->SetShowCaption(fShowCaption);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -682,16 +690,16 @@ ShowImageWindow::MessageReceived(BMessage *pmsg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_ZOOM_IN:
|
case MSG_ZOOM_IN:
|
||||||
fpImageView->ZoomIn();
|
fImageView->ZoomIn();
|
||||||
break;
|
break;
|
||||||
case MSG_ZOOM_OUT:
|
case MSG_ZOOM_OUT:
|
||||||
fpImageView->ZoomOut();
|
fImageView->ZoomOut();
|
||||||
break;
|
break;
|
||||||
case MSG_ORIGINAL_SIZE:
|
case MSG_ORIGINAL_SIZE:
|
||||||
fpImageView->SetZoom(1.0);
|
fImageView->SetZoom(1.0);
|
||||||
break;
|
break;
|
||||||
case MSG_SCALE_BILINEAR:
|
case MSG_SCALE_BILINEAR:
|
||||||
fpImageView->SetScaleBilinear(ToggleMenuItem(pmsg->what));
|
fImageView->SetScaleBilinear(ToggleMenuItem(pmsg->what));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -720,12 +728,12 @@ ShowImageWindow::SaveAs(BMessage *pmsg)
|
|||||||
ppanelMsg->AddInt32(TYPE_FLD, outType);
|
ppanelMsg->AddInt32(TYPE_FLD, outType);
|
||||||
|
|
||||||
// Create save panel and show it
|
// Create save panel and show it
|
||||||
fpSavePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(this), NULL, 0,
|
fSavePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(this), NULL, 0,
|
||||||
false, ppanelMsg);
|
false, ppanelMsg);
|
||||||
if (!fpSavePanel)
|
if (!fSavePanel)
|
||||||
return;
|
return;
|
||||||
fpSavePanel->Window()->SetWorkspaces(B_CURRENT_WORKSPACE);
|
fSavePanel->Window()->SetWorkspaces(B_CURRENT_WORKSPACE);
|
||||||
fpSavePanel->Show();
|
fSavePanel->Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -757,7 +765,7 @@ ShowImageWindow::SaveToFile(BMessage *pmsg)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Translate the image and write it out to the output file
|
// Translate the image and write it out to the output file
|
||||||
BBitmapStream stream(fpImageView->GetBitmap());
|
BBitmapStream stream(fImageView->GetBitmap());
|
||||||
BTranslatorRoster *proster = BTranslatorRoster::Default();
|
BTranslatorRoster *proster = BTranslatorRoster::Default();
|
||||||
if (proster->Translate(outTranslator, &stream, NULL,
|
if (proster->Translate(outTranslator, &stream, NULL,
|
||||||
&file, outType) != B_OK) {
|
&file, outType) != B_OK) {
|
||||||
@@ -774,7 +782,7 @@ ShowImageWindow::SaveToFile(BMessage *pmsg)
|
|||||||
bool
|
bool
|
||||||
ShowImageWindow::CanQuit()
|
ShowImageWindow::CanQuit()
|
||||||
{
|
{
|
||||||
if (fpSavePanel)
|
if (fSavePanel)
|
||||||
// Don't allow this window to be closed if a save panel is open
|
// Don't allow this window to be closed if a save panel is open
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
@@ -790,31 +798,76 @@ ShowImageWindow::ToggleFullScreen()
|
|||||||
BScreen screen;
|
BScreen screen;
|
||||||
fWindowFrame = Frame();
|
fWindowFrame = Frame();
|
||||||
frame = screen.Frame();
|
frame = screen.Frame();
|
||||||
frame.top -= fpBar->Bounds().Height()+1;
|
frame.top -= fBar->Bounds().Height()+1;
|
||||||
frame.right += B_V_SCROLL_BAR_WIDTH;
|
frame.right += B_V_SCROLL_BAR_WIDTH;
|
||||||
frame.bottom += B_H_SCROLL_BAR_HEIGHT;
|
frame.bottom += B_H_SCROLL_BAR_HEIGHT;
|
||||||
frame.InsetBy(-1, -1); // PEN_SIZE in ShowImageView
|
frame.InsetBy(-1, -1); // PEN_SIZE in ShowImageView
|
||||||
|
|
||||||
SetFlags(Flags() | B_NOT_RESIZABLE | B_NOT_MOVABLE);
|
SetFlags(Flags() | B_NOT_RESIZABLE | B_NOT_MOVABLE);
|
||||||
fpImageView->SetAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE);
|
fImageView->SetAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE);
|
||||||
} else {
|
} else {
|
||||||
frame = fWindowFrame;
|
frame = fWindowFrame;
|
||||||
|
|
||||||
SetFlags(Flags() & ~(B_NOT_RESIZABLE | B_NOT_MOVABLE));
|
SetFlags(Flags() & ~(B_NOT_RESIZABLE | B_NOT_MOVABLE));
|
||||||
fpImageView->SetAlignment(B_ALIGN_LEFT, B_ALIGN_TOP);
|
fImageView->SetAlignment(B_ALIGN_LEFT, B_ALIGN_TOP);
|
||||||
}
|
}
|
||||||
fpImageView->SetBorder(!fFullScreen);
|
fImageView->SetBorder(!fFullScreen);
|
||||||
fpImageView->SetShowCaption(fFullScreen && fShowCaption);
|
fImageView->SetShowCaption(fFullScreen && fShowCaption);
|
||||||
MoveTo(frame.left, frame.top);
|
MoveTo(frame.left, frame.top);
|
||||||
ResizeTo(frame.Width(), frame.Height());
|
ResizeTo(frame.Width(), frame.Height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ShowImageWindow::LoadSettings()
|
||||||
|
{
|
||||||
|
ShowImageSettings* settings;
|
||||||
|
settings = my_app->Settings();
|
||||||
|
int32 op;
|
||||||
|
float f;
|
||||||
|
if (settings->Lock()) {
|
||||||
|
fShowCaption = settings->GetBool("ShowCaption", fShowCaption);
|
||||||
|
fPrintOptions.SetBounds(BRect(0, 0, 1023, 767));
|
||||||
|
|
||||||
|
op = settings->GetInt32("PO:Option", fPrintOptions.Option());
|
||||||
|
fPrintOptions.SetOption((enum PrintOptions::Option)op);
|
||||||
|
|
||||||
|
f = settings->GetFloat("PO:ZoomFactor", fPrintOptions.ZoomFactor());
|
||||||
|
fPrintOptions.SetZoomFactor(f);
|
||||||
|
|
||||||
|
f = settings->GetFloat("PO:DPI", fPrintOptions.DPI());
|
||||||
|
fPrintOptions.SetDPI(f);
|
||||||
|
|
||||||
|
f = settings->GetFloat("PO:Width", fPrintOptions.Width());
|
||||||
|
fPrintOptions.SetWidth(f);
|
||||||
|
|
||||||
|
f = settings->GetFloat("PO:Height", fPrintOptions.Height());
|
||||||
|
fPrintOptions.SetHeight(f);
|
||||||
|
|
||||||
|
settings->Unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ShowImageWindow::SavePrintOptions()
|
||||||
|
{
|
||||||
|
ShowImageSettings* settings;
|
||||||
|
settings = my_app->Settings();
|
||||||
|
if (settings->Lock()) {
|
||||||
|
settings->SetInt32("PO:Option", fPrintOptions.Option());
|
||||||
|
settings->SetFloat("PO:ZoomFactor", fPrintOptions.ZoomFactor());
|
||||||
|
settings->SetFloat("PO:DPI", fPrintOptions.DPI());
|
||||||
|
settings->SetFloat("PO:Width", fPrintOptions.Width());
|
||||||
|
settings->SetFloat("PO:Height", fPrintOptions.Height());
|
||||||
|
settings->Unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ShowImageWindow::PageSetup()
|
ShowImageWindow::PageSetup()
|
||||||
{
|
{
|
||||||
status_t st;
|
status_t st;
|
||||||
BString name;
|
BString name;
|
||||||
fpImageView->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));
|
||||||
@@ -834,8 +887,8 @@ ShowImageWindow::PrepareForPrint()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fPrintOptions.SetBounds(fpImageView->GetBitmap()->Bounds());
|
fPrintOptions.SetBounds(fImageView->GetBitmap()->Bounds());
|
||||||
fPrintOptions.SetWidth(fpImageView->GetBitmap()->Bounds().Width()+1);
|
fPrintOptions.SetWidth(fImageView->GetBitmap()->Bounds().Width()+1);
|
||||||
|
|
||||||
new PrintOptionsWindow(BPoint(Frame().left+30, Frame().top+50), &fPrintOptions, this);
|
new PrintOptionsWindow(BPoint(Frame().left+30, Frame().top+50), &fPrintOptions, this);
|
||||||
}
|
}
|
||||||
@@ -848,9 +901,11 @@ ShowImageWindow::Print(BMessage *msg)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SavePrintOptions();
|
||||||
|
|
||||||
BString name;
|
BString name;
|
||||||
fPrintOptions.SetBounds(fpImageView->GetBitmap()->Bounds());
|
fPrintOptions.SetBounds(fImageView->GetBitmap()->Bounds());
|
||||||
fpImageView->GetName(&name);
|
fImageView->GetName(&name);
|
||||||
BPrintJob printJob(name.String());
|
BPrintJob printJob(name.String());
|
||||||
printJob.SetSettings(new BMessage(*fPrintSettings));
|
printJob.SetSettings(new BMessage(*fPrintSettings));
|
||||||
if (printJob.ConfigJob() == B_OK) {
|
if (printJob.ConfigJob() == B_OK) {
|
||||||
@@ -870,7 +925,7 @@ ShowImageWindow::Print(BMessage *msg)
|
|||||||
lastPage = firstPage;
|
lastPage = firstPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
bitmap = fpImageView->GetBitmap();
|
bitmap = fImageView->GetBitmap();
|
||||||
imageWidth = bitmap->Bounds().Width() + 1.0;
|
imageWidth = bitmap->Bounds().Width() + 1.0;
|
||||||
imageHeight = bitmap->Bounds().Height() + 1.0;
|
imageHeight = bitmap->Bounds().Height() + 1.0;
|
||||||
|
|
||||||
@@ -901,9 +956,9 @@ ShowImageWindow::Print(BMessage *msg)
|
|||||||
|
|
||||||
// XXX: eventually print large images on several pages
|
// XXX: eventually print large images on several pages
|
||||||
printJob.BeginJob();
|
printJob.BeginJob();
|
||||||
fpImageView->SetScale(width / imageWidth);
|
fImageView->SetScale(width / imageWidth);
|
||||||
printJob.DrawView(fpImageView, bitmap->Bounds(), BPoint(printableRect.left, printableRect.top));
|
printJob.DrawView(fImageView, bitmap->Bounds(), BPoint(printableRect.left, printableRect.top));
|
||||||
fpImageView->SetScale(1.0);
|
fImageView->SetScale(1.0);
|
||||||
printJob.SpoolPage();
|
printJob.SpoolPage();
|
||||||
printJob.CommitJob();
|
printJob.CommitJob();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
virtual void Quit();
|
virtual void Quit();
|
||||||
|
|
||||||
status_t InitCheck();
|
status_t InitCheck();
|
||||||
ShowImageView *GetShowImageView() const { return fpImageView; }
|
ShowImageView *GetShowImageView() const { return fImageView; }
|
||||||
|
|
||||||
void UpdateTitle();
|
void UpdateTitle();
|
||||||
void BuildViewMenu(BMenu *menu);
|
void BuildViewMenu(BMenu *menu);
|
||||||
@@ -66,7 +66,7 @@ private:
|
|||||||
long unsigned int msg, char shortcut, uint32 modifier,
|
long unsigned int msg, char shortcut, uint32 modifier,
|
||||||
char target, bool enabled);
|
char target, bool enabled);
|
||||||
|
|
||||||
BMenuItem* AddDelayItem(BMenu *pmenu, char *caption, float value, bool marked);
|
BMenuItem* AddDelayItem(BMenu *pmenu, char *caption, float value);
|
||||||
void UpdateRecentDocumentsMenu();
|
void UpdateRecentDocumentsMenu();
|
||||||
|
|
||||||
bool ToggleMenuItem(uint32 what);
|
bool ToggleMenuItem(uint32 what);
|
||||||
@@ -82,18 +82,20 @@ private:
|
|||||||
bool CanQuit();
|
bool CanQuit();
|
||||||
// returns true if the window can be closed safely, false if not
|
// returns true if the window can be closed safely, false if not
|
||||||
void ToggleFullScreen();
|
void ToggleFullScreen();
|
||||||
|
void LoadSettings();
|
||||||
|
void SavePrintOptions();
|
||||||
bool PageSetup();
|
bool PageSetup();
|
||||||
void PrepareForPrint();
|
void PrepareForPrint();
|
||||||
void Print(BMessage *msg);
|
void Print(BMessage *msg);
|
||||||
|
|
||||||
BFilePanel *fpSavePanel;
|
BFilePanel *fSavePanel;
|
||||||
BMenuBar *fpBar;
|
BMenuBar *fBar;
|
||||||
BMenu *fpOpenMenu;
|
BMenu *fOpenMenu;
|
||||||
BMenu *fpBrowseMenu;
|
BMenu *fBrowseMenu;
|
||||||
BMenu *fpGoToPageMenu;
|
BMenu *fGoToPageMenu;
|
||||||
BMenu *fpSlideShowDelay;
|
BMenu *fSlideShowDelay;
|
||||||
ShowImageView *fpImageView;
|
ShowImageView *fImageView;
|
||||||
ShowImageStatusView *fpStatusView;
|
ShowImageStatusView *fStatusView;
|
||||||
bool fFullScreen;
|
bool fFullScreen;
|
||||||
BRect fWindowFrame;
|
BRect fWindowFrame;
|
||||||
bool fShowCaption;
|
bool fShowCaption;
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user