Made UI font size sensitive using layout manager.
Please review. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32226 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2008, Haiku. All rights reserved.
|
* Copyright 2002-2009, Haiku. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -24,6 +24,10 @@
|
|||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
// Haiku
|
||||||
|
#include <Layout.h>
|
||||||
|
#include <GroupLayout.h>
|
||||||
|
#include <GroupLayoutBuilder.h>
|
||||||
|
|
||||||
static const float a0_width = 2380.0;
|
static const float a0_width = 2380.0;
|
||||||
static const float a0_height = 3368.0;
|
static const float a0_height = 3368.0;
|
||||||
@@ -88,10 +92,19 @@ static void GetPageFormat(float w, float h, BString& label)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static BGroupLayoutBuilder
|
||||||
|
LeftAlign(BView* view)
|
||||||
|
{
|
||||||
|
return BGroupLayoutBuilder(B_HORIZONTAL)
|
||||||
|
.Add(view)
|
||||||
|
.AddGlue();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter,
|
ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter,
|
||||||
BMessage* settings, AutoReply* sender)
|
BMessage* settings, AutoReply* sender)
|
||||||
: BWindow(ConfigWindow::GetWindowFrame(), "Page Setup",
|
: BWindow(ConfigWindow::GetWindowFrame(), "Page Setup",
|
||||||
B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
|
B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
|
||||||
, fKind(kind)
|
, fKind(kind)
|
||||||
, fDefaultPrinter(defaultPrinter)
|
, fDefaultPrinter(defaultPrinter)
|
||||||
, fSettings(settings)
|
, fSettings(settings)
|
||||||
@@ -106,82 +119,91 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter,
|
|||||||
if (kind == kJobSetup)
|
if (kind == kJobSetup)
|
||||||
SetTitle("Print Setup");
|
SetTitle("Print Setup");
|
||||||
|
|
||||||
BView* panel = new BBox(Bounds(), "top_panel", B_FOLLOW_ALL,
|
BView* panel = new BBox(Bounds(), "temporary", B_FOLLOW_ALL, B_WILL_DRAW);
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
|
|
||||||
B_PLAIN_BORDER);
|
|
||||||
|
|
||||||
AddChild(panel);
|
AddChild(panel);
|
||||||
|
|
||||||
float left = 10, top = 10;
|
BRect dummyRect(0, 0, 1, 1);
|
||||||
BRect r(left, top, 160, 20);
|
|
||||||
|
|
||||||
// print selection popup menu
|
// print selection pop up menu
|
||||||
BPopUpMenu* menu = new BPopUpMenu("Select a Printer");
|
BPopUpMenu* menu = new BPopUpMenu("Select a Printer");
|
||||||
SetupPrintersMenu(menu);
|
SetupPrintersMenu(menu);
|
||||||
|
|
||||||
float width = be_plain_font->StringWidth("Printer:") + 10.0;
|
fPrinters = new BMenuField("Printer:", menu, NULL);
|
||||||
r.right = r.left + width + menu->MaxContentWidth() + 10;
|
|
||||||
fPrinters = new BMenuField(r, "Printer", "Printer:", menu);
|
|
||||||
fPrinters->SetDivider(width);
|
|
||||||
panel->AddChild(fPrinters);
|
|
||||||
top += fPrinters->Bounds().Height() + 10;
|
|
||||||
|
|
||||||
// page format button
|
// page format button
|
||||||
r.OffsetTo(left, top);
|
fPageSetup = AddPictureButton(panel, dummyRect, "Page Format", "PAGE_SETUP_ON",
|
||||||
fPageSetup = AddPictureButton(panel, r, "Page Format", "PAGE_SETUP_ON",
|
|
||||||
"PAGE_SETUP_OFF", MSG_PAGE_SETUP);
|
"PAGE_SETUP_OFF", MSG_PAGE_SETUP);
|
||||||
|
|
||||||
// add description to button
|
// add description to button
|
||||||
r.OffsetTo(left + fPageSetup->Bounds().Width() + 5, fPageSetup->Frame().top);
|
BStringView *pageFormatTitle = new BStringView("pageFormatTitle", "Paper Setup:");
|
||||||
BStringView *stringView = AddStringView(panel, r, "Paper Setup:");
|
fPageFormatText = new BStringView("pageFormatText", "");
|
||||||
stringView->ResizeToPreferred();
|
|
||||||
r = stringView->Frame();
|
|
||||||
r.OffsetBy(0, r.Height());
|
|
||||||
fPageFormatText = AddStringView(panel, r, "");
|
|
||||||
fPageFormatText->ResizeToPreferred();
|
|
||||||
top = fPageSetup->Frame().bottom + 15;
|
|
||||||
|
|
||||||
// page selection button
|
// page selection button
|
||||||
fJobSetup = NULL;
|
fJobSetup = NULL;
|
||||||
|
BStringView* jobSetupTitle = NULL;
|
||||||
if (kind == kJobSetup) {
|
if (kind == kJobSetup) {
|
||||||
r.OffsetTo(left, top);
|
fJobSetup = AddPictureButton(panel, dummyRect, "Page Selection", "JOB_SETUP_ON",
|
||||||
fJobSetup = AddPictureButton(panel, r, "Page Selection", "JOB_SETUP_ON",
|
|
||||||
"JOB_SETUP_OFF", MSG_JOB_SETUP);
|
"JOB_SETUP_OFF", MSG_JOB_SETUP);
|
||||||
// add description to button
|
// add description to button
|
||||||
r.OffsetTo(left + fJobSetup->Bounds().Width() + 5, top);
|
jobSetupTitle = new BStringView("jobSetupTitle", "Pages to Print:");
|
||||||
stringView = AddStringView(panel, r, "Pages to Print:");
|
fJobSetupText = new BStringView("jobSetupText", "");
|
||||||
stringView->ResizeToPreferred();
|
|
||||||
r.OffsetBy(0, stringView->Frame().Height());
|
|
||||||
fJobSetupText = AddStringView(panel, r, "");
|
|
||||||
fJobSetupText->ResizeToPreferred();
|
|
||||||
top = fJobSetup->Frame().bottom + 15;
|
|
||||||
}
|
}
|
||||||
top += 5;
|
|
||||||
|
|
||||||
// separator line
|
// separator line
|
||||||
BRect line(Bounds());
|
BBox* separator = new BBox(dummyRect, "line", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
|
||||||
line.OffsetTo(0, top);
|
separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));
|
||||||
line.bottom = line.top+1;
|
|
||||||
AddChild(new BBox(line, "line", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP));
|
|
||||||
top += 10;
|
|
||||||
|
|
||||||
// Cancel button
|
// Cancel & OK button
|
||||||
r.OffsetTo(left, top);
|
BButton* cancel = new BButton(dummyRect, "Cancel", "Cancel",
|
||||||
BButton* cancel = new BButton(r, "Cancel", "Cancel",
|
|
||||||
new BMessage(B_QUIT_REQUESTED));
|
new BMessage(B_QUIT_REQUESTED));
|
||||||
panel->AddChild(cancel);
|
fOk = new BButton(dummyRect, "OK", "OK", new BMessage(MSG_OK));
|
||||||
cancel->ResizeToPreferred();
|
|
||||||
left = cancel->Frame().right + 10;
|
|
||||||
|
|
||||||
// OK button
|
RemoveChild(panel);
|
||||||
r.OffsetTo(left, top);
|
|
||||||
fOk = new BButton(r, "OK", "OK", new BMessage(MSG_OK));
|
|
||||||
panel->AddChild(fOk);
|
|
||||||
fOk->ResizeToPreferred();
|
|
||||||
top += fOk->Bounds().Height() + 10;
|
|
||||||
|
|
||||||
// resize window
|
SetLayout(new BGroupLayout(B_VERTICAL));
|
||||||
ResizeTo(fOk->Frame().right + 10, top);
|
BGroupLayoutBuilder builder(B_VERTICAL);
|
||||||
|
|
||||||
|
builder
|
||||||
|
.Add(fPrinters)
|
||||||
|
.AddStrut(5)
|
||||||
|
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
|
||||||
|
.Add(fPageSetup)
|
||||||
|
.AddStrut(5)
|
||||||
|
.Add(BGroupLayoutBuilder(B_VERTICAL)
|
||||||
|
.Add(LeftAlign(pageFormatTitle))
|
||||||
|
.Add(LeftAlign(fPageFormatText))
|
||||||
|
)
|
||||||
|
.AddGlue()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fJobSetup != NULL) {
|
||||||
|
builder
|
||||||
|
.AddStrut(5)
|
||||||
|
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
|
||||||
|
.Add(fJobSetup)
|
||||||
|
.AddStrut(5)
|
||||||
|
.Add(BGroupLayoutBuilder(B_VERTICAL)
|
||||||
|
.Add(LeftAlign(jobSetupTitle))
|
||||||
|
.Add(LeftAlign(fJobSetupText))
|
||||||
|
)
|
||||||
|
.AddGlue()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
builder
|
||||||
|
.AddStrut(5)
|
||||||
|
.Add(separator)
|
||||||
|
.AddStrut(5)
|
||||||
|
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
|
||||||
|
.AddGlue()
|
||||||
|
.Add(cancel)
|
||||||
|
.AddStrut(5)
|
||||||
|
.Add(fOk)
|
||||||
|
.AddGlue()
|
||||||
|
)
|
||||||
|
.SetInsets(5, 5, 5, 5);
|
||||||
|
|
||||||
|
AddChild(builder);
|
||||||
|
|
||||||
AddShortcut('a', 0, new BMessage(B_ABOUT_REQUESTED));
|
AddShortcut('a', 0, new BMessage(B_ABOUT_REQUESTED));
|
||||||
|
|
||||||
@@ -307,6 +329,7 @@ BPictureButton* ConfigWindow::AddPictureButton(BView* panel, BRect frame,
|
|||||||
onBM->Lock();
|
onBM->Lock();
|
||||||
button->ResizeTo(onBM->Bounds().Width(), onBM->Bounds().Height());
|
button->ResizeTo(onBM->Bounds().Width(), onBM->Bounds().Height());
|
||||||
onBM->Unlock();
|
onBM->Unlock();
|
||||||
|
panel->RemoveChild(button);
|
||||||
|
|
||||||
BPicture* disabled = BitmapToGrayedPicture(panel, offBM);
|
BPicture* disabled = BitmapToGrayedPicture(panel, offBM);
|
||||||
button->SetDisabledOn(disabled);
|
button->SetDisabledOn(disabled);
|
||||||
@@ -324,17 +347,6 @@ BPictureButton* ConfigWindow::AddPictureButton(BView* panel, BRect frame,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BStringView* ConfigWindow::AddStringView(BView* panel, BRect frame, const char* text)
|
|
||||||
{
|
|
||||||
// frame.bottom = frame.top ;
|
|
||||||
BStringView* string = new BStringView(frame, "", text);
|
|
||||||
string->SetViewColor(panel->ViewColor());
|
|
||||||
string->SetLowColor(panel->ViewColor());
|
|
||||||
panel->AddChild(string);
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ConfigWindow::PrinterForMimeType()
|
void ConfigWindow::PrinterForMimeType()
|
||||||
{
|
{
|
||||||
BAutolock lock(gLock);
|
BAutolock lock(gLock);
|
||||||
@@ -426,11 +438,9 @@ void ConfigWindow::UpdateUI()
|
|||||||
if (fJobSetup) {
|
if (fJobSetup) {
|
||||||
fJobSetup->SetEnabled(false);
|
fJobSetup->SetEnabled(false);
|
||||||
fJobSetupText->SetText("Undefined job settings");
|
fJobSetupText->SetText("Undefined job settings");
|
||||||
fJobSetupText->ResizeToPreferred();
|
|
||||||
}
|
}
|
||||||
fOk->SetEnabled(false);
|
fOk->SetEnabled(false);
|
||||||
fPageFormatText->SetText("Undefined paper format");
|
fPageFormatText->SetText("Undefined paper format");
|
||||||
fPageFormatText->ResizeToPreferred();
|
|
||||||
} else {
|
} else {
|
||||||
fPageSetup->SetEnabled(true);
|
fPageSetup->SetEnabled(true);
|
||||||
|
|
||||||
@@ -456,7 +466,6 @@ void ConfigWindow::UpdateUI()
|
|||||||
pageFormat << "Undefined paper format";
|
pageFormat << "Undefined paper format";
|
||||||
}
|
}
|
||||||
fPageFormatText->SetText(pageFormat.String());
|
fPageFormatText->SetText(pageFormat.String());
|
||||||
fPageFormatText->ResizeToPreferred();
|
|
||||||
|
|
||||||
// display information about job
|
// display information about job
|
||||||
if (fKind == kJobSetup) {
|
if (fKind == kJobSetup) {
|
||||||
@@ -478,17 +487,8 @@ void ConfigWindow::UpdateUI()
|
|||||||
job << "Undefined job settings";
|
job << "Undefined job settings";
|
||||||
}
|
}
|
||||||
fJobSetupText->SetText(job.String());
|
fJobSetupText->SetText(job.String());
|
||||||
fJobSetupText->ResizeToPreferred();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fOk->Frame().right < fPageFormatText->Frame().right)
|
|
||||||
ResizeTo(fPageFormatText->Frame().right + 10, Bounds().bottom);
|
|
||||||
|
|
||||||
if (fJobSetupText) {
|
|
||||||
if (fOk->Frame().right < fJobSetupText->Frame().right)
|
|
||||||
ResizeTo(fJobSetupText->Frame().right + 10, Bounds().bottom);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
BPictureButton* AddPictureButton(BView* panel, BRect frame, const char* name,
|
BPictureButton* AddPictureButton(BView* panel, BRect frame, const char* name,
|
||||||
const char* on, const char* off, uint32 what);
|
const char* on, const char* off, uint32 what);
|
||||||
BStringView* AddStringView(BView* panel, BRect frame, const char* text);
|
|
||||||
void PrinterForMimeType();
|
void PrinterForMimeType();
|
||||||
void SetupPrintersMenu(BMenu* menu);
|
void SetupPrintersMenu(BMenu* menu);
|
||||||
void UpdateAppSettings(const char* mime, const char* printer);
|
void UpdateAppSettings(const char* mime, const char* printer);
|
||||||
|
|||||||
Reference in New Issue
Block a user