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"
|
||||||
@ -68,12 +74,15 @@ PrintOptions::SetHeight(float h)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#undef TR_CONTEXT
|
||||||
|
#define TR_CONTEXT "PrintOptionsWindow"
|
||||||
|
|
||||||
PrintOptionsWindow::PrintOptionsWindow(BPoint at, PrintOptions* options,
|
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);
|
|
||||||
|
|
||||||
// center button
|
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||||
button->MoveTo((Bounds().Width()-button->Bounds().Width())/2,
|
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
|
||||||
button->Frame().top);
|
.Add(BGridLayoutBuilder()
|
||||||
|
.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)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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(rect, "Ratio", kKeepAspectRatioLabel,
|
fAspectRatio = new BCheckBox("Ratio",
|
||||||
new BMessage(kWidthModifiedMsg));
|
TR("Keep original proportions"), new BMessage(kWidthModifiedMsg));
|
||||||
fAspectRatio->SetValue(B_CONTROL_ON);
|
fAspectRatio->SetValue(B_CONTROL_ON);
|
||||||
AddControl(back_view, fAspectRatio, column2, rect);
|
|
||||||
|
|
||||||
fApply = new BButton(rect, "apply", kApplyLabel, new BMessage(kApplyMsg));
|
fApply = new BButton("apply", TR("Apply"), 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>
|
||||||
|
|
||||||
@ -33,6 +35,8 @@ 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,6 +47,9 @@ ShowImageApp::~ShowImageApp()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#undef TR_CONTEXT
|
||||||
|
#define TR_CONTEXT "AboutWindow"
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageApp::AboutRequested()
|
ShowImageApp::AboutRequested()
|
||||||
{
|
{
|
||||||
@ -53,7 +60,7 @@ ShowImageApp::AboutRequested()
|
|||||||
"Ryan Leavengood",
|
"Ryan Leavengood",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
BAboutWindow about("ShowImage", 2003, authors);
|
BAboutWindow about(TR("ShowImage"), 2003, authors);
|
||||||
about.Show();
|
about.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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"
|
||||||
@ -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());
|
||||||
@ -244,12 +253,15 @@ ShowImageWindow::BuildContextMenu(BMenu *menu)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#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,8 +321,8 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,69 +330,77 @@ ShowImageWindow::_BuildViewMenu(BMenu *menu, bool popupMenu)
|
|||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user