Fixed various issues:
* ArgvReceived() did not work with relative paths. * Simplified quitting (no more CanQuit() and overriding BWindow::Quit()). * Updated signature. * Cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16260 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
6697289d80
commit
efa8b4f392
|
@ -1,28 +1,8 @@
|
|||
/*
|
||||
** ShowImage.rdef
|
||||
**
|
||||
*/
|
||||
* ShowImage.rdef
|
||||
*/
|
||||
|
||||
/* BEOS:APP_SIG :
|
||||
application:/x-vnd.obos.app-name
|
||||
*/
|
||||
|
||||
resource app_signature "application/x-vnd.obos.showimage";
|
||||
|
||||
/* BEOS:APP_FLAGS :
|
||||
00000000 = SINGLE LAUNCH
|
||||
00000001 = MULTIPLE LAUNCH
|
||||
00000002 = EXCLUSIVE LAUNCH
|
||||
00000004 = BACKGROUND APP + SINGLE LAUNCH
|
||||
00000005 = BACKGROUND APP + MULTIPLE LAUNCH
|
||||
00000006 = BACKGROUND APP + EXCLUSIVE LAUNCH
|
||||
00000008 = ARGV_ONLY + SINGLE LAUNCH
|
||||
00000009 = ARGV_ONLY + MULTIPLE LAUNCH
|
||||
0000000A = ARGV_ONLY + EXCLUSIVE LAUNCH
|
||||
0000000C = ARGV_ONLY + BACKGROUND APP + SINGLE LAUNCH
|
||||
0000000D = ARGV_ONLY + BACKGROUND APP + MULTIPLE LAUNCH
|
||||
0000000E = ARGV_ONLY + BACKGROUND APP + EXCLUSIVE LAUNCH
|
||||
*/
|
||||
resource app_signature "application/x-vnd.haiku-showimage";
|
||||
|
||||
resource app_flags B_SINGLE_LAUNCH;
|
||||
|
||||
|
@ -36,19 +16,18 @@ resource file_types message {
|
|||
};
|
||||
|
||||
resource app_version {
|
||||
|
||||
major = 0,
|
||||
middle = 0,
|
||||
minor = 1,
|
||||
|
||||
|
||||
/* 0 = development 1 = alpha 2 = beta
|
||||
3 = gamma 4 = golden master 5 = final */
|
||||
variety = 1,
|
||||
|
||||
|
||||
internal = 0,
|
||||
|
||||
|
||||
short_info = "Show Image",
|
||||
long_info = "OpenBeOS - ShowImage"
|
||||
long_info = "ShowImage - Copyright 2003-2006 Haiku."
|
||||
};
|
||||
|
||||
resource large_icon array {
|
||||
|
|
|
@ -1,80 +1,71 @@
|
|||
/*****************************************************************************/
|
||||
// ShowImageApp
|
||||
// Written by Fernando Francisco de Oliveira, Michael Wilber, Michael Pfeiffer
|
||||
//
|
||||
// ShowImageApp.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.
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
* Copyright 2003-2006, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Fernando Francisco de Oliveira
|
||||
* Michael Wilber
|
||||
* Michael Pfeiffer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <Alert.h>
|
||||
#include <FilePanel.h>
|
||||
#include <String.h>
|
||||
#include <Clipboard.h>
|
||||
|
||||
#include "ShowImageConstants.h"
|
||||
#include "ShowImageApp.h"
|
||||
#include "ShowImageConstants.h"
|
||||
#include "ShowImageWindow.h"
|
||||
|
||||
int main(int, char **)
|
||||
{
|
||||
ShowImageApp theApp;
|
||||
theApp.Run();
|
||||
return 0;
|
||||
}
|
||||
#include <Alert.h>
|
||||
#include <Clipboard.h>
|
||||
#include <FilePanel.h>
|
||||
#include <Path.h>
|
||||
#include <String.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#define WINDOWS_TO_IGNORE 1
|
||||
|
||||
extern const char *kApplicationSignature = "application/x-vnd.haiku-showimage";
|
||||
|
||||
|
||||
ShowImageApp::ShowImageApp()
|
||||
: BApplication(APP_SIG)
|
||||
: BApplication(kApplicationSignature)
|
||||
{
|
||||
fPulseStarted = false;
|
||||
fOpenPanel = new BFilePanel(B_OPEN_PANEL);
|
||||
}
|
||||
|
||||
|
||||
ShowImageApp::~ShowImageApp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ShowImageApp::AboutRequested()
|
||||
{
|
||||
BAlert* pAlert = new BAlert("About ShowImage",
|
||||
BAlert* alert = new BAlert("About ShowImage",
|
||||
"Haiku ShowImage\n\nby Fernando F. Oliveira, Michael Wilber and Michael Pfeiffer", "OK");
|
||||
pAlert->Go();
|
||||
alert->Go();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ShowImageApp::ReadyToRun()
|
||||
{
|
||||
if (CountWindows() == WINDOWS_TO_IGNORE)
|
||||
fOpenPanel->Show();
|
||||
else
|
||||
else {
|
||||
// If image windows are already open
|
||||
// (paths supplied on the command line)
|
||||
// start checking the number of open windows
|
||||
StartPulse();
|
||||
}
|
||||
|
||||
be_clipboard->StartWatching(be_app_messenger);
|
||||
// tell the clipboard to notify this app when its contents change
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ShowImageApp::StartPulse()
|
||||
{
|
||||
|
@ -87,106 +78,117 @@ ShowImageApp::StartPulse()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ShowImageApp::Pulse()
|
||||
{
|
||||
// Bug: The BFilePanel is automatically closed if the volume that
|
||||
// is displayed is unmounted.
|
||||
if (!IsLaunching() && CountWindows() <= WINDOWS_TO_IGNORE)
|
||||
if (!IsLaunching() && CountWindows() <= WINDOWS_TO_IGNORE) {
|
||||
// If the application is not launching and
|
||||
// all windows are closed except for the file open panel,
|
||||
// quit the application
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ShowImageApp::ArgvReceived(int32 argc, char **argv)
|
||||
{
|
||||
BMessage *pmsg = NULL;
|
||||
BMessage message;
|
||||
bool hasRefs = false;
|
||||
|
||||
// get current working directory
|
||||
const char *cwd;
|
||||
if (CurrentMessage() == NULL || CurrentMessage()->FindString("cwd", &cwd) != B_OK)
|
||||
cwd = "";
|
||||
|
||||
for (int32 i = 1; i < argc; i++) {
|
||||
BPath path(cwd);
|
||||
path.Append(argv[i]);
|
||||
|
||||
entry_ref ref;
|
||||
status_t err = get_ref_for_path(argv[i], &ref);
|
||||
status_t err = get_ref_for_path(path.Path(), &ref);
|
||||
if (err == B_OK) {
|
||||
if (!pmsg) {
|
||||
pmsg = new BMessage;
|
||||
pmsg->what = B_REFS_RECEIVED;
|
||||
}
|
||||
pmsg->AddRef("refs", &ref);
|
||||
message.AddRef("refs", &ref);
|
||||
hasRefs = true;
|
||||
}
|
||||
}
|
||||
if (pmsg) {
|
||||
RefsReceived(pmsg);
|
||||
delete pmsg;
|
||||
}
|
||||
|
||||
if (hasRefs)
|
||||
RefsReceived(&message);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ShowImageApp::MessageReceived(BMessage *pmsg)
|
||||
ShowImageApp::MessageReceived(BMessage *message)
|
||||
{
|
||||
switch (pmsg->what) {
|
||||
switch (message->what) {
|
||||
case MSG_FILE_OPEN:
|
||||
fOpenPanel->Show();
|
||||
break;
|
||||
|
||||
|
||||
case MSG_WINDOW_QUIT:
|
||||
break;
|
||||
|
||||
|
||||
case B_CANCEL:
|
||||
// File open panel was closed,
|
||||
// start checking count of open windows
|
||||
StartPulse();
|
||||
break;
|
||||
|
||||
|
||||
case B_CLIPBOARD_CHANGED:
|
||||
CheckClipboard();
|
||||
break;
|
||||
|
||||
default:
|
||||
BApplication::MessageReceived(pmsg);
|
||||
BApplication::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ShowImageApp::RefsReceived(BMessage *pmsg)
|
||||
ShowImageApp::RefsReceived(BMessage *message)
|
||||
{
|
||||
//
|
||||
// If a tracker window opened me, get a messenger from it.
|
||||
//
|
||||
if (pmsg->HasMessenger("TrackerViewToken")) {
|
||||
pmsg->FindMessenger("TrackerViewToken", &fTrackerMessenger);
|
||||
}
|
||||
if (message->HasMessenger("TrackerViewToken"))
|
||||
message->FindMessenger("TrackerViewToken", &fTrackerMessenger);
|
||||
|
||||
uint32 type;
|
||||
int32 count;
|
||||
status_t ret = pmsg->GetInfo("refs", &type, &count);
|
||||
status_t ret = message->GetInfo("refs", &type, &count);
|
||||
if (ret != B_OK || type != B_REF_TYPE)
|
||||
return;
|
||||
|
||||
entry_ref ref;
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
if (pmsg->FindRef("refs", i, &ref) == B_OK)
|
||||
if (message->FindRef("refs", i, &ref) == B_OK)
|
||||
Open(&ref);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ShowImageApp::Open(const entry_ref *pref)
|
||||
{
|
||||
new ShowImageWindow(pref, fTrackerMessenger);
|
||||
}
|
||||
|
||||
void
|
||||
ShowImageApp::BroadcastToWindows(BMessage *pmsg)
|
||||
ShowImageApp::Open(const entry_ref *ref)
|
||||
{
|
||||
const int32 n = CountWindows();
|
||||
for (int32 i = 0; i < n ; i ++) {
|
||||
new ShowImageWindow(ref, fTrackerMessenger);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ShowImageApp::BroadcastToWindows(BMessage *message)
|
||||
{
|
||||
const int32 count = CountWindows();
|
||||
for (int32 i = 0; i < count; i ++) {
|
||||
// BMessenger checks for us if BWindow is still a valid object
|
||||
BMessenger msgr(WindowAt(i));
|
||||
msgr.SendMessage(pmsg);
|
||||
msgr.SendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ShowImageApp::CheckClipboard()
|
||||
{
|
||||
|
@ -195,32 +197,45 @@ ShowImageApp::CheckClipboard()
|
|||
// After checking the clipboard, a message is sent to
|
||||
// all windows indicating that the clipboard has changed
|
||||
// and whether or not the clipboard contains useful data.
|
||||
bool bdata = false;
|
||||
|
||||
if (be_clipboard->Lock()) {
|
||||
BMessage *pclip;
|
||||
if ((pclip = be_clipboard->Data()) != NULL) {
|
||||
BString strClass;
|
||||
if (pclip->FindString("class", &strClass) == B_OK) {
|
||||
if (strClass == "BBitmap")
|
||||
bdata = true;
|
||||
bool dataAvailable = false;
|
||||
|
||||
if (be_clipboard->Lock()) {
|
||||
BMessage *clip = be_clipboard->Data();
|
||||
if (clip != NULL) {
|
||||
BString className;
|
||||
if (clip->FindString("class", &className) == B_OK) {
|
||||
if (className == "BBitmap")
|
||||
dataAvailable = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
be_clipboard->Unlock();
|
||||
}
|
||||
|
||||
|
||||
BMessage msg(MSG_CLIPBOARD_CHANGED);
|
||||
msg.AddBool("data_available", bdata);
|
||||
msg.AddBool("data_available", dataAvailable);
|
||||
BroadcastToWindows(&msg);
|
||||
}
|
||||
|
||||
void
|
||||
ShowImageApp::Quit()
|
||||
|
||||
bool
|
||||
ShowImageApp::QuitRequested()
|
||||
{
|
||||
be_clipboard->StopWatching(be_app_messenger);
|
||||
// tell clipboard we don't want anymore notification
|
||||
|
||||
BApplication::Quit();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
int
|
||||
main(int, char **)
|
||||
{
|
||||
ShowImageApp theApp;
|
||||
theApp.Run();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,65 +1,52 @@
|
|||
/*****************************************************************************/
|
||||
// ShowImageApp
|
||||
// Written by Fernando Francisco de Oliveira, Michael Wilber, Michael Pfeiffer
|
||||
//
|
||||
// ShowImageApp.h
|
||||
//
|
||||
//
|
||||
// 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.
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
* Copyright 2003-2006, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Fernando Francisco de Oliveira
|
||||
* Michael Wilber
|
||||
* Michael Pfeiffer
|
||||
*/
|
||||
#ifndef SHOW_IMAGE_APP_H
|
||||
#define SHOW_IMAGE_APP_H
|
||||
|
||||
#ifndef _ShowImageApp_h
|
||||
#define _ShowImageApp_h
|
||||
|
||||
#include <Application.h>
|
||||
|
||||
#include "ShowImageSettings.h"
|
||||
|
||||
#include <Application.h>
|
||||
|
||||
|
||||
class ShowImageApp : public BApplication {
|
||||
public:
|
||||
ShowImageApp();
|
||||
public:
|
||||
ShowImageApp();
|
||||
virtual ~ShowImageApp();
|
||||
|
||||
public:
|
||||
virtual void AboutRequested();
|
||||
virtual void ArgvReceived(int32 argc, char **argv);
|
||||
virtual void MessageReceived(BMessage *pmsg);
|
||||
virtual void ReadyToRun();
|
||||
virtual void Pulse();
|
||||
virtual void RefsReceived(BMessage *pmsg);
|
||||
virtual void Quit();
|
||||
public:
|
||||
virtual void AboutRequested();
|
||||
virtual void ArgvReceived(int32 argc, char **argv);
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void ReadyToRun();
|
||||
virtual void Pulse();
|
||||
virtual void RefsReceived(BMessage *message);
|
||||
virtual bool QuitRequested();
|
||||
|
||||
ShowImageSettings* Settings() { return &fSettings; }
|
||||
ShowImageSettings* Settings() { return &fSettings; }
|
||||
|
||||
private:
|
||||
void StartPulse();
|
||||
void Open(const entry_ref *pref);
|
||||
void BroadcastToWindows(BMessage *pmsg);
|
||||
void CheckClipboard();
|
||||
private:
|
||||
void StartPulse();
|
||||
void Open(const entry_ref *ref);
|
||||
void BroadcastToWindows(BMessage *message);
|
||||
void CheckClipboard();
|
||||
|
||||
BMessenger fTrackerMessenger; // of the window this was launched
|
||||
BFilePanel *fOpenPanel;
|
||||
bool fPulseStarted;
|
||||
ShowImageSettings fSettings;
|
||||
BMessenger fTrackerMessenger; // of the window this was launched
|
||||
BFilePanel *fOpenPanel;
|
||||
bool fPulseStarted;
|
||||
ShowImageSettings fSettings;
|
||||
};
|
||||
|
||||
extern const char *kApplicationSignature;
|
||||
|
||||
#define my_app dynamic_cast<ShowImageApp*>(be_app)
|
||||
|
||||
#endif /* _ShowImageApp_h */
|
||||
#endif // SHOW_IMAGE_APP_H
|
||||
|
||||
|
|
|
@ -28,4 +28,3 @@
|
|||
|
||||
#include "ShowImageConstants.h"
|
||||
|
||||
extern const char *APP_SIG = "application/x-vnd.obos.showimage";
|
||||
|
|
|
@ -1,40 +1,22 @@
|
|||
/*****************************************************************************/
|
||||
// ShowImageConstants
|
||||
// Written by Fernando Francisco de Oliveira, Michael Wilber, Michael Pfeiffer
|
||||
//
|
||||
// ShowImageConstants.h
|
||||
//
|
||||
//
|
||||
// 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.
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
* Copyright 2003-2006, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Fernando Francisco de Oliveira
|
||||
* Michael Wilber
|
||||
* Michael Pfeiffer
|
||||
*/
|
||||
#ifndef SHOW_IMAGE_CONSTANTS_H
|
||||
#define SHOW_IMAGE_CONSTANTS_H
|
||||
|
||||
#ifndef _ShowImageConstants_
|
||||
#define _ShowImageConstants_
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
const uint32 MSG_CAPTURE_MOUSE = 'mCPM';
|
||||
const uint32 MSG_CHANGE_FOCUS = 'mCFS';
|
||||
const uint32 MSG_FILE_OPEN = 'mFOP';
|
||||
const uint32 MSG_CLOSE = 'mCLS';
|
||||
const uint32 MSG_WINDOW_QUIT = 'mWQT';
|
||||
const uint32 MSG_OUTPUT_TYPE = 'BTMN';
|
||||
const uint32 MSG_SAVE_PANEL = 'mFSP';
|
||||
|
@ -75,7 +57,4 @@ const uint32 MSG_ORIGINAL_SIZE = 'mOSZ';
|
|||
const uint32 MSG_INVALIDATE = 'mIVD';
|
||||
const uint32 MSG_SCALE_BILINEAR = 'mSBL';
|
||||
|
||||
extern const char *APP_SIG;
|
||||
|
||||
|
||||
#endif /* _ShowImageConstants_ */
|
||||
#endif // SHOW_IMAGE_CONSTANTS_H
|
||||
|
|
|
@ -1,58 +1,12 @@
|
|||
/*****************************************************************************/
|
||||
// ShowImageView
|
||||
// Written by Fernando Francisco de Oliveira, Michael Wilber, Michael Pfeiffer
|
||||
//
|
||||
// ShowImageView.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 <stdio.h>
|
||||
#include <math.h>
|
||||
#include <new>
|
||||
|
||||
#include <Debug.h>
|
||||
#include <Message.h>
|
||||
#include <ScrollBar.h>
|
||||
#include <StopWatch.h>
|
||||
#include <Alert.h>
|
||||
#include <MenuBar.h>
|
||||
#include <MenuItem.h>
|
||||
#include <File.h>
|
||||
#include <Bitmap.h>
|
||||
#include <TranslatorRoster.h>
|
||||
#include <BitmapStream.h>
|
||||
#include <Rect.h>
|
||||
#include <SupportDefs.h>
|
||||
#include <Directory.h>
|
||||
#include <Entry.h>
|
||||
#include <Application.h>
|
||||
#include <Roster.h>
|
||||
#include <NodeInfo.h>
|
||||
#include <Clipboard.h>
|
||||
#include <Path.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <Region.h>
|
||||
#include <Screen.h>
|
||||
/*
|
||||
* Copyright 2003-2006, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Fernando Francisco de Oliveira
|
||||
* Michael Wilber
|
||||
* Michael Pfeiffer
|
||||
*/
|
||||
|
||||
|
||||
#include "ShowImageApp.h"
|
||||
|
@ -60,6 +14,34 @@
|
|||
#include "ShowImageView.h"
|
||||
#include "ShowImageWindow.h"
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Application.h>
|
||||
#include <Bitmap.h>
|
||||
#include <BitmapStream.h>
|
||||
#include <Clipboard.h>
|
||||
#include <Debug.h>
|
||||
#include <Directory.h>
|
||||
#include <Entry.h>
|
||||
#include <File.h>
|
||||
#include <MenuBar.h>
|
||||
#include <MenuItem.h>
|
||||
#include <Message.h>
|
||||
#include <NodeInfo.h>
|
||||
#include <Path.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <Rect.h>
|
||||
#include <Region.h>
|
||||
#include <Roster.h>
|
||||
#include <Screen.h>
|
||||
#include <ScrollBar.h>
|
||||
#include <StopWatch.h>
|
||||
#include <SupportDefs.h>
|
||||
#include <TranslatorRoster.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <new>
|
||||
#include <stdio.h>
|
||||
|
||||
using std::nothrow;
|
||||
|
||||
#ifndef min
|
||||
|
@ -306,12 +288,14 @@ ShowImageView::Notify(const char* status)
|
|||
Invalidate();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ShowImageView::AddToRecentDocuments()
|
||||
{
|
||||
be_roster->AddToRecentDocuments(&fCurrentRef, APP_SIG);
|
||||
be_roster->AddToRecentDocuments(&fCurrentRef, kApplicationSignature);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ShowImageView::DeleteScaler()
|
||||
{
|
||||
|
@ -325,6 +309,7 @@ ShowImageView::DeleteScaler()
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ShowImageView::DeleteBitmap()
|
||||
{
|
||||
|
@ -339,15 +324,18 @@ ShowImageView::DeleteBitmap()
|
|||
fBitmap = NULL;
|
||||
}
|
||||
|
||||
|
||||
void ShowImageView::DeleteSelBitmap()
|
||||
{
|
||||
delete fSelBitmap;
|
||||
fSelBitmap = NULL;
|
||||
}
|
||||
|
||||
|
||||
const rgb_color kAlphaLow = (rgb_color){ 0xbb, 0xbb, 0xbb, 0xff };
|
||||
const rgb_color kAlphaHigh = (rgb_color){ 0xe0, 0xe0, 0xe0, 0xff };
|
||||
|
||||
|
||||
inline void
|
||||
blend_colors(uint8* d, uint8 r, uint8 g, uint8 b, uint8 a)
|
||||
{
|
||||
|
@ -356,6 +344,7 @@ blend_colors(uint8* d, uint8 r, uint8 g, uint8 b, uint8 a)
|
|||
d[2] = ((r - d[2]) * a + (d[2] << 8)) >> 8;
|
||||
}
|
||||
|
||||
|
||||
BBitmap*
|
||||
compose_checker_background(const BBitmap* bitmap)
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,42 +1,24 @@
|
|||
/*****************************************************************************/
|
||||
// ShowImageWindow
|
||||
// Written by Fernando Francisco de Oliveira, Michael Wilber, Michael Pfeiffer
|
||||
//
|
||||
// ShowImageWindow.h
|
||||
//
|
||||
//
|
||||
// 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.
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
* Copyright 2003-2006, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Fernando Francisco de Oliveira
|
||||
* Michael Wilber
|
||||
* Michael Pfeiffer
|
||||
*/
|
||||
#ifndef SHOW_IMAGE_WINDOW_H
|
||||
#define SHOW_IMAGE_WINDOW_H
|
||||
|
||||
#ifndef _ShowImageWindow_h
|
||||
#define _ShowImageWindow_h
|
||||
|
||||
#include <Menu.h>
|
||||
#include <Window.h>
|
||||
#include <FilePanel.h>
|
||||
#include <TranslationDefs.h>
|
||||
#include <String.h>
|
||||
|
||||
#include "PrintOptionsWindow.h"
|
||||
|
||||
#include <FilePanel.h>
|
||||
#include <Menu.h>
|
||||
#include <String.h>
|
||||
#include <TranslationDefs.h>
|
||||
#include <Window.h>
|
||||
|
||||
class ShowImageView;
|
||||
class ShowImageStatusView;
|
||||
|
||||
|
@ -44,76 +26,71 @@ class ShowImageStatusView;
|
|||
#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 s);
|
||||
class RecentDocumentsMenu : public BMenu {
|
||||
public:
|
||||
RecentDocumentsMenu(const char *title, menu_layout layout = B_ITEMS_IN_COLUMN);
|
||||
bool AddDynamicItem(add_state s);
|
||||
|
||||
private:
|
||||
void UpdateRecentDocumentsMenu();
|
||||
private:
|
||||
void UpdateRecentDocumentsMenu();
|
||||
};
|
||||
|
||||
class ShowImageWindow : public BWindow {
|
||||
public:
|
||||
ShowImageWindow(const entry_ref *pref, const BMessenger& trackerMessenger);
|
||||
virtual ~ShowImageWindow();
|
||||
public:
|
||||
ShowImageWindow(const entry_ref *pref, const BMessenger& trackerMessenger);
|
||||
virtual ~ShowImageWindow();
|
||||
|
||||
virtual void FrameResized(float width, float height);
|
||||
virtual void MessageReceived(BMessage *pmsg);
|
||||
virtual bool QuitRequested();
|
||||
virtual void Quit();
|
||||
virtual void Zoom(BPoint origin, float width, float height);
|
||||
|
||||
status_t InitCheck();
|
||||
ShowImageView *GetShowImageView() const { return fImageView; }
|
||||
|
||||
void UpdateTitle();
|
||||
void BuildViewMenu(BMenu *menu);
|
||||
void LoadMenus(BMenuBar *pbar);
|
||||
void WindowRedimension(BBitmap *pbitmap);
|
||||
virtual void FrameResized(float width, float height);
|
||||
virtual void MessageReceived(BMessage *pmsg);
|
||||
virtual bool QuitRequested();
|
||||
virtual void Zoom(BPoint origin, float width, float height);
|
||||
|
||||
private:
|
||||
BMenuItem *AddItemMenu(BMenu *pmenu, char *caption,
|
||||
long unsigned int msg, char shortcut, uint32 modifier,
|
||||
char target, bool enabled);
|
||||
status_t InitCheck();
|
||||
ShowImageView *GetShowImageView() const { return fImageView; }
|
||||
|
||||
BMenuItem* AddDelayItem(BMenu *pmenu, char *caption, float value);
|
||||
|
||||
bool ToggleMenuItem(uint32 what);
|
||||
void EnableMenuItem(BMenu *menu, uint32 what, bool enable);
|
||||
void MarkMenuItem(BMenu *menu, uint32 what, bool marked);
|
||||
void MarkSlideShowDelay(float value);
|
||||
void ResizeToWindow(bool shrink, uint32 what);
|
||||
void UpdateTitle();
|
||||
void BuildViewMenu(BMenu *menu);
|
||||
void AddMenus(BMenuBar *pbar);
|
||||
void WindowRedimension(BBitmap *pbitmap);
|
||||
|
||||
private:
|
||||
BMenuItem *AddItemMenu(BMenu *pmenu, char *caption,
|
||||
long unsigned int msg, char shortcut, uint32 modifier,
|
||||
char target, bool enabled);
|
||||
BMenuItem* AddDelayItem(BMenu *pmenu, char *caption, float value);
|
||||
|
||||
bool ToggleMenuItem(uint32 what);
|
||||
void EnableMenuItem(BMenu *menu, uint32 what, bool enable);
|
||||
void MarkMenuItem(BMenu *menu, uint32 what, bool marked);
|
||||
void MarkSlideShowDelay(float value);
|
||||
void ResizeToWindow(bool shrink, uint32 what);
|
||||
|
||||
void SaveAs(BMessage *pmsg);
|
||||
// Handle Save As submenu choice
|
||||
void SaveToFile(BMessage *pmsg);
|
||||
// Handle save file panel message
|
||||
bool ClosePrompt();
|
||||
bool CanQuit();
|
||||
// returns true if the window can be closed safely, false if not
|
||||
void ToggleFullScreen();
|
||||
void LoadSettings();
|
||||
void SavePrintOptions();
|
||||
bool PageSetup();
|
||||
void PrepareForPrint();
|
||||
void Print(BMessage *msg);
|
||||
void SaveAs(BMessage *pmsg);
|
||||
// Handle Save As submenu choice
|
||||
void SaveToFile(BMessage *pmsg);
|
||||
// Handle save file panel message
|
||||
bool ClosePrompt();
|
||||
void ToggleFullScreen();
|
||||
void LoadSettings();
|
||||
void SavePrintOptions();
|
||||
bool PageSetup();
|
||||
void PrepareForPrint();
|
||||
void Print(BMessage *msg);
|
||||
|
||||
BFilePanel *fSavePanel;
|
||||
BMenuBar *fBar;
|
||||
BMenu *fOpenMenu;
|
||||
BMenu *fBrowseMenu;
|
||||
BMenu *fGoToPageMenu;
|
||||
BMenu *fSlideShowDelay;
|
||||
ShowImageView *fImageView;
|
||||
ShowImageStatusView *fStatusView;
|
||||
bool fModified;
|
||||
bool fFullScreen;
|
||||
BRect fWindowFrame;
|
||||
bool fShowCaption;
|
||||
BMessage *fPrintSettings;
|
||||
PrintOptions fPrintOptions;
|
||||
BFilePanel *fSavePanel;
|
||||
BMenuBar *fBar;
|
||||
BMenu *fOpenMenu;
|
||||
BMenu *fBrowseMenu;
|
||||
BMenu *fGoToPageMenu;
|
||||
BMenu *fSlideShowDelay;
|
||||
ShowImageView *fImageView;
|
||||
ShowImageStatusView *fStatusView;
|
||||
bool fModified;
|
||||
bool fFullScreen;
|
||||
BRect fWindowFrame;
|
||||
bool fShowCaption;
|
||||
BMessage *fPrintSettings;
|
||||
PrintOptions fPrintOptions;
|
||||
};
|
||||
|
||||
#endif /* _ShowImageWindow_h */
|
||||
#endif // SHOW_IMAGE_WINDOW_H
|
||||
|
|
Loading…
Reference in New Issue