Patch by mt. Localization and conversion to use the layout API with coding style
fixes along the way. Thanks a lot! Fixes #5563. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35929 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
af3253dea5
commit
1ed4535f34
@ -17,7 +17,17 @@ Application ShowImage :
|
|||||||
ProgressWindow.cpp
|
ProgressWindow.cpp
|
||||||
ResizerWindow.cpp
|
ResizerWindow.cpp
|
||||||
: libshared.a
|
: libshared.a
|
||||||
be tracker translation $(TARGET_LIBSUPC++)
|
be tracker translation liblocale.so $(TARGET_LIBSUPC++)
|
||||||
: ShowImage.rdef
|
: ShowImage.rdef
|
||||||
;
|
;
|
||||||
|
|
||||||
|
DoCatalogs ShowImage :
|
||||||
|
x-vnd.Haiku-ShowImage
|
||||||
|
:
|
||||||
|
PrintOptionsWindow.cpp
|
||||||
|
ResizerWindow.cpp
|
||||||
|
ShowImageApp.cpp
|
||||||
|
ShowImageWindow.cpp
|
||||||
|
: en.catalog
|
||||||
|
:
|
||||||
|
;
|
||||||
|
@ -13,6 +13,12 @@
|
|||||||
|
|
||||||
#include <Box.h>
|
#include <Box.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
|
#include <Catalog.h>
|
||||||
|
#include <ControlLook.h>
|
||||||
|
#include <GroupLayoutBuilder.h>
|
||||||
|
#include <GridLayoutBuilder.h>
|
||||||
|
#include <Locale.h>
|
||||||
|
#include <LayoutBuilder.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include "ShowImageConstants.h"
|
#include "ShowImageConstants.h"
|
||||||
@ -23,8 +29,8 @@ PrintOptions::PrintOptions()
|
|||||||
fOption(kFitToPage),
|
fOption(kFitToPage),
|
||||||
fZoomFactor(1.0),
|
fZoomFactor(1.0),
|
||||||
fDPI(72.0),
|
fDPI(72.0),
|
||||||
fWidth(1024/72.0),
|
fWidth(1024 / 72.0),
|
||||||
fHeight(768/72.0)
|
fHeight(768 / 72.0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,12 +74,15 @@ PrintOptions::SetHeight(float h)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PrintOptionsWindow::PrintOptionsWindow(BPoint at, PrintOptions *options,
|
#undef TR_CONTEXT
|
||||||
|
#define TR_CONTEXT "PrintOptionsWindow"
|
||||||
|
|
||||||
|
PrintOptionsWindow::PrintOptionsWindow(BPoint at, PrintOptions* options,
|
||||||
BWindow* listener)
|
BWindow* listener)
|
||||||
:
|
:
|
||||||
BWindow(BRect(at.x, at.y, at.x + 300, at.y + 200), "Print options",
|
BWindow(BRect(at.x, at.y, at.x + 300, at.y + 200), TR("Print options"),
|
||||||
B_TITLED_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL,
|
B_TITLED_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL,
|
||||||
B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
|
B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS),
|
||||||
fPrintOptions(options),
|
fPrintOptions(options),
|
||||||
fCurrentOptions(*options),
|
fCurrentOptions(*options),
|
||||||
fListener(listener),
|
fListener(listener),
|
||||||
@ -94,35 +103,24 @@ PrintOptionsWindow::~PrintOptionsWindow()
|
|||||||
|
|
||||||
|
|
||||||
BRadioButton*
|
BRadioButton*
|
||||||
PrintOptionsWindow::AddRadioButton(BView* view, BPoint& at, const char* name,
|
PrintOptionsWindow::AddRadioButton(const char* name,
|
||||||
const char* label, uint32 what, bool selected)
|
const char* label, uint32 what, bool selected)
|
||||||
{
|
{
|
||||||
BRect rect(0, 0, 100, 20);
|
|
||||||
BRadioButton* button;
|
BRadioButton* button;
|
||||||
rect.OffsetBy(at);
|
button = new BRadioButton(name, label, new BMessage(what));
|
||||||
button = new BRadioButton(rect, name, label, new BMessage(what));
|
|
||||||
view->AddChild(button);
|
|
||||||
button->ResizeToPreferred();
|
|
||||||
at.y += button->Bounds().Height() + kLineSkip;
|
|
||||||
button->SetValue(selected ? B_CONTROL_ON : B_CONTROL_OFF);
|
button->SetValue(selected ? B_CONTROL_ON : B_CONTROL_OFF);
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BTextControl*
|
BTextControl*
|
||||||
PrintOptionsWindow::AddTextControl(BView* view, BPoint& at, const char* name,
|
PrintOptionsWindow::AddTextControl(const char* name,
|
||||||
const char* label, float value, float divider, uint32 what)
|
const char* label, float value, uint32 what)
|
||||||
{
|
{
|
||||||
BRect rect(0, 0, divider + 45, 20);
|
|
||||||
BTextControl* text;
|
BTextControl* text;
|
||||||
rect.OffsetBy(at);
|
text = new BTextControl(name, label, "", new BMessage(what));
|
||||||
text = new BTextControl(rect, name, label, "", new BMessage(what));
|
|
||||||
view->AddChild(text);
|
|
||||||
text->SetModificationMessage(new BMessage(what));
|
text->SetModificationMessage(new BMessage(what));
|
||||||
text->SetDivider(divider);
|
|
||||||
text->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
|
|
||||||
SetValue(text, value);
|
SetValue(text, value);
|
||||||
at.y += text->Bounds().Height() + kLineSkip;
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,68 +128,72 @@ PrintOptionsWindow::AddTextControl(BView* view, BPoint& at, const char* name,
|
|||||||
void
|
void
|
||||||
PrintOptionsWindow::Setup()
|
PrintOptionsWindow::Setup()
|
||||||
{
|
{
|
||||||
BRect rect(Bounds());
|
|
||||||
BPoint at(kIndent, kIndent), textAt;
|
|
||||||
BString value;
|
BString value;
|
||||||
enum PrintOptions::Option op = fCurrentOptions.Option();
|
enum PrintOptions::Option op = fCurrentOptions.Option();
|
||||||
BRadioButton* rb;
|
BRadioButton* rbFit;
|
||||||
|
BRadioButton* rbZoom;
|
||||||
|
BRadioButton* rbDpi;
|
||||||
|
BRadioButton* rbResize;
|
||||||
BBox* line;
|
BBox* line;
|
||||||
BButton* button;
|
BButton* button;
|
||||||
|
|
||||||
BBox *panel = new BBox(rect, "top_panel", B_FOLLOW_ALL,
|
rbFit = AddRadioButton("fit_to_page", TR("Fit image to page"),
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
|
|
||||||
B_PLAIN_BORDER);
|
|
||||||
AddChild(panel);
|
|
||||||
|
|
||||||
AddRadioButton(panel, at, "fit_to_page", "Fit image to page",
|
|
||||||
kMsgFitToPageSelected, op == PrintOptions::kFitToPage);
|
kMsgFitToPageSelected, op == PrintOptions::kFitToPage);
|
||||||
textAt = at;
|
|
||||||
rb = AddRadioButton(panel, at, "zoom_factor", "Zoom factor in %: ",
|
rbZoom = AddRadioButton("zoom_factor", TR("Zoom factor in %:"),
|
||||||
kMsgZoomFactorSelected, op == PrintOptions::kZoomFactor);
|
kMsgZoomFactorSelected, op == PrintOptions::kZoomFactor);
|
||||||
textAt.x = rb->Bounds().right + 5;
|
|
||||||
fZoomFactor = AddTextControl(panel, textAt, "zoom_factor_text", "",
|
|
||||||
fCurrentOptions.ZoomFactor()*100, 0, kMsgZoomFactorChanged);
|
|
||||||
|
|
||||||
textAt = at;
|
fZoomFactor = AddTextControl("zoom_factor_text", "",
|
||||||
rb = AddRadioButton(panel, at, "dpi", "DPI: ", kMsgDPISelected,
|
fCurrentOptions.ZoomFactor() * 100, kMsgZoomFactorChanged);
|
||||||
|
|
||||||
|
rbDpi = AddRadioButton("dpi", TR("DPI:"), kMsgDPISelected,
|
||||||
op == PrintOptions::kDPI);
|
op == PrintOptions::kDPI);
|
||||||
textAt.x = rb->Bounds().right + 5;
|
|
||||||
fDPI = AddTextControl(panel, textAt, "dpi_text", "", fCurrentOptions.DPI(),
|
|
||||||
0, kMsgDPIChanged);
|
|
||||||
|
|
||||||
rb = AddRadioButton(panel, at, "width_and_height",
|
fDPI = AddTextControl("dpi_text", "", fCurrentOptions.DPI(),
|
||||||
"Resize to (in 1/72 inches):", kMsgWidthAndHeightSelected,
|
kMsgDPIChanged);
|
||||||
|
|
||||||
|
rbResize = AddRadioButton("width_and_height",
|
||||||
|
TR("Resize to (in 1/72 inches):"), kMsgWidthAndHeightSelected,
|
||||||
op == PrintOptions::kWidth || op == PrintOptions::kHeight);
|
op == PrintOptions::kWidth || op == PrintOptions::kHeight);
|
||||||
at.x += 15;
|
|
||||||
textAt = at;
|
|
||||||
fWidth = AddTextControl(panel, textAt, "width", "Width: ",
|
|
||||||
fCurrentOptions.Width(), 40, kMsgWidthChanged);
|
|
||||||
textAt = at;
|
|
||||||
textAt.x += fWidth->Bounds().Width() + 5;
|
|
||||||
fHeight = AddTextControl(panel, textAt, "height", "Height: ",
|
|
||||||
fCurrentOptions.Height(), 40, kMsgHeightChanged);
|
|
||||||
|
|
||||||
at.x = 0;
|
fWidth = AddTextControl("width", TR("Width:"),
|
||||||
at.y = textAt.y;
|
fCurrentOptions.Width(), kMsgWidthChanged);
|
||||||
line = new BBox(BRect(rect.left+3, at.y, rect.right-3, at.y + 1), NULL,
|
|
||||||
B_FOLLOW_LEFT | B_FOLLOW_TOP);
|
|
||||||
panel->AddChild(line);
|
|
||||||
|
|
||||||
at.y += 10;
|
fHeight = AddTextControl("height", TR("Height: "),
|
||||||
rect.OffsetBy(at);
|
fCurrentOptions.Height(), kMsgHeightChanged);
|
||||||
button = new BButton(rect, "job setup", "Job setup",
|
|
||||||
|
line = new BBox(B_EMPTY_STRING, B_WILL_DRAW | B_FRAME_EVENTS,
|
||||||
|
B_FANCY_BORDER);
|
||||||
|
line->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));
|
||||||
|
|
||||||
|
button = new BButton("job setup", TR("Job setup"),
|
||||||
new BMessage(kMsgJobSetup));
|
new BMessage(kMsgJobSetup));
|
||||||
panel->AddChild(button);
|
|
||||||
button->ResizeToPreferred();
|
|
||||||
|
|
||||||
SetDefaultButton(button);
|
SetDefaultButton(button);
|
||||||
|
|
||||||
// resize window
|
const float spacing = be_control_look->DefaultItemSpacing();
|
||||||
ResizeTo(fHeight->Frame().right + kIndent, button->Frame().bottom + kIndent);
|
|
||||||
|
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||||
// center button
|
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
|
||||||
button->MoveTo((Bounds().Width()-button->Bounds().Width())/2,
|
.Add(BGridLayoutBuilder()
|
||||||
button->Frame().top);
|
.Add(rbFit, 0, 0)
|
||||||
|
.Add(rbZoom, 0, 1)
|
||||||
|
.Add(fZoomFactor, 1, 1)
|
||||||
|
.Add(rbDpi, 0, 2)
|
||||||
|
.Add(fDPI, 1, 2)
|
||||||
|
.Add(rbResize, 0, 3)
|
||||||
|
)
|
||||||
|
.AddGroup(B_HORIZONTAL, spacing)
|
||||||
|
.Add(fWidth)
|
||||||
|
.Add(fHeight)
|
||||||
|
.AddGlue()
|
||||||
|
.SetInsets(22, 0, 0, 0)
|
||||||
|
.End()
|
||||||
|
.Add(line)
|
||||||
|
.AddGroup(B_HORIZONTAL, 0)
|
||||||
|
.Add(button)
|
||||||
|
.End()
|
||||||
|
.SetInsets(spacing, spacing, spacing, spacing)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -245,14 +247,14 @@ PrintOptionsWindow::MessageReceived(BMessage* msg)
|
|||||||
case kMsgZoomFactorChanged:
|
case kMsgZoomFactorChanged:
|
||||||
if (GetValue(fZoomFactor, &value)
|
if (GetValue(fZoomFactor, &value)
|
||||||
&& fCurrentOptions.ZoomFactor() != value) {
|
&& fCurrentOptions.ZoomFactor() != value) {
|
||||||
fCurrentOptions.SetZoomFactor(value/100);
|
fCurrentOptions.SetZoomFactor(value / 100);
|
||||||
SetValue(fDPI, fCurrentOptions.DPI());
|
SetValue(fDPI, fCurrentOptions.DPI());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kMsgDPIChanged:
|
case kMsgDPIChanged:
|
||||||
if (GetValue(fDPI, &value) && fCurrentOptions.DPI() != value) {
|
if (GetValue(fDPI, &value) && fCurrentOptions.DPI() != value) {
|
||||||
fCurrentOptions.SetDPI(value);
|
fCurrentOptions.SetDPI(value);
|
||||||
SetValue(fZoomFactor, 100*fCurrentOptions.ZoomFactor());
|
SetValue(fZoomFactor, 100 * fCurrentOptions.ZoomFactor());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kMsgWidthChanged:
|
case kMsgWidthChanged:
|
||||||
|
@ -64,13 +64,11 @@ public:
|
|||||||
void MessageReceived(BMessage* msg);
|
void MessageReceived(BMessage* msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BRadioButton* AddRadioButton(BView* view, BPoint& at,
|
BRadioButton* AddRadioButton(const char* name, const char* label,
|
||||||
const char* name, const char* label,
|
|
||||||
uint32 what, bool selected);
|
uint32 what, bool selected);
|
||||||
|
|
||||||
BTextControl* AddTextControl(BView* view, BPoint& at,
|
BTextControl* AddTextControl(const char* name, const char* label,
|
||||||
const char* name, const char* label,
|
float value, uint32 what);
|
||||||
float value, float divider, uint32 what);
|
|
||||||
|
|
||||||
void Setup();
|
void Setup();
|
||||||
enum PrintOptions::Option MsgToOption(uint32 what);
|
enum PrintOptions::Option MsgToOption(uint32 what);
|
||||||
|
@ -17,7 +17,13 @@
|
|||||||
|
|
||||||
#include <Box.h>
|
#include <Box.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
|
#include <Catalog.h>
|
||||||
#include <CheckBox.h>
|
#include <CheckBox.h>
|
||||||
|
#include <ControlLook.h>
|
||||||
|
#include <GroupLayoutBuilder.h>
|
||||||
|
#include <GridLayoutBuilder.h>
|
||||||
|
#include <Locale.h>
|
||||||
|
#include <LayoutBuilder.h>
|
||||||
#include <RadioButton.h>
|
#include <RadioButton.h>
|
||||||
#include <Rect.h>
|
#include <Rect.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
@ -26,71 +32,56 @@
|
|||||||
#include "ShowImageConstants.h"
|
#include "ShowImageConstants.h"
|
||||||
|
|
||||||
|
|
||||||
static const char* kWidthLabel = "Width:";
|
#undef TR_CONTEXT
|
||||||
static const char* kHeightLabel = "Height:";
|
#define TR_CONTEXT "ResizerWindow"
|
||||||
static const char* kKeepAspectRatioLabel = "Keep original proportions";
|
|
||||||
static const char* kApplyLabel = "Apply";
|
|
||||||
|
|
||||||
static const float kLineDistance = 5;
|
|
||||||
static const float kHorizontalIndent = 10;
|
|
||||||
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,
|
BWindow(BRect(100, 100, 300, 300), TR("Resize"), B_FLOATING_WINDOW,
|
||||||
B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
|
B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS),
|
||||||
fOriginalWidth(width),
|
fOriginalWidth(width),
|
||||||
fOriginalHeight(height),
|
fOriginalHeight(height),
|
||||||
fTarget(target)
|
fTarget(target)
|
||||||
{
|
{
|
||||||
BView* back_view = new BView(Bounds(), "", B_FOLLOW_ALL, B_WILL_DRAW);
|
|
||||||
back_view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
AddChild(back_view);
|
|
||||||
|
|
||||||
const float widthLabelWidth = back_view->StringWidth(kWidthLabel);
|
|
||||||
const float heightLabelWidth = back_view->StringWidth(kHeightLabel);
|
|
||||||
const float column2 = max_c(widthLabelWidth, heightLabelWidth);
|
|
||||||
|
|
||||||
const float textControlWidth = column2 + back_view->StringWidth("999999");
|
|
||||||
const float keepAspectRatioLabelWidth = 20
|
|
||||||
+ back_view->StringWidth(kKeepAspectRatioLabel);
|
|
||||||
const float width2 = 2 * kHorizontalIndent
|
|
||||||
+ max_c(textControlWidth, keepAspectRatioLabelWidth);
|
|
||||||
|
|
||||||
ResizeTo(width2+1, Bounds().Height()+1);
|
|
||||||
|
|
||||||
const float top = kVerticalIndent;
|
|
||||||
const float left = kHorizontalIndent;
|
|
||||||
BRect rect(left, top, width2 - kHorizontalIndent, top + 10);
|
|
||||||
|
|
||||||
BString widthValue;
|
BString widthValue;
|
||||||
widthValue << width;
|
widthValue << width;
|
||||||
fWidth = new BTextControl(rect, "width", kWidthLabel, widthValue.String(),
|
fWidth = new BTextControl("width", TR("Width:"), widthValue.String(), NULL);
|
||||||
NULL);
|
|
||||||
fWidth->SetModificationMessage(new BMessage(kWidthModifiedMsg));
|
fWidth->SetModificationMessage(new BMessage(kWidthModifiedMsg));
|
||||||
AddControl(back_view, fWidth, column2, rect);
|
|
||||||
|
|
||||||
BString heightValue;
|
BString heightValue;
|
||||||
heightValue << height;
|
heightValue << height;
|
||||||
fHeight = new BTextControl(rect, "height", kHeightLabel,
|
fHeight = new BTextControl("height",
|
||||||
heightValue.String(), NULL);
|
TR("Height:"), heightValue.String(), NULL);
|
||||||
fHeight->SetModificationMessage(new BMessage(kHeightModifiedMsg));
|
fHeight->SetModificationMessage(new BMessage(kHeightModifiedMsg));
|
||||||
AddControl(back_view, fHeight, column2, rect);
|
|
||||||
|
fAspectRatio = new BCheckBox("Ratio",
|
||||||
fAspectRatio = new BCheckBox(rect, "Ratio", kKeepAspectRatioLabel,
|
TR("Keep original proportions"), new BMessage(kWidthModifiedMsg));
|
||||||
new BMessage(kWidthModifiedMsg));
|
|
||||||
fAspectRatio->SetValue(B_CONTROL_ON);
|
fAspectRatio->SetValue(B_CONTROL_ON);
|
||||||
AddControl(back_view, fAspectRatio, column2, rect);
|
|
||||||
|
fApply = new BButton("apply", TR("Apply"), new BMessage(kApplyMsg));
|
||||||
fApply = new BButton(rect, "apply", kApplyLabel, new BMessage(kApplyMsg));
|
|
||||||
fApply->MakeDefault(true);
|
fApply->MakeDefault(true);
|
||||||
AddControl(back_view, fApply, column2, rect);
|
|
||||||
LeftAlign(fApply);
|
const float spacing = be_control_look->DefaultItemSpacing();
|
||||||
|
const float labelspacing = be_control_look->DefaultLabelSpacing();
|
||||||
|
|
||||||
|
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||||
|
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
|
||||||
|
.Add(BGridLayoutBuilder(labelspacing, 0)
|
||||||
|
.Add(fWidth->CreateLabelLayoutItem(), 0, 0)
|
||||||
|
.Add(fWidth->CreateTextViewLayoutItem(), 1, 0)
|
||||||
|
.Add(fHeight->CreateLabelLayoutItem(), 0, 1)
|
||||||
|
.Add(fHeight->CreateTextViewLayoutItem(), 1, 1)
|
||||||
|
)
|
||||||
|
.Add(fAspectRatio)
|
||||||
|
.AddGroup(B_HORIZONTAL, 0)
|
||||||
|
.AddGlue()
|
||||||
|
.Add(fApply)
|
||||||
|
.End()
|
||||||
|
.SetInsets(spacing, spacing, spacing, spacing)
|
||||||
|
);
|
||||||
|
|
||||||
fWidth->MakeFocus();
|
fWidth->MakeFocus();
|
||||||
|
|
||||||
ResizeTo(width2, rect.top);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -99,52 +90,6 @@ ResizerWindow::~ResizerWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ResizerWindow::AddControl(BView* view, BControl* control, float column2,
|
|
||||||
BRect& rect)
|
|
||||||
{
|
|
||||||
float width, height;
|
|
||||||
view->AddChild(control);
|
|
||||||
control->GetPreferredSize(&width, &height);
|
|
||||||
if (dynamic_cast<BButton*>(control) != NULL) {
|
|
||||||
control->ResizeTo(width, height);
|
|
||||||
} else {
|
|
||||||
control->ResizeTo(control->Bounds().Width(), height);
|
|
||||||
}
|
|
||||||
float top = control->Frame().bottom + kLineDistance;
|
|
||||||
rect.OffsetTo(rect.left, top);
|
|
||||||
|
|
||||||
if (dynamic_cast<BTextControl*>(control) != NULL) {
|
|
||||||
((BTextControl*)control)->SetDivider(column2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ResizerWindow::AddSeparatorLine(BView* view, BRect& rect)
|
|
||||||
{
|
|
||||||
const float lineWidth = 3;
|
|
||||||
BRect line(Bounds());
|
|
||||||
line.left += 3;
|
|
||||||
line.right -= 3;
|
|
||||||
line.top = rect.top;
|
|
||||||
line.bottom = line.top + lineWidth - 1;
|
|
||||||
BBox* separatorLine = new BBox(line, "", B_FOLLOW_LEFT_RIGHT,
|
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER);
|
|
||||||
view->AddChild(separatorLine);
|
|
||||||
rect.OffsetBy(0, kLineDistance + lineWidth);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ResizerWindow::LeftAlign(BControl* control)
|
|
||||||
{
|
|
||||||
BRect frame = control->Frame();
|
|
||||||
float left = Bounds().Width() - frame.Width() - kHorizontalIndent;
|
|
||||||
control->MoveTo(left, frame.top);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ResizerWindow::MessageReceived(BMessage* message)
|
ResizerWindow::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <Messenger.h>
|
#include <Messenger.h>
|
||||||
#include <View.h>
|
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
class BCheckBox;
|
class BCheckBox;
|
||||||
@ -50,10 +49,6 @@ class ResizerWindow : public BWindow {
|
|||||||
kApplyMsg,
|
kApplyMsg,
|
||||||
};
|
};
|
||||||
|
|
||||||
void AddControl(BView* parent, BControl* control,
|
|
||||||
float column2, BRect& rect);
|
|
||||||
void AddSeparatorLine(BView* parent, BRect& rect);
|
|
||||||
void LeftAlign(BControl* control);
|
|
||||||
|
|
||||||
BTextControl* fWidth;
|
BTextControl* fWidth;
|
||||||
BTextControl* fHeight;
|
BTextControl* fHeight;
|
||||||
|
@ -15,8 +15,10 @@
|
|||||||
|
|
||||||
#include <AboutWindow.h>
|
#include <AboutWindow.h>
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
|
#include <Catalog.h>
|
||||||
#include <Clipboard.h>
|
#include <Clipboard.h>
|
||||||
#include <FilePanel.h>
|
#include <FilePanel.h>
|
||||||
|
#include <Locale.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
@ -26,13 +28,15 @@
|
|||||||
|
|
||||||
#define WINDOWS_TO_IGNORE 1
|
#define WINDOWS_TO_IGNORE 1
|
||||||
|
|
||||||
extern const char *kApplicationSignature = "application/x-vnd.Haiku-ShowImage";
|
extern const char* kApplicationSignature = "application/x-vnd.Haiku-ShowImage";
|
||||||
|
|
||||||
|
|
||||||
ShowImageApp::ShowImageApp()
|
ShowImageApp::ShowImageApp()
|
||||||
:
|
:
|
||||||
BApplication(kApplicationSignature)
|
BApplication(kApplicationSignature)
|
||||||
{
|
{
|
||||||
|
be_locale->GetAppCatalog(&fCatalog);
|
||||||
|
|
||||||
fPulseStarted = false;
|
fPulseStarted = false;
|
||||||
fOpenPanel = new BFilePanel(B_OPEN_PANEL);
|
fOpenPanel = new BFilePanel(B_OPEN_PANEL);
|
||||||
}
|
}
|
||||||
@ -43,17 +47,20 @@ ShowImageApp::~ShowImageApp()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#undef TR_CONTEXT
|
||||||
|
#define TR_CONTEXT "AboutWindow"
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageApp::AboutRequested()
|
ShowImageApp::AboutRequested()
|
||||||
{
|
{
|
||||||
const char *authors[] = {
|
const char* authors[] = {
|
||||||
"Fernando F. Oliveira",
|
"Fernando F. Oliveira",
|
||||||
"Michael Wilber",
|
"Michael Wilber",
|
||||||
"Michael Pfeiffer",
|
"Michael Pfeiffer",
|
||||||
"Ryan Leavengood",
|
"Ryan Leavengood",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
BAboutWindow about("ShowImage", 2003, authors);
|
BAboutWindow about(TR("ShowImage"), 2003, authors);
|
||||||
about.Show();
|
about.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +116,7 @@ ShowImageApp::ArgvReceived(int32 argc, char **argv)
|
|||||||
bool hasRefs = false;
|
bool hasRefs = false;
|
||||||
|
|
||||||
// get current working directory
|
// get current working directory
|
||||||
const char *cwd;
|
const char* cwd;
|
||||||
if (CurrentMessage() == NULL
|
if (CurrentMessage() == NULL
|
||||||
|| CurrentMessage()->FindString("cwd", &cwd) != B_OK)
|
|| CurrentMessage()->FindString("cwd", &cwd) != B_OK)
|
||||||
cwd = "";
|
cwd = "";
|
||||||
@ -139,7 +146,7 @@ ShowImageApp::ArgvReceived(int32 argc, char **argv)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageApp::MessageReceived(BMessage *message)
|
ShowImageApp::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case MSG_FILE_OPEN:
|
case MSG_FILE_OPEN:
|
||||||
@ -167,7 +174,7 @@ ShowImageApp::MessageReceived(BMessage *message)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageApp::RefsReceived(BMessage *message)
|
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 (message->HasMessenger("TrackerViewToken"))
|
||||||
@ -188,14 +195,14 @@ ShowImageApp::RefsReceived(BMessage *message)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageApp::Open(const entry_ref *ref)
|
ShowImageApp::Open(const entry_ref* ref)
|
||||||
{
|
{
|
||||||
new ShowImageWindow(ref, fTrackerMessenger);
|
new ShowImageWindow(ref, fTrackerMessenger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageApp::BroadcastToWindows(BMessage *message)
|
ShowImageApp::BroadcastToWindows(BMessage* message)
|
||||||
{
|
{
|
||||||
const int32 count = CountWindows();
|
const int32 count = CountWindows();
|
||||||
for (int32 i = 0; i < count; i ++) {
|
for (int32 i = 0; i < count; i ++) {
|
||||||
@ -217,7 +224,7 @@ ShowImageApp::CheckClipboard()
|
|||||||
bool dataAvailable = false;
|
bool dataAvailable = false;
|
||||||
|
|
||||||
if (be_clipboard->Lock()) {
|
if (be_clipboard->Lock()) {
|
||||||
BMessage *clip = be_clipboard->Data();
|
BMessage* clip = be_clipboard->Data();
|
||||||
if (clip != NULL) {
|
if (clip != NULL) {
|
||||||
BString className;
|
BString className;
|
||||||
if (clip->FindString("class", &className) == B_OK) {
|
if (clip->FindString("class", &className) == B_OK) {
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "ShowImageSettings.h"
|
#include "ShowImageSettings.h"
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
|
#include <Catalog.h>
|
||||||
#include <FilePanel.h>
|
#include <FilePanel.h>
|
||||||
|
|
||||||
|
|
||||||
@ -42,6 +43,7 @@ private:
|
|||||||
BFilePanel *fOpenPanel;
|
BFilePanel *fOpenPanel;
|
||||||
bool fPulseStarted;
|
bool fPulseStarted;
|
||||||
ShowImageSettings fSettings;
|
ShowImageSettings fSettings;
|
||||||
|
BCatalog fCatalog;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,10 +21,12 @@
|
|||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
#include <BitmapStream.h>
|
#include <BitmapStream.h>
|
||||||
|
#include <Catalog.h>
|
||||||
#include <Clipboard.h>
|
#include <Clipboard.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <FilePanel.h>
|
#include <FilePanel.h>
|
||||||
|
#include <Locale.h>
|
||||||
#include <Menu.h>
|
#include <Menu.h>
|
||||||
#include <MenuBar.h>
|
#include <MenuBar.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
@ -38,6 +40,7 @@
|
|||||||
#include <TranslationDefs.h>
|
#include <TranslationDefs.h>
|
||||||
#include <TranslationUtils.h>
|
#include <TranslationUtils.h>
|
||||||
#include <TranslatorRoster.h>
|
#include <TranslatorRoster.h>
|
||||||
|
#include <stdlib.h> // for bs_printf()
|
||||||
|
|
||||||
#include "EntryMenuItem.h"
|
#include "EntryMenuItem.h"
|
||||||
#include "ResizerWindow.h"
|
#include "ResizerWindow.h"
|
||||||
@ -51,7 +54,7 @@
|
|||||||
|
|
||||||
class ShowImageWindow::RecentDocumentsMenu : public BMenu {
|
class ShowImageWindow::RecentDocumentsMenu : public BMenu {
|
||||||
public:
|
public:
|
||||||
RecentDocumentsMenu(const char *title,
|
RecentDocumentsMenu(const char* title,
|
||||||
menu_layout layout = B_ITEMS_IN_COLUMN);
|
menu_layout layout = B_ITEMS_IN_COLUMN);
|
||||||
bool AddDynamicItem(add_state addState);
|
bool AddDynamicItem(add_state addState);
|
||||||
|
|
||||||
@ -60,7 +63,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
ShowImageWindow::RecentDocumentsMenu::RecentDocumentsMenu(const char *title,
|
ShowImageWindow::RecentDocumentsMenu::RecentDocumentsMenu(const char* title,
|
||||||
menu_layout layout)
|
menu_layout layout)
|
||||||
:
|
:
|
||||||
BMenu(title, layout)
|
BMenu(title, layout)
|
||||||
@ -77,7 +80,7 @@ ShowImageWindow::RecentDocumentsMenu::AddDynamicItem(add_state addState)
|
|||||||
while (CountItems() > 0)
|
while (CountItems() > 0)
|
||||||
delete RemoveItem(0L);
|
delete RemoveItem(0L);
|
||||||
|
|
||||||
BMenuItem *item;
|
BMenuItem* item;
|
||||||
BMessage list, *msg;
|
BMessage list, *msg;
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
char name[B_FILE_NAME_LENGTH];
|
char name[B_FILE_NAME_LENGTH];
|
||||||
@ -106,7 +109,7 @@ const char* kTypeField = "be:type";
|
|||||||
const char* kTranslatorField = "be:translator";
|
const char* kTranslatorField = "be:translator";
|
||||||
|
|
||||||
|
|
||||||
ShowImageWindow::ShowImageWindow(const entry_ref *ref,
|
ShowImageWindow::ShowImageWindow(const entry_ref* ref,
|
||||||
const BMessenger& trackerMessenger)
|
const BMessenger& trackerMessenger)
|
||||||
:
|
:
|
||||||
BWindow(BRect(5, 24, 250, 100), "", B_DOCUMENT_WINDOW, 0),
|
BWindow(BRect(5, 24, 250, 100), "", B_DOCUMENT_WINDOW, 0),
|
||||||
@ -143,7 +146,7 @@ ShowImageWindow::ShowImageWindow(const entry_ref *ref,
|
|||||||
fImageView = new ShowImageView(viewFrame, "image_view", B_FOLLOW_ALL,
|
fImageView = new ShowImageView(viewFrame, "image_view", B_FOLLOW_ALL,
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED);
|
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED);
|
||||||
// wrap a scroll view around the view
|
// wrap a scroll view around the view
|
||||||
BScrollView *scrollView = new BScrollView("image_scroller", fImageView,
|
BScrollView* scrollView = new BScrollView("image_scroller", fImageView,
|
||||||
B_FOLLOW_ALL, 0, false, false, B_PLAIN_BORDER);
|
B_FOLLOW_ALL, 0, false, false, B_PLAIN_BORDER);
|
||||||
AddChild(scrollView);
|
AddChild(scrollView);
|
||||||
|
|
||||||
@ -154,7 +157,7 @@ ShowImageWindow::ShowImageWindow(const entry_ref *ref,
|
|||||||
rect.left = viewFrame.left + kstatusWidth;
|
rect.left = viewFrame.left + kstatusWidth;
|
||||||
rect.right = viewFrame.right + 1;
|
rect.right = viewFrame.right + 1;
|
||||||
rect.bottom += 1;
|
rect.bottom += 1;
|
||||||
BScrollBar *horizontalScrollBar = new BScrollBar(rect, "hscroll",
|
BScrollBar* horizontalScrollBar = new BScrollBar(rect, "hscroll",
|
||||||
fImageView, 0, 150, B_HORIZONTAL);
|
fImageView, 0, 150, B_HORIZONTAL);
|
||||||
AddChild(horizontalScrollBar);
|
AddChild(horizontalScrollBar);
|
||||||
|
|
||||||
@ -170,7 +173,7 @@ ShowImageWindow::ShowImageWindow(const entry_ref *ref,
|
|||||||
rect.left = viewFrame.right + 1;
|
rect.left = viewFrame.right + 1;
|
||||||
rect.bottom = viewFrame.bottom + 1;
|
rect.bottom = viewFrame.bottom + 1;
|
||||||
rect.right += 1;
|
rect.right += 1;
|
||||||
BScrollBar *verticalScrollBar = new BScrollBar(rect, "vscroll", fImageView,
|
BScrollBar* verticalScrollBar = new BScrollBar(rect, "vscroll", fImageView,
|
||||||
0, 150, B_VERTICAL);
|
0, 150, B_VERTICAL);
|
||||||
AddChild(verticalScrollBar);
|
AddChild(verticalScrollBar);
|
||||||
|
|
||||||
@ -180,11 +183,14 @@ ShowImageWindow::ShowImageWindow(const entry_ref *ref,
|
|||||||
fImageView->SetImage(ref);
|
fImageView->SetImage(ref);
|
||||||
fImageView->SetTrackerMessenger(trackerMessenger);
|
fImageView->SetTrackerMessenger(trackerMessenger);
|
||||||
|
|
||||||
|
#undef TR_CONTEXT
|
||||||
|
#define TR_CONTEXT "LoadAlerts"
|
||||||
|
|
||||||
if (InitCheck() != B_OK) {
|
if (InitCheck() != B_OK) {
|
||||||
BAlert* alert;
|
BAlert* alert;
|
||||||
alert = new BAlert("ShowImage",
|
alert = new BAlert(TR("ShowImage"),
|
||||||
"Could not load image! Either the file or an image translator for "
|
TR("Could not load image! Either the file or an image translator for it does not exist."),
|
||||||
"it does not exist.", "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_INFO_ALERT);
|
TR("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_INFO_ALERT);
|
||||||
alert->Go();
|
alert->Go();
|
||||||
|
|
||||||
// quit if file could not be opened
|
// quit if file could not be opened
|
||||||
@ -192,8 +198,11 @@ ShowImageWindow::ShowImageWindow(const entry_ref *ref,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef TR_CONTEXT
|
||||||
|
#define TR_CONTEXT "Menus"
|
||||||
|
|
||||||
// add View menu here so it can access ShowImageView methods
|
// add View menu here so it can access ShowImageView methods
|
||||||
BMenu* menu = new BMenu("View");
|
BMenu* menu = new BMenu(TR("View"));
|
||||||
_BuildViewMenu(menu, false);
|
_BuildViewMenu(menu, false);
|
||||||
fBar->AddItem(menu);
|
fBar->AddItem(menu);
|
||||||
_MarkMenuItem(fBar, MSG_DITHER_IMAGE, fImageView->GetDither());
|
_MarkMenuItem(fBar, MSG_DITHER_IMAGE, fImageView->GetDither());
|
||||||
@ -238,18 +247,21 @@ ShowImageWindow::UpdateTitle()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageWindow::BuildContextMenu(BMenu *menu)
|
ShowImageWindow::BuildContextMenu(BMenu* menu)
|
||||||
{
|
{
|
||||||
_BuildViewMenu(menu, true);
|
_BuildViewMenu(menu, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#undef TR_CONTEXT
|
||||||
|
#define TR_CONTEXT "Menus"
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageWindow::_BuildViewMenu(BMenu *menu, bool popupMenu)
|
ShowImageWindow::_BuildViewMenu(BMenu* menu, bool popupMenu)
|
||||||
{
|
{
|
||||||
_AddItemMenu(menu, "Slide show", MSG_SLIDE_SHOW, 0, 0, this);
|
_AddItemMenu(menu, TR("Slide show"), MSG_SLIDE_SHOW, 0, 0, this);
|
||||||
_MarkMenuItem(menu, MSG_SLIDE_SHOW, fImageView->SlideShowStarted());
|
_MarkMenuItem(menu, MSG_SLIDE_SHOW, fImageView->SlideShowStarted());
|
||||||
BMenu* delayMenu = new BMenu("Slide delay");
|
BMenu* delayMenu = new BMenu(TR("Slide delay"));
|
||||||
if (fSlideShowDelay == NULL)
|
if (fSlideShowDelay == NULL)
|
||||||
fSlideShowDelay = delayMenu;
|
fSlideShowDelay = delayMenu;
|
||||||
|
|
||||||
@ -258,38 +270,38 @@ ShowImageWindow::_BuildViewMenu(BMenu *menu, bool popupMenu)
|
|||||||
// if slide show delay is too short! (Especially if loading the image
|
// if slide show delay is too short! (Especially if loading the image
|
||||||
// takes as long as or longer than the slide show delay). Should load
|
// takes as long as or longer than the slide show delay). Should load
|
||||||
// in background thread!
|
// in background thread!
|
||||||
_AddDelayItem(delayMenu, "3 seconds", 3);
|
_AddDelayItem(delayMenu, TR("3 seconds"), 3);
|
||||||
_AddDelayItem(delayMenu, "4 seconds", 4);
|
_AddDelayItem(delayMenu, TR("4 seconds"), 4);
|
||||||
_AddDelayItem(delayMenu, "5 seconds", 5);
|
_AddDelayItem(delayMenu, TR("5 seconds"), 5);
|
||||||
_AddDelayItem(delayMenu, "6 seconds", 6);
|
_AddDelayItem(delayMenu, TR("6 seconds"), 6);
|
||||||
_AddDelayItem(delayMenu, "7 seconds", 7);
|
_AddDelayItem(delayMenu, TR("7 seconds"), 7);
|
||||||
_AddDelayItem(delayMenu, "8 seconds", 8);
|
_AddDelayItem(delayMenu, TR("8 seconds"), 8);
|
||||||
_AddDelayItem(delayMenu, "9 seconds", 9);
|
_AddDelayItem(delayMenu, TR("9 seconds"), 9);
|
||||||
_AddDelayItem(delayMenu, "10 seconds", 10);
|
_AddDelayItem(delayMenu, TR("10 seconds"), 10);
|
||||||
_AddDelayItem(delayMenu, "20 seconds", 20);
|
_AddDelayItem(delayMenu, TR("20 seconds"), 20);
|
||||||
menu->AddItem(delayMenu);
|
menu->AddItem(delayMenu);
|
||||||
|
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
|
|
||||||
_AddItemMenu(menu, "Original size", MSG_ORIGINAL_SIZE, '1', 0, this);
|
_AddItemMenu(menu, TR("Original size"), MSG_ORIGINAL_SIZE, '1', 0, this);
|
||||||
_AddItemMenu(menu, "Zoom in", MSG_ZOOM_IN, '+', 0, this);
|
_AddItemMenu(menu, TR("Zoom in"), MSG_ZOOM_IN, '+', 0, this);
|
||||||
_AddItemMenu(menu, "Zoom out", MSG_ZOOM_OUT, '-', 0, this);
|
_AddItemMenu(menu, TR("Zoom out"), MSG_ZOOM_OUT, '-', 0, this);
|
||||||
|
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
|
|
||||||
_AddItemMenu(menu, "High-quality zooming", MSG_SCALE_BILINEAR, 0, 0, this);
|
_AddItemMenu(menu, TR("High-quality zooming"), MSG_SCALE_BILINEAR, 0, 0, this);
|
||||||
|
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
|
|
||||||
_AddItemMenu(menu, "Shrink to window", MSG_SHRINK_TO_WINDOW, 0, 0, this);
|
_AddItemMenu(menu, TR("Shrink to window"), MSG_SHRINK_TO_WINDOW, 0, 0, this);
|
||||||
_AddItemMenu(menu, "Zoom to window", MSG_ZOOM_TO_WINDOW, 0, 0, this);
|
_AddItemMenu(menu, TR("Zoom to window"), MSG_ZOOM_TO_WINDOW, 0, 0, this);
|
||||||
|
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
|
|
||||||
_AddItemMenu(menu, "Full screen", MSG_FULL_SCREEN, B_ENTER, 0, this);
|
_AddItemMenu(menu, TR("Full screen"), MSG_FULL_SCREEN, B_ENTER, 0, this);
|
||||||
_MarkMenuItem(menu, MSG_FULL_SCREEN, fFullScreen);
|
_MarkMenuItem(menu, MSG_FULL_SCREEN, fFullScreen);
|
||||||
|
|
||||||
_AddItemMenu(menu, "Show caption in full screen mode", MSG_SHOW_CAPTION, 0,
|
_AddItemMenu(menu, TR("Show caption in full screen mode"), MSG_SHOW_CAPTION, 0,
|
||||||
0, this);
|
0, this);
|
||||||
_MarkMenuItem(menu, MSG_SHOW_CAPTION, fShowCaption);
|
_MarkMenuItem(menu, MSG_SHOW_CAPTION, fShowCaption);
|
||||||
|
|
||||||
@ -309,84 +321,92 @@ ShowImageWindow::_BuildViewMenu(BMenu *menu, bool popupMenu)
|
|||||||
|
|
||||||
if (popupMenu) {
|
if (popupMenu) {
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
_AddItemMenu(menu, "Use as background" B_UTF8_ELLIPSIS, MSG_DESKTOP_BACKGROUND, 0, 0,
|
_AddItemMenu(menu, TR("Use as background" B_UTF8_ELLIPSIS),
|
||||||
this);
|
MSG_DESKTOP_BACKGROUND, 0, 0, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageWindow::AddMenus(BMenuBar *bar)
|
ShowImageWindow::AddMenus(BMenuBar* bar)
|
||||||
{
|
{
|
||||||
BMenu *menu = new BMenu("File");
|
BMenu* menu = new BMenu(TR("File"));
|
||||||
fOpenMenu = new RecentDocumentsMenu("Open");
|
fOpenMenu = new RecentDocumentsMenu(TR("Open"));
|
||||||
menu->AddItem(fOpenMenu);
|
menu->AddItem(fOpenMenu);
|
||||||
fOpenMenu->Superitem()->SetTrigger('O');
|
fOpenMenu->Superitem()->SetTrigger('O');
|
||||||
fOpenMenu->Superitem()->SetMessage(new BMessage(MSG_FILE_OPEN));
|
fOpenMenu->Superitem()->SetMessage(new BMessage(MSG_FILE_OPEN));
|
||||||
fOpenMenu->Superitem()->SetTarget(be_app);
|
fOpenMenu->Superitem()->SetTarget(be_app);
|
||||||
fOpenMenu->Superitem()->SetShortcut('O', 0);
|
fOpenMenu->Superitem()->SetShortcut('O', 0);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
BMenu *pmenuSaveAs = new BMenu("Save as" B_UTF8_ELLIPSIS, B_ITEMS_IN_COLUMN);
|
BMenu *pmenuSaveAs = new BMenu(TR("Save as" B_UTF8_ELLIPSIS),
|
||||||
|
B_ITEMS_IN_COLUMN);
|
||||||
BTranslationUtils::AddTranslationItems(pmenuSaveAs, B_TRANSLATOR_BITMAP);
|
BTranslationUtils::AddTranslationItems(pmenuSaveAs, B_TRANSLATOR_BITMAP);
|
||||||
// Fill Save As submenu with all types that can be converted
|
// Fill Save As submenu with all types that can be converted
|
||||||
// to from the Be bitmap image format
|
// to from the Be bitmap image format
|
||||||
menu->AddItem(pmenuSaveAs);
|
menu->AddItem(pmenuSaveAs);
|
||||||
_AddItemMenu(menu, "Close", B_QUIT_REQUESTED, 'W', 0, this);
|
_AddItemMenu(menu, TR("Close"), B_QUIT_REQUESTED, 'W', 0, this);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
_AddItemMenu(menu, "Page setup" B_UTF8_ELLIPSIS, MSG_PAGE_SETUP, 0, 0, this);
|
_AddItemMenu(menu, TR("Page setup" B_UTF8_ELLIPSIS),
|
||||||
_AddItemMenu(menu, "Print" B_UTF8_ELLIPSIS, MSG_PREPARE_PRINT, 'P', 0, this);
|
MSG_PAGE_SETUP, 0, 0, this);
|
||||||
|
_AddItemMenu(menu, TR("Print" B_UTF8_ELLIPSIS),
|
||||||
|
MSG_PREPARE_PRINT, 'P', 0, this);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
_AddItemMenu(menu, "About ShowImage" B_UTF8_ELLIPSIS, B_ABOUT_REQUESTED, 0, 0,
|
_AddItemMenu(menu, TR("About ShowImage" B_UTF8_ELLIPSIS),
|
||||||
be_app);
|
B_ABOUT_REQUESTED, 0, 0, be_app);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
_AddItemMenu(menu, "Quit", B_QUIT_REQUESTED, 'Q', 0, be_app);
|
_AddItemMenu(menu, TR("Quit"), B_QUIT_REQUESTED, 'Q', 0, be_app);
|
||||||
bar->AddItem(menu);
|
bar->AddItem(menu);
|
||||||
|
|
||||||
menu = new BMenu("Edit");
|
menu = new BMenu(TR("Edit"));
|
||||||
_AddItemMenu(menu, "Undo", B_UNDO, 'Z', 0, this, false);
|
_AddItemMenu(menu, TR("Undo"), B_UNDO, 'Z', 0, this, false);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
_AddItemMenu(menu, "Cut", B_CUT, 'X', 0, this, false);
|
_AddItemMenu(menu, TR("Cut"), B_CUT, 'X', 0, this, false);
|
||||||
_AddItemMenu(menu, "Copy", B_COPY, 'C', 0, this, false);
|
_AddItemMenu(menu, TR("Copy"), B_COPY, 'C', 0, this, false);
|
||||||
_AddItemMenu(menu, "Paste", B_PASTE, 'V', 0, this, false);
|
_AddItemMenu(menu, TR("Paste"), B_PASTE, 'V', 0, this, false);
|
||||||
_AddItemMenu(menu, "Clear", MSG_CLEAR_SELECT, 0, 0, this, false);
|
_AddItemMenu(menu, TR("Clear"), MSG_CLEAR_SELECT, 0, 0, this, false);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
_AddItemMenu(menu, "Select all", MSG_SELECT_ALL, 'A', 0, this);
|
_AddItemMenu(menu, TR("Select all"), MSG_SELECT_ALL, 'A', 0, this);
|
||||||
bar->AddItem(menu);
|
bar->AddItem(menu);
|
||||||
|
|
||||||
menu = fBrowseMenu = new BMenu("Browse");
|
menu = fBrowseMenu = new BMenu(TR("Browse"));
|
||||||
_AddItemMenu(menu, "First page", MSG_PAGE_FIRST, B_LEFT_ARROW, B_SHIFT_KEY, this);
|
_AddItemMenu(menu, TR("First page"),
|
||||||
_AddItemMenu(menu, "Last page", MSG_PAGE_LAST, B_RIGHT_ARROW, B_SHIFT_KEY, this);
|
MSG_PAGE_FIRST, B_LEFT_ARROW, B_SHIFT_KEY, this);
|
||||||
_AddItemMenu(menu, "Previous page", MSG_PAGE_PREV, B_LEFT_ARROW, 0, this);
|
_AddItemMenu(menu, TR("Last page"),
|
||||||
_AddItemMenu(menu, "Next page", MSG_PAGE_NEXT, B_RIGHT_ARROW, 0, this);
|
MSG_PAGE_LAST, B_RIGHT_ARROW, B_SHIFT_KEY, this);
|
||||||
fGoToPageMenu = new BMenu("Go to page");
|
_AddItemMenu(menu, TR("Previous page"), MSG_PAGE_PREV, B_LEFT_ARROW, 0, this);
|
||||||
|
_AddItemMenu(menu, TR("Next page"), MSG_PAGE_NEXT, B_RIGHT_ARROW, 0, this);
|
||||||
|
fGoToPageMenu = new BMenu(TR("Go to page"));
|
||||||
fGoToPageMenu->SetRadioMode(true);
|
fGoToPageMenu->SetRadioMode(true);
|
||||||
menu->AddItem(fGoToPageMenu);
|
menu->AddItem(fGoToPageMenu);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
_AddItemMenu(menu, "Previous file", MSG_FILE_PREV, B_UP_ARROW, 0, this);
|
_AddItemMenu(menu, TR("Previous file"), MSG_FILE_PREV, B_UP_ARROW, 0, this);
|
||||||
_AddItemMenu(menu, "Next file", MSG_FILE_NEXT, B_DOWN_ARROW, 0, this);
|
_AddItemMenu(menu, TR("Next file"), MSG_FILE_NEXT, B_DOWN_ARROW, 0, this);
|
||||||
bar->AddItem(menu);
|
bar->AddItem(menu);
|
||||||
|
|
||||||
menu = new BMenu("Image");
|
menu = new BMenu(TR("Image"));
|
||||||
_AddItemMenu(menu, "Rotate clockwise", MSG_ROTATE_90, 'R', 0, this);
|
_AddItemMenu(menu, TR("Rotate clockwise"), MSG_ROTATE_90, 'R', 0, this);
|
||||||
_AddItemMenu(menu, "Rotate counterclockwise", MSG_ROTATE_270, 'R', B_SHIFT_KEY, this);
|
_AddItemMenu(menu, TR("Rotate counterclockwise"),
|
||||||
|
MSG_ROTATE_270, 'R', B_SHIFT_KEY, this);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
_AddItemMenu(menu, "Flip left to right", MSG_FLIP_LEFT_TO_RIGHT, 0, 0, this);
|
_AddItemMenu(menu, TR("Flip left to right"),
|
||||||
_AddItemMenu(menu, "Flip top to bottom", MSG_FLIP_TOP_TO_BOTTOM, 0, 0, this);
|
MSG_FLIP_LEFT_TO_RIGHT, 0, 0, this);
|
||||||
|
_AddItemMenu(menu, TR("Flip top to bottom"),
|
||||||
|
MSG_FLIP_TOP_TO_BOTTOM, 0, 0, this);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
_AddItemMenu(menu, "Invert colors", MSG_INVERT, 0, 0, this);
|
_AddItemMenu(menu, TR("Invert colors"), MSG_INVERT, 0, 0, this);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
fResizeItem = _AddItemMenu(menu, "Resize" B_UTF8_ELLIPSIS,
|
fResizeItem = _AddItemMenu(menu, TR("Resize" B_UTF8_ELLIPSIS),
|
||||||
MSG_OPEN_RESIZER_WINDOW, 0, 0, this);
|
MSG_OPEN_RESIZER_WINDOW, 0, 0, this);
|
||||||
bar->AddItem(menu);
|
bar->AddItem(menu);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
_AddItemMenu(menu, "Use as background" B_UTF8_ELLIPSIS, MSG_DESKTOP_BACKGROUND, 0, 0,
|
_AddItemMenu(menu, TR("Use as background" B_UTF8_ELLIPSIS),
|
||||||
this);
|
MSG_DESKTOP_BACKGROUND, 0, 0, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMenuItem*
|
BMenuItem*
|
||||||
ShowImageWindow::_AddItemMenu(BMenu *menu, const char *label, uint32 what,
|
ShowImageWindow::_AddItemMenu(BMenu* menu, const char* label, uint32 what,
|
||||||
const char shortcut, uint32 modifier, const BHandler *target, bool enabled)
|
const char shortcut, uint32 modifier, const BHandler* target, bool enabled)
|
||||||
{
|
{
|
||||||
BMenuItem* item = new BMenuItem(label, new BMessage(what), shortcut, modifier);
|
BMenuItem* item = new BMenuItem(label, new BMessage(what), shortcut, modifier);
|
||||||
menu->AddItem(item);
|
menu->AddItem(item);
|
||||||
@ -399,7 +419,7 @@ ShowImageWindow::_AddItemMenu(BMenu *menu, const char *label, uint32 what,
|
|||||||
|
|
||||||
|
|
||||||
BMenuItem*
|
BMenuItem*
|
||||||
ShowImageWindow::_AddDelayItem(BMenu *menu, const char *label, float value)
|
ShowImageWindow::_AddDelayItem(BMenu* menu, const char* label, float value)
|
||||||
{
|
{
|
||||||
BMessage* message = new BMessage(MSG_SLIDE_SHOW_DELAY);
|
BMessage* message = new BMessage(MSG_SLIDE_SHOW_DELAY);
|
||||||
message->AddFloat("value", value);
|
message->AddFloat("value", value);
|
||||||
@ -417,7 +437,7 @@ ShowImageWindow::_AddDelayItem(BMenu *menu, const char *label, float value)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageWindow::WindowRedimension(BBitmap *pbitmap)
|
ShowImageWindow::WindowRedimension(BBitmap* pbitmap)
|
||||||
{
|
{
|
||||||
BScreen screen;
|
BScreen screen;
|
||||||
if (!screen.IsValid())
|
if (!screen.IsValid())
|
||||||
@ -468,7 +488,7 @@ bool
|
|||||||
ShowImageWindow::_ToggleMenuItem(uint32 what)
|
ShowImageWindow::_ToggleMenuItem(uint32 what)
|
||||||
{
|
{
|
||||||
bool marked = false;
|
bool marked = false;
|
||||||
BMenuItem *item = fBar->FindItem(what);
|
BMenuItem* item = fBar->FindItem(what);
|
||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
marked = !item->IsMarked();
|
marked = !item->IsMarked();
|
||||||
item->SetMarked(marked);
|
item->SetMarked(marked);
|
||||||
@ -478,7 +498,7 @@ ShowImageWindow::_ToggleMenuItem(uint32 what)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageWindow::_EnableMenuItem(BMenu *menu, uint32 what, bool enable)
|
ShowImageWindow::_EnableMenuItem(BMenu* menu, uint32 what, bool enable)
|
||||||
{
|
{
|
||||||
BMenuItem* item = menu->FindItem(what);
|
BMenuItem* item = menu->FindItem(what);
|
||||||
if (item && item->IsEnabled() != enable)
|
if (item && item->IsEnabled() != enable)
|
||||||
@ -487,7 +507,7 @@ ShowImageWindow::_EnableMenuItem(BMenu *menu, uint32 what, bool enable)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageWindow::_MarkMenuItem(BMenu *menu, uint32 what, bool marked)
|
ShowImageWindow::_MarkMenuItem(BMenu* menu, uint32 what, bool marked)
|
||||||
{
|
{
|
||||||
BMenuItem* item = menu->FindItem(what);
|
BMenuItem* item = menu->FindItem(what);
|
||||||
if (item && item->IsMarked() != marked)
|
if (item && item->IsMarked() != marked)
|
||||||
@ -530,7 +550,7 @@ ShowImageWindow::_ResizeToWindow(bool shrink, uint32 what)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageWindow::MessageReceived(BMessage *message)
|
ShowImageWindow::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case MSG_MODIFIED:
|
case MSG_MODIFIED:
|
||||||
@ -578,7 +598,7 @@ ShowImageWindow::MessageReceived(BMessage *message)
|
|||||||
|
|
||||||
for (int32 i = 1; i <= pages; i++) {
|
for (int32 i = 1; i <= pages; i++) {
|
||||||
// Fill Go To page submenu with an entry for each page
|
// Fill Go To page submenu with an entry for each page
|
||||||
BMessage *pgomsg = new BMessage(MSG_GOTO_PAGE);
|
BMessage* pgomsg = new BMessage(MSG_GOTO_PAGE);
|
||||||
pgomsg->AddInt32("page", i);
|
pgomsg->AddInt32("page", i);
|
||||||
|
|
||||||
char shortcut = 0;
|
char shortcut = 0;
|
||||||
@ -591,7 +611,7 @@ ShowImageWindow::MessageReceived(BMessage *message)
|
|||||||
BString strCaption;
|
BString strCaption;
|
||||||
strCaption << i;
|
strCaption << i;
|
||||||
|
|
||||||
BMenuItem *item = new BMenuItem(strCaption.String(), pgomsg,
|
BMenuItem* item = new BMenuItem(strCaption.String(), pgomsg,
|
||||||
shortcut);
|
shortcut);
|
||||||
if (curPage == i)
|
if (curPage == i)
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
@ -786,7 +806,7 @@ ShowImageWindow::MessageReceived(BMessage *message)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_SLIDE_SHOW: {
|
case MSG_SLIDE_SHOW: {
|
||||||
BMenuItem *item = fBar->FindItem(message->what);
|
BMenuItem* item = fBar->FindItem(message->what);
|
||||||
if (!item)
|
if (!item)
|
||||||
break;
|
break;
|
||||||
if (item->IsMarked()) {
|
if (item->IsMarked()) {
|
||||||
@ -892,7 +912,7 @@ ShowImageWindow::MessageReceived(BMessage *message)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageWindow::_SaveAs(BMessage *message)
|
ShowImageWindow::_SaveAs(BMessage* message)
|
||||||
{
|
{
|
||||||
// Read the translator and output type the user chose
|
// Read the translator and output type the user chose
|
||||||
translator_id outTranslator;
|
translator_id outTranslator;
|
||||||
@ -922,14 +942,14 @@ ShowImageWindow::_SaveAs(BMessage *message)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageWindow::_SaveToFile(BMessage *message)
|
ShowImageWindow::_SaveToFile(BMessage* message)
|
||||||
{
|
{
|
||||||
// Read in where the file should be saved
|
// Read in where the file should be saved
|
||||||
entry_ref dirRef;
|
entry_ref dirRef;
|
||||||
if (message->FindRef("directory", &dirRef) != B_OK)
|
if (message->FindRef("directory", &dirRef) != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const char *filename;
|
const char* filename;
|
||||||
if (message->FindString("name", &filename) != B_OK)
|
if (message->FindString("name", &filename) != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -945,8 +965,8 @@ ShowImageWindow::_SaveToFile(BMessage *message)
|
|||||||
|
|
||||||
// Find the translator_format information needed to
|
// Find the translator_format information needed to
|
||||||
// write a MIME attribute for the image file
|
// write a MIME attribute for the image file
|
||||||
BTranslatorRoster *roster = BTranslatorRoster::Default();
|
BTranslatorRoster* roster = BTranslatorRoster::Default();
|
||||||
const translation_format *outFormat = NULL;
|
const translation_format* outFormat = NULL;
|
||||||
int32 outCount = 0;
|
int32 outCount = 0;
|
||||||
if (roster->GetOutputFormats(outTranslator, &outFormat, &outCount) != B_OK
|
if (roster->GetOutputFormats(outTranslator, &outFormat, &outCount) != B_OK
|
||||||
|| outCount < 1)
|
|| outCount < 1)
|
||||||
@ -966,6 +986,25 @@ ShowImageWindow::_SaveToFile(BMessage *message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// This is temporary solution for building BString with printf like format.
|
||||||
|
// will be removed in the future.
|
||||||
|
static void
|
||||||
|
bs_printf(BString* string, const char* format, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
char* buf;
|
||||||
|
|
||||||
|
va_start(ap, format);
|
||||||
|
vasprintf(&buf, format, ap);
|
||||||
|
string->SetTo(buf);
|
||||||
|
free(buf);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#undef TR_CONTEXT
|
||||||
|
#define TR_CONTEXT "ClosePrompt"
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ShowImageWindow::_ClosePrompt()
|
ShowImageWindow::_ClosePrompt()
|
||||||
{
|
{
|
||||||
@ -977,14 +1016,19 @@ ShowImageWindow::_ClosePrompt()
|
|||||||
page = fImageView->CurrentPage();
|
page = fImageView->CurrentPage();
|
||||||
BString prompt, name;
|
BString prompt, name;
|
||||||
fImageView->GetName(&name);
|
fImageView->GetName(&name);
|
||||||
prompt << "The document '" << name << "'";
|
|
||||||
if (count > 1)
|
|
||||||
prompt << " (page " << page << ")";
|
|
||||||
|
|
||||||
prompt << " has been changed. "
|
if (count > 1) {
|
||||||
<< "Do you want to close the document?";
|
bs_printf(&prompt,
|
||||||
BAlert *pAlert = new BAlert("Close document", prompt.String(),
|
TR("The document '%s' (page %d) has been changed. Do you want to close the document?"),
|
||||||
"Cancel", "Close");
|
name.String(), page);
|
||||||
|
} else {
|
||||||
|
bs_printf(&prompt,
|
||||||
|
TR("The document '%s' has been changed. Do you want to close the document?"),
|
||||||
|
name.String());
|
||||||
|
}
|
||||||
|
|
||||||
|
BAlert* pAlert = new BAlert(TR("Close document"), prompt.String(),
|
||||||
|
TR("Cancel"), TR("Close"));
|
||||||
if (pAlert->Go() == 0) {
|
if (pAlert->Go() == 0) {
|
||||||
// Cancel
|
// Cancel
|
||||||
return false;
|
return false;
|
||||||
@ -1104,15 +1148,15 @@ ShowImageWindow::_PrepareForPrint()
|
|||||||
}
|
}
|
||||||
|
|
||||||
fPrintOptions.SetBounds(fImageView->GetBitmap()->Bounds());
|
fPrintOptions.SetBounds(fImageView->GetBitmap()->Bounds());
|
||||||
fPrintOptions.SetWidth(fImageView->GetBitmap()->Bounds().Width()+1);
|
fPrintOptions.SetWidth(fImageView->GetBitmap()->Bounds().Width() + 1);
|
||||||
|
|
||||||
new PrintOptionsWindow(BPoint(Frame().left+30, Frame().top+50),
|
new PrintOptionsWindow(BPoint(Frame().left + 30, Frame().top + 50),
|
||||||
&fPrintOptions, this);
|
&fPrintOptions, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageWindow::_Print(BMessage *msg)
|
ShowImageWindow::_Print(BMessage* msg)
|
||||||
{
|
{
|
||||||
status_t st;
|
status_t st;
|
||||||
if (msg->FindInt32("status", &st) != B_OK || st != B_OK)
|
if (msg->FindInt32("status", &st) != B_OK || st != B_OK)
|
||||||
|
Loading…
Reference in New Issue
Block a user