* merge parts of libprint and libprintutils to make both indepentend
* adjust all drivers to take that into account * fix UpdateText() signature in JSDSlider to avoid warning git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26648 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
|
||||
InterfaceUtils.cpp
|
||||
|
||||
Copyright (c) 2002 OpenBeOS.
|
||||
|
||||
Author:
|
||||
Michael Pfeiffer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _INTERFACE_UTILS_H
|
||||
#define _INTERFACE_UTILS_H
|
||||
|
||||
#include <InterfaceKit.h>
|
||||
#include <MessageFilter.h>
|
||||
|
||||
|
||||
class EscapeMessageFilter : public BMessageFilter
|
||||
{
|
||||
private:
|
||||
BWindow *fWindow;
|
||||
int32 fWhat;
|
||||
|
||||
public:
|
||||
EscapeMessageFilter(BWindow *window, int32 what);
|
||||
filter_result Filter(BMessage *msg, BHandler **target);
|
||||
};
|
||||
|
||||
|
||||
class HWindow : public BWindow
|
||||
{
|
||||
protected:
|
||||
void Init(uint32 escape_msg);
|
||||
|
||||
public:
|
||||
typedef BWindow inherited;
|
||||
|
||||
HWindow(BRect frame, const char *title, window_type type, uint32 flags, uint32 workspace = B_CURRENT_WORKSPACE, uint32 escape_msg = B_QUIT_REQUESTED);
|
||||
HWindow(BRect frame, const char *title, window_look look, window_feel feel, uint32 flags, uint32 workspace = B_CURRENT_WORKSPACE, uint32 escape_msg = B_QUIT_REQUESTED);
|
||||
|
||||
virtual void MessageReceived(BMessage* m);
|
||||
virtual void AboutRequested();
|
||||
virtual const char* AboutText() const { return NULL; }
|
||||
};
|
||||
|
||||
|
||||
class BlockingWindow : public HWindow
|
||||
{
|
||||
public:
|
||||
BlockingWindow(BRect frame, const char *title, window_type type, uint32 flags, uint32 workspace = B_CURRENT_WORKSPACE, uint32 escape_msg = B_QUIT_REQUESTED);
|
||||
BlockingWindow(BRect frame, const char *title, window_look look, window_feel feel, uint32 flags, uint32 workspace = B_CURRENT_WORKSPACE, uint32 escape_msg = B_QUIT_REQUESTED);
|
||||
~BlockingWindow();
|
||||
|
||||
bool QuitRequested();
|
||||
// Quit() is called by child class with result code
|
||||
void Quit(status_t result);
|
||||
// Show window and wait for it to quit, returns result code
|
||||
virtual status_t Go();
|
||||
// Or quit window e.g. something went wrong in constructor
|
||||
void Quit();
|
||||
// Sets the result that is returned when the user closes the window.
|
||||
// Default is B_OK.
|
||||
void SetUserQuitResult(status_t result);
|
||||
|
||||
typedef HWindow inherited;
|
||||
|
||||
private:
|
||||
void Init(const char* title);
|
||||
|
||||
status_t fUserQuitResult;
|
||||
bool fReadyToQuit;
|
||||
sem_id fExitSem;
|
||||
status_t* fResult;
|
||||
};
|
||||
|
||||
// --------------------------------------------------
|
||||
class TextView : public BTextView
|
||||
{
|
||||
public:
|
||||
typedef BTextView inherited;
|
||||
|
||||
TextView(BRect frame,
|
||||
const char *name,
|
||||
BRect textRect,
|
||||
uint32 rmask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||
|
||||
TextView(BRect frame,
|
||||
const char *name,
|
||||
BRect textRect,
|
||||
const BFont *font, const rgb_color *color,
|
||||
uint32 rmask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||
|
||||
void KeyDown(const char *bytes, int32 numBytes);
|
||||
void MakeFocus(bool focus = true);
|
||||
void Draw(BRect r);
|
||||
};
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
class TextControl : public BView
|
||||
{
|
||||
BStringView *fLabel;
|
||||
TextView *fText;
|
||||
public:
|
||||
TextControl(BRect frame,
|
||||
const char *name,
|
||||
const char *label,
|
||||
const char *initial_text,
|
||||
BMessage *message,
|
||||
uint32 rmask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||
const char *Label() { return fLabel->Text(); }
|
||||
const char *Text() { return fText->Text(); }
|
||||
void MakeFocus(bool focus = true) { fText->MakeFocus(focus); }
|
||||
void ConvertToParent(BView* parent, BView* child, BRect &rect);
|
||||
void FocusSetTo(BView* child);
|
||||
};
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
class Table : public BView
|
||||
{
|
||||
public:
|
||||
typedef BView inherited;
|
||||
|
||||
Table(BRect frame, const char *name, uint32 rmode, uint32 flags);
|
||||
void ScrollTo(BPoint p);
|
||||
};
|
||||
|
||||
class DragListView : public BListView
|
||||
{
|
||||
public:
|
||||
DragListView(BRect frame, const char *name,
|
||||
list_view_type type = B_SINGLE_SELECTION_LIST,
|
||||
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS);
|
||||
bool InitiateDrag(BPoint point, int32 index, bool wasSelected);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -17,15 +17,15 @@
|
||||
class JSDSlider : public BSlider
|
||||
{
|
||||
public:
|
||||
JSDSlider(BRect frame, const char* name, const char *label, BMessage *msg,
|
||||
int32 min, int32 max, thumb_style t);
|
||||
JSDSlider(BRect frame, const char* name, const char *label,
|
||||
BMessage *msg, int32 min, int32 max, thumb_style t);
|
||||
|
||||
virtual ~JSDSlider();
|
||||
|
||||
virtual const char* UpdateText() const;
|
||||
|
||||
~JSDSlider();
|
||||
|
||||
char* UpdateText() const;
|
||||
|
||||
private:
|
||||
BString* fResult;
|
||||
mutable BString fResult;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
|
||||
PrintJobReader
|
||||
|
||||
Copyright (c) 2002 OpenBeOS.
|
||||
|
||||
Author:
|
||||
Michael Pfeiffer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _PRINT_JOB_READER_H
|
||||
#define _PRINT_JOB_READER_H
|
||||
|
||||
#include <File.h>
|
||||
#include <Message.h>
|
||||
#include <Picture.h>
|
||||
|
||||
class PrintJobPage {
|
||||
BFile fJobFile; // the job file
|
||||
off_t fNextPicture; // offset to first picture
|
||||
int32 fNumberOfPictures; // of this page
|
||||
int32 fPicture; // the picture returned by NextPicture()
|
||||
status_t fStatus;
|
||||
|
||||
public:
|
||||
PrintJobPage();
|
||||
PrintJobPage(const PrintJobPage& copy);
|
||||
PrintJobPage(BFile* jobFile, off_t start);
|
||||
status_t InitCheck() const;
|
||||
|
||||
int32 NumberOfPictures() const { return fNumberOfPictures; }
|
||||
|
||||
status_t NextPicture(BPicture& picture, BPoint& p, BRect& r);
|
||||
|
||||
PrintJobPage& operator=(const PrintJobPage& copy);
|
||||
};
|
||||
|
||||
class PrintJobReader {
|
||||
BFile fJobFile; // the job file
|
||||
int32 fNumberOfPages; // the number of pages in the job file
|
||||
BMessage fJobSettings; // the settings extracted from the job file
|
||||
off_t* fPageIndex; // start positions of pages in the job file
|
||||
|
||||
void BuildPageIndex();
|
||||
|
||||
public:
|
||||
PrintJobReader(BFile* jobFile);
|
||||
virtual ~PrintJobReader();
|
||||
|
||||
// test after construction if this is a valid job file
|
||||
status_t InitCheck() const;
|
||||
|
||||
// accessors to informations from job file
|
||||
int32 NumberOfPages() const { return fNumberOfPages; }
|
||||
int32 FirstPage() const;
|
||||
int32 LastPage() const;
|
||||
const BMessage* JobSettings() const { return &fJobSettings; }
|
||||
BRect PaperRect() const;
|
||||
BRect PrintableRect() const;
|
||||
void GetResolution(int32 *xdpi, int32 *ydpi) const;
|
||||
float GetScale() const;
|
||||
|
||||
// retrieve page
|
||||
status_t GetPage(int32 no, PrintJobPage& pjp);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
|
||||
PDF Writer printer driver.
|
||||
|
||||
Copyright (c) 2001, 2002 OpenBeOS.
|
||||
Copyright (c) 2005 - 2008 Haiku.
|
||||
|
||||
Authors:
|
||||
Philippe Houdoin
|
||||
Simon Gauvin
|
||||
Michael Pfeiffer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _PRINT_UTILS_H_
|
||||
#define _PRINT_UTILS_H_
|
||||
|
||||
|
||||
#include <List.h>
|
||||
#include <MessageFilter.h>
|
||||
#include <String.h>
|
||||
#include <Rect.h>
|
||||
|
||||
|
||||
class BHandler;
|
||||
class BMessage;
|
||||
class BWindow;
|
||||
|
||||
|
||||
#define BEGINS_CHAR(byte) ((byte & 0xc0) != 0x80)
|
||||
|
||||
|
||||
BRect ScaleRect(const BRect& rect, float scale);
|
||||
|
||||
|
||||
// set or replace a value in a BMessage
|
||||
void SetBool(BMessage* msg, const char* name, bool value);
|
||||
void SetFloat(BMessage* msg, const char* name, float value);
|
||||
void SetInt32(BMessage* msg, const char* name, int32 value);
|
||||
void SetString(BMessage* msg, const char* name, const char* value);
|
||||
void SetRect(BMessage* msg, const char* name, const BRect& rect);
|
||||
void SetString(BMessage* msg, const char* name, const BString& value);
|
||||
void AddFields(BMessage* to, const BMessage* from, const char* excludeList[] = NULL,
|
||||
const char* includeList[] = NULL, bool overwrite = true);
|
||||
|
||||
|
||||
template <class T>
|
||||
class TList {
|
||||
private:
|
||||
BList fList;
|
||||
typedef int (*sort_func)(const void*, const void*);
|
||||
|
||||
public:
|
||||
virtual ~TList();
|
||||
void MakeEmpty();
|
||||
int32 CountItems() const;
|
||||
T* ItemAt(int32 index) const;
|
||||
void AddItem(T* p);
|
||||
T* RemoveItem(int i);
|
||||
T* Items();
|
||||
void SortItems(int (*comp)(const T**, const T**));
|
||||
};
|
||||
|
||||
// TList
|
||||
template<class T>
|
||||
TList<T>::~TList() {
|
||||
MakeEmpty();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void TList<T>::MakeEmpty() {
|
||||
const int32 n = CountItems();
|
||||
for (int i = 0; i < n; i++) {
|
||||
delete ItemAt(i);
|
||||
}
|
||||
fList.MakeEmpty();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
int32 TList<T>::CountItems() const {
|
||||
return fList.CountItems();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
T* TList<T>::ItemAt(int32 index) const {
|
||||
return (T*)fList.ItemAt(index);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void TList<T>::AddItem(T* p) {
|
||||
fList.AddItem(p);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* TList<T>::RemoveItem(int i) {
|
||||
return (T*)fList.RemoveItem(i);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
T* TList<T>::Items() {
|
||||
return (T*)fList.Items();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void TList<T>::SortItems(int (*comp)(const T**, const T**)) {
|
||||
sort_func sort = (sort_func)comp;
|
||||
fList.SortItems(sort);
|
||||
}
|
||||
|
||||
#endif // _PRINT_UTILS_H_
|
||||
Reference in New Issue
Block a user