Author: laplace Date: 2010-10-16 21:56:34 +0200 (Sat, 16 Oct 2010) New Revision: 38986 Changeset: http://dev.haiku-os.org/changeset/38986 Removed: haiku/trunk/src/add-ons/print/drivers/pdf/source/PrinterSetupWindow.cpp haiku/trunk/src/add-ons/print/drivers/pdf/source/PrinterSetupWindow.h Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/headers/libs/print/libprint/JSDSlider.h haiku/trunk/headers/libs/print/libprint/JobSetupDlg.h haiku/trunk/headers/libs/print/libprint/MarginView.h haiku/trunk/headers/libs/print/libprint/PageSetupDlg.h haiku/trunk/src/add-ons/print/drivers/pdf/source/Jamfile haiku/trunk/src/add-ons/print/drivers/pdf/source/JobSetupWindow.cpp haiku/trunk/src/add-ons/print/drivers/pdf/source/JobSetupWindow.h haiku/trunk/src/add-ons/print/drivers/pdf/source/PageSetupWindow.cpp haiku/trunk/src/add-ons/print/drivers/pdf/source/PrinterDriver.cpp haiku/trunk/src/add-ons/print/drivers/preview/JobSetupWindow.cpp haiku/trunk/src/add-ons/print/drivers/preview/PageSetupWindow.cpp haiku/trunk/src/libs/print/libprint/JSDSlider.cpp haiku/trunk/src/libs/print/libprint/JobSetupDlg.cpp haiku/trunk/src/libs/print/libprint/MarginView.cpp haiku/trunk/src/libs/print/libprint/PageSetupDlg.cpp haiku/trunk/src/libs/print/libprint/StatusWindow.cpp haiku/trunk/src/servers/print/ConfigWindow.cpp Log: * Use layout API in libprint dialogs. * Use layout API in preview printer add-on. * Use layout API in some dialogs in PDF Writer. * Removed unused class PrinterSetupWindow from PDF Writer. * Improved layout in print_server configuration dialog. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2010-10-16 19:21:56 UTC (rev 38985) +++ haiku/trunk/build/jam/HaikuImage 2010-10-16 19:56:34 UTC (rev 38986) @@ -139,8 +139,14 @@ #legacy.media_addon ; SYSTEM_ADD_ONS_MEDIA_PLUGINS = $(X86_ONLY)ffmpeg raw_decoder ; -SYSTEM_ADD_ONS_PRINT = Canon\ LIPS3\ Compatible Canon\ LIPS4\ Compatible - PCL5\ Compatible PCL6\ Compatible PDF\ Writer PS\ Compatible Preview +SYSTEM_ADD_ONS_PRINT = + Canon\ LIPS3\ Compatible + Canon\ LIPS4\ Compatible + PCL5\ Compatible + PCL6\ Compatible + PDF\ Writer + PS\ Compatible + Preview ; SYSTEM_ADD_ONS_PRINT_TRANSPORT = HP\ JetDirect IPP LPR Parallel\ Port Print\ To\ File Serial\ Port USB\ Port Modified: haiku/trunk/headers/libs/print/libprint/JSDSlider.h =================================================================== --- haiku/trunk/headers/libs/print/libprint/JSDSlider.h 2010-10-16 19:21:56 UTC (rev 38985) +++ haiku/trunk/headers/libs/print/libprint/JSDSlider.h 2010-10-16 19:56:34 UTC (rev 38986) @@ -17,15 +17,12 @@ class JSDSlider : public BSlider { public: - JSDSlider(BRect frame, const char* name, const char *label, - BMessage *msg, int32 min, int32 max, thumb_style t); + JSDSlider(const char* name, const char* label, + BMessage* msg, int32 min, int32 max); virtual ~JSDSlider(); -#ifdef __HAIKU__ virtual const char* UpdateText() const; -#else - virtual char* UpdateText() const; -#endif + private: mutable BString fResult; }; Modified: haiku/trunk/headers/libs/print/libprint/JobSetupDlg.h =================================================================== --- haiku/trunk/headers/libs/print/libprint/JobSetupDlg.h 2010-10-16 19:21:56 UTC (rev 38985) +++ haiku/trunk/headers/libs/print/libprint/JobSetupDlg.h 2010-10-16 19:56:34 UTC (rev 38986) @@ -26,14 +26,15 @@ class JobSetupView : public BView { public: - JobSetupView(BRect frame, JobData *job_data, PrinterData *printer_data, const PrinterCap *printer_cap); + JobSetupView(JobData* job_data, PrinterData* printer_data, + const PrinterCap* printer_cap); virtual void AttachedToWindow(); - virtual void MessageReceived(BMessage *msg); + virtual void MessageReceived(BMessage* msg); bool UpdateJobData(bool showPreview); private: void UpdateButtonEnabledState(); - BRadioButton* AddPageSelectionItem(BView* parent, BRect rect, const char* name, const char* label, + BRadioButton* CreatePageSelectionItem(const char* name, const char* label, JobData::PageSelection pageSelection); void AllowOnlyDigits(BTextView* textView, int maxDigits); JobData::Color getColor(); Modified: haiku/trunk/headers/libs/print/libprint/MarginView.h =================================================================== --- haiku/trunk/headers/libs/print/libprint/MarginView.h 2010-10-16 19:21:56 UTC (rev 38985) +++ haiku/trunk/headers/libs/print/libprint/MarginView.h 2010-10-16 19:56:34 UTC (rev 38986) @@ -143,6 +143,24 @@ kUnitPoint }; +class PageView : public BView +{ +public: + PageView(); + + void SetPageSize(float pageWidth, float pageHeight); + void SetMargins(BRect margins); + + virtual void Draw(BRect bounds); + + +private: + float fPageWidth; + float fPageHeight; + + BRect fMargins; +}; + /** * Class MarginView */ @@ -151,7 +169,7 @@ friend class MarginManager; public: - MarginView(BRect rect, int32 pageWidth = 0, + MarginView(int32 pageWidth = 0, int32 pageHeight = 0, BRect margins = BRect(1, 1, 1, 1), // 1 inch MarginUnit unit = kUnitInch); @@ -159,8 +177,6 @@ virtual ~MarginView(); virtual void AttachedToWindow(); - virtual void Draw(BRect rect); - virtual void FrameResized(float width, float height); virtual void MessageReceived(BMessage *msg); // point.x = width, point.y = height @@ -190,33 +206,25 @@ // performed internally using the supplied popup void _SetMarginUnit(MarginUnit unit); - // Calculate the view size for the margins - void _CalculateViewSize(uint32 msg); - private: BTextControl* fTop; BTextControl* fBottom; BTextControl* fLeft; BTextControl* fRight; - // rect that holds the margins for the page as a set of point offsets - BRect fMargins; - - // the maximum size of the page view calculated from the view size - float fMaxPageWidth; - float fMaxPageHeight; - // the actual size of the page in points float fPageHeight; float fPageWidth; + // rect that holds the margins for the page as a set of point offsets + BRect fMargins; + // the units used to calculate the page size MarginUnit fMarginUnit; float fUnitValue; - // the size of the drawing area we have to draw the view in pixels - float fViewHeight; - float fViewWidth; + PageView* fPage; + BStringView* fPageSize; }; #endif // _MARGIN_VIEW_H Modified: haiku/trunk/headers/libs/print/libprint/PageSetupDlg.h =================================================================== --- haiku/trunk/headers/libs/print/libprint/PageSetupDlg.h 2010-10-16 19:21:56 UTC (rev 38985) +++ haiku/trunk/headers/libs/print/libprint/PageSetupDlg.h 2010-10-16 19:56:34 UTC (rev 38986) @@ -20,7 +20,8 @@ class PageSetupView : public BView { public: - PageSetupView(BRect frame, JobData *job_data, PrinterData *printer_data, const PrinterCap *printer_cap); + PageSetupView(JobData *job_data, PrinterData *printer_data, + const PrinterCap *printer_cap); ~PageSetupView(); virtual void AttachedToWindow(); bool UpdateJobData(); @@ -43,11 +44,13 @@ class PageSetupDlg : public DialogWindow { public: - PageSetupDlg(JobData *job_data, PrinterData *printer_data, const PrinterCap *printer_cap); + PageSetupDlg(JobData *job_data, PrinterData *printer_data, + const PrinterCap *printer_cap); virtual void MessageReceived(BMessage *message); private: - BMessageFilter *fFilter; + BMessageFilter* fFilter; + PageSetupView* fPageSetupView; }; #endif /* __PAGESETUPDLG_H */ Modified: haiku/trunk/src/add-ons/print/drivers/pdf/source/Jamfile =================================================================== --- haiku/trunk/src/add-ons/print/drivers/pdf/source/Jamfile 2010-10-16 19:21:56 UTC (rev 38985) +++ haiku/trunk/src/add-ons/print/drivers/pdf/source/Jamfile 2010-10-16 19:56:34 UTC (rev 38986) @@ -35,7 +35,6 @@ PrinterDriver.cpp PrinterPrefs.cpp PrinterSettings.cpp - PrinterSetupWindow.cpp RegExp.cpp Report.cpp Scanner.cpp Modified: haiku/trunk/src/add-ons/print/drivers/pdf/source/JobSetupWindow.cpp =================================================================== --- haiku/trunk/src/add-ons/print/drivers/pdf/source/JobSetupWindow.cpp 2010-10-16 19:21:56 UTC (rev 38985) +++ haiku/trunk/src/add-ons/print/drivers/pdf/source/JobSetupWindow.cpp 2010-10-16 19:56:34 UTC (rev 38986) @@ -3,6 +3,7 @@ PDF Writer printer driver. Copyright (c) 2001-2003 OpenBeOS. +Copyright (c) 2010 Haiku, Inc. Authors: Philippe Houdoin @@ -29,6 +30,9 @@ */ +#include <GridView.h> +#include <GroupLayout.h> +#include <GroupLayoutBuilder.h> #include <InterfaceKit.h> #include <SupportKit.h> #include <stdlib.h> @@ -40,51 +44,40 @@ #include "DocInfoWindow.h" static const char* includeKeys[] = { - "doc_info", + "doc_info", #if HAVE_FULLVERSION_PDF_LIB - "master_password", "user_password", "permissions", + "master_password", "user_password", "permissions", #endif NULL }; // -------------------------------------------------- JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName) - : HWindow(BRect(0, 0, 320, 160), "Job Setup", B_TITLED_WINDOW_LOOK, - B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | - B_NOT_ZOOMABLE) + : HWindow(BRect(0, 0, 100, 100), "Job Setup", + B_TITLED_WINDOW_LOOK, + B_MODAL_APP_WINDOW_FEEL, + B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE + | B_AUTO_UPDATE_SIZE_LIMITS) { - fSetupMsg = msg; - fExitSem = create_sem(0, "JobSetup"); - fResult = B_ERROR; - + fSetupMsg = msg; + fExitSem = create_sem(0, "JobSetup"); + fResult = B_ERROR; + if (printerName) { BString title; title << printerName << " Job Setup"; SetTitle(title.String()); fPrinterName = printerName; } - - // ---- Ok, build a default job setup user interface - BRect r; - BBox *panel; - BBox *line; - BButton *ok; - BButton *cancel; - BStringView *sv; - float x, y, w, h; - float indent; - int32 copies; - int32 firstPage; - int32 lastPage; - bool allPages; - char buffer[80]; - + // PrinterDriver ensures that property exists - fSetupMsg->FindInt32("copies", &copies); + int32 firstPage; fSetupMsg->FindInt32("first_page", &firstPage); + int32 lastPage; fSetupMsg->FindInt32("last_page", &lastPage); + BMessage doc_info; - if (B_OK != fSetupMsg->FindMessage("doc_info", &doc_info)) { + if (fSetupMsg->FindMessage("doc_info", &doc_info) != B_OK) { // default fields doc_info.AddString("Author", ""); doc_info.AddString("Subject", ""); @@ -92,157 +85,84 @@ fSetupMsg->AddMessage("doc_info", &doc_info); } AddFields(&fDocInfo, fSetupMsg, NULL, includeKeys); + + bool allPages = firstPage == 1 && lastPage == MAX_INT32; - allPages = firstPage == 1 && lastPage == MAX_INT32; + fAll = new BRadioButton("allPages", "Print all pages", + new BMessage(ALL_PAGES_MGS)); + fAll->SetValue(allPages); - r = Bounds(); + fRange = new BRadioButton("pagesRange", "Print pages:", + new BMessage(RANGE_SELECTION_MSG)); + fRange->SetValue(!allPages); - // add a *dialog* background - panel = new BBox(r, "top_panel", B_FOLLOW_ALL, - B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, - B_PLAIN_BORDER); + fFrom = new BTextControl("from", "From:", "SomeSpaceHere", NULL); + fFrom->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT); + fFrom->SetEnabled(!allPages); - const int kMargin = 6; + fTo = new BTextControl("to", "To:", "", NULL); + fTo->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT); + fTo->SetEnabled(!allPages); - //const char *kCopiesLabel = "Copies:"; - const char *kCopiesLabelExtraSpace = "Copies:##"; - const char *kPagesRangeLabel = "Pages:"; - const char *kAllPagesLabel = "All"; - const char *kPagesRangeSelectionLabel = ""; - const char *kFromLabel = "From:"; - const char *kFromLabelExtraSpace = "From:##"; - const char *kToLabel = "To:"; - const char *kToLabelExtraSpace = "To:##"; + BString buffer; + buffer << firstPage; + fFrom->SetText(buffer.String()); - r = panel->Bounds(); + buffer = ""; + buffer << lastPage; + fTo->SetText(buffer.String()); - x = r.left + kMargin; - y = r.top + kMargin; - - - // add a "copies" input field - -/* Simon: temporarily removed this code - sprintf(buffer, "%d", (int)copies); - fCopies = new BTextControl(BRect(x, y, x+100, y+20), "copies", kCopiesLabel, - buffer, new BMessage(NB_COPIES_MSG)); - fCopies->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT); - fCopies->ResizeToPreferred(); - fCopies->GetPreferredSize(&w, &h); - panel->AddChild(fCopies); - - y += h + kMargin; // "new line" -*/ - // add a "pages" label - sv = new BStringView(BRect(x, y, x+100, y+20), "pages_range", kPagesRangeLabel); - panel->AddChild(sv); - sv->ResizeToPreferred(); - sv->GetPreferredSize(&w, &h); - - // align "copies" textcontrol field on the "allPages" radiobutton bellow... - indent = be_plain_font->StringWidth(kCopiesLabelExtraSpace); - w += kMargin; - if ( w > indent ) - indent = w; - // fCopies->SetDivider(indent); - - x += indent; - - // add a "all" radiobutton - fAll = new BRadioButton(BRect(x, y, x+100, y+20), "all_pages", kAllPagesLabel, - new BMessage(ALL_PAGES_MGS)); - fAll->ResizeToPreferred(); - fAll->GetPreferredSize(&w, &h); - fAll->SetValue(allPages); - panel->AddChild(fAll); - - y += h + kMargin; // "new line" - - // add a range selection raddiobutton - fRange = new BRadioButton(BRect(x, y, x+100, y+20), "pages_range_selection", kPagesRangeSelectionLabel, - new BMessage(RANGE_SELECTION_MSG)); - fRange->ResizeToPreferred(); - fRange->GetPreferredSize(&w, &h); - fRange->SetValue(!allPages); - panel->AddChild(fRange); - - x += w + kMargin; - - // add a "from" field - if (allPages) { - buffer[0] = 0; - } else { - sprintf(buffer, "%d", (int)firstPage); + for (uint32 i = 0; i < '0'; i++) { + fTo->TextView()->DisallowChar(i); + fFrom->TextView()->DisallowChar(i); } - fFrom = new BTextControl(BRect(x, y, x+100, y+20), "from_field", kFromLabel, buffer, - new BMessage(RANGE_FROM_MSG)); - fFrom->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT); - fFrom->SetDivider(be_plain_font->StringWidth(kFromLabelExtraSpace)); - fFrom->ResizeToPreferred(); - fFrom->GetPreferredSize(&w, &h); - panel->AddChild(fFrom); - x += w + kMargin; - - // add a "to" field - if (allPages) { - buffer[0] = 0; - } else { - sprintf(buffer, "%d", (int)lastPage); + for (uint32 i = '9' + 1; i < 255; i++) { + fTo->TextView()->DisallowChar(i); + fFrom->TextView()->DisallowChar(i); } - fTo = new BTextControl(BRect(x, y, x+100, y+20), "to_field", kToLabel, buffer, - new BMessage(RANGE_TO_MSG)); - fTo->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT); - fTo->SetDivider(be_plain_font->StringWidth(kToLabelExtraSpace)); - fTo->ResizeToPreferred(); - fTo->GetPreferredSize(&w, &h); - panel->AddChild(fTo); - y += h + kMargin + kMargin; // "new line" - x = r.left + kMargin; + BBox *separator = new BBox("separator"); + separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1)); - // add a separator line... - line = new BBox(BRect(r.left, y - 1, r.right, y), NULL, - B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP ); - panel->AddChild(line); + BButton *documentInfo = new BButton("documentInfo", + "Document" B_UTF8_ELLIPSIS, + new BMessage(DOC_INFO_MSG)); - y += 2 + kMargin + kMargin; // "new line" + BButton *cancel = new BButton("cancel", "Cancel", new BMessage(CANCEL_MSG)); - // add a "OK" button, and make it default - ok = new BButton(BRect(x, y, x+100, y+20), NULL, "OK", new BMessage(OK_MSG), B_FOLLOW_RIGHT | B_FOLLOW_TOP); + BButton *ok = new BButton("ok", "OK", new BMessage(OK_MSG)); ok->MakeDefault(true); - ok->ResizeToPreferred(); - ok->GetPreferredSize(&w, &h); - x = r.right - w - kMargin; - ok->MoveTo(x, ok->Frame().top); // put the ok bottom at bottom right corner - panel->AddChild(ok); - // add a "Cancel" button - cancel = new BButton(BRect(x, y, x + 100, y + 20), NULL, "Cancel", new BMessage(CANCEL_MSG), B_FOLLOW_RIGHT | B_FOLLOW_TOP); - cancel->ResizeToPreferred(); - cancel->GetPreferredSize(&w, &h); - cancel->MoveTo(x - w - kMargin, y); // put cancel button left next the ok button - panel->AddChild(cancel); + BGridView* settings = new BGridView(); + BGridLayout* settingsLayout = settings->GridLayout(); + settingsLayout->AddItem(fFrom->CreateLabelLayoutItem(), 0, 0); + settingsLayout->AddItem(fFrom->CreateTextViewLayoutItem(), 1, 0); + settingsLayout->AddItem(fTo->CreateLabelLayoutItem(), 0, 1); + settingsLayout->AddItem(fTo->CreateTextViewLayoutItem(), 1, 1); + settingsLayout->SetSpacing(0, 0); - // add a "DocInfo" button - BButton *button = new BButton(r, NULL, "Doc Info", new BMessage(DOC_INFO_MSG), - B_FOLLOW_RIGHT | B_FOLLOW_TOP); - button->GetPreferredSize(&w, &h); - button->ResizeToPreferred(); - button->MoveTo(8, y); - panel->AddChild(button); - - // Finally, add our panel to window - AddChild(panel); - - // Auto resize window - ResizeTo(ok->Frame().right + kMargin, ok->Frame().bottom + kMargin); + SetLayout(new BGroupLayout(B_VERTICAL)); + AddChild(BGroupLayoutBuilder(B_VERTICAL, 0) + .Add(fAll) + .Add(fRange) + .Add(settings) + .AddGlue() + .Add(separator) + .AddGroup(B_HORIZONTAL, 10, 1.0f) + .Add(documentInfo) + .AddGlue() + .Add(cancel) + .Add(ok) + .End() + .SetInsets(10, 10, 10, 10) + ); } // -------------------------------------------------- void -JobSetupWindow::UpdateJobMessage() +JobSetupWindow::UpdateJobMessage() { int32 copies = 1; @@ -290,16 +210,21 @@ fResult = B_OK; release_sem(fExitSem); break; - + case CANCEL_MSG: release_sem(fExitSem); break; - case RANGE_FROM_MSG: - case RANGE_TO_MSG: - fRange->SetValue(B_CONTROL_ON); + case ALL_PAGES_MGS: + fTo->SetEnabled(false); + fFrom->SetEnabled(false); break; + case RANGE_SELECTION_MSG: + fTo->SetEnabled(true); + fFrom->SetEnabled(true); + break; + case DOC_INFO_MSG: (new DocInfoWindow(&fDocInfo))->Show(); break; @@ -309,8 +234,8 @@ break; } } + - // -------------------------------------------------- status_t JobSetupWindow::Go() Modified: haiku/trunk/src/add-ons/print/drivers/pdf/source/JobSetupWindow.h =================================================================== --- haiku/trunk/src/add-ons/print/drivers/pdf/source/JobSetupWindow.h 2010-10-16 19:21:56 UTC (rev 38985) +++ haiku/trunk/src/add-ons/print/drivers/pdf/source/JobSetupWindow.h 2010-10-16 19:56:34 UTC (rev 38986) @@ -71,7 +71,6 @@ status_t fResult; BMessage *fSetupMsg; BMessage fDocInfo; - BTextControl *fCopies; BRadioButton *fAll; BRadioButton *fRange; BTextControl *fFrom; Modified: haiku/trunk/src/add-ons/print/drivers/pdf/source/PageSetupWindow.cpp =================================================================== --- haiku/trunk/src/add-ons/print/drivers/pdf/source/PageSetupWindow.cpp 2010-10-16 19:21:56 UTC (rev 38985) +++ haiku/trunk/src/add-ons/print/drivers/pdf/source/PageSetupWindow.cpp 2010-10-16 19:56:34 UTC (rev 38986) @@ -45,6 +45,9 @@ #include <Box.h> #include <Button.h> +#include <GridView.h> +#include <GroupLayout.h> +#include <GroupLayoutBuilder.h> #include <MenuField.h> #include <Message.h> #include <PopUpMenu.h> @@ -92,15 +95,16 @@ PageSetupWindow::PageSetupWindow(BMessage *msg, const char *printerName) - : HWindow(BRect(0,0,400,220), "Page setup", B_TITLED_WINDOW_LOOK, - B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | - B_NOT_ZOOMABLE), + : HWindow(BRect(0, 0, 200, 100), "Page setup", B_TITLED_WINDOW_LOOK, + B_MODAL_APP_WINDOW_FEEL, + B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE + | B_AUTO_UPDATE_SIZE_LIMITS), fResult(B_ERROR), fSetupMsg(msg), fAdvancedSettings(*msg), fPrinterDirName(printerName) { - fExitSem = create_sem(0, "PageSetup"); + fExitSem = create_sem(0, "PageSetup"); if (printerName) SetTitle(BString(printerName).Append(" page setup").String()); @@ -151,29 +155,13 @@ if (fSetupMsg->FindMessage("fonts", &fonts) == B_OK) fFonts->SetTo(&fonts); - // add a *dialog* background - BRect bounds(Bounds()); - BBox *panel = new BBox(bounds, "background", B_FOLLOW_ALL, - B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER); - AddChild(panel); - - bounds.InsetBy(10.0, 10.0); - bounds.right = 230.0; - bounds.bottom = 160.0; - fMarginView = new MarginView(bounds, int32(width), int32(height), margin, + fMarginView = new MarginView(int32(width), int32(height), margin, MarginUnit(units)); - panel->AddChild(fMarginView); - fMarginView->SetResizingMode(B_FOLLOW_NONE); - BPopUpMenu* m = new BPopUpMenu("Page size"); - m->SetRadioMode(true); + BPopUpMenu* pageSize = new BPopUpMenu("Page size"); + pageSize->SetRadioMode(true); - bounds.OffsetBy(bounds.Width() + 10.0, 5.0); - float divider = be_plain_font->StringWidth("PDF compatibility: "); - fPageSizeMenu = new BMenuField(bounds, "page_size", "Page size:", m); - panel->AddChild(fPageSizeMenu); - fPageSizeMenu->ResizeToPreferred(); - fPageSizeMenu->SetDivider(divider); + fPageSizeMenu = new BMenuField("page_size", "Page size:", pageSize); fPageSizeMenu->Menu()->SetLabelFromMarked(true); for (int32 i = 0; pageFormat[i].label != NULL; i++) { @@ -181,99 +169,98 @@ message->AddFloat("width", pageFormat[i].width); message->AddFloat("height", pageFormat[i].height); BMenuItem* item = new BMenuItem(pageFormat[i].label, message); - m->AddItem(item); + pageSize->AddItem(item); if (label.Compare(pageFormat[i].label) == 0) item->SetMarked(true); } - m = new BPopUpMenu("Orientation"); - m->SetRadioMode(true); + BPopUpMenu* orientationPopUpMenu = new BPopUpMenu("Orientation"); + orientationPopUpMenu->SetRadioMode(true); - bounds.OffsetBy(0.0, fPageSizeMenu->Bounds().Height() + 10.0); - fOrientationMenu = new BMenuField(bounds, "orientation", "Orientation:", m); - panel->AddChild(fOrientationMenu); - fOrientationMenu->ResizeToPreferred(); - fOrientationMenu->SetDivider(divider); + fOrientationMenu = new BMenuField("orientation", "Orientation:", + orientationPopUpMenu); fOrientationMenu->Menu()->SetLabelFromMarked(true); for (int32 i = 0; orientation[i].label != NULL; i++) { BMessage* message = new BMessage(ORIENTATION_CHANGED); message->AddInt32("orientation", orientation[i].orientation); BMenuItem* item = new BMenuItem(orientation[i].label, message); - m->AddItem(item); + orientationPopUpMenu->AddItem(item); if (fCurrentOrientation == orientation[i].orientation) item->SetMarked(true); } - m = new BPopUpMenu("PDF compatibility"); - m->SetRadioMode(true); + BPopUpMenu* compatibility = new BPopUpMenu("PDF compatibility"); + compatibility->SetRadioMode(true); - bounds.OffsetBy(0.0, fOrientationMenu->Bounds().Height() + 10.0); - fPDFCompatibilityMenu = new BMenuField(bounds, "pdf_compatibility", - "PDF compatibility:", m); - panel->AddChild(fPDFCompatibilityMenu); - fPDFCompatibilityMenu->ResizeToPreferred(); - fPDFCompatibilityMenu->SetDivider(divider); + fPDFCompatibilityMenu = new BMenuField("pdf_compatibility", + "PDF compatibility:", compatibility); fPDFCompatibilityMenu->Menu()->SetLabelFromMarked(true); for (int32 i = 0; pdf_compatibility[i] != NULL; i++) { BMenuItem* item = new BMenuItem(pdf_compatibility[i], NULL); - m->AddItem(item); + compatibility->AddItem(item); if (setting_value == pdf_compatibility[i]) item->SetMarked(true); } - bounds.OffsetBy(0.0, fPDFCompatibilityMenu->Bounds().Height() + 10.0); - fPDFCompressionSlider = new BSlider(bounds, "pdf_compression", - "Compression:", NULL, 0, 9); - panel->AddChild(fPDFCompressionSlider); + fPDFCompressionSlider = new BSlider("pdf_compression", + "Compression:", NULL, 0, 9, B_HORIZONTAL); fPDFCompressionSlider->SetLimitLabels("None", "Best"); fPDFCompressionSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fPDFCompressionSlider->SetValue(compression); - fPDFCompressionSlider->ResizeToPreferred(); - bounds = Bounds(); - bounds.InsetBy(5.0, 0.0); - bounds.top = MAX(fPDFCompressionSlider->Frame().bottom, - fMarginView->Frame().bottom) + 10.0; - BBox *line = new BBox(BRect(bounds.left, bounds.top, bounds.right, - bounds.top + 1.0), NULL, B_FOLLOW_LEFT_RIGHT); - panel->AddChild(line); + BBox *separator = new BBox("separator"); + separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1)); - bounds.InsetBy(5.0, 0.0); - bounds.OffsetBy(0.0, 11.0); - BButton *cancel = new BButton(bounds, NULL, "Cancel", new BMessage(CANCEL_MSG)); - panel->AddChild(cancel); - cancel->ResizeToPreferred(); + BButton *cancel = new BButton("cancel", "Cancel", new BMessage(CANCEL_MSG)); - BButton *ok = new BButton(bounds, NULL, "OK", new BMessage(OK_MSG)); - panel->AddChild(ok, cancel); - ok->ResizeToPreferred(); - - bounds.right = fPDFCompressionSlider->Frame().right; - ok->MoveTo(bounds.right - ok->Bounds().Width(), ok->Frame().top); - - bounds = ok->Frame(); - cancel->MoveTo(bounds.left - cancel->Bounds().Width() - 10.0, bounds.top); - + BButton *ok = new BButton("ok", "OK", new BMessage(OK_MSG)); ok->MakeDefault(true); - ResizeTo(bounds.right + 10.0, bounds.bottom + 10.0); - BButton *button = new BButton(bounds, NULL, "Fonts" B_UTF8_ELLIPSIS, + BButton *fontsButton = new BButton("fonts", "Fonts" B_UTF8_ELLIPSIS, new BMessage(FONTS_MSG)); - panel->AddChild(button); - button->ResizeToPreferred(); - button->MoveTo(fMarginView->Frame().left, bounds.top); - bounds = button->Frame(); - button = new BButton(bounds, NULL, "Advanced" B_UTF8_ELLIPSIS, + BButton* advancedButton = new BButton("advanced", + "Advanced" B_UTF8_ELLIPSIS, new BMessage(ADVANCED_MSG)); - panel->AddChild(button); - button->ResizeToPreferred(); - button->MoveTo(bounds.right + 10, bounds.top); + BGridView* settings = new BGridView(); + BGridLayout* settingsLayout = settings->GridLayout(); + settingsLayout->AddItem(fPageSizeMenu->CreateLabelLayoutItem(), 0, 0); + settingsLayout->AddItem(fPageSizeMenu->CreateMenuBarLayoutItem(), 1, 0); + settingsLayout->AddItem(fOrientationMenu->CreateLabelLayoutItem(), 0, 1); + settingsLayout->AddItem(fOrientationMenu->CreateMenuBarLayoutItem(), 1, 1); + settingsLayout->AddItem(fPDFCompatibilityMenu->CreateLabelLayoutItem(), 0, 2); + settingsLayout->AddItem(fPDFCompatibilityMenu->CreateMenuBarLayoutItem(), 1, 2); + settingsLayout->AddView(fPDFCompressionSlider, 0, 3, 2); + settingsLayout->SetSpacing(0, 0); + + SetLayout(new BGroupLayout(B_VERTICAL)); + AddChild(BGroupLayoutBuilder(B_VERTICAL, 0) + .AddGroup(B_HORIZONTAL, 5, 1) + .AddGroup(B_VERTICAL, 0, 1.0f) + .Add(fMarginView) + .AddGlue() + .End() + .AddGroup(B_VERTICAL, 0, 1.0f) + .Add(settings) + .AddGlue() + .End() + .End() + .Add(separator) + .AddGroup(B_HORIZONTAL, 10, 1.0f) + .Add(fontsButton) + .Add(advancedButton) + .AddGlue() + .Add(cancel) + .Add(ok) + .End() + .SetInsets(10, 10, 10, 10) + ); + BRect winFrame(Frame()); BRect screenFrame(BScreen().Frame()); MoveTo((screenFrame.right - winFrame.right) / 2, Modified: haiku/trunk/src/add-ons/print/drivers/pdf/source/PrinterDriver.cpp =================================================================== --- haiku/trunk/src/add-ons/print/drivers/pdf/source/PrinterDriver.cpp 2010-10-16 19:21:56 UTC (rev 38985) +++ haiku/trunk/src/add-ons/print/drivers/pdf/source/PrinterDriver.cpp 2010-10-16 19:56:34 UTC (rev 38986) @@ -37,7 +37,6 @@ #include "PrinterDriver.h" -#include "PrinterSetupWindow.h" #include "PageSetupWindow.h" #include "JobSetupWindow.h" #include "StatusWindow.h" @@ -222,10 +221,7 @@ PrinterDriver::PrinterSetup(char *printerName) // name of printer, to attach printer settings { - PrinterSetupWindow *psw; - - psw = new PrinterSetupWindow(printerName); - return psw->Go(); + return B_OK; } Modified: haiku/trunk/src/add-ons/print/drivers/preview/JobSetupWindow.cpp =================================================================== --- haiku/trunk/src/add-ons/print/drivers/preview/JobSetupWindow.cpp 2010-10-16 19:21:56 UTC (rev 38985) +++ haiku/trunk/src/add-ons/print/drivers/preview/JobSetupWindow.cpp 2010-10-16 19:56:34 UTC (rev 38986) @@ -18,15 +18,19 @@ #include <Box.h> #include <Button.h> +#include <GridView.h> +#include <GroupLayout.h> +#include <GroupLayoutBuilder.h> #include <RadioButton.h> #include <Screen.h> #include <TextControl.h> JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName) - : BlockingWindow(BRect(0, 0, 300, 200), "Job Setup", B_TITLED_WINDOW_LOOK, - B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | - B_NOT_ZOOMABLE), + : BlockingWindow(BRect(0, 0, 100, 100), "Job Setup", + B_TITLED_WINDOW_LOOK, + B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | + B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS), fPrinterName(printerName), fSetupMsg(msg) { @@ -40,42 +44,20 @@ fSetupMsg->FindInt32("last_page", &lastPage); bool allPages = firstPage == 1 && lastPage == LONG_MAX; - BRect bounds(Bounds()); - BBox *panel = new BBox(bounds, "background", B_FOLLOW_ALL, - B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER); - AddChild(panel); - - bounds.InsetBy(10.0, 10.0); - - fAll = new BRadioButton(bounds, "allPages", "Print all pages", + fAll = new BRadioButton("allPages", "Print all pages", new BMessage(ALL_PAGES_MGS)); - panel->AddChild(fAll); - fAll->ResizeToPreferred(); fAll->SetValue(allPages); - bounds.OffsetBy(0.0, fAll->Bounds().Height() + 10.0); - fRange = new BRadioButton(bounds, "pagesRange", "Print pages:", + fRange = new BRadioButton("pagesRange", "Print selected pages:", new BMessage(RANGE_SELECTION_MSG)); - panel->AddChild(fRange); - fRange->ResizeToPreferred(); fRange->SetValue(!allPages); - bounds.OffsetBy(0.0, fRange->Bounds().Height() + 5.0); - BRect rect(bounds); - rect.right = be_plain_font->StringWidth("From: SomeSpaceHere"); - fFrom = new BTextControl(rect, "from", "From:", "SomeSpaceHere", NULL); - panel->AddChild(fFrom); + fFrom = new BTextControl("from", "From:", "SomeSpaceHere", NULL); fFrom->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT); - fFrom->ResizeToPreferred(); - fFrom->SetDivider(be_plain_font->StringWidth("From: ")); fFrom->SetEnabled(!allPages); - rect = fFrom->Frame(); - fTo = new BTextControl(rect, "to", "To:", "SomeSpaceHere", NULL); - panel->AddChild(fTo); + fTo = new BTextControl("to", "To:", "", NULL); fTo->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT); - fTo->SetDivider(be_plain_font->StringWidth("To: ")); - fTo->MoveTo(fFrom->Frame().right + 10.0, fTo->Frame().top); fTo->SetEnabled(!allPages); BString buffer; @@ -96,28 +78,37 @@ fFrom->TextView()->DisallowChar(i); } - bounds.OffsetBy(0.0, fTo->Bounds().Height() + 10.0); - BBox *line = new BBox(BRect(bounds.left - 5.0, bounds.top, bounds.right + 5.0, - bounds.top + 1.0), NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP ); - panel->AddChild(line); + BBox *separator = new BBox("separator"); + separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1)); - bounds.OffsetBy(0.0, 11.0); - BButton *cancel = new BButton(bounds, NULL, "Cancel", new BMessage(CANCEL_MSG)); - panel->AddChild(cancel); - cancel->ResizeToPreferred(); + BButton *cancel = new BButton("cancel", "Cancel", new BMessage(CANCEL_MSG)); - BButton *ok = new BButton(bounds, NULL, "OK", new BMessage(OK_MSG)); - panel->AddChild(ok, cancel); - ok->ResizeToPreferred(); + BButton *ok = new BButton("ok", "OK", new BMessage(OK_MSG)); + ok->MakeDefault(true); - bounds.right = fTo->Frame().right; - ok->MoveTo(bounds.right - ok->Bounds().Width(), ok->Frame().top); + BGridView* settings = new BGridView(); + BGridLayout* settingsLayout = settings->GridLayout(); + settingsLayout->AddItem(fFrom->CreateLabelLayoutItem(), 0, 0); + settingsLayout->AddItem(fFrom->CreateTextViewLayoutItem(), 1, 0); + settingsLayout->AddItem(fTo->CreateLabelLayoutItem(), 0, 1); + settingsLayout->AddItem(fTo->CreateTextViewLayoutItem(), 1, 1); + settingsLayout->SetSpacing(0, 0); - bounds = ok->Frame(); - cancel->MoveTo(bounds.left - cancel->Bounds().Width() - 10.0, bounds.top); + SetLayout(new BGroupLayout(B_VERTICAL)); + AddChild(BGroupLayoutBuilder(B_VERTICAL, 0) + .Add(fAll) + .Add(fRange) + .Add(settings) + .AddGlue() + .Add(separator) + .AddGroup(B_HORIZONTAL, 10, 1.0f) + .AddGlue() + .Add(cancel) + .Add(ok) + .End() + .SetInsets(10, 10, 10, 10) + ); - ok->MakeDefault(true); - ResizeTo(bounds.right + 10.0, bounds.bottom + 10.0); BRect winFrame(Frame()); BRect screenFrame(BScreen().Frame()); @@ -154,27 +145,27 @@ JobSetupWindow::MessageReceived(BMessage *msg) { switch (msg->what) { - case OK_MSG: { + case OK_MSG: UpdateJobMessage(); Quit(B_OK); - } break; + break; - case CANCEL_MSG: { + case CANCEL_MSG: Quit(B_ERROR); - } break; + break; - case ALL_PAGES_MGS : { + case ALL_PAGES_MGS: fTo->SetEnabled(false); fFrom->SetEnabled(false); - } break; + break; - case RANGE_SELECTION_MSG : { + case RANGE_SELECTION_MSG: fTo->SetEnabled(true); fFrom->SetEnabled(true); - } break; + break; - default: { + default: BlockingWindow::MessageReceived(msg); - } break; + break; } } Modified: haiku/trunk/src/add-ons/print/drivers/preview/PageSetupWindow.cpp =================================================================== --- haiku/trunk/src/add-ons/print/drivers/preview/PageSetupWindow.cpp 2010-10-16 19:21:56 UTC (rev 38985) +++ haiku/trunk/src/add-ons/print/drivers/preview/PageSetupWindow.cpp 2010-10-16 19:56:34 UTC (rev 38986) @@ -20,6 +20,9 @@ #include <Box.h> #include <Button.h> +#include <GridView.h> +#include <GroupLayout.h> +#include <GroupLayoutBuilder.h> #include <MenuField.h> #include <Message.h> #include <PopUpMenu.h> @@ -90,9 +93,11 @@ PageSetupWindow::PageSetupWindow(BMessage *msg, const char *printerName) - : BlockingWindow(BRect(0,0,400,220), "Page setup", B_TITLED_WINDOW_LOOK, - B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | - B_NOT_ZOOMABLE), + : BlockingWindow(BRect(0, 0, 100, 100), "Page setup", + B_TITLED_WINDOW_LOOK, + B_MODAL_APP_WINDOW_FEEL, + B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE + | B_AUTO_UPDATE_SIZE_LIMITS), fSetupMsg(msg), fPrinterDirName(printerName) [... truncated: 2091 lines follow ...]