* 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:
@@ -90,8 +90,6 @@ public:
|
||||
|
||||
// mimetype from sender
|
||||
bool MimeTypeForSender(BMessage* sender, BString& mime);
|
||||
// adds fields to message or replaces existing fields
|
||||
void AddFields(BMessage* to, const BMessage* from, const char* excludeList[] = NULL, const char* includeList[] = NULL, bool overwrite = true);
|
||||
// load bitmap from application resources
|
||||
BBitmap* LoadBitmap(const char* name, uint32 type_code = B_TRANSLATOR_BITMAP);
|
||||
// convert bitmap to picture; view must be attached to a window!
|
||||
@@ -99,7 +97,4 @@ BBitmap* LoadBitmap(const char* name, uint32 type_code = B_TRANSLATOR_BITMAP);
|
||||
BPicture *BitmapToPicture(BView* view, BBitmap *bitmap);
|
||||
BPicture *BitmapToGrayedPicture(BView* view, BBitmap *bitmap);
|
||||
|
||||
// scalar multiplication
|
||||
BRect ScaleRect(BRect rect, float scale);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
/*
|
||||
|
||||
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>
|
||||
|
||||
// --------------------------------------------------
|
||||
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
|
||||
@@ -1,222 +0,0 @@
|
||||
/*
|
||||
|
||||
MarginView.h
|
||||
|
||||
Copyright (c) 2002 OpenBeOS.
|
||||
|
||||
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.
|
||||
|
||||
Documentation:
|
||||
|
||||
The MarginView is designed to be a self contained component that manages
|
||||
the display of a BBox control that shows a graphic of a page and its'
|
||||
margings. The component also includes text fields that are used to mofify
|
||||
the margin values and a popup to change the units used for the margins.
|
||||
|
||||
There are two interfaces for the MarginView component:
|
||||
|
||||
1) Set methods:
|
||||
- page size
|
||||
- orientation
|
||||
|
||||
Get methods to retrieve:
|
||||
- margins
|
||||
- page size
|
||||
|
||||
The method interface is available for the parent Component to call on
|
||||
the MarginView in response to the Window receiveing messages from
|
||||
other BControls that it contains, such as a Page Size popup. The
|
||||
Get methods are used to extract the page size and margins so that
|
||||
the printer driver may put these values into a BMessage for printing.
|
||||
|
||||
2) 'Optional' Message interface:
|
||||
- Set Page Size
|
||||
- Flip Orientation
|
||||
|
||||
The message interface is available for GUI Controls, BPopupMenu to send
|
||||
messages to the MarginView if the parent Window is not used to handle
|
||||
the messages.
|
||||
|
||||
General Use of MarginView component:
|
||||
|
||||
1) Simply construct a new MarginView object with the margins
|
||||
you want as defaults and add this view to the parent view
|
||||
of the dialog.
|
||||
|
||||
MarginView *mv;
|
||||
mv = new MarginView(viewSizeRect, pageWidth, pageHeight);
|
||||
parentView->AddChild(mv);
|
||||
|
||||
* you can also set the margins in the constructor, and the units:
|
||||
|
||||
mv = new MarginView(viewSizeRect, pageWidth, pageHeight
|
||||
marginRect, kUnitPointS);
|
||||
|
||||
! but remeber to have the marginRect values match the UNITS :-)
|
||||
|
||||
2) Set Page Size with methods:
|
||||
|
||||
mv-SetPageSize( pageWidth, pageHeight );
|
||||
mv->UpdateView();
|
||||
|
||||
3) Set Page Size with BMessage:
|
||||
|
||||
BMessage* msg = new BMessage(CHANGE_PAGE_SIZE);
|
||||
msg->AddFloat("width", pageWidth);
|
||||
msg->AddFloat("height", pageHeight);
|
||||
mv->PostMessage(msg);
|
||||
|
||||
4) Flip Page with methods:
|
||||
|
||||
mv-SetPageSize( pageHeight, pageWidth );
|
||||
mv->UpdateView();
|
||||
|
||||
5) Flip Page with BMessage:
|
||||
|
||||
BMessage* msg = new BMessage(FLIP_PAGE);
|
||||
mv->Looper()->PostMessage(msg);
|
||||
|
||||
Note: the MarginView DOES NOT keep track of the orientation. This
|
||||
should be done by the code for the Page setup dialog.
|
||||
|
||||
6) Get Page Size
|
||||
|
||||
BPoint pageSize = mv->GetPageSize();
|
||||
|
||||
7) Get Margins
|
||||
|
||||
BRect margins = mv->GetMargins();
|
||||
|
||||
8) Get Units
|
||||
|
||||
uint32 units = mv->GetUnits();
|
||||
|
||||
where units is one of:
|
||||
kUnitInch, 72 points/in
|
||||
kUnitCM, 28.346 points/cm
|
||||
kUnitPoint, 1 point/point
|
||||
*/
|
||||
|
||||
#ifndef _MARGIN_VIEW_H
|
||||
#define _MARGIN_VIEW_H
|
||||
|
||||
#include <InterfaceKit.h>
|
||||
#include <Looper.h>
|
||||
|
||||
class BTextControl;
|
||||
class MarginManager;
|
||||
|
||||
// Messages that the MarginManager accepts
|
||||
const uint32 TOP_MARGIN_CHANGED = 'tchg';
|
||||
const uint32 RIGHT_MARGIN_CHANGED = 'rchg';
|
||||
const uint32 LEFT_MARGIN_CHANGED = 'lchg';
|
||||
const uint32 BOTTOM_MARGIN_CHANGED = 'bchg';
|
||||
const uint32 MARGIN_CHANGED = 'mchg';
|
||||
const uint32 CHANGE_PAGE_SIZE = 'chps';
|
||||
const uint32 FLIP_PAGE = 'flip';
|
||||
const uint32 MARGIN_UNIT_CHANGED = 'mucg';
|
||||
|
||||
enum MarginUnit {
|
||||
kUnitInch = 0,
|
||||
kUnitCM,
|
||||
kUnitPoint
|
||||
};
|
||||
|
||||
/**
|
||||
* Class MarginView
|
||||
*/
|
||||
class MarginView : public BBox
|
||||
{
|
||||
friend class MarginManager;
|
||||
|
||||
public:
|
||||
MarginView(BRect rect, int32 pageWidth = 0,
|
||||
int32 pageHeight = 0,
|
||||
BRect margins = BRect(1, 1, 1, 1), // 1 inch
|
||||
MarginUnit unit = kUnitInch);
|
||||
|
||||
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
|
||||
BPoint PageSize() const;
|
||||
void SetPageSize(float pageWidth, float pageHeight);
|
||||
|
||||
// margin
|
||||
BRect Margin() const;
|
||||
|
||||
// units
|
||||
MarginUnit Unit() const;
|
||||
|
||||
// will cause a recalc and redraw
|
||||
void UpdateView(uint32 msg);
|
||||
|
||||
private:
|
||||
// all the GUI construction code
|
||||
void _ConstructGUI();
|
||||
|
||||
// utility method
|
||||
void _AllowOnlyNumbers(BTextControl *textControl,
|
||||
int32 maxNum);
|
||||
|
||||
// performed internally using text fields
|
||||
void _SetMargin(BRect margin);
|
||||
|
||||
// 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;
|
||||
|
||||
// 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;
|
||||
};
|
||||
|
||||
#endif // _MARGIN_VIEW_H
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
|
||||
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
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
/*
|
||||
|
||||
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 _UTILS_H
|
||||
#define _UTILS_H
|
||||
|
||||
|
||||
#include <List.h>
|
||||
#include <MessageFilter.h>
|
||||
#include <String.h>
|
||||
#include <Rect.h>
|
||||
|
||||
|
||||
class BHandler;
|
||||
class BMessage;
|
||||
class BWindow;
|
||||
|
||||
|
||||
// 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);
|
||||
|
||||
|
||||
class EscapeMessageFilter : public BMessageFilter
|
||||
{
|
||||
private:
|
||||
BWindow *fWindow;
|
||||
int32 fWhat;
|
||||
|
||||
public:
|
||||
EscapeMessageFilter(BWindow *window, int32 what);
|
||||
filter_result Filter(BMessage *msg, BHandler **target);
|
||||
};
|
||||
|
||||
|
||||
#define BEGINS_CHAR(byte) ((byte & 0xc0) != 0x80)
|
||||
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user