* first steps towards a new printer api...
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26925 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright 2008 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Julun, <[email protected]
|
||||
*/
|
||||
#ifndef _JOB_SETUP_PANEL_H_
|
||||
#define _JOB_SETUP_PANEL_H_
|
||||
|
||||
|
||||
#include <PrintPanel.h>
|
||||
|
||||
|
||||
class BButton;
|
||||
class BCheckBox;
|
||||
class BMenuField;
|
||||
class BPopUpMenu;
|
||||
class BRadioButton;
|
||||
class BStringView;
|
||||
class BTextControl;
|
||||
class BTextView;
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
namespace Print {
|
||||
|
||||
|
||||
class BPrinter;
|
||||
class BPrinterRoster;
|
||||
|
||||
|
||||
enum print_range {
|
||||
B_ALL_PAGES = 0,
|
||||
B_SELECTION = 1,
|
||||
B_PAGE_RANGE = 2
|
||||
};
|
||||
|
||||
|
||||
const uint32 B_NO_OPTIONS = 0x00000000;
|
||||
const uint32 B_PRINT_TO_FILE = 0x00000001;
|
||||
const uint32 B_PRINT_SELECTION = 0x00000002;
|
||||
const uint32 B_PRINT_PAGE_RANGE = 0x00000004;
|
||||
const uint32 B_PRINT_COLLATE_COPIES = 0x00000008;
|
||||
|
||||
|
||||
|
||||
class BJobSetupPanel : public BPrintPanel {
|
||||
public:
|
||||
BJobSetupPanel(BPrinter* printer);
|
||||
BJobSetupPanel(BPrinter* printer, uint32 flags);
|
||||
virtual ~BJobSetupPanel();
|
||||
|
||||
BJobSetupPanel(BMessage* data);
|
||||
static BArchivable* Instantiate(BMessage* data);
|
||||
virtual status_t Archive(BMessage* data, bool deep = true) const;
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
virtual status_t Go();
|
||||
|
||||
BPrinter* Printer() const;
|
||||
void SetPrinter(BPrinter* printer, bool keepSettings);
|
||||
|
||||
print_range PrintRange() const;
|
||||
void SetPrintRange(print_range range);
|
||||
|
||||
int32 FirstPage() const;
|
||||
int32 LastPage() const;
|
||||
void SetPageRange(int32 firstPage, int32 lastPage);
|
||||
|
||||
uint32 OptionFlags() const;
|
||||
void SetOptionFlags(uint32 flags);
|
||||
|
||||
private:
|
||||
void _InitObject();
|
||||
void _SetupInterface();
|
||||
void _DisallowChar(BTextView* textView);
|
||||
|
||||
private:
|
||||
BPrinter* fPrinter;
|
||||
BPrinterRoster* fPrinterRoster;
|
||||
|
||||
print_range fPrintRange;
|
||||
uint32 fJobPanelFlags;
|
||||
|
||||
BPopUpMenu* fPrinterPopUp;
|
||||
BMenuField* fPrinterMenuField;
|
||||
BButton* fProperties;
|
||||
BStringView* fPrinterInfo;
|
||||
BCheckBox* fPrintToFile;
|
||||
BRadioButton* fPrintAll;
|
||||
BRadioButton* fPagesFrom;
|
||||
BTextControl* fFirstPage;
|
||||
BTextControl* fLastPage;
|
||||
BRadioButton* fSelection;
|
||||
BTextControl* fNumberOfCopies;
|
||||
BCheckBox* fCollate;
|
||||
BCheckBox* fReverse;
|
||||
BCheckBox* fColor;
|
||||
BCheckBox* fDuplex;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Print
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // _JOB_SETUP_PANEL_H_
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright 2008 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Julun, <[email protected]
|
||||
*/
|
||||
#ifndef _PRINT_PANEL_H_
|
||||
#define _PRINT_PANEL_H_
|
||||
|
||||
|
||||
#include <MessageFilter.h>
|
||||
#include <String.h>
|
||||
#include <Window.h>
|
||||
|
||||
|
||||
class BArchivable;
|
||||
class BGroupView;
|
||||
class BHandler;
|
||||
class BMessage;
|
||||
class BView;
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
namespace Print {
|
||||
|
||||
|
||||
class BPrintPanel : public BWindow {
|
||||
public:
|
||||
BPrintPanel(const BString& title);
|
||||
virtual ~BPrintPanel();
|
||||
|
||||
BPrintPanel(BMessage* data);
|
||||
static BArchivable* Instantiate(BMessage* data);
|
||||
virtual status_t Archive(BMessage* data, bool deep = true) const;
|
||||
|
||||
virtual status_t Go() = 0;
|
||||
|
||||
BView* Panel() const;
|
||||
void AddPanel(BView* panel);
|
||||
bool RemovePanel(BView* child);
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void FrameResized(float newWidth, float newHeight);
|
||||
|
||||
virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
|
||||
BMessage* specifier, int32 form,
|
||||
const char* property);
|
||||
virtual status_t GetSupportedSuites(BMessage* data);
|
||||
virtual status_t Perform(perform_code d, void* arg);
|
||||
|
||||
virtual void Quit();
|
||||
virtual bool QuitRequested();
|
||||
virtual void DispatchMessage(BMessage* message, BHandler* handler);
|
||||
|
||||
protected:
|
||||
virtual status_t ShowPanel();
|
||||
|
||||
private:
|
||||
void AddChild(BView* child, BView* before = NULL);
|
||||
bool RemoveChild(BView* child);
|
||||
BView* ChildAt(int32 index) const;
|
||||
|
||||
class _BPrintPanelFilter_ : public BMessageFilter {
|
||||
public:
|
||||
_BPrintPanelFilter_(BPrintPanel* panel);
|
||||
filter_result Filter(BMessage* msg, BHandler** target);
|
||||
|
||||
private:
|
||||
BPrintPanel* fPrintPanel;
|
||||
};
|
||||
|
||||
private:
|
||||
virtual void _ReservedBPrintPanel1();
|
||||
virtual void _ReservedBPrintPanel2();
|
||||
virtual void _ReservedBPrintPanel3();
|
||||
virtual void _ReservedBPrintPanel4();
|
||||
virtual void _ReservedBPrintPanel5();
|
||||
|
||||
private:
|
||||
BGroupView* fPanel;
|
||||
sem_id fPrintPanelSem;
|
||||
status_t fPrintPanelResult;
|
||||
|
||||
uint32 _reserved[5];
|
||||
};
|
||||
|
||||
|
||||
} // namespace Print
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // _PRINT_PANEL_H_
|
||||
Executable
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright 2008 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Julun, <[email protected]
|
||||
*/
|
||||
#ifndef _PRINTER_H_
|
||||
#define _PRINTER_H_
|
||||
|
||||
|
||||
#include <Directory.h>
|
||||
#include <Entry.h>
|
||||
#include <image.h>
|
||||
#include <Message.h>
|
||||
#include <Node.h>
|
||||
#include <Path.h>
|
||||
#include <String.h>
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
namespace Print {
|
||||
|
||||
|
||||
class BPrinter {
|
||||
public:
|
||||
BPrinter();
|
||||
BPrinter(const BEntry& entry);
|
||||
BPrinter(const BPrinter& printer);
|
||||
BPrinter(const node_ref& nodeRef);
|
||||
BPrinter(const entry_ref& entryRef);
|
||||
BPrinter(const BDirectory& directory);
|
||||
~BPrinter();
|
||||
|
||||
status_t SetTo(const BEntry& entry);
|
||||
status_t SetTo(const node_ref& nodeRef);
|
||||
status_t SetTo(const entry_ref& entryRef);
|
||||
status_t SetTo(const BDirectory& directory);
|
||||
void Unset();
|
||||
|
||||
bool IsValid() const;
|
||||
status_t InitCheck() const;
|
||||
|
||||
bool IsFree() const;
|
||||
bool IsDefault() const;
|
||||
bool IsShareable() const;
|
||||
|
||||
BString Name() const;
|
||||
BString State() const;
|
||||
BString Driver() const;
|
||||
BString Comments() const;
|
||||
BString Transport() const;
|
||||
BString TransportAddress() const;
|
||||
status_t DefaultSettings(BMessage& settings);
|
||||
|
||||
status_t StartWatching(const BMessenger& listener);
|
||||
void StopWatching();
|
||||
|
||||
BPrinter& operator=(const BPrinter& printer);
|
||||
bool operator==(const BPrinter& printer) const;
|
||||
bool operator!=(const BPrinter& printer) const;
|
||||
|
||||
private:
|
||||
status_t _Configure() const;
|
||||
status_t _ConfigureJob(BMessage& settings);
|
||||
status_t _ConfigurePage(BMessage& settings);
|
||||
|
||||
BPath _DriverPath() const;
|
||||
image_id _LoadDriver() const;
|
||||
void _AddPrinterName(BMessage& settings);
|
||||
BString _ReadAttribute(const char* attribute) const;
|
||||
|
||||
private:
|
||||
BMessenger* fListener;
|
||||
entry_ref fPrinterEntryRef;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Print
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // _PRINTER_H_
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2008 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Julun, <[email protected]
|
||||
*/
|
||||
#ifndef _PRINTER_ROSTER_H_
|
||||
#define _PRINTER_ROSTER_H_
|
||||
|
||||
|
||||
#include <Directory.h>
|
||||
#include <Messenger.h>
|
||||
#include <Node.h>
|
||||
#include <String.h>
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
namespace Print {
|
||||
|
||||
|
||||
class BPrinter;
|
||||
|
||||
|
||||
class BPrinterRoster {
|
||||
public:
|
||||
BPrinterRoster();
|
||||
~BPrinterRoster();
|
||||
|
||||
int32 CountPrinters();
|
||||
|
||||
status_t GetNextPrinter(BPrinter* printer);
|
||||
status_t GetDefaultPrinter(BPrinter* printer);
|
||||
status_t FindPrinter(const BString& name, BPrinter* printer);
|
||||
|
||||
status_t Rewind();
|
||||
|
||||
status_t StartWatching(const BMessenger& listener);
|
||||
void StopWatching();
|
||||
|
||||
private:
|
||||
BPrinterRoster(const BPrinterRoster& printerRoster);
|
||||
BPrinterRoster& operator=(const BPrinterRoster& printerRoster);
|
||||
|
||||
private:
|
||||
BMessenger* fListener;
|
||||
|
||||
node_ref fUserPrintersNodRef;
|
||||
BDirectory fUserPrintersDirectory;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Print
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // _PRINTER_ROSTER_H_
|
||||
Reference in New Issue
Block a user