20#include <kcoloractions.h>
22#include <tqpopupmenu.h>
23#include <tqwhatsthis.h>
26#include <tdeapplication.h>
27#include <tdetoolbar.h>
28#include <tdetoolbarbutton.h>
31KColorAction::KColorAction( const TQString& text, int accel,
32 TQObject* parent, const char* name )
39KColorAction::KColorAction( const TQString& text, int accel,
40 TQObject* receiver, const char* slot, TQObject* parent,
48KColorAction::KColorAction( const TQString& text, Type type, int accel,
49 TQObject* parent, const char* name )
56KColorAction::KColorAction( const TQString& text, Type type, int accel,
57 TQObject* receiver, const char* slot, TQObject* parent,
65KColorAction::KColorAction( TQObject* parent, const char* name )
72void KColorAction::setColor( const TQColor &c )
81TQColor KColorAction::color() const
86void KColorAction::setType( Type t )
95KColorAction::Type KColorAction::type() const
100void KColorAction::init()
106void KColorAction::createPixmap()
112 col.rgb( &r, &g, &b );
116 pix += "static char * text_xpm[] = {\n";
120 pix += "\"20 20 11 1\",\n";
121 pix += "\"h c #c0c000\",\n";
122 pix += "\"g c #808000\",\n";
123 pix += "\"f c #c0c0ff\",\n";
124 pix += "\"a c #000000\",\n";
125 pix += "\"d c #ff8000\",\n";
126 pix += "\". c none\",\n";
127 pix += "\"e c #0000c0\",\n";
128 pix += "\"i c #ffff00\",\n";
129 line.sprintf( "\"# c #%02X%02X%02X \",\n", r, g, b );
131 pix += "\"b c #c00000\",\n";
132 pix += "\"c c #ff0000\",\n";
133 pix += "\"....................\",\n";
134 pix += "\"....................\",\n";
135 pix += "\"....................\",\n";
136 pix += "\"........#...........\",\n";
137 pix += "\"........#a..........\",\n";
138 pix += "\".......###..........\",\n";
139 pix += "\".......###a.........\",\n";
140 pix += "\"......##aa#.........\",\n";
141 pix += "\"......##a.#a........\",\n";
142 pix += "\".....##a...#........\",\n";
143 pix += "\".....#######a.......\",\n";
144 pix += "\"....##aaaaaa#.......\",\n";
145 pix += "\"....##a.....aaaaaaaa\",\n";
146 pix += "\"...####....#abbccdda\",\n";
147 pix += "\"....aaaa....abbccdda\",\n";
148 pix += "\"............aee##ffa\",\n";
149 pix += "\"............aee##ffa\",\n";
150 pix += "\"............agghhiia\",\n";
151 pix += "\"............agghhiia\",\n";
152 pix += "\"............aaaaaaaa\"};\n";
155 pix += "\" 20 20 3 1 \",\n";
157 pix += "\" c none \",\n";
158 pix += "\"+ c white \",\n";
159 line.sprintf( "\". c #%02X%02X%02X \",\n", r, g, b );
164 pix += "\" ................ \",\n";
165 pix += "\" ................ \",\n";
166 pix += "\" ................ \",\n";
167 pix += "\" ...++++++++++... \",\n";
168 pix += "\" ...++++++++++... \",\n";
169 pix += "\" ...++++++++++... \",\n";
170 pix += "\" ...++++++++++... \",\n";
171 pix += "\" ...++++++++++... \",\n";
172 pix += "\" ...++++++++++... \",\n";
173 pix += "\" ...++++++++++... \",\n";
174 pix += "\" ...++++++++++... \",\n";
175 pix += "\" ...++++++++++... \",\n";
176 pix += "\" ...++++++++++... \",\n";
177 pix += "\" ................ \",\n";
178 pix += "\" ................ \",\n";
179 pix += "\" ................ \",\n";
183 case BackgroundColor: {
184 pix += "\" 20 20 3 1 \",\n";
186 pix += "\" c none \",\n";
187 pix += "\". c red \",\n";
188 line.sprintf( "\"+ c #%02X%02X%02X \",\n", r, g, b );
193 pix += "\" ................ \",\n";
194 pix += "\" ................ \",\n";
195 pix += "\" ..++++++++++++.. \",\n";
196 pix += "\" ..++++++++++++.. \",\n";
197 pix += "\" ..++++++++++++.. \",\n";
198 pix += "\" ..++++++++++++.. \",\n";
199 pix += "\" ..++++++++++++.. \",\n";
200 pix += "\" ..++++++++++++.. \",\n";
201 pix += "\" ..++++++++++++.. \",\n";
202 pix += "\" ..++++++++++++.. \",\n";
203 pix += "\" ..++++++++++++.. \",\n";
204 pix += "\" ..++++++++++++.. \",\n";
205 pix += "\" ..++++++++++++.. \",\n";
206 pix += "\" ..++++++++++++.. \",\n";
207 pix += "\" ................ \",\n";
208 pix += "\" ................ \",\n";
214 TQPixmap pixmap( pix );
219TDESelectColorAction::TDESelectColorAction( const TQString& text, Type type,
220 const TQObject* receiver, const char* slot,
222 TDEAction( text, TDEShortcut(), receiver, slot, parent, name ), m_type( type ),
223 m_color( TQt::black )
227TDESelectColorAction::~TDESelectColorAction()
231int TDESelectColorAction::plug( TQWidget* w, int index )
234 kdWarning() << "TDESelectColorAction::plug called with 0 argument\n";
237 if (kapp && !kapp->authorizeTDEAction( name()))
240 if ( w->inherits( "TQPopupMenu") )
242 TQPopupMenu* menu = static_cast<TQPopupMenu* >( w );
254 id = menu->insertItem( iconSet( TDEIcon::Small, 0 ), text(), this,
255 TQ_SLOT( slotActivated() ), 0, -1, index );
258 id = menu->insertItem( text(), this, TQ_SLOT( slotActivated() ),
261 updateShortcut( menu, id );
266 menu->setItemEnabled( id, false );
269 menu->setWhatsThis( id, whatsThisWithIcon() );
271 addContainer( menu, id );
272 connect( menu, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
274 if ( parentCollection() )
275 parentCollection()->connectHighlight( menu, this );
277 return containerCount() - 1;
279 else if ( w->inherits( "TDEToolBar" ) )
281 TDEToolBar *bar = static_cast<TDEToolBar * >( w );
284 TDEInstance *instance;
285 if ( parentCollection() )
286 instance = parentCollection()->instance();
288 instance = TDEGlobal::instance();
290 if ( icon().isEmpty() )
293 TQ_SLOT( slotActivated() ),
297 bar-> insertButton( icon(), id_, TQ_SIGNAL( clicked() ), this,
298 TQ_SLOT( slotActivated() ),
299 isEnabled(), plainText(), index, instance );
301 bar-> getButton( id_ )->setName( TQCString( "toolbutton_")+ name() );
304 TQWhatsThis::add( bar-> getButton(id_), whatsThisWithIcon() );
309 addContainer( bar, id_ );
311 connect( bar, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
313 if ( parentCollection() )
314 parentCollection()->connectHighlight( bar, this );
316 return containerCount() - 1;
322TQColor TDESelectColorAction::color() const
327TDESelectColorAction::Type TDESelectColorAction::type() const
332void TDESelectColorAction::setColor( const TQColor & )
336void TDESelectColorAction::setType( Type )
340TQString TDESelectColorAction::whatsThisWithIcon() const
343 if (!icon().isEmpty())
344 return TQString::fromLatin1( "<img source=\"small|%1\"> %2").arg(icon()).arg( text);
348#include <kcoloractions.moc>
TQIconSet iconSet() const
virtual bool isEnabled() const
virtual TQString toolTip() const
virtual TQString text() const
virtual void setIconSet(const TQIconSet &iconSet)
virtual TQString whatsThis() const
static int getToolButtonID()
const char * name(StdAction id)
|