1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
/***************************************************************************
* Copyright (C) 2003 by Jason Kivlighn *
* ([email protected]) *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef SETUPDISPLAY_H
#define SETUPDISPLAY_H
#include <tdehtml_part.h>
#include <dom/html_element.h>
#include <dom/css_stylesheet.h>
#include <tqdom.h>
#include <tqwidget.h>
#include <tqmap.h>
#include "datablocks/recipe.h"
#include "datablocks/kreborder.h"
#include "klomanager.h"
#include <math.h>
class TDEPopupMenu;
class TQAction;
class TQLabel;
class TQWidget;
class StyleSheet;
class KreDisplayItem
{
public:
KreDisplayItem( const TQString &id, const TQString &name );
void clear();
TQString nodeId;
TQString name;
KreBorder border;
int alignment;
int columns;
bool show;
TQColor backgroundColor;
TQColor textColor;
TQFont font;
};
typedef TQMap< KreDisplayItem*, unsigned int > PropertiesMap;
/** @brief A TDEHTMLPart for editing specific CSS properties
*
* Set up the items of a recipe for display.
*
* @author Jason Kivlighn
*/
class SetupDisplay : public TDEHTMLPart, protected KLOManager
{
TQ_OBJECT
public:
SetupDisplay( const Recipe &, TQWidget *parent );
~SetupDisplay();
enum Properties { None = 0, BackgroundColor = 1, TextColor = 2, Font = 4, Visibility = 8, Alignment = 32, Columns = 64, Border = 128 };
void saveLayout( const TQString & );
void loadLayout( const TQString & );
void loadTemplate( const TQString &filename );
bool hasChanges() const
{
return has_changes;
}
void setItemShown( KreDisplayItem *item, bool visible );
const PropertiesMap properties() const
{
return * box_properties;
}
void reload();
signals:
void itemVisibilityChanged( KreDisplayItem *, bool );
protected:
virtual void begin (const KURL &url=KURL(), int xOffset=0, int yOffset=0);
virtual void loadBackgroundColor( const TQString &obj, const TQColor& );
virtual void loadFont( const TQString &obj, const TQFont& );
virtual void loadTextColor( const TQString &obj, const TQColor& );
virtual void loadVisibility( const TQString &obj, bool );
virtual void loadAlignment( const TQString &obj, int );
virtual void loadBorder( const TQString &obj, const KreBorder& );
virtual void loadColumns( const TQString &obj, int );
virtual void beginObject( const TQString &obj );
virtual void endObject();
protected slots:
void nodeClicked(const TQString &url,const TQPoint &point);
void changeMade();
//slots to set properties of item boxes
void setBackgroundColor();
void setBorder();
void setColumns();
void setTextColor();
void setFont();
void setShown( int id );
void setAlignment( TQAction * );
private:
PropertiesMap *box_properties;
TQMap<TQString, KreDisplayItem*> *node_item_map;
bool has_changes;
// Methods
void applyStylesheet();
void loadPageLayout( const TQDomElement &tag );
void loadHTMLView( const TQString &templateFile = TQString::null, const TQString &styleFile = TQString::null );
void createItem( const TQString &id, const TQString &name, unsigned int properties );
//the name of the element under the mouse on a right-click
TQString m_currNodeId;
//the item corresponding to the current point of processing the KLO
KreDisplayItem *m_currentItem;
TDEPopupMenu *popup;
DOM::CSSStyleSheet m_styleSheet;
Recipe m_sample;
TQString m_activeTemplate;
TQString m_activeStyle;
};
#endif //SETUPDISPLAY_H
|