• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeprint
 

tdeprint

  • tdeprint
driver.h
1/*
2 * This file is part of the KDE libraries
3 * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
4 *
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License version 2 as published by the Free Software Foundation.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 **/
20
21#ifndef DRIVER_H
22#define DRIVER_H
23
24#if !defined( _TDEPRINT_COMPILE ) && defined( __GNUC__ )
25#warning internal header, do not use except if you are a TDEPrint developer
26#endif
27
28#include <tqstring.h>
29#include <tqptrlist.h>
30#include <tqdict.h>
31#include <tqmap.h>
32#include <tqrect.h>
33#include <tqsize.h>
34
35#include <tdelibs_export.h>
36
37class DriverItem;
38class TQListView;
39
40/***********************
41 * Forward definitions *
42 ***********************/
43
44class DrBase;
45class DrMain;
46class DrGroup;
47class DrConstraint;
48class DrPageSize;
49
50/*************************************
51 * Base class for all driver objects *
52 *************************************/
53
61class TDEPRINT_EXPORT DrBase
62{
63public:
64 enum Type { Base = 0, Main, ChoiceGroup, Group, String, Integer, Float, List, Boolean };
65
66 DrBase();
67 virtual ~DrBase();
68
69 Type type() const { return m_type; }
70 bool isOption() const { return (m_type >= DrBase::String); }
71
72 const TQString& get(const TQString& key) const { return m_map[key]; }
73 void set(const TQString& key, const TQString& val) { m_map[key] = val; }
74 bool has(const TQString& key) const { return m_map.contains(key); }
75 const TQString& name() const { return m_name; }
76 void setName(const TQString& s) { m_name = s; }
77 bool conflict() const { return m_conflict; }
78 void setConflict(bool on) { m_conflict = on; }
79
80 virtual TQString valueText();
81 virtual TQString prettyText();
82 virtual void setValueText(const TQString&);
83 virtual DriverItem* createItem(DriverItem *parent, DriverItem *after = 0);
84 virtual void setOptions(const TQMap<TQString,TQString>& opts);
85 virtual void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false);
86 virtual DrBase* clone();
87
88protected:
89 TQMap<TQString,TQString> m_map;
90 TQString m_name; // used as a search key, better to have defined directly
91 Type m_type;
92 bool m_conflict;
93};
94
95/**********************
96 * Option group class *
97 **********************/
98
106class TDEPRINT_EXPORT DrGroup : public DrBase
107{
108public:
109 DrGroup();
110 ~DrGroup();
111
112 void addOption(DrBase *opt);
113 void addGroup(DrGroup *grp);
114 void addObject(DrBase *optgrp);
115 void clearConflict();
116 void removeOption(const TQString& name);
117 void removeGroup(DrGroup *grp);
118 bool isEmpty();
119
120 virtual DriverItem* createItem(DriverItem *parent, DriverItem *after = 0);
121 DrBase* findOption(const TQString& name, DrGroup **parentGroup = 0);
122 DrGroup* findGroup(DrGroup *grp, DrGroup **parentGroup = 0);
123 void setOptions(const TQMap<TQString,TQString>& opts);
124 void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false);
125 DrBase* clone();
126
127 const TQPtrList<DrGroup>& groups() { return m_subgroups; }
128 const TQPtrList<DrBase>& options() { return m_listoptions; }
129
130 static TQString groupForOption( const TQString& optname );
131
132protected:
133 void createTree(DriverItem *parent);
134 void flattenGroup(TQMap<TQString, DrBase*>&, int&);
135
136protected:
137 TQPtrList<DrGroup> m_subgroups;
138 TQDict<DrBase> m_options;
139 TQPtrList<DrBase> m_listoptions; // keep track of order of appearance
140};
141
142/*********************
143 * Main driver class *
144 *********************/
145
153class TDEPRINT_EXPORT DrMain : public DrGroup
154{
155public:
156 DrMain();
157 ~DrMain();
158
159 DriverItem* createTreeView(TQListView *parent);
160 void addConstraint(DrConstraint *c) { m_constraints.append(c); }
161 int checkConstraints();
162 DrPageSize* findPageSize(const TQString& name) { return m_pagesizes.find(name); }
163 void addPageSize(DrPageSize *sz);
164 void removeOptionGlobally(const TQString& name);
165 void removeGroupGlobally(DrGroup *grp);
166 TQMap<TQString, DrBase*> flatten();
167 DrMain* cloneDriver();
168
169protected:
170 TQPtrList<DrConstraint> m_constraints;
171 TQDict<DrPageSize> m_pagesizes;
172};
173
174/**********************************************************
175 * Choice group class: a choice that involve a sub-option *
176 **********************************************************/
177
185class DrChoiceGroup : public DrGroup
186{
187public:
188 DrChoiceGroup();
189 ~DrChoiceGroup();
190
191 DriverItem* createItem(DriverItem *parent, DriverItem *after = 0);
192};
193
194/***********************
195 * String option class *
196 ***********************/
197
205class TDEPRINT_EXPORT DrStringOption : public DrBase
206{
207public:
208 DrStringOption();
209 ~DrStringOption();
210
211 virtual TQString valueText();
212 virtual void setValueText(const TQString& s);
213
214protected:
215 TQString m_value;
216};
217
218/**********************************
219 * Integer numerical option class *
220 **********************************/
221
229class TDEPRINT_EXPORT DrIntegerOption : public DrBase
230{
231public:
232 DrIntegerOption();
233 ~DrIntegerOption();
234
235 virtual TQString valueText();
236 virtual void setValueText(const TQString& s);
237 TQString fixedVal();
238
239protected:
240 int m_value;
241};
242
243/********************************
244 * Float numerical option class *
245 ********************************/
246
254class TDEPRINT_EXPORT DrFloatOption : public DrBase
255{
256public:
257 DrFloatOption();
258 ~DrFloatOption();
259
260 virtual TQString valueText();
261 virtual void setValueText(const TQString& s);
262 TQString fixedVal();
263
264protected:
265 float m_value;
266};
267
268/***********************
269 * Single choice class *
270 ***********************/
271
279class TDEPRINT_EXPORT DrListOption : public DrBase
280{
281public:
282 DrListOption();
283 ~DrListOption();
284
285 void addChoice(DrBase *ch) { m_choices.append(ch); }
286 TQPtrList<DrBase>* choices() { return &m_choices; }
287 DrBase* currentChoice() const { return m_current; }
288 DrBase* findChoice(const TQString& txt);
289 void setChoice(int choicenum);
290
291 virtual TQString valueText();
292 virtual TQString prettyText();
293 virtual void setValueText(const TQString& s);
294 void setOptions(const TQMap<TQString,TQString>& opts);
295 void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false);
296 DriverItem* createItem(DriverItem *parent, DriverItem *after = 0);
297 DrBase* clone();
298
299protected:
300 TQPtrList<DrBase> m_choices;
301 DrBase *m_current;
302};
303
311class TDEPRINT_EXPORT DrBooleanOption : public DrListOption
312{
313 /* just an overloaded class, with different type */
314public:
315 DrBooleanOption() : DrListOption() { m_type = DrBase::Boolean; }
316 ~DrBooleanOption() {}
317};
318
319/********************
320 * Constraint class *
321 ********************/
322
330class DrConstraint
331{
332public:
333 DrConstraint(const TQString& o1, const TQString& o2, const TQString& c1 = TQString::null, const TQString& c2 = TQString::null);
334 DrConstraint(const DrConstraint&);
335
336 bool check(DrMain*);
337
338protected:
339 TQString m_opt1, m_opt2;
340 TQString m_choice1, m_choice2;
341 DrListOption *m_option1, *m_option2;
342};
343
344/*******************
345 * Page Size class *
346 *******************/
347
355class DrPageSize
356{
357public:
358 DrPageSize(const TQString& s, float width, float height, float left, float bottom, float right, float top);
359 DrPageSize(const DrPageSize&);
360
366 float pageWidth() const { return m_width; }
367 float pageHeight() const { return m_height; }
368 float leftMargin() const { return m_left; }
369 float rightMargin() const { return m_right; }
370 float topMargin() const { return m_top; }
371 float bottomMargin() const { return m_bottom; }
372 TQString pageName() const { return m_name; }
373
374 TQSize pageSize() const;
375 TQRect pageRect() const;
376 TQSize margins() const;
377
378protected:
379 TQString m_name;
380 float m_width, m_height, m_left, m_bottom, m_right, m_top;
381};
382
383#endif

tdeprint

Skip menu "tdeprint"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeprint

Skip menu "tdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.9.4
This website is maintained by Timothy Pearson.