2003-10-14 21:06:50 +04:00
|
|
|
/*
|
|
|
|
|
|
|
|
PDF Writer printer driver.
|
|
|
|
|
2008-07-13 15:11:43 +04:00
|
|
|
Copyright (c) 2001, 2002 OpenBeOS.
|
|
|
|
Copyright (c) 2005 - 2008 Haiku.
|
2003-10-14 21:06:50 +04:00
|
|
|
|
2008-07-13 15:11:43 +04:00
|
|
|
Authors:
|
2003-10-14 21:06:50 +04:00
|
|
|
Philippe Houdoin
|
2008-07-13 15:11:43 +04:00
|
|
|
Simon Gauvin
|
2003-10-14 21:06:50 +04:00
|
|
|
Michael Pfeiffer
|
2008-07-13 15:11:43 +04:00
|
|
|
|
2003-10-14 21:06:50 +04:00
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2008-07-27 02:36:01 +04:00
|
|
|
#ifndef _PRINT_UTILS_H_
|
|
|
|
#define _PRINT_UTILS_H_
|
2003-10-14 21:06:50 +04:00
|
|
|
|
2008-07-13 15:11:43 +04:00
|
|
|
|
|
|
|
#include <List.h>
|
2003-10-14 21:06:50 +04:00
|
|
|
#include <MessageFilter.h>
|
2008-07-13 15:11:43 +04:00
|
|
|
#include <String.h>
|
|
|
|
#include <Rect.h>
|
2003-10-14 21:06:50 +04:00
|
|
|
|
|
|
|
|
2008-07-13 15:11:43 +04:00
|
|
|
class BHandler;
|
|
|
|
class BMessage;
|
|
|
|
class BWindow;
|
|
|
|
|
2003-10-14 21:06:50 +04:00
|
|
|
|
2008-07-27 02:36:01 +04:00
|
|
|
#define BEGINS_CHAR(byte) ((byte & 0xc0) != 0x80)
|
|
|
|
|
|
|
|
|
|
|
|
BRect ScaleRect(const BRect& rect, float scale);
|
|
|
|
|
|
|
|
|
2005-01-08 12:12:12 +03:00
|
|
|
// set or replace a value in a BMessage
|
2008-07-13 15:11:43 +04:00
|
|
|
void SetBool(BMessage* msg, const char* name, bool value);
|
2005-01-08 12:12:12 +03:00
|
|
|
void SetFloat(BMessage* msg, const char* name, float value);
|
|
|
|
void SetInt32(BMessage* msg, const char* name, int32 value);
|
2008-07-13 15:11:43 +04:00
|
|
|
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);
|
2008-07-27 02:36:01 +04:00
|
|
|
void AddFields(BMessage* to, const BMessage* from, const char* excludeList[] = NULL,
|
|
|
|
const char* includeList[] = NULL, bool overwrite = true);
|
2003-10-14 21:06:50 +04:00
|
|
|
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
class TList {
|
|
|
|
private:
|
|
|
|
BList fList;
|
|
|
|
typedef int (*sort_func)(const void*, const void*);
|
2008-07-13 15:11:43 +04:00
|
|
|
|
2003-10-14 21:06:50 +04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2008-07-27 02:36:01 +04:00
|
|
|
#endif // _PRINT_UTILS_H_
|