- Cleanup to match coding guidelines. The header cleanup might have been
overkill. - Updating some copyright years. - ResizerWindow.h was not self-contained. Some of the other files were skipped due to complexity and planned code changes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32296 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,48 +1,33 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// EntryMenuItem
|
* Copyright 2003-2009 Haiku Inc. All rights reserved.
|
||||||
// Written by Michael Pfeiffer
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*
|
||||||
// EntryMenuItem.cpp
|
* Authors:
|
||||||
//
|
* Michael Pfeiffer, [email protected]
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003 OpenBeOS Project
|
|
||||||
//
|
#include "EntryMenuItem.h"
|
||||||
// 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 <Node.h>
|
#include <Node.h>
|
||||||
#include <NodeInfo.h>
|
#include <NodeInfo.h>
|
||||||
|
|
||||||
#include "EntryMenuItem.h"
|
|
||||||
|
|
||||||
EntryMenuItem::EntryMenuItem(entry_ref* ref, const char* label, BMessage* message, char shortcut, uint32 modifiers)
|
EntryMenuItem::EntryMenuItem(entry_ref* ref, const char* label,
|
||||||
: BMenuItem(label, message, shortcut, modifiers)
|
BMessage* message, char shortcut, uint32 modifiers)
|
||||||
, fEntry(*ref)
|
:
|
||||||
, fSmallIcon(NULL)
|
BMenuItem(label, message, shortcut, modifiers),
|
||||||
|
fEntry(*ref),
|
||||||
|
fSmallIcon(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EntryMenuItem::~EntryMenuItem()
|
EntryMenuItem::~EntryMenuItem()
|
||||||
{
|
{
|
||||||
delete fSmallIcon;
|
delete fSmallIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
EntryMenuItem::GetContentSize(float* width, float* height)
|
EntryMenuItem::GetContentSize(float* width, float* height)
|
||||||
{
|
{
|
||||||
@@ -53,6 +38,7 @@ EntryMenuItem::GetContentSize(float* width, float* height)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
EntryMenuItem::DrawContent()
|
EntryMenuItem::DrawContent()
|
||||||
{
|
{
|
||||||
@@ -60,7 +46,7 @@ EntryMenuItem::DrawContent()
|
|||||||
BPoint pos(view->PenLocation());
|
BPoint pos(view->PenLocation());
|
||||||
|
|
||||||
if (fSmallIcon == NULL) {
|
if (fSmallIcon == NULL) {
|
||||||
fSmallIcon = LoadIcon(); // load on demand
|
fSmallIcon = LoadIcon(); // Load on demand
|
||||||
}
|
}
|
||||||
|
|
||||||
view->MovePenBy(kTextIndent, 0);
|
view->MovePenBy(kTextIndent, 0);
|
||||||
@@ -72,17 +58,20 @@ EntryMenuItem::DrawContent()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BBitmap*
|
BBitmap*
|
||||||
EntryMenuItem::GetIcon(BMimeType* mimeType)
|
EntryMenuItem::GetIcon(BMimeType* mimeType)
|
||||||
{
|
{
|
||||||
BBitmap* icon;
|
BBitmap* icon;
|
||||||
icon = new BBitmap(BRect(0, 0, kIconSize-1, kIconSize-1), B_CMAP8);
|
icon = new BBitmap(BRect(0, 0, kIconSize - 1, kIconSize - 1), B_CMAP8);
|
||||||
if (mimeType->GetIcon(icon, B_MINI_ICON) != B_OK) {
|
if (mimeType->GetIcon(icon, B_MINI_ICON) != B_OK) {
|
||||||
delete icon; icon = NULL;
|
delete icon;
|
||||||
|
icon = NULL;
|
||||||
}
|
}
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BBitmap*
|
BBitmap*
|
||||||
EntryMenuItem::LoadIcon()
|
EntryMenuItem::LoadIcon()
|
||||||
{
|
{
|
||||||
@@ -93,20 +82,21 @@ EntryMenuItem::LoadIcon()
|
|||||||
|
|
||||||
// Note: BNodeInfo::GetTrackerIcon does not work as expected!
|
// Note: BNodeInfo::GetTrackerIcon does not work as expected!
|
||||||
|
|
||||||
// try to get the icon stored in file attribute
|
// Try to get the icon stored in file attribute
|
||||||
icon = new BBitmap(BRect(0, 0, kIconSize-1, kIconSize-1), B_CMAP8);
|
icon = new BBitmap(BRect(0, 0, kIconSize-1, kIconSize-1), B_CMAP8);
|
||||||
if (info.GetIcon(icon, B_MINI_ICON) == B_OK) {
|
if (info.GetIcon(icon, B_MINI_ICON) == B_OK) {
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
delete icon; icon = NULL;
|
delete icon;
|
||||||
|
icon = NULL;
|
||||||
|
|
||||||
// get the icon from type
|
// Get the icon from type
|
||||||
if (info.GetType(type) == B_OK) {
|
if (info.GetType(type) == B_OK) {
|
||||||
BMimeType mimeType(type);
|
BMimeType mimeType(type);
|
||||||
BMimeType superType;
|
BMimeType superType;
|
||||||
if (mimeType.InitCheck() == B_OK) {
|
if (mimeType.InitCheck() == B_OK) {
|
||||||
icon = GetIcon(&mimeType);
|
icon = GetIcon(&mimeType);
|
||||||
// or super type
|
// Or super type
|
||||||
if (icon == NULL && mimeType.GetSupertype(&superType) == B_OK) {
|
if (icon == NULL && mimeType.GetSupertype(&superType) == B_OK) {
|
||||||
icon = GetIcon(&superType);
|
icon = GetIcon(&superType);
|
||||||
}
|
}
|
||||||
@@ -115,3 +105,4 @@ EntryMenuItem::LoadIcon()
|
|||||||
|
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,59 +1,42 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// EntryMenuItem
|
* Copyright 2003-2009 Haiku Inc. All rights reserved.
|
||||||
// Written by Michael Pfeiffer
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*
|
||||||
// EntryMenuItem.h
|
* Authors:
|
||||||
//
|
* Michael Pfeiffer, [email protected]
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003 OpenBeOS Project
|
#ifndef ENTRY_MENU_ITEM_H
|
||||||
//
|
#define ENTRY_MENU_ITEM_H
|
||||||
// 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 _EntryMenuItem_h
|
|
||||||
#define _EntryMenuItem_h
|
|
||||||
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <Mime.h>
|
#include <Mime.h>
|
||||||
|
|
||||||
class EntryMenuItem : public BMenuItem
|
|
||||||
{
|
class EntryMenuItem : public BMenuItem {
|
||||||
public:
|
public:
|
||||||
EntryMenuItem(entry_ref* entry, const char* label, BMessage* message, char shortcut = 0, uint32 modifiers = 0);
|
EntryMenuItem(entry_ref* entry, const char* label,
|
||||||
~EntryMenuItem();
|
BMessage* message, char shortcut = 0, uint32 modifiers = 0);
|
||||||
|
~EntryMenuItem();
|
||||||
|
|
||||||
void GetContentSize(float* width, float* height);
|
void GetContentSize(float* width, float* height);
|
||||||
void DrawContent();
|
void DrawContent();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
BBitmap* GetIcon(BMimeType* mimeType);
|
||||||
|
BBitmap* LoadIcon();
|
||||||
|
|
||||||
|
entry_ref fEntry;
|
||||||
|
BBitmap* fSmallIcon;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
kIconSize = 16,
|
kIconSize = 16,
|
||||||
kTextIndent = kIconSize + 4,
|
kTextIndent = kIconSize + 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
BBitmap* GetIcon(BMimeType* mimeType);
|
|
||||||
BBitmap* LoadIcon();
|
|
||||||
|
|
||||||
entry_ref fEntry;
|
|
||||||
BBitmap* fSmallIcon;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
#endif // ENTRY_MENU_ITEM_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,55 +1,41 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// PrintOptionsWindow
|
* Copyright 2003-2009 Haiku Inc. All rights reserved.
|
||||||
// Written by Michael Pfeiffer
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*
|
||||||
// PrintOptionsWindow.cpp
|
* Authors:
|
||||||
//
|
* Michael Pfeiffer, [email protected]
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003 OpenBeOS Project
|
|
||||||
//
|
#include "PrintOptionsWindow.h"
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
#include <stdio.h> // for sprintf
|
||||||
// to deal in the Software without restriction, including without limitation
|
#include <stdlib.h> // for atof
|
||||||
// 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 <Box.h>
|
#include <Box.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <stdio.h> // for sprintf
|
|
||||||
#include <stdlib.h> // for atof
|
|
||||||
|
|
||||||
#include "PrintOptionsWindow.h"
|
|
||||||
#include "ShowImageConstants.h"
|
#include "ShowImageConstants.h"
|
||||||
|
|
||||||
|
|
||||||
PrintOptions::PrintOptions()
|
PrintOptions::PrintOptions()
|
||||||
: fOption(kFitToPage)
|
:
|
||||||
, fZoomFactor(1.0)
|
fOption(kFitToPage),
|
||||||
, fDPI(72.0)
|
fZoomFactor(1.0),
|
||||||
, fWidth(1024 / 72.0)
|
fDPI(72.0),
|
||||||
, fHeight(768 / 72.0)
|
fWidth(1024/72.0),
|
||||||
|
fHeight(768/72.0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrintOptions::SetBounds(BRect rect)
|
PrintOptions::SetBounds(BRect rect)
|
||||||
{
|
{
|
||||||
fBounds = rect;
|
fBounds = rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrintOptions::SetZoomFactor(float f)
|
PrintOptions::SetZoomFactor(float f)
|
||||||
{
|
{
|
||||||
@@ -57,6 +43,7 @@ PrintOptions::SetZoomFactor(float f)
|
|||||||
fDPI = 72.0 / fZoomFactor;
|
fDPI = 72.0 / fZoomFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrintOptions::SetDPI(float dpi)
|
PrintOptions::SetDPI(float dpi)
|
||||||
{
|
{
|
||||||
@@ -64,13 +51,15 @@ PrintOptions::SetDPI(float dpi)
|
|||||||
fZoomFactor = 72.0 / dpi;
|
fZoomFactor = 72.0 / dpi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrintOptions::SetWidth(float w)
|
PrintOptions::SetWidth(float w)
|
||||||
{
|
{
|
||||||
fWidth = w;
|
fWidth = w;
|
||||||
fHeight = (fBounds.Height()+1) * w / (fBounds.Width()+1);
|
fHeight = (fBounds.Height() + 1) * w / (fBounds.Width() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrintOptions::SetHeight(float h)
|
PrintOptions::SetHeight(float h)
|
||||||
{
|
{
|
||||||
@@ -78,20 +67,24 @@ PrintOptions::SetHeight(float h)
|
|||||||
fHeight = h;
|
fHeight = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintOptionsWindow::PrintOptionsWindow(BPoint at, PrintOptions *options, BWindow* listener)
|
|
||||||
: BWindow(BRect(at.x, at.y, at.x+300, at.y+200), "Print Options",
|
PrintOptionsWindow::PrintOptionsWindow(BPoint at, PrintOptions *options,
|
||||||
B_TITLED_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL,
|
BWindow* listener)
|
||||||
B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
|
:
|
||||||
, fPrintOptions(options)
|
BWindow(BRect(at.x, at.y, at.x + 300, at.y + 200), "Print Options",
|
||||||
, fCurrentOptions(*options)
|
B_TITLED_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL,
|
||||||
, fListener(listener)
|
B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
|
||||||
, fStatus(B_ERROR)
|
fPrintOptions(options),
|
||||||
|
fCurrentOptions(*options),
|
||||||
|
fListener(listener),
|
||||||
|
fStatus(B_ERROR)
|
||||||
{
|
{
|
||||||
AddToSubset(listener);
|
AddToSubset(listener);
|
||||||
Setup();
|
Setup();
|
||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PrintOptionsWindow::~PrintOptionsWindow()
|
PrintOptionsWindow::~PrintOptionsWindow()
|
||||||
{
|
{
|
||||||
BMessage msg(MSG_PRINT);
|
BMessage msg(MSG_PRINT);
|
||||||
@@ -99,8 +92,10 @@ PrintOptionsWindow::~PrintOptionsWindow()
|
|||||||
fListener.SendMessage(&msg);
|
fListener.SendMessage(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BRadioButton*
|
BRadioButton*
|
||||||
PrintOptionsWindow::AddRadioButton(BView* view, BPoint& at, const char* name, const char* label, uint32 what, bool selected)
|
PrintOptionsWindow::AddRadioButton(BView* view, BPoint& at, const char* name,
|
||||||
|
const char* label, uint32 what, bool selected)
|
||||||
{
|
{
|
||||||
BRect rect(0, 0, 100, 20);
|
BRect rect(0, 0, 100, 20);
|
||||||
BRadioButton* button;
|
BRadioButton* button;
|
||||||
@@ -113,8 +108,10 @@ PrintOptionsWindow::AddRadioButton(BView* view, BPoint& at, const char* name, co
|
|||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BTextControl*
|
BTextControl*
|
||||||
PrintOptionsWindow::AddTextControl(BView* view, BPoint& at, const char* name, const char* label, float value, float divider, uint32 what)
|
PrintOptionsWindow::AddTextControl(BView* view, BPoint& at, const char* name,
|
||||||
|
const char* label, float value, float divider, uint32 what)
|
||||||
{
|
{
|
||||||
BRect rect(0, 0, divider + 45, 20);
|
BRect rect(0, 0, divider + 45, 20);
|
||||||
BTextControl* text;
|
BTextControl* text;
|
||||||
@@ -129,6 +126,7 @@ PrintOptionsWindow::AddTextControl(BView* view, BPoint& at, const char* name, co
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrintOptionsWindow::Setup()
|
PrintOptionsWindow::Setup()
|
||||||
{
|
{
|
||||||
@@ -145,24 +143,33 @@ PrintOptionsWindow::Setup()
|
|||||||
B_PLAIN_BORDER);
|
B_PLAIN_BORDER);
|
||||||
AddChild(panel);
|
AddChild(panel);
|
||||||
|
|
||||||
AddRadioButton(panel, at, "fit_to_page", "Fit Image to Page", kMsgFitToPageSelected, op == PrintOptions::kFitToPage);
|
AddRadioButton(panel, at, "fit_to_page", "Fit Image to Page",
|
||||||
|
kMsgFitToPageSelected, op == PrintOptions::kFitToPage);
|
||||||
textAt = at;
|
textAt = at;
|
||||||
rb = AddRadioButton(panel, at, "zoom_factor", "Zoom Factor in %: ", kMsgZoomFactorSelected, op == PrintOptions::kZoomFactor);
|
rb = AddRadioButton(panel, at, "zoom_factor", "Zoom Factor in %: ",
|
||||||
|
kMsgZoomFactorSelected, op == PrintOptions::kZoomFactor);
|
||||||
textAt.x = rb->Bounds().right + 5;
|
textAt.x = rb->Bounds().right + 5;
|
||||||
fZoomFactor = AddTextControl(panel, textAt, "zoom_factor_text", "", fCurrentOptions.ZoomFactor()*100, 0, kMsgZoomFactorChanged);
|
fZoomFactor = AddTextControl(panel, textAt, "zoom_factor_text", "",
|
||||||
|
fCurrentOptions.ZoomFactor()*100, 0, kMsgZoomFactorChanged);
|
||||||
|
|
||||||
textAt = at;
|
textAt = at;
|
||||||
rb = AddRadioButton(panel, at, "dpi", "DPI: ", kMsgDPISelected, op == PrintOptions::kDPI);
|
rb = AddRadioButton(panel, at, "dpi", "DPI: ", kMsgDPISelected,
|
||||||
|
op == PrintOptions::kDPI);
|
||||||
textAt.x = rb->Bounds().right + 5;
|
textAt.x = rb->Bounds().right + 5;
|
||||||
fDPI = AddTextControl(panel, textAt, "dpi_text", "", fCurrentOptions.DPI(), 0, kMsgDPIChanged);
|
fDPI = AddTextControl(panel, textAt, "dpi_text", "", fCurrentOptions.DPI(),
|
||||||
|
0, kMsgDPIChanged);
|
||||||
|
|
||||||
rb = AddRadioButton(panel, at, "width_and_height", "Resize To (in 1/72 Inches):", kMsgWidthAndHeightSelected, op == PrintOptions::kWidth || op == PrintOptions::kHeight);
|
rb = AddRadioButton(panel, at, "width_and_height",
|
||||||
|
"Resize To (in 1/72 Inches):", kMsgWidthAndHeightSelected,
|
||||||
|
op == PrintOptions::kWidth || op == PrintOptions::kHeight);
|
||||||
at.x += 15;
|
at.x += 15;
|
||||||
textAt = at;
|
textAt = at;
|
||||||
fWidth = AddTextControl(panel, textAt, "width", "Width: ", fCurrentOptions.Width(), 40, kMsgWidthChanged);
|
fWidth = AddTextControl(panel, textAt, "width", "Width: ",
|
||||||
|
fCurrentOptions.Width(), 40, kMsgWidthChanged);
|
||||||
textAt = at;
|
textAt = at;
|
||||||
textAt.x += fWidth->Bounds().Width() + 5;
|
textAt.x += fWidth->Bounds().Width() + 5;
|
||||||
fHeight = AddTextControl(panel, textAt, "height", "Height: ", fCurrentOptions.Height(), 40, kMsgHeightChanged);
|
fHeight = AddTextControl(panel, textAt, "height", "Height: ",
|
||||||
|
fCurrentOptions.Height(), 40, kMsgHeightChanged);
|
||||||
|
|
||||||
at.x = 0;
|
at.x = 0;
|
||||||
at.y = textAt.y;
|
at.y = textAt.y;
|
||||||
@@ -172,7 +179,8 @@ PrintOptionsWindow::Setup()
|
|||||||
|
|
||||||
at.y += 10;
|
at.y += 10;
|
||||||
rect.OffsetBy(at);
|
rect.OffsetBy(at);
|
||||||
button = new BButton(rect, "job setup", "Job Setup", new BMessage(kMsgJobSetup));
|
button = new BButton(rect, "job setup", "Job Setup",
|
||||||
|
new BMessage(kMsgJobSetup));
|
||||||
panel->AddChild(button);
|
panel->AddChild(button);
|
||||||
button->ResizeToPreferred();
|
button->ResizeToPreferred();
|
||||||
|
|
||||||
@@ -182,11 +190,14 @@ PrintOptionsWindow::Setup()
|
|||||||
ResizeTo(fHeight->Frame().right + kIndent, button->Frame().bottom + kIndent);
|
ResizeTo(fHeight->Frame().right + kIndent, button->Frame().bottom + kIndent);
|
||||||
|
|
||||||
// center button
|
// center button
|
||||||
button->MoveTo((Bounds().Width()-button->Bounds().Width())/2, button->Frame().top);
|
button->MoveTo((Bounds().Width()-button->Bounds().Width())/2,
|
||||||
|
button->Frame().top);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
enum PrintOptions::Option
|
enum PrintOptions::Option
|
||||||
PrintOptionsWindow::MsgToOption(uint32 what) {
|
PrintOptionsWindow::MsgToOption(uint32 what)
|
||||||
|
{
|
||||||
switch (what) {
|
switch (what) {
|
||||||
case kMsgFitToPageSelected: return PrintOptions::kFitToPage;
|
case kMsgFitToPageSelected: return PrintOptions::kFitToPage;
|
||||||
case kMsgZoomFactorSelected: return PrintOptions::kZoomFactor;
|
case kMsgZoomFactorSelected: return PrintOptions::kZoomFactor;
|
||||||
@@ -196,6 +207,7 @@ PrintOptionsWindow::MsgToOption(uint32 what) {
|
|||||||
return PrintOptions::kFitToPage;
|
return PrintOptions::kFitToPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PrintOptionsWindow::GetValue(BTextControl* text, float* value)
|
PrintOptionsWindow::GetValue(BTextControl* text, float* value)
|
||||||
{
|
{
|
||||||
@@ -203,6 +215,7 @@ PrintOptionsWindow::GetValue(BTextControl* text, float* value)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrintOptionsWindow::SetValue(BTextControl* text, float value)
|
PrintOptionsWindow::SetValue(BTextControl* text, float value)
|
||||||
{
|
{
|
||||||
@@ -216,6 +229,7 @@ PrintOptionsWindow::SetValue(BTextControl* text, float value)
|
|||||||
text->SetModificationMessage(msg);
|
text->SetModificationMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrintOptionsWindow::MessageReceived(BMessage* msg)
|
PrintOptionsWindow::MessageReceived(BMessage* msg)
|
||||||
{
|
{
|
||||||
@@ -229,7 +243,8 @@ PrintOptionsWindow::MessageReceived(BMessage* msg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kMsgZoomFactorChanged:
|
case kMsgZoomFactorChanged:
|
||||||
if (GetValue(fZoomFactor, &value) && fCurrentOptions.ZoomFactor() != value) {
|
if (GetValue(fZoomFactor, &value)
|
||||||
|
&& fCurrentOptions.ZoomFactor() != value) {
|
||||||
fCurrentOptions.SetZoomFactor(value/100);
|
fCurrentOptions.SetZoomFactor(value/100);
|
||||||
SetValue(fDPI, fCurrentOptions.DPI());
|
SetValue(fDPI, fCurrentOptions.DPI());
|
||||||
}
|
}
|
||||||
@@ -263,3 +278,4 @@ PrintOptionsWindow::MessageReceived(BMessage* msg)
|
|||||||
BWindow::MessageReceived(msg);
|
BWindow::MessageReceived(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,42 +1,29 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// PrintOptionsWindow
|
* Copyright 2003-2009 Haiku Inc. All rights reserved.
|
||||||
// Written by Michael Pfeiffer
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*
|
||||||
// PrintOptionsWindow.h
|
* Authors:
|
||||||
//
|
* Michael Pfeiffer, [email protected]
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003 OpenBeOS Project
|
#ifndef PRINT_OPTIONS_WINDOW_H
|
||||||
//
|
#define PRINT_OPTIONS_WINDOW_H
|
||||||
// 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 _PrintOptionsWindow_h
|
|
||||||
#define _PrintOptionsWindow_h
|
|
||||||
|
|
||||||
#include <Window.h>
|
|
||||||
#include <RadioButton.h>
|
|
||||||
#include <TextControl.h>
|
|
||||||
#include <Messenger.h>
|
#include <Messenger.h>
|
||||||
|
#include <RadioButton.h>
|
||||||
#include <Rect.h>
|
#include <Rect.h>
|
||||||
|
#include <TextControl.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
class PrintOptions {
|
class PrintOptions {
|
||||||
public:
|
public:
|
||||||
|
PrintOptions();
|
||||||
|
|
||||||
|
// bounds of the image
|
||||||
|
BRect Bounds() const { return fBounds; }
|
||||||
|
void SetBounds(BRect bounds);
|
||||||
|
|
||||||
enum Option {
|
enum Option {
|
||||||
kFitToPage,
|
kFitToPage,
|
||||||
kZoomFactor,
|
kZoomFactor,
|
||||||
@@ -45,50 +32,60 @@ public:
|
|||||||
kHeight,
|
kHeight,
|
||||||
kNumberOfOptions
|
kNumberOfOptions
|
||||||
};
|
};
|
||||||
|
enum Option Option() const { return fOption; }
|
||||||
PrintOptions();
|
void SetOption(enum Option op) { fOption = op; }
|
||||||
|
|
||||||
// bounds of the image
|
// ZoomFactor = 72.0 / dpi
|
||||||
BRect Bounds() const { return fBounds; }
|
float ZoomFactor() const { return fZoomFactor; }
|
||||||
void SetBounds(BRect bounds);
|
void SetZoomFactor(float z);
|
||||||
|
float DPI() const { return fDPI; }
|
||||||
enum Option Option() const { return fOption; }
|
void SetDPI(float dpi);
|
||||||
void SetOption(enum Option op) { fOption = op; }
|
|
||||||
// zoomFactor = 72.0 / dpi
|
// Setting width/height updates height/width to keep aspect ratio
|
||||||
float ZoomFactor() const { return fZoomFactor; }
|
float Width() const { return fWidth; }
|
||||||
void SetZoomFactor(float z);
|
float Height() const { return fHeight; }
|
||||||
float DPI() const { return fDPI; }
|
void SetWidth(float width);
|
||||||
void SetDPI(float dpi);
|
void SetHeight(float height);
|
||||||
// setting width/height updates height/width to keep aspect ratio
|
|
||||||
float Width() const { return fWidth; }
|
|
||||||
float Height() const { return fHeight; }
|
|
||||||
void SetWidth(float width);
|
|
||||||
void SetHeight(float height);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BRect fBounds;
|
BRect fBounds;
|
||||||
enum Option fOption;
|
enum Option fOption;
|
||||||
float fZoomFactor;
|
float fZoomFactor;
|
||||||
float fDPI;
|
float fDPI;
|
||||||
float fWidth, fHeight; // 1/72 Inches
|
float fWidth, fHeight; // 1/72 Inches
|
||||||
};
|
};
|
||||||
|
|
||||||
class PrintOptionsWindow : public BWindow
|
class PrintOptionsWindow : public BWindow {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
PrintOptionsWindow(BPoint at, PrintOptions* options, BWindow* listener);
|
PrintOptionsWindow(BPoint at,
|
||||||
~PrintOptionsWindow();
|
PrintOptions* options, BWindow* listener);
|
||||||
|
~PrintOptionsWindow();
|
||||||
|
|
||||||
void MessageReceived(BMessage* msg);
|
void MessageReceived(BMessage* msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BRadioButton* AddRadioButton(BView* view, BPoint& at, const char* name, const char* label, uint32 what, bool selected);
|
BRadioButton* AddRadioButton(BView* view, BPoint& at,
|
||||||
BTextControl* AddTextControl(BView* view, BPoint& at, const char* name, const char* label, float value, float divider, uint32 what);
|
const char* name, const char* label,
|
||||||
void Setup();
|
uint32 what, bool selected);
|
||||||
enum PrintOptions::Option MsgToOption(uint32 what);
|
|
||||||
bool GetValue(BTextControl* text, float* value);
|
BTextControl* AddTextControl(BView* view, BPoint& at,
|
||||||
void SetValue(BTextControl* text, float value);
|
const char* name, const char* label,
|
||||||
|
float value, float divider, uint32 what);
|
||||||
|
|
||||||
|
void Setup();
|
||||||
|
enum PrintOptions::Option MsgToOption(uint32 what);
|
||||||
|
bool GetValue(BTextControl* text, float* value);
|
||||||
|
void SetValue(BTextControl* text, float value);
|
||||||
|
|
||||||
|
PrintOptions* fPrintOptions;
|
||||||
|
PrintOptions fCurrentOptions;
|
||||||
|
BMessenger fListener;
|
||||||
|
status_t fStatus;
|
||||||
|
BTextControl* fZoomFactor;
|
||||||
|
BTextControl* fDPI;
|
||||||
|
BTextControl* fWidth;
|
||||||
|
BTextControl* fHeight;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
kMsgOK = 'mPOW',
|
kMsgOK = 'mPOW',
|
||||||
kMsgFitToPageSelected,
|
kMsgFitToPageSelected,
|
||||||
@@ -106,15 +103,8 @@ private:
|
|||||||
kIndent = 5,
|
kIndent = 5,
|
||||||
kLineSkip = 5,
|
kLineSkip = 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
PrintOptions* fPrintOptions;
|
|
||||||
PrintOptions fCurrentOptions;
|
|
||||||
BMessenger fListener;
|
|
||||||
status_t fStatus;
|
|
||||||
BTextControl* fZoomFactor;
|
|
||||||
BTextControl* fDPI;
|
|
||||||
BTextControl* fWidth;
|
|
||||||
BTextControl* fHeight;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -3,23 +3,24 @@
|
|||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "ProgressWindow.h"
|
#include "ProgressWindow.h"
|
||||||
#include "ShowImageConstants.h"
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <MessageRunner.h>
|
#include <MessageRunner.h>
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
#include <StatusBar.h>
|
#include <StatusBar.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "ShowImageConstants.h"
|
||||||
|
|
||||||
|
|
||||||
static const uint32 kMsgShow = 'show';
|
static const uint32 kMsgShow = 'show';
|
||||||
|
|
||||||
|
|
||||||
ProgressWindow::ProgressWindow(BWindow* referenceWindow)
|
ProgressWindow::ProgressWindow(BWindow* referenceWindow)
|
||||||
: BWindow(BRect(0, 0, 250, 100), "Progress Monitor",
|
:
|
||||||
|
BWindow(BRect(0, 0, 250, 100), "Progress Monitor",
|
||||||
B_MODAL_WINDOW_LOOK, B_FLOATING_APP_WINDOW_FEEL,
|
B_MODAL_WINDOW_LOOK, B_FLOATING_APP_WINDOW_FEEL,
|
||||||
B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS),
|
B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS),
|
||||||
fRunner(NULL)
|
fRunner(NULL)
|
||||||
|
|||||||
@@ -13,20 +13,21 @@ class BStatusBar;
|
|||||||
|
|
||||||
|
|
||||||
class ProgressWindow : public BWindow {
|
class ProgressWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
ProgressWindow(BWindow* referenceWindow);
|
ProgressWindow(BWindow* referenceWindow);
|
||||||
virtual ~ProgressWindow();
|
virtual ~ProgressWindow();
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage *message);
|
||||||
|
|
||||||
void Start();
|
void Start();
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BStatusBar* fStatusBar;
|
BStatusBar* fStatusBar;
|
||||||
BMessageRunner* fRunner;
|
BMessageRunner* fRunner;
|
||||||
bool fRetrievedUpdate;
|
bool fRetrievedUpdate;
|
||||||
bool fRetrievedShow;
|
bool fRetrievedShow;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // PROGRESS_WINDOW_H
|
#endif // PROGRESS_WINDOW_H
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006-2007, Haiku, Inc. All Rights Reserved.
|
* Copyright 2006-2009, Haiku, Inc. All Rights Reserved.
|
||||||
* Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd.
|
* Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd.
|
||||||
* Copyright 2006 Bernd Korz. All Rights Reserved
|
* Copyright 2006 Bernd Korz. All Rights Reserved
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
@@ -7,10 +7,13 @@
|
|||||||
* Authors:
|
* Authors:
|
||||||
* yellowTAB GmbH
|
* yellowTAB GmbH
|
||||||
* Bernd Korz
|
* Bernd Korz
|
||||||
* Michael Pfeiffer
|
* Michael Pfeiffer
|
||||||
* Ryan Leavengood
|
* Ryan Leavengood
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "ResizerWindow.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <Box.h>
|
#include <Box.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
@@ -20,9 +23,6 @@
|
|||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "ResizerWindow.h"
|
|
||||||
#include "ShowImageConstants.h"
|
#include "ShowImageConstants.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -37,10 +37,12 @@ static const float kVerticalIndent = 10;
|
|||||||
|
|
||||||
|
|
||||||
ResizerWindow::ResizerWindow(BMessenger target, int32 width, int32 height)
|
ResizerWindow::ResizerWindow(BMessenger target, int32 width, int32 height)
|
||||||
: BWindow(BRect(100, 100, 300, 300), "Resize", B_FLOATING_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
|
:
|
||||||
, fOriginalWidth(width)
|
BWindow(BRect(100, 100, 300, 300), "Resize", B_FLOATING_WINDOW,
|
||||||
, fOriginalHeight(height)
|
B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
|
||||||
, fTarget(target)
|
fOriginalWidth(width),
|
||||||
|
fOriginalHeight(height),
|
||||||
|
fTarget(target)
|
||||||
{
|
{
|
||||||
BView* back_view = new BView(Bounds(), "", B_FOLLOW_ALL, B_WILL_DRAW);
|
BView* back_view = new BView(Bounds(), "", B_FOLLOW_ALL, B_WILL_DRAW);
|
||||||
back_view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
back_view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
@@ -51,8 +53,10 @@ ResizerWindow::ResizerWindow(BMessenger target, int32 width, int32 height)
|
|||||||
const float column2 = max_c(widthLabelWidth, heightLabelWidth);
|
const float column2 = max_c(widthLabelWidth, heightLabelWidth);
|
||||||
|
|
||||||
const float textControlWidth = column2 + back_view->StringWidth("999999");
|
const float textControlWidth = column2 + back_view->StringWidth("999999");
|
||||||
const float keepAspectRatioLabelWidth = 20 + back_view->StringWidth(kKeepAspectRatioLabel);
|
const float keepAspectRatioLabelWidth = 20
|
||||||
const float width2 = 2 * kHorizontalIndent + max_c(textControlWidth, keepAspectRatioLabelWidth);
|
+ back_view->StringWidth(kKeepAspectRatioLabel);
|
||||||
|
const float width2 = 2 * kHorizontalIndent
|
||||||
|
+ max_c(textControlWidth, keepAspectRatioLabelWidth);
|
||||||
|
|
||||||
ResizeTo(width2+1, Bounds().Height()+1);
|
ResizeTo(width2+1, Bounds().Height()+1);
|
||||||
|
|
||||||
@@ -62,17 +66,20 @@ ResizerWindow::ResizerWindow(BMessenger target, int32 width, int32 height)
|
|||||||
|
|
||||||
BString widthValue;
|
BString widthValue;
|
||||||
widthValue << width;
|
widthValue << width;
|
||||||
fWidth = new BTextControl(rect, "width", kWidthLabel, widthValue.String(), NULL);
|
fWidth = new BTextControl(rect, "width", kWidthLabel, widthValue.String(),
|
||||||
|
NULL);
|
||||||
fWidth->SetModificationMessage(new BMessage(kWidthModifiedMsg));
|
fWidth->SetModificationMessage(new BMessage(kWidthModifiedMsg));
|
||||||
AddControl(back_view, fWidth, column2, rect);
|
AddControl(back_view, fWidth, column2, rect);
|
||||||
|
|
||||||
BString heightValue;
|
BString heightValue;
|
||||||
heightValue << height;
|
heightValue << height;
|
||||||
fHeight = new BTextControl(rect, "height", kHeightLabel, heightValue.String(), NULL);
|
fHeight = new BTextControl(rect, "height", kHeightLabel,
|
||||||
|
heightValue.String(), NULL);
|
||||||
fHeight->SetModificationMessage(new BMessage(kHeightModifiedMsg));
|
fHeight->SetModificationMessage(new BMessage(kHeightModifiedMsg));
|
||||||
AddControl(back_view, fHeight, column2, rect);
|
AddControl(back_view, fHeight, column2, rect);
|
||||||
|
|
||||||
fAspectRatio = new BCheckBox(rect, "Ratio", kKeepAspectRatioLabel, new BMessage(kWidthModifiedMsg));
|
fAspectRatio = new BCheckBox(rect, "Ratio", kKeepAspectRatioLabel,
|
||||||
|
new BMessage(kWidthModifiedMsg));
|
||||||
fAspectRatio->SetValue(B_CONTROL_ON);
|
fAspectRatio->SetValue(B_CONTROL_ON);
|
||||||
AddControl(back_view, fAspectRatio, column2, rect);
|
AddControl(back_view, fAspectRatio, column2, rect);
|
||||||
|
|
||||||
@@ -87,8 +94,14 @@ ResizerWindow::ResizerWindow(BMessenger target, int32 width, int32 height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ResizerWindow::~ResizerWindow()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ResizerWindow::AddControl(BView* view, BControl* control, float column2, BRect& rect)
|
ResizerWindow::AddControl(BView* view, BControl* control, float column2,
|
||||||
|
BRect& rect)
|
||||||
{
|
{
|
||||||
float width, height;
|
float width, height;
|
||||||
view->AddChild(control);
|
view->AddChild(control);
|
||||||
@@ -116,7 +129,8 @@ ResizerWindow::AddSeparatorLine(BView* view, BRect& rect)
|
|||||||
line.right -= 3;
|
line.right -= 3;
|
||||||
line.top = rect.top;
|
line.top = rect.top;
|
||||||
line.bottom = line.top + lineWidth - 1;
|
line.bottom = line.top + lineWidth - 1;
|
||||||
BBox* separatorLine = new BBox(line, "", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER);
|
BBox* separatorLine = new BBox(line, "", B_FOLLOW_LEFT_RIGHT,
|
||||||
|
B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER);
|
||||||
view->AddChild(separatorLine);
|
view->AddChild(separatorLine);
|
||||||
rect.OffsetBy(0, kLineDistance + lineWidth);
|
rect.OffsetBy(0, kLineDistance + lineWidth);
|
||||||
}
|
}
|
||||||
@@ -177,7 +191,8 @@ ResizerWindow::MessageReceived(BMessage* message)
|
|||||||
case kWidthModifiedMsg:
|
case kWidthModifiedMsg:
|
||||||
if (fAspectRatio->Value() == B_CONTROL_ON) {
|
if (fAspectRatio->Value() == B_CONTROL_ON) {
|
||||||
int w = atoi(fWidth->Text());
|
int w = atoi(fWidth->Text());
|
||||||
int h = (int)((int64)w * (int64) fOriginalHeight / (int64) fOriginalWidth);
|
int h = (int)((int64)w * (int64) fOriginalHeight
|
||||||
|
/ (int64) fOriginalWidth);
|
||||||
BString height;
|
BString height;
|
||||||
height << h;
|
height << h;
|
||||||
BMessage* msg = new BMessage(*fHeight->ModificationMessage());
|
BMessage* msg = new BMessage(*fHeight->ModificationMessage());
|
||||||
@@ -189,7 +204,8 @@ ResizerWindow::MessageReceived(BMessage* message)
|
|||||||
case kHeightModifiedMsg:
|
case kHeightModifiedMsg:
|
||||||
if (fAspectRatio->Value() == B_CONTROL_ON) {
|
if (fAspectRatio->Value() == B_CONTROL_ON) {
|
||||||
int h = atoi(fHeight->Text());
|
int h = atoi(fHeight->Text());
|
||||||
int w = (int)((int64)h * (int64) fOriginalWidth / (int64) fOriginalHeight);
|
int w = (int)((int64)h * (int64) fOriginalWidth
|
||||||
|
/ (int64) fOriginalHeight);
|
||||||
BString width;
|
BString width;
|
||||||
width << w;
|
width << w;
|
||||||
BMessage* msg = new BMessage(*fWidth->ModificationMessage());
|
BMessage* msg = new BMessage(*fWidth->ModificationMessage());
|
||||||
@@ -213,11 +229,6 @@ ResizerWindow::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ResizerWindow::~ResizerWindow()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ResizerWindow::QuitRequested()
|
ResizerWindow::QuitRequested()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006-2007, Haiku, Inc. All Rights Reserved.
|
* Copyright 2006-2009, Haiku, Inc. All Rights Reserved.
|
||||||
* Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd.
|
* Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd.
|
||||||
* Copyright 2006 Bernd Korz. All Rights Reserved
|
* Copyright 2006 Bernd Korz. All Rights Reserved
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
@@ -7,15 +7,16 @@
|
|||||||
* Authors:
|
* Authors:
|
||||||
* yellowTAB GmbH
|
* yellowTAB GmbH
|
||||||
* Bernd Korz
|
* Bernd Korz
|
||||||
* Michael Pfeiffer
|
* Michael Pfeiffer
|
||||||
* Ryan Leavengood
|
* Ryan Leavengood
|
||||||
*/
|
*/
|
||||||
#ifndef _RESIZER_WINDOW_H
|
#ifndef RESIZER_WINDOW_H
|
||||||
#define _RESIZER_WINDOW_H
|
#define RESIZER_WINDOW_H
|
||||||
|
|
||||||
|
|
||||||
#include <Window.h>
|
#include <Messenger.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
class BCheckBox;
|
class BCheckBox;
|
||||||
class BControl;
|
class BControl;
|
||||||
@@ -24,7 +25,8 @@ class BTextControl;
|
|||||||
|
|
||||||
class ResizerWindow : public BWindow {
|
class ResizerWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
ResizerWindow(BMessenger target, int32 width, int32 height );
|
ResizerWindow(BMessenger target, int32 width,
|
||||||
|
int32 height );
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage* msg);
|
virtual void MessageReceived(BMessage* msg);
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
@@ -36,7 +38,8 @@ class ResizerWindow : public BWindow {
|
|||||||
kActivateMsg = 'RSRa',
|
kActivateMsg = 'RSRa',
|
||||||
// activates the window
|
// activates the window
|
||||||
kUpdateMsg,
|
kUpdateMsg,
|
||||||
// provides the new size of the image in two "int32" fields "width" and "height"
|
// provides the new size of the image in two "int32" fields
|
||||||
|
// "width" and "height"
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -47,10 +50,10 @@ class ResizerWindow : public BWindow {
|
|||||||
kApplyMsg,
|
kApplyMsg,
|
||||||
};
|
};
|
||||||
|
|
||||||
void AddControl(BView* parent, BControl* control, float column2,
|
void AddControl(BView* parent, BControl* control,
|
||||||
BRect& rect);
|
float column2, BRect& rect);
|
||||||
void AddSeparatorLine(BView* parent, BRect& rect);
|
void AddSeparatorLine(BView* parent, BRect& rect);
|
||||||
void LeftAlign(BControl* control);
|
void LeftAlign(BControl* control);
|
||||||
|
|
||||||
BTextControl* fWidth;
|
BTextControl* fWidth;
|
||||||
BTextControl* fHeight;
|
BTextControl* fHeight;
|
||||||
@@ -58,9 +61,10 @@ class ResizerWindow : public BWindow {
|
|||||||
BButton* fApply;
|
BButton* fApply;
|
||||||
// the original size of the image use for aspect ratio calculation
|
// the original size of the image use for aspect ratio calculation
|
||||||
// to avoid rounding errors
|
// to avoid rounding errors
|
||||||
int32 fOriginalWidth;
|
int32 fOriginalWidth;
|
||||||
int32 fOriginalHeight;
|
int32 fOriginalHeight;
|
||||||
BMessenger fTarget;
|
BMessenger fTarget;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _RESIZER_WINDOW_H
|
|
||||||
|
#endif // RESIZER_WINDOW_H
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ resource app_version {
|
|||||||
internal = 0,
|
internal = 0,
|
||||||
|
|
||||||
short_info = "ShowImage",
|
short_info = "ShowImage",
|
||||||
long_info = "ShowImage ©2003-2007 Haiku, Inc."
|
long_info = "ShowImage ©2003-2009 Haiku, Inc."
|
||||||
};
|
};
|
||||||
|
|
||||||
resource app_flags B_SINGLE_LAUNCH;
|
resource app_flags B_SINGLE_LAUNCH;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
|
* Copyright 2003-2009, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -9,10 +9,9 @@
|
|||||||
* Ryan Leavengood
|
* Ryan Leavengood
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "ShowImageApp.h"
|
#include "ShowImageApp.h"
|
||||||
#include "ShowImageConstants.h"
|
|
||||||
#include "ShowImageWindow.h"
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <AboutWindow.h>
|
#include <AboutWindow.h>
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
@@ -21,7 +20,8 @@
|
|||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "ShowImageConstants.h"
|
||||||
|
#include "ShowImageWindow.h"
|
||||||
|
|
||||||
|
|
||||||
#define WINDOWS_TO_IGNORE 1
|
#define WINDOWS_TO_IGNORE 1
|
||||||
@@ -30,7 +30,8 @@ extern const char *kApplicationSignature = "application/x-vnd.Haiku-ShowImage";
|
|||||||
|
|
||||||
|
|
||||||
ShowImageApp::ShowImageApp()
|
ShowImageApp::ShowImageApp()
|
||||||
: BApplication(kApplicationSignature)
|
:
|
||||||
|
BApplication(kApplicationSignature)
|
||||||
{
|
{
|
||||||
fPulseStarted = false;
|
fPulseStarted = false;
|
||||||
fOpenPanel = new BFilePanel(B_OPEN_PANEL);
|
fOpenPanel = new BFilePanel(B_OPEN_PANEL);
|
||||||
@@ -109,7 +110,8 @@ ShowImageApp::ArgvReceived(int32 argc, char **argv)
|
|||||||
|
|
||||||
// get current working directory
|
// get current working directory
|
||||||
const char *cwd;
|
const char *cwd;
|
||||||
if (CurrentMessage() == NULL || CurrentMessage()->FindString("cwd", &cwd) != B_OK)
|
if (CurrentMessage() == NULL
|
||||||
|
|| CurrentMessage()->FindString("cwd", &cwd) != B_OK)
|
||||||
cwd = "";
|
cwd = "";
|
||||||
|
|
||||||
for (int32 i = 1; i < argc; i++) {
|
for (int32 i = 1; i < argc; i++) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2006, Haiku, Inc. All Rights Reserved.
|
* Copyright 2003-2009, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -18,36 +18,37 @@
|
|||||||
|
|
||||||
|
|
||||||
class ShowImageApp : public BApplication {
|
class ShowImageApp : public BApplication {
|
||||||
public:
|
public:
|
||||||
ShowImageApp();
|
ShowImageApp();
|
||||||
virtual ~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 *message);
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void ReadyToRun();
|
||||||
virtual void ReadyToRun();
|
virtual void Pulse();
|
||||||
virtual void Pulse();
|
virtual void RefsReceived(BMessage *message);
|
||||||
virtual void RefsReceived(BMessage *message);
|
virtual bool QuitRequested();
|
||||||
virtual bool QuitRequested();
|
|
||||||
|
|
||||||
ShowImageSettings* Settings() { return &fSettings; }
|
ShowImageSettings* Settings() { return &fSettings; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void StartPulse();
|
void StartPulse();
|
||||||
void Open(const entry_ref *ref);
|
void Open(const entry_ref *ref);
|
||||||
void BroadcastToWindows(BMessage *message);
|
void BroadcastToWindows(BMessage *message);
|
||||||
void CheckClipboard();
|
void CheckClipboard();
|
||||||
|
|
||||||
BMessenger fTrackerMessenger; // of the window this was launched
|
BMessenger fTrackerMessenger;
|
||||||
BFilePanel *fOpenPanel;
|
BFilePanel *fOpenPanel;
|
||||||
bool fPulseStarted;
|
bool fPulseStarted;
|
||||||
ShowImageSettings fSettings;
|
ShowImageSettings fSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern const char *kApplicationSignature;
|
extern const char *kApplicationSignature;
|
||||||
|
|
||||||
#define my_app dynamic_cast<ShowImageApp*>(be_app)
|
#define my_app dynamic_cast<ShowImageApp*>(be_app)
|
||||||
|
|
||||||
|
|
||||||
#endif // SHOW_IMAGE_APP_H
|
#endif // SHOW_IMAGE_APP_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,42 +1,24 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// ShowImageSettings
|
* Copyright 2003-2009 Haiku Inc. All rights reserved.
|
||||||
// Written by Michael Pfeiffer
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*
|
||||||
// ShowImageSettings.cpp
|
* Authors:
|
||||||
//
|
* Michael Pfeiffer, [email protected]
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003 OpenBeOS Project
|
|
||||||
//
|
#include "ShowImageSettings.h"
|
||||||
// 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 <File.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
|
||||||
#include "ShowImageSettings.h"
|
|
||||||
|
|
||||||
ShowImageSettings::ShowImageSettings()
|
ShowImageSettings::ShowImageSettings()
|
||||||
{
|
{
|
||||||
Load();
|
Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ShowImageSettings::~ShowImageSettings()
|
ShowImageSettings::~ShowImageSettings()
|
||||||
{
|
{
|
||||||
if (Lock()) {
|
if (Lock()) {
|
||||||
@@ -45,18 +27,21 @@ ShowImageSettings::~ShowImageSettings()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ShowImageSettings::Lock()
|
ShowImageSettings::Lock()
|
||||||
{
|
{
|
||||||
return fLock.Lock();
|
return fLock.Lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageSettings::Unlock()
|
ShowImageSettings::Unlock()
|
||||||
{
|
{
|
||||||
fLock.Unlock();
|
fLock.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ShowImageSettings::GetBool(const char* name, bool defaultValue)
|
ShowImageSettings::GetBool(const char* name, bool defaultValue)
|
||||||
{
|
{
|
||||||
@@ -68,6 +53,7 @@ ShowImageSettings::GetBool(const char* name, bool defaultValue)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
ShowImageSettings::GetInt32(const char* name, int32 defaultValue)
|
ShowImageSettings::GetInt32(const char* name, int32 defaultValue)
|
||||||
{
|
{
|
||||||
@@ -79,6 +65,7 @@ ShowImageSettings::GetInt32(const char* name, int32 defaultValue)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float
|
float
|
||||||
ShowImageSettings::GetFloat(const char* name, float defaultValue)
|
ShowImageSettings::GetFloat(const char* name, float defaultValue)
|
||||||
{
|
{
|
||||||
@@ -90,6 +77,7 @@ ShowImageSettings::GetFloat(const char* name, float defaultValue)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BRect
|
BRect
|
||||||
ShowImageSettings::GetRect(const char* name, BRect defaultValue)
|
ShowImageSettings::GetRect(const char* name, BRect defaultValue)
|
||||||
{
|
{
|
||||||
@@ -101,6 +89,7 @@ ShowImageSettings::GetRect(const char* name, BRect defaultValue)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
ShowImageSettings::GetString(const char* name, const char* defaultValue)
|
ShowImageSettings::GetString(const char* name, const char* defaultValue)
|
||||||
{
|
{
|
||||||
@@ -112,6 +101,7 @@ ShowImageSettings::GetString(const char* name, const char* defaultValue)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageSettings::SetBool(const char* name, bool value)
|
ShowImageSettings::SetBool(const char* name, bool value)
|
||||||
{
|
{
|
||||||
@@ -122,6 +112,7 @@ ShowImageSettings::SetBool(const char* name, bool value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageSettings::SetInt32(const char* name, int32 value)
|
ShowImageSettings::SetInt32(const char* name, int32 value)
|
||||||
{
|
{
|
||||||
@@ -132,6 +123,7 @@ ShowImageSettings::SetInt32(const char* name, int32 value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageSettings::SetFloat(const char* name, float value)
|
ShowImageSettings::SetFloat(const char* name, float value)
|
||||||
{
|
{
|
||||||
@@ -142,6 +134,7 @@ ShowImageSettings::SetFloat(const char* name, float value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageSettings::SetRect(const char* name, BRect value)
|
ShowImageSettings::SetRect(const char* name, BRect value)
|
||||||
{
|
{
|
||||||
@@ -152,6 +145,7 @@ ShowImageSettings::SetRect(const char* name, BRect value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageSettings::SetString(const char* name, const char* value)
|
ShowImageSettings::SetString(const char* name, const char* value)
|
||||||
{
|
{
|
||||||
@@ -162,6 +156,7 @@ ShowImageSettings::SetString(const char* name, const char* value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ShowImageSettings::OpenSettingsFile(BFile* file, bool forReading)
|
ShowImageSettings::OpenSettingsFile(BFile* file, bool forReading)
|
||||||
{
|
{
|
||||||
@@ -182,6 +177,7 @@ ShowImageSettings::OpenSettingsFile(BFile* file, bool forReading)
|
|||||||
return st == B_OK;
|
return st == B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageSettings::Load()
|
ShowImageSettings::Load()
|
||||||
{
|
{
|
||||||
@@ -191,6 +187,7 @@ ShowImageSettings::Load()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageSettings::Save()
|
ShowImageSettings::Save()
|
||||||
{
|
{
|
||||||
@@ -199,3 +196,4 @@ ShowImageSettings::Save()
|
|||||||
fSettings.Flatten(&file);
|
fSettings.Flatten(&file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,64 +1,45 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// ShowImageSettings
|
* Copyright 2003-2009 Haiku Inc. All rights reserved.
|
||||||
// Written by Michael Pfeiffer
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*
|
||||||
// ShowImageSettings.cpp
|
* Authors:
|
||||||
//
|
* Michael Pfeiffer, [email protected]
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003 OpenBeOS Project
|
#ifndef SHOW_IMAGE_SETTINGS_H
|
||||||
//
|
#define SHOW_IMAGE_SETTINGS_H
|
||||||
// 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 <File.h>
|
#include <File.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
|
|
||||||
class ShowImageSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ShowImageSettings();
|
|
||||||
~ShowImageSettings();
|
|
||||||
|
|
||||||
bool Lock();
|
class ShowImageSettings {
|
||||||
bool GetBool(const char* name, bool defaultValue);
|
public:
|
||||||
int32 GetInt32(const char* name, int32 defaultValue);
|
ShowImageSettings();
|
||||||
float GetFloat(const char* name, float defaultValue);
|
~ShowImageSettings();
|
||||||
BRect GetRect(const char* name, BRect defaultValue);
|
|
||||||
const char* GetString(const char* name, const char* defaultValue);
|
bool Lock();
|
||||||
void SetBool(const char* name, bool value);
|
bool GetBool(const char* name, bool defaultValue);
|
||||||
void SetInt32(const char* name, int32 value);
|
int32 GetInt32(const char* name, int32 defaultValue);
|
||||||
void SetFloat(const char* name, float value);
|
float GetFloat(const char* name, float defaultValue);
|
||||||
void SetRect(const char* name, BRect value);
|
BRect GetRect(const char* name, BRect defaultValue);
|
||||||
void SetString(const char* name, const char* value);
|
const char* GetString(const char* name, const char* defaultValue);
|
||||||
void Unlock();
|
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:
|
private:
|
||||||
bool OpenSettingsFile(BFile* file, bool forReading);
|
bool OpenSettingsFile(BFile* file, bool forReading);
|
||||||
void Load();
|
void Load();
|
||||||
void Save();
|
void Save();
|
||||||
|
|
||||||
BLocker fLock;
|
BLocker fLock;
|
||||||
BMessage fSettings;
|
BMessage fSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
#endif // SHOW_IMAGE_SETTINGS_H
|
||||||
|
|||||||
@@ -1,44 +1,27 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// ShowImageStatusView
|
* Copyright 2003-2009 Haiku Inc. All rights reserved.
|
||||||
// Written by Fernando Francisco de Oliveira, Michael Wilber
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*
|
||||||
// ShowImageStatusView.cpp
|
* Authors:
|
||||||
//
|
* Fernando Francisco de Oliveira
|
||||||
//
|
* Michael Wilber
|
||||||
// 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 "ShowImageStatusView.h"
|
#include "ShowImageStatusView.h"
|
||||||
#include "ShowImageView.h"
|
|
||||||
#include "ShowImageWindow.h"
|
|
||||||
|
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <PopUpMenu.h>
|
#include <PopUpMenu.h>
|
||||||
|
|
||||||
|
#include "ShowImageView.h"
|
||||||
|
#include "ShowImageWindow.h"
|
||||||
|
|
||||||
|
|
||||||
ShowImageStatusView::ShowImageStatusView(BRect rect, const char* name,
|
ShowImageStatusView::ShowImageStatusView(BRect rect, const char* name,
|
||||||
uint32 resizingMode, uint32 flags)
|
uint32 resizingMode, uint32 flags)
|
||||||
: BView(rect, name, resizingMode, flags)
|
:
|
||||||
|
BView(rect, name, resizingMode, flags)
|
||||||
{
|
{
|
||||||
SetViewColor(B_TRANSPARENT_32_BIT);
|
SetViewColor(B_TRANSPARENT_32_BIT);
|
||||||
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
@@ -76,7 +59,7 @@ ShowImageStatusView::Draw(BRect updateRect)
|
|||||||
|
|
||||||
b.InsetBy(1.0, 1.0);
|
b.InsetBy(1.0, 1.0);
|
||||||
|
|
||||||
// truncate and layout text
|
// Truncate and layout text
|
||||||
BString truncated(fText);
|
BString truncated(fText);
|
||||||
BFont font;
|
BFont font;
|
||||||
GetFont(&font);
|
GetFont(&font);
|
||||||
@@ -87,8 +70,7 @@ ShowImageStatusView::Draw(BRect updateRect)
|
|||||||
FillRect(b, B_SOLID_LOW);
|
FillRect(b, B_SOLID_LOW);
|
||||||
SetDrawingMode(B_OP_OVER);
|
SetDrawingMode(B_OP_OVER);
|
||||||
DrawString(truncated.String(), BPoint(b.left + 2.0,
|
DrawString(truncated.String(), BPoint(b.left + 2.0,
|
||||||
floorf(b.top + b.Height() / 2.0
|
floorf(b.top + b.Height() / 2.0 + fh.ascent / 2.0)));
|
||||||
+ fh.ascent / 2.0)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,50 +1,31 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// ShowImageStatusView
|
* Copyright 2003-2009 Haiku Inc. All rights reserved.
|
||||||
// Written by Fernando Francisco de Oliveira, Michael Wilber
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*
|
||||||
// ShowImageStatusView.h
|
* Authors:
|
||||||
//
|
* Fernando Francisco de Oliveira
|
||||||
//
|
* Michael Wilber
|
||||||
// Copyright (c) 2003 OpenBeOS Project
|
*/
|
||||||
//
|
#ifndef SHOW_IMAGE_STATUS_VIEW_H
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
#define SHOW_IMAGE_STATUS_VIEW_H
|
||||||
// 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 _ShowImageStatusView_h
|
|
||||||
#define _ShowImageStatusView_h
|
|
||||||
|
|
||||||
#include <View.h>
|
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
#include <View.h>
|
||||||
|
|
||||||
|
|
||||||
class ShowImageStatusView : public BView {
|
class ShowImageStatusView : public BView {
|
||||||
public:
|
public:
|
||||||
ShowImageStatusView(BRect rect, const char *name, uint32 resizingMode,
|
ShowImageStatusView(BRect rect, const char *name,
|
||||||
uint32 flags);
|
uint32 resizingMode, uint32 flags);
|
||||||
|
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
|
virtual void MouseDown(BPoint where);
|
||||||
virtual void MouseDown(BPoint where);
|
void SetText(BString &text);
|
||||||
|
|
||||||
void SetText(BString &text);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BString fText;
|
BString fText;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _ShowImageStatusView_h */
|
|
||||||
|
#endif // SHOW_IMAGE_STATUS_VIEW_H
|
||||||
|
|||||||
@@ -1,49 +1,33 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// ShowImageUndo
|
* Copyright 2003-2009 Haiku Inc. All rights reserved.
|
||||||
// Written by Michael Wilber
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*
|
||||||
// ShowImageUndo.cpp
|
* Authors:
|
||||||
//
|
* Michael Wilber
|
||||||
//
|
*/
|
||||||
// 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 "ShowImageUndo.h"
|
#include "ShowImageUndo.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
ShowImageUndo::ShowImageUndo()
|
ShowImageUndo::ShowImageUndo()
|
||||||
|
:
|
||||||
|
fWindow(NULL),
|
||||||
|
fUndoType(0),
|
||||||
|
fRestore(NULL),
|
||||||
|
fSelection(NULL)
|
||||||
{
|
{
|
||||||
fWindow = NULL;
|
|
||||||
fUndoType = 0;
|
|
||||||
fRestore = NULL;
|
|
||||||
fSelection = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ShowImageUndo::~ShowImageUndo()
|
ShowImageUndo::~ShowImageUndo()
|
||||||
{
|
{
|
||||||
InternalClear();
|
InternalClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageUndo::InternalClear()
|
ShowImageUndo::InternalClear()
|
||||||
{
|
{
|
||||||
@@ -54,6 +38,7 @@ ShowImageUndo::InternalClear()
|
|||||||
fSelection = NULL;
|
fSelection = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageUndo::Clear()
|
ShowImageUndo::Clear()
|
||||||
{
|
{
|
||||||
@@ -61,12 +46,14 @@ ShowImageUndo::Clear()
|
|||||||
SendUndoStateMessage(false);
|
SendUndoStateMessage(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageUndo::SendUndoStateMessage(bool bCanUndo)
|
ShowImageUndo::SendUndoStateMessage(bool bCanUndo)
|
||||||
{
|
{
|
||||||
if (fWindow) {
|
if (fWindow) {
|
||||||
if (!fWindow->IsLocked()) {
|
if (!fWindow->IsLocked()) {
|
||||||
fprintf(stderr, "ShowImageUndo::SendUndoStateMessage: window must be locked!");
|
fprintf(stderr,
|
||||||
|
"ShowImageUndo::SendUndoStateMessage: window must be locked!");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
BMessage msg(MSG_UNDO_STATE);
|
BMessage msg(MSG_UNDO_STATE);
|
||||||
@@ -75,6 +62,7 @@ ShowImageUndo::SendUndoStateMessage(bool bCanUndo)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageUndo::SetTo(BRect rect, BBitmap *restore, BBitmap *selection)
|
ShowImageUndo::SetTo(BRect rect, BBitmap *restore, BBitmap *selection)
|
||||||
{
|
{
|
||||||
@@ -89,6 +77,7 @@ ShowImageUndo::SetTo(BRect rect, BBitmap *restore, BBitmap *selection)
|
|||||||
SendUndoStateMessage(true);
|
SendUndoStateMessage(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageUndo::Undo(BRect rect, BBitmap *restore, BBitmap *selection)
|
ShowImageUndo::Undo(BRect rect, BBitmap *restore, BBitmap *selection)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,79 +1,63 @@
|
|||||||
/*****************************************************************************/
|
/*
|
||||||
// ShowImageUndo
|
* Copyright 2003-2009 Haiku Inc. All rights reserved.
|
||||||
// Written by Michael Wilber
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*
|
||||||
// ShowImageUndo.h
|
* Authors:
|
||||||
//
|
* Michael Wilber
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003 OpenBeOS Project
|
#ifndef SHOW_IMAGE_UNDO_H
|
||||||
//
|
#define SHOW_IMAGE_UNDO_H
|
||||||
// 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 _ShowImageUndo_h
|
|
||||||
#define _ShowImageUndo_h
|
|
||||||
|
|
||||||
#include <Rect.h>
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
#include <Window.h>
|
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <Messenger.h>
|
#include <Messenger.h>
|
||||||
|
#include <Rect.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
#include "ShowImageConstants.h"
|
#include "ShowImageConstants.h"
|
||||||
|
|
||||||
|
|
||||||
// for Undo
|
// for Undo
|
||||||
#define UNDO_UNDO 1
|
#define UNDO_UNDO 1
|
||||||
#define UNDO_REDO 2
|
#define UNDO_REDO 2
|
||||||
|
|
||||||
|
|
||||||
class ShowImageUndo {
|
class ShowImageUndo {
|
||||||
public:
|
public:
|
||||||
ShowImageUndo();
|
ShowImageUndo();
|
||||||
~ShowImageUndo();
|
~ShowImageUndo();
|
||||||
|
|
||||||
void SetWindow(BWindow *win) { fWindow = win; }
|
void SetWindow(BWindow* win) { fWindow = win; }
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
// NOTE: THESE TWO FUNCTIONS DO NOT MAKE COPIES OF THE
|
// NOTE: THESE TWO FUNCTIONS DO NOT MAKE COPIES OF THE
|
||||||
// BITMAPS PASSED TO THEM
|
// BITMAPS PASSED TO THEM
|
||||||
void SetTo(BRect rect, BBitmap *restore, BBitmap *selection);
|
void SetTo(BRect rect, BBitmap* restore, BBitmap* selection);
|
||||||
void Undo(BRect rect, BBitmap *restore, BBitmap *selection);
|
void Undo(BRect rect, BBitmap* restore, BBitmap* selection);
|
||||||
|
|
||||||
int32 GetType() { return fUndoType; }
|
int32 GetType() { return fUndoType; }
|
||||||
BRect GetRect() { return fRect; }
|
BRect GetRect() { return fRect; }
|
||||||
BBitmap *GetRestoreBitmap() { return fRestore; }
|
BBitmap* GetRestoreBitmap() { return fRestore; }
|
||||||
BBitmap *GetSelectionBitmap() { return fSelection; }
|
BBitmap* GetSelectionBitmap() { return fSelection; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InternalClear();
|
void InternalClear();
|
||||||
void SendUndoStateMessage(bool bCanUndo);
|
void SendUndoStateMessage(bool bCanUndo);
|
||||||
|
|
||||||
BWindow *fWindow;
|
BWindow* fWindow;
|
||||||
// Window to which notification messages are sent
|
// Window to which notification messages are sent
|
||||||
int32 fUndoType;
|
int32 fUndoType;
|
||||||
// Nothing, Undo or Redo
|
// Nothing, Undo or Redo
|
||||||
BRect fRect;
|
BRect fRect;
|
||||||
// Area of background bitmap where change took place
|
// Area of background bitmap where change took place
|
||||||
BBitmap *fRestore;
|
BBitmap* fRestore;
|
||||||
// Changed portion of background bitmap, before change took place
|
// Changed portion of background bitmap, before change took place
|
||||||
BBitmap *fSelection;
|
BBitmap* fSelection;
|
||||||
// Selection present before change took place
|
// Selection present before change took place
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _ShowImageUndo_h */
|
|
||||||
|
#endif // SHOW_IMAGE_UNDO_H
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user