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:
@@ -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";
|
resource app_signature "application/x-vnd.haiku-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_flags B_SINGLE_LAUNCH;
|
resource app_flags B_SINGLE_LAUNCH;
|
||||||
|
|
||||||
@@ -36,7 +16,6 @@ resource file_types message {
|
|||||||
};
|
};
|
||||||
|
|
||||||
resource app_version {
|
resource app_version {
|
||||||
|
|
||||||
major = 0,
|
major = 0,
|
||||||
middle = 0,
|
middle = 0,
|
||||||
minor = 1,
|
minor = 1,
|
||||||
@@ -48,7 +27,7 @@ resource app_version {
|
|||||||
internal = 0,
|
internal = 0,
|
||||||
|
|
||||||
short_info = "Show Image",
|
short_info = "Show Image",
|
||||||
long_info = "OpenBeOS - ShowImage"
|
long_info = "ShowImage - Copyright 2003-2006 Haiku."
|
||||||
};
|
};
|
||||||
|
|
||||||
resource large_icon array {
|
resource large_icon array {
|
||||||
|
|||||||
@@ -1,80 +1,71 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// ShowImageApp
|
* 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.
|
||||||
//
|
*
|
||||||
// ShowImageApp.cpp
|
* 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
|
|
||||||
// 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 <Alert.h>
|
|
||||||
#include <FilePanel.h>
|
|
||||||
#include <String.h>
|
|
||||||
#include <Clipboard.h>
|
|
||||||
|
|
||||||
#include "ShowImageConstants.h"
|
|
||||||
#include "ShowImageApp.h"
|
#include "ShowImageApp.h"
|
||||||
|
#include "ShowImageConstants.h"
|
||||||
#include "ShowImageWindow.h"
|
#include "ShowImageWindow.h"
|
||||||
|
|
||||||
int main(int, char **)
|
#include <Alert.h>
|
||||||
{
|
#include <Clipboard.h>
|
||||||
ShowImageApp theApp;
|
#include <FilePanel.h>
|
||||||
theApp.Run();
|
#include <Path.h>
|
||||||
return 0;
|
#include <String.h>
|
||||||
}
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
#define WINDOWS_TO_IGNORE 1
|
#define WINDOWS_TO_IGNORE 1
|
||||||
|
|
||||||
|
extern const char *kApplicationSignature = "application/x-vnd.haiku-showimage";
|
||||||
|
|
||||||
|
|
||||||
ShowImageApp::ShowImageApp()
|
ShowImageApp::ShowImageApp()
|
||||||
: BApplication(APP_SIG)
|
: BApplication(kApplicationSignature)
|
||||||
{
|
{
|
||||||
fPulseStarted = false;
|
fPulseStarted = false;
|
||||||
fOpenPanel = new BFilePanel(B_OPEN_PANEL);
|
fOpenPanel = new BFilePanel(B_OPEN_PANEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ShowImageApp::~ShowImageApp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageApp::AboutRequested()
|
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");
|
"Haiku ShowImage\n\nby Fernando F. Oliveira, Michael Wilber and Michael Pfeiffer", "OK");
|
||||||
pAlert->Go();
|
alert->Go();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageApp::ReadyToRun()
|
ShowImageApp::ReadyToRun()
|
||||||
{
|
{
|
||||||
if (CountWindows() == WINDOWS_TO_IGNORE)
|
if (CountWindows() == WINDOWS_TO_IGNORE)
|
||||||
fOpenPanel->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)
|
||||||
// start checking the number of open windows
|
// start checking the number of open windows
|
||||||
StartPulse();
|
StartPulse();
|
||||||
|
}
|
||||||
|
|
||||||
be_clipboard->StartWatching(be_app_messenger);
|
be_clipboard->StartWatching(be_app_messenger);
|
||||||
// tell the clipboard to notify this app when its contents change
|
// tell the clipboard to notify this app when its contents change
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageApp::StartPulse()
|
ShowImageApp::StartPulse()
|
||||||
{
|
{
|
||||||
@@ -87,43 +78,53 @@ ShowImageApp::StartPulse()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageApp::Pulse()
|
ShowImageApp::Pulse()
|
||||||
{
|
{
|
||||||
// Bug: The BFilePanel is automatically closed if the volume that
|
// Bug: The BFilePanel is automatically closed if the volume that
|
||||||
// is displayed is unmounted.
|
// is displayed is unmounted.
|
||||||
if (!IsLaunching() && CountWindows() <= WINDOWS_TO_IGNORE)
|
if (!IsLaunching() && CountWindows() <= WINDOWS_TO_IGNORE) {
|
||||||
// If the application is not launching and
|
// If the application is not launching and
|
||||||
// all windows are closed except for the file open panel,
|
// all windows are closed except for the file open panel,
|
||||||
// quit the application
|
// quit the application
|
||||||
PostMessage(B_QUIT_REQUESTED);
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageApp::ArgvReceived(int32 argc, char **argv)
|
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++) {
|
for (int32 i = 1; i < argc; i++) {
|
||||||
|
BPath path(cwd);
|
||||||
|
path.Append(argv[i]);
|
||||||
|
|
||||||
entry_ref ref;
|
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 (err == B_OK) {
|
||||||
if (!pmsg) {
|
message.AddRef("refs", &ref);
|
||||||
pmsg = new BMessage;
|
hasRefs = true;
|
||||||
pmsg->what = B_REFS_RECEIVED;
|
|
||||||
}
|
|
||||||
pmsg->AddRef("refs", &ref);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pmsg) {
|
|
||||||
RefsReceived(pmsg);
|
if (hasRefs)
|
||||||
delete pmsg;
|
RefsReceived(&message);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageApp::MessageReceived(BMessage *pmsg)
|
ShowImageApp::MessageReceived(BMessage *message)
|
||||||
{
|
{
|
||||||
switch (pmsg->what) {
|
switch (message->what) {
|
||||||
case MSG_FILE_OPEN:
|
case MSG_FILE_OPEN:
|
||||||
fOpenPanel->Show();
|
fOpenPanel->Show();
|
||||||
break;
|
break;
|
||||||
@@ -142,51 +143,52 @@ ShowImageApp::MessageReceived(BMessage *pmsg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BApplication::MessageReceived(pmsg);
|
BApplication::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageApp::RefsReceived(BMessage *pmsg)
|
ShowImageApp::RefsReceived(BMessage *message)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
// If a tracker window opened me, get a messenger from it.
|
// If a tracker window opened me, get a messenger from it.
|
||||||
//
|
if (message->HasMessenger("TrackerViewToken"))
|
||||||
if (pmsg->HasMessenger("TrackerViewToken")) {
|
message->FindMessenger("TrackerViewToken", &fTrackerMessenger);
|
||||||
pmsg->FindMessenger("TrackerViewToken", &fTrackerMessenger);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32 type;
|
uint32 type;
|
||||||
int32 count;
|
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)
|
if (ret != B_OK || type != B_REF_TYPE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
for (int32 i = 0; i < count; i++) {
|
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);
|
Open(&ref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ShowImageApp::Open(const entry_ref *pref)
|
|
||||||
{
|
|
||||||
new ShowImageWindow(pref, fTrackerMessenger);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageApp::BroadcastToWindows(BMessage *pmsg)
|
ShowImageApp::Open(const entry_ref *ref)
|
||||||
{
|
{
|
||||||
const int32 n = CountWindows();
|
new ShowImageWindow(ref, fTrackerMessenger);
|
||||||
for (int32 i = 0; i < n ; i ++) {
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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 checks for us if BWindow is still a valid object
|
||||||
BMessenger msgr(WindowAt(i));
|
BMessenger msgr(WindowAt(i));
|
||||||
msgr.SendMessage(pmsg);
|
msgr.SendMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageApp::CheckClipboard()
|
ShowImageApp::CheckClipboard()
|
||||||
{
|
{
|
||||||
@@ -195,15 +197,15 @@ ShowImageApp::CheckClipboard()
|
|||||||
// After checking the clipboard, a message is sent to
|
// After checking the clipboard, a message is sent to
|
||||||
// all windows indicating that the clipboard has changed
|
// all windows indicating that the clipboard has changed
|
||||||
// and whether or not the clipboard contains useful data.
|
// and whether or not the clipboard contains useful data.
|
||||||
bool bdata = false;
|
bool dataAvailable = false;
|
||||||
|
|
||||||
if (be_clipboard->Lock()) {
|
if (be_clipboard->Lock()) {
|
||||||
BMessage *pclip;
|
BMessage *clip = be_clipboard->Data();
|
||||||
if ((pclip = be_clipboard->Data()) != NULL) {
|
if (clip != NULL) {
|
||||||
BString strClass;
|
BString className;
|
||||||
if (pclip->FindString("class", &strClass) == B_OK) {
|
if (clip->FindString("class", &className) == B_OK) {
|
||||||
if (strClass == "BBitmap")
|
if (className == "BBitmap")
|
||||||
bdata = true;
|
dataAvailable = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,16 +213,29 @@ ShowImageApp::CheckClipboard()
|
|||||||
}
|
}
|
||||||
|
|
||||||
BMessage msg(MSG_CLIPBOARD_CHANGED);
|
BMessage msg(MSG_CLIPBOARD_CHANGED);
|
||||||
msg.AddBool("data_available", bdata);
|
msg.AddBool("data_available", dataAvailable);
|
||||||
BroadcastToWindows(&msg);
|
BroadcastToWindows(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ShowImageApp::Quit()
|
bool
|
||||||
|
ShowImageApp::QuitRequested()
|
||||||
{
|
{
|
||||||
be_clipboard->StopWatching(be_app_messenger);
|
be_clipboard->StopWatching(be_app_messenger);
|
||||||
// tell clipboard we don't want anymore notification
|
// 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,57 +1,41 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// ShowImageApp
|
* 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.
|
||||||
//
|
*
|
||||||
// ShowImageApp.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_APP_H
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
#define SHOW_IMAGE_APP_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 _ShowImageApp_h
|
|
||||||
#define _ShowImageApp_h
|
|
||||||
|
|
||||||
#include <Application.h>
|
|
||||||
|
|
||||||
#include "ShowImageSettings.h"
|
#include "ShowImageSettings.h"
|
||||||
|
|
||||||
class ShowImageApp : public BApplication {
|
#include <Application.h>
|
||||||
public:
|
|
||||||
ShowImageApp();
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
class ShowImageApp : public BApplication {
|
||||||
|
public:
|
||||||
|
ShowImageApp();
|
||||||
|
virtual ~ShowImageApp();
|
||||||
|
|
||||||
|
public:
|
||||||
virtual void AboutRequested();
|
virtual void AboutRequested();
|
||||||
virtual void ArgvReceived(int32 argc, char **argv);
|
virtual void ArgvReceived(int32 argc, char **argv);
|
||||||
virtual void MessageReceived(BMessage *pmsg);
|
virtual void MessageReceived(BMessage *message);
|
||||||
virtual void ReadyToRun();
|
virtual void ReadyToRun();
|
||||||
virtual void Pulse();
|
virtual void Pulse();
|
||||||
virtual void RefsReceived(BMessage *pmsg);
|
virtual void RefsReceived(BMessage *message);
|
||||||
virtual void Quit();
|
virtual bool QuitRequested();
|
||||||
|
|
||||||
ShowImageSettings* Settings() { return &fSettings; }
|
ShowImageSettings* Settings() { return &fSettings; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void StartPulse();
|
void StartPulse();
|
||||||
void Open(const entry_ref *pref);
|
void Open(const entry_ref *ref);
|
||||||
void BroadcastToWindows(BMessage *pmsg);
|
void BroadcastToWindows(BMessage *message);
|
||||||
void CheckClipboard();
|
void CheckClipboard();
|
||||||
|
|
||||||
BMessenger fTrackerMessenger; // of the window this was launched
|
BMessenger fTrackerMessenger; // of the window this was launched
|
||||||
@@ -60,6 +44,9 @@ private:
|
|||||||
ShowImageSettings fSettings;
|
ShowImageSettings fSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern const char *kApplicationSignature;
|
||||||
|
|
||||||
#define my_app dynamic_cast<ShowImageApp*>(be_app)
|
#define my_app dynamic_cast<ShowImageApp*>(be_app)
|
||||||
|
|
||||||
#endif /* _ShowImageApp_h */
|
#endif // SHOW_IMAGE_APP_H
|
||||||
|
|
||||||
|
|||||||
@@ -28,4 +28,3 @@
|
|||||||
|
|
||||||
#include "ShowImageConstants.h"
|
#include "ShowImageConstants.h"
|
||||||
|
|
||||||
extern const char *APP_SIG = "application/x-vnd.obos.showimage";
|
|
||||||
|
|||||||
@@ -1,40 +1,22 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// ShowImageConstants
|
* 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.
|
||||||
//
|
*
|
||||||
// ShowImageConstants.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_CONSTANTS_H
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
#define SHOW_IMAGE_CONSTANTS_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 _ShowImageConstants_
|
|
||||||
#define _ShowImageConstants_
|
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
|
||||||
const uint32 MSG_CAPTURE_MOUSE = 'mCPM';
|
const uint32 MSG_CAPTURE_MOUSE = 'mCPM';
|
||||||
const uint32 MSG_CHANGE_FOCUS = 'mCFS';
|
const uint32 MSG_CHANGE_FOCUS = 'mCFS';
|
||||||
const uint32 MSG_FILE_OPEN = 'mFOP';
|
const uint32 MSG_FILE_OPEN = 'mFOP';
|
||||||
const uint32 MSG_CLOSE = 'mCLS';
|
|
||||||
const uint32 MSG_WINDOW_QUIT = 'mWQT';
|
const uint32 MSG_WINDOW_QUIT = 'mWQT';
|
||||||
const uint32 MSG_OUTPUT_TYPE = 'BTMN';
|
const uint32 MSG_OUTPUT_TYPE = 'BTMN';
|
||||||
const uint32 MSG_SAVE_PANEL = 'mFSP';
|
const uint32 MSG_SAVE_PANEL = 'mFSP';
|
||||||
@@ -75,7 +57,4 @@ 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';
|
||||||
|
|
||||||
extern const char *APP_SIG;
|
#endif // SHOW_IMAGE_CONSTANTS_H
|
||||||
|
|
||||||
|
|
||||||
#endif /* _ShowImageConstants_ */
|
|
||||||
|
|||||||
@@ -1,58 +1,12 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// 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.cpp
|
* 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
|
|
||||||
// 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>
|
|
||||||
|
|
||||||
|
|
||||||
#include "ShowImageApp.h"
|
#include "ShowImageApp.h"
|
||||||
@@ -60,6 +14,34 @@
|
|||||||
#include "ShowImageView.h"
|
#include "ShowImageView.h"
|
||||||
#include "ShowImageWindow.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;
|
using std::nothrow;
|
||||||
|
|
||||||
#ifndef min
|
#ifndef min
|
||||||
@@ -306,12 +288,14 @@ ShowImageView::Notify(const char* status)
|
|||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageView::AddToRecentDocuments()
|
ShowImageView::AddToRecentDocuments()
|
||||||
{
|
{
|
||||||
be_roster->AddToRecentDocuments(&fCurrentRef, APP_SIG);
|
be_roster->AddToRecentDocuments(&fCurrentRef, kApplicationSignature);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageView::DeleteScaler()
|
ShowImageView::DeleteScaler()
|
||||||
{
|
{
|
||||||
@@ -325,6 +309,7 @@ ShowImageView::DeleteScaler()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageView::DeleteBitmap()
|
ShowImageView::DeleteBitmap()
|
||||||
{
|
{
|
||||||
@@ -339,15 +324,18 @@ ShowImageView::DeleteBitmap()
|
|||||||
fBitmap = NULL;
|
fBitmap = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ShowImageView::DeleteSelBitmap()
|
void ShowImageView::DeleteSelBitmap()
|
||||||
{
|
{
|
||||||
delete fSelBitmap;
|
delete fSelBitmap;
|
||||||
fSelBitmap = NULL;
|
fSelBitmap = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const rgb_color kAlphaLow = (rgb_color){ 0xbb, 0xbb, 0xbb, 0xff };
|
const rgb_color kAlphaLow = (rgb_color){ 0xbb, 0xbb, 0xbb, 0xff };
|
||||||
const rgb_color kAlphaHigh = (rgb_color){ 0xe0, 0xe0, 0xe0, 0xff };
|
const rgb_color kAlphaHigh = (rgb_color){ 0xe0, 0xe0, 0xe0, 0xff };
|
||||||
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
blend_colors(uint8* d, uint8 r, uint8 g, uint8 b, uint8 a)
|
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;
|
d[2] = ((r - d[2]) * a + (d[2] << 8)) >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BBitmap*
|
BBitmap*
|
||||||
compose_checker_background(const BBitmap* bitmap)
|
compose_checker_background(const BBitmap* bitmap)
|
||||||
{
|
{
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,42 +1,24 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// ShowImageWindow
|
* 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.
|
||||||
//
|
*
|
||||||
// ShowImageWindow.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_WINDOW_H
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
#define SHOW_IMAGE_WINDOW_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 _ShowImageWindow_h
|
|
||||||
#define _ShowImageWindow_h
|
|
||||||
|
|
||||||
#include <Menu.h>
|
|
||||||
#include <Window.h>
|
|
||||||
#include <FilePanel.h>
|
|
||||||
#include <TranslationDefs.h>
|
|
||||||
#include <String.h>
|
|
||||||
|
|
||||||
#include "PrintOptionsWindow.h"
|
#include "PrintOptionsWindow.h"
|
||||||
|
|
||||||
|
#include <FilePanel.h>
|
||||||
|
#include <Menu.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <TranslationDefs.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
class ShowImageView;
|
class ShowImageView;
|
||||||
class ShowImageStatusView;
|
class ShowImageStatusView;
|
||||||
|
|
||||||
@@ -44,25 +26,23 @@ class ShowImageStatusView;
|
|||||||
#define TRANSLATOR_FLD "be:translator"
|
#define TRANSLATOR_FLD "be:translator"
|
||||||
#define TYPE_FLD "be:type"
|
#define TYPE_FLD "be:type"
|
||||||
|
|
||||||
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 s);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateRecentDocumentsMenu();
|
void UpdateRecentDocumentsMenu();
|
||||||
};
|
};
|
||||||
|
|
||||||
class ShowImageWindow : public BWindow {
|
class ShowImageWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
ShowImageWindow(const entry_ref *pref, const BMessenger& trackerMessenger);
|
ShowImageWindow(const entry_ref *pref, 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 *pmsg);
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
virtual void Quit();
|
|
||||||
virtual void Zoom(BPoint origin, float width, float height);
|
virtual void Zoom(BPoint origin, float width, float height);
|
||||||
|
|
||||||
status_t InitCheck();
|
status_t InitCheck();
|
||||||
@@ -70,14 +50,13 @@ public:
|
|||||||
|
|
||||||
void UpdateTitle();
|
void UpdateTitle();
|
||||||
void BuildViewMenu(BMenu *menu);
|
void BuildViewMenu(BMenu *menu);
|
||||||
void LoadMenus(BMenuBar *pbar);
|
void AddMenus(BMenuBar *pbar);
|
||||||
void WindowRedimension(BBitmap *pbitmap);
|
void WindowRedimension(BBitmap *pbitmap);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BMenuItem *AddItemMenu(BMenu *pmenu, char *caption,
|
BMenuItem *AddItemMenu(BMenu *pmenu, char *caption,
|
||||||
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);
|
BMenuItem* AddDelayItem(BMenu *pmenu, char *caption, float value);
|
||||||
|
|
||||||
bool ToggleMenuItem(uint32 what);
|
bool ToggleMenuItem(uint32 what);
|
||||||
@@ -91,8 +70,6 @@ private:
|
|||||||
void SaveToFile(BMessage *pmsg);
|
void SaveToFile(BMessage *pmsg);
|
||||||
// Handle save file panel message
|
// Handle save file panel message
|
||||||
bool ClosePrompt();
|
bool ClosePrompt();
|
||||||
bool CanQuit();
|
|
||||||
// returns true if the window can be closed safely, false if not
|
|
||||||
void ToggleFullScreen();
|
void ToggleFullScreen();
|
||||||
void LoadSettings();
|
void LoadSettings();
|
||||||
void SavePrintOptions();
|
void SavePrintOptions();
|
||||||
@@ -116,4 +93,4 @@ private:
|
|||||||
PrintOptions fPrintOptions;
|
PrintOptions fPrintOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _ShowImageWindow_h */
|
#endif // SHOW_IMAGE_WINDOW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user