libyui  3.10.0
YWidget.cc
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YWidget.cc
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 
26 #include <signal.h>
27 #include <iostream>
28 #include <sstream>
29 
30 #define YUILogComponent "ui"
31 #include "YUILog.h"
32 
33 #include "YUISymbols.h"
34 #include "YShortcut.h"
35 #include "YWidget.h"
36 #include "YDialog.h"
37 #include "YUI.h"
38 #include "YDialog.h"
39 #include "YUIException.h"
40 #include "YWidgetID.h"
41 #include "YBothDim.h"
42 #include "YMacroRecorder.h"
43 
44 #include "YChildrenManager.h"
45 
46 #define MAX_DEBUG_LABEL_LEN 50
47 #define YWIDGET_MAGIC 42
48 
49 #define CHECK_FOR_DUPLICATE_CHILDREN 1
50 #define LOG_WIDGET_REP 0
51 
52 using std::string;
53 
54 
55 
57 {
58  /**
59  * Constructor
60  **/
61  YWidgetPrivate( YWidgetChildrenManager * manager, YWidget * parentWidget = 0 )
62  : childrenManager( manager )
63  , parent( parentWidget )
64  , beingDestroyed( false )
65  , enabled( true )
66  , notify( false )
67  , notifyContextMenu( false )
68  , sendKeyEvents( false )
69  , autoShortcut( false )
70  , toolkitWidgetRep( 0 )
71  , id( 0 )
72  , functionKey( 0 )
73  {
74  stretch.hor = false;
75  stretch.vert = false;
76  weight.hor = 0;
77  weight.vert = 0;
78  }
79 
80  //
81  // Data members
82  //
83 
84  YWidgetChildrenManager * childrenManager;
85  YWidget * parent;
86  bool beingDestroyed;
87  bool enabled;
88  bool notify;
89  bool notifyContextMenu;
90  bool sendKeyEvents;
91  bool autoShortcut;
92  void * toolkitWidgetRep;
93  YWidgetID * id;
94  YBothDim<bool> stretch;
95  YBothDim<int> weight;
96  int functionKey;
97  string helpText;
98 };
99 
100 
101 
102 
103 bool YWidget::_usedOperatorNew = false;
104 
105 
107  : _magic( YWIDGET_MAGIC )
108  , priv( new YWidgetPrivate( new YWidgetChildrenRejector( this ), parent ) )
109 {
110  YUI_CHECK_NEW( priv );
111  YUI_CHECK_NEW( priv->childrenManager );
112 
113  if ( ! _usedOperatorNew )
114  {
115  yuiError() << "FATAL: Widget at "
116  << std::hex << (void *) this << std::dec
117  << " not created with operator new !"
118  << endl;
119  yuiError() << "Check core dump for a backtrace." << endl;
120  abort();
121  }
122 
123  _usedOperatorNew = false;
124 
125  if ( parent )
126  parent->addChild( this );
127 }
128 
129 
130 void * YWidget::operator new( size_t size )
131 {
132  _usedOperatorNew = true;
133  return ::operator new( size );
134 }
135 
136 
138 {
139  YUI_CHECK_WIDGET( this );
141  // yuiDebug() << "Destructor of YWidget " << this << endl;
142 
143  deleteChildren();
144  YUI::ui()->deleteNotify( this );
145 
146  if ( parent() && ! parent()->beingDestroyed() )
147  parent()->removeChild( this );
148 
149  delete priv->childrenManager;
150 
151  if ( priv->id )
152  delete priv->id;
153 
154  invalidate();
155 }
156 
157 
160 {
161  return priv->childrenManager;
162 }
163 
164 
165 void
167 {
168  YUI_CHECK_PTR( newChildrenManager );
169 
170  delete priv->childrenManager;
171  priv->childrenManager = newChildrenManager;
172 }
173 
174 
175 void
177 {
178 #if CHECK_FOR_DUPLICATE_CHILDREN
179  if ( child && childrenManager()->contains( child ) )
180  {
181  yuiError() << this << " already contains " << child << endl;
182  YUI_THROW( YUIInvalidChildException<YWidget>( this, child ) );
183  }
184 #endif
185 
186  childrenManager()->add( child );
187 }
188 
189 
190 void
192 {
193  if ( ! beingDestroyed() )
194  {
195  // yuiDebug() << "Removing " << child << " from " << this << endl;
196  childrenManager()->remove( child );
197  }
198 }
199 
200 
201 void
203 {
204  YWidgetList::const_iterator it = childrenBegin();
205 
206  while ( it != childrenEnd() )
207  {
208  YWidget * child = *it;
209  ++it;
210 
211  if ( child->isValid() )
212  {
213  // yuiDebug() << "Deleting " << child << endl;
214  delete child;
215  }
216  }
217 
218  childrenManager()->clear();
219 }
220 
221 
222 string
224 {
226 
227  if ( label.size() > MAX_DEBUG_LABEL_LEN )
228  {
229  label.resize( MAX_DEBUG_LABEL_LEN );
230  label.append( "..." );
231  }
232 
233  for ( unsigned i=0; i < label.size(); i++ )
234  {
235  if ( label[i] == '\n' )
236  label[i] = ' ';
237  }
238 
239  return label;
240 }
241 
242 
243 bool
245 {
246  return _magic == YWIDGET_MAGIC;
247 }
248 
249 
250 void
251 YWidget::invalidate()
252 {
253  _magic = 0;
254 }
255 
256 
257 bool
259 {
260  return priv->beingDestroyed;
261 }
262 
263 void
265 {
266  priv->beingDestroyed = true;
267 }
268 
269 
270 YWidget *
272 {
273  return priv->parent;
274 }
275 
276 
277 bool
279 {
280  return priv->parent;
281 }
282 
283 
284 void
286 {
287  if ( newParent && priv->parent )
288  {
290  yuiWarning() << "Reparenting " << this
291  << " from " << priv->parent
292  << " to " << newParent << endl;
293  YUI_THROW( YUIException( string( widgetClass() ) + " already has a parent!" ) );
294  }
295 
296  priv->parent = newParent;
297 }
298 
299 
301 {
302  return priv->sendKeyEvents;
303 }
304 
305 
306 void YWidget::setSendKeyEvents( bool doSend )
307 {
308  priv->sendKeyEvents = doSend;
309 }
310 
311 
313 {
314  return priv->autoShortcut;
315 }
316 
317 
318 void YWidget::setAutoShortcut( bool newAutoShortcut )
319 {
320  priv->autoShortcut = newAutoShortcut;
321 }
322 
323 
325 {
326  return priv->functionKey;
327 }
328 
329 
331 {
332  return priv->functionKey > 0;
333 }
334 
335 
336 void YWidget::setFunctionKey( int fkey_no )
337 {
338  priv->functionKey = fkey_no;
339 }
340 
341 
342 string YWidget::helpText() const
343 {
344  return priv->helpText;
345 }
346 
347 
348 void YWidget::setHelpText( const string & helpText )
349 {
350  priv->helpText = helpText;
351 }
352 
353 
354 YWidgetID *
355 YWidget::id() const
356 {
357  return priv->id;
358 }
359 
360 
361 void YWidget::setId( YWidgetID * newId )
362 {
363  if ( priv->id )
364  delete priv->id;
365 
366  priv->id = newId;
367 }
368 
369 
370 bool YWidget::hasId() const
371 {
372  return priv->id != 0;
373 }
374 
375 
377 {
378  YWidget * widget = this;
379 
380  while ( widget )
381  {
382  YDialog * dialog = dynamic_cast<YDialog *> (widget);
383 
384  if ( dialog )
385  return dialog;
386  else
387  widget = widget->parent();
388  }
389 
390  return 0;
391 }
392 
393 
394 const YPropertySet &
396 {
397  static YPropertySet propSet;
398 
399  if ( propSet.isEmpty() )
400  {
401  /**
402  * @property boolean Enabled enabled/disabled state of this widget
403  * @property boolean Notify the current notify state (see also `opt( `notify ))
404  * @property boolean ContextMenu the current contextmenu state (see also `opt( `notifyContextMenu ))
405  * @property string WidgetClass the widget class of this widget (YLabel, YPushButton, ...)
406  * @property string DebugLabel (possibly translated) text describing this widget for debugging
407  * @property string ID widget id as a read-only property
408  * @property string HelpText help text
409  * @property integer HWeight horizontal layout weight (same as `HWeight(widget())
410  * @property integer VWeight vertical layout weight (same as `VWeight(widget())
411  * @property boolean HStretch horizontally stretchable? (same as `opt(`hstretch))
412  * @property boolean VStretch vertically stretchable? (same as `opt(`vstretch))
413  **/
414 
415  propSet.add( YProperty( YUIProperty_Enabled, YBoolProperty ) );
416  propSet.add( YProperty( YUIProperty_Notify, YBoolProperty ) );
417  propSet.add( YProperty( YUIProperty_WidgetClass, YStringProperty, true ) ); // read-only
418  propSet.add( YProperty( YUIProperty_DebugLabel, YStringProperty, true ) ); // read-only
419  propSet.add( YProperty( YUIProperty_ID, YStringProperty, true ) ); // read-only
420  propSet.add( YProperty( YUIProperty_HelpText, YStringProperty ) );
421  propSet.add( YProperty( YUIProperty_HWeight, YIntegerProperty ) );
422  propSet.add( YProperty( YUIProperty_VWeight, YIntegerProperty ) );
423  propSet.add( YProperty( YUIProperty_HStretch, YBoolProperty ) );
424  propSet.add( YProperty( YUIProperty_VStretch, YBoolProperty ) );
425  }
426 
427  return propSet;
428 }
429 
430 
431 bool
432 YWidget::setProperty( const string & propertyName, const YPropertyValue & val )
433 {
434  try
435  {
436  propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch
437  }
438  catch( YUIPropertyException & exception )
439  {
440  exception.setWidget( this );
441  throw;
442  }
443 
444  if ( propertyName == YUIProperty_Enabled ) setEnabled( val.boolVal() );
445  else if ( propertyName == YUIProperty_Notify ) setNotify ( val.boolVal() );
446  else if ( propertyName == YUIProperty_HelpText ) setHelpText( val.stringVal() );
447  else if ( propertyName == YUIProperty_HWeight ) setWeight( YD_HORIZ, val.integerVal() );
448  else if ( propertyName == YUIProperty_VWeight ) setWeight( YD_VERT , val.integerVal() );
449  else if ( propertyName == YUIProperty_HStretch ) setStretchable( YD_HORIZ, val.boolVal() );
450  else if ( propertyName == YUIProperty_VStretch ) setStretchable( YD_VERT , val.boolVal() );
451 
452  return true; // success -- no special processing necessary
453 }
454 
455 
457 YWidget::getProperty( const string & propertyName )
458 {
459  try
460  {
461  propertySet().check( propertyName ); // throws exceptions if not found
462  }
463  catch( YUIPropertyException & exception )
464  {
465  exception.setWidget( this );
466  throw;
467  }
468 
469  if ( propertyName == YUIProperty_Enabled ) return YPropertyValue( isEnabled() );
470  if ( propertyName == YUIProperty_Notify ) return YPropertyValue( notify() );
471  if ( propertyName == YUIProperty_ContextMenu ) return YPropertyValue( notifyContextMenu() );
472  if ( propertyName == YUIProperty_WidgetClass ) return YPropertyValue( widgetClass() );
473  if ( propertyName == YUIProperty_HelpText ) return YPropertyValue( helpText() );
474  if ( propertyName == YUIProperty_DebugLabel ) return YPropertyValue( debugLabel() );
475  if ( propertyName == YUIProperty_HWeight ) return YPropertyValue( weight( YD_HORIZ ) );
476  if ( propertyName == YUIProperty_VWeight ) return YPropertyValue( weight( YD_VERT ) );
477  if ( propertyName == YUIProperty_HStretch ) return YPropertyValue( stretchable( YD_HORIZ ) );
478  if ( propertyName == YUIProperty_VStretch ) return YPropertyValue( stretchable( YD_VERT ) );
479  if ( propertyName == YUIProperty_ID && this->hasId() ) return YPropertyValue(this->id()->toString());
480 
481  return YPropertyValue( false ); // NOTREACHED
482 }
483 
484 
485 void *
487 {
488  return priv->toolkitWidgetRep;
489 }
490 
491 
492 void
494 {
495  priv->toolkitWidgetRep = rep;
496 }
497 
498 
499 void
500 YWidget::setEnabled( bool enabled )
501 {
502  priv->enabled = enabled;
503 }
504 
505 
506 bool
508 {
509  return priv->enabled;
510 }
511 
512 
513 void YWidget::setShortcutString( const string & str )
514 {
515  yuiError() << "Default setShortcutString() method called - "
516  << "this should be reimplemented in "
517  << widgetClass()
518  << endl;
519 }
520 
521 
522 void YWidget::setNotify( bool notify )
523 {
524  priv->notify = notify;
525 }
526 
527 
528 void YWidget::setNotifyContextMenu( bool notifyContextMenu )
529 {
530  priv->notifyContextMenu = notifyContextMenu;
531 }
532 
533 
534 bool YWidget::notify() const
535 {
536  return priv->notify;
537 }
538 
539 
541 {
542  return priv->notifyContextMenu;
543 }
544 
545 
546 int YWidget::preferredSize( YUIDimension dim )
547 {
548  switch ( dim )
549  {
550  case YD_HORIZ: return preferredWidth();
551  case YD_VERT : return preferredHeight();
552 
553  default:
554  YUI_THROW( YUIInvalidDimensionException() );
555  return 0;
556  }
557 }
558 
559 
560 void YWidget::setStretchable( YUIDimension dim, bool newStretch )
561 {
562  priv->stretch[ dim ] = newStretch;
563 }
564 
565 
566 void YWidget::setDefaultStretchable( YUIDimension dim, bool newStretch )
567 {
568  priv->stretch[ dim ] |= newStretch;
569 }
570 
571 
572 bool YWidget::stretchable( YUIDimension dim ) const
573 {
574  return priv->stretch[ dim ];
575 }
576 
577 
578 int YWidget::weight( YUIDimension dim )
579 {
580  return priv->weight[ dim ];
581 }
582 
583 
584 void YWidget::setWeight( YUIDimension dim, int weight )
585 {
586  priv->weight[ dim ] = weight;
587 }
588 
589 
590 bool YWidget::hasWeight( YUIDimension dim )
591 {
592  // DO NOT simply return priv->weight[ dim ] here
593  // since weight() might be overwritten in derived classes!
594 
595  return weight( dim ) > 0;
596 }
597 
598 
600 {
601  yuiWarning() << this << " cannot accept the keyboard focus." << endl;
602  return false;
603 }
604 
605 
606 YWidget *
607 YWidget::findWidget( YWidgetID * id, bool doThrow ) const
608 {
609  if ( ! id )
610  {
611  if ( doThrow )
612  YUI_THROW( YUIWidgetNotFoundException( "Null ID" ) );
613 
614  return 0;
615  }
616 
617  for ( YWidgetListConstIterator it = childrenBegin();
618  it != childrenEnd();
619  ++it )
620  {
621  YWidget * child = *it;
622  YUI_CHECK_WIDGET( child );
623 
624  if ( child->id() && child->id()->isEqual( id ) )
625  return child;
626 
627  if ( child->hasChildren() )
628  {
629  YWidget * found = child->findWidget( id, false );
630 
631  if ( found )
632  return found;
633  }
634  }
635 
636  if ( doThrow )
637  YUI_THROW( YUIWidgetNotFoundException( id->toString() ) );
638 
639  return 0;
640 }
641 
642 
643 void YWidget::setChildrenEnabled( bool enabled )
644 {
645  for ( YWidgetListConstIterator it = childrenBegin();
646  it != childrenEnd();
647  ++it )
648  {
649  YWidget * child = *it;
650 
651  if ( child->hasChildren() )
652  {
653  // yuiDebug() << "Recursing into " << child << endl;
654  child->setChildrenEnabled( enabled );
655  }
656 
657  // yuiDebug() << ( enabled ? "Enabling " : "Disabling " ) << child << endl;
658  child->setEnabled( enabled );
659  }
660 }
661 
662 
664 {
665  YWidget * dialog = findDialog();
666 
667  if ( dialog )
668  dialog->dumpWidgetTree();
669  else
670  dumpWidgetTree();
671 }
672 
673 
674 void YWidget::dumpWidgetTree( int indentationLevel )
675 {
676  dumpWidget( this, indentationLevel );
677 
678  for ( YWidgetListConstIterator it = childrenBegin();
679  it != childrenEnd();
680  ++it )
681  {
682  YWidget * child = *it;
683 
684  if ( child->hasChildren() )
685  child->dumpWidgetTree ( indentationLevel + 1 );
686  else
687  dumpWidget( child, indentationLevel + 1 );
688  }
689 }
690 
691 
692 void YWidget::dumpWidget( YWidget *w, int indentationLevel )
693 {
694  std::ostringstream str;
695 
696  string indentation ( indentationLevel * 4, ' ' );
697  str << "Widget tree: " << indentation << w;
698 
699  if ( w->widgetRep() )
700  {
701  str << " (widgetRep: "
702  << std::hex << w->widgetRep() << std::dec
703  << ")";
704  }
705 
706  string stretch;
707 
708  if ( w->stretchable( YD_HORIZ ) ) stretch += "hstretch ";
709  if ( w->stretchable( YD_VERT ) ) stretch += "vstretch";
710 
711  if ( ! stretch.empty() )
712  str << " ( " << stretch << " ) ";
713 
714  yuiMilestone() << str.str() << endl;
715 }
716 
717 
718 void
720 {
721  //
722  // Record this widget's user input property (if there is any)
723  //
724 
725  if ( userInputProperty() )
726  {
727  macroRecorder->recordWidgetProperty( this, userInputProperty() );
728  }
729 
730  //
731  // Record the child widgets' (if there are any) user input
732  //
733 
734  for ( YWidgetListConstIterator it = childrenBegin();
735  it != childrenEnd();
736  ++it )
737  {
738  YWidget *widget = *it;
739 
740  if ( widget->hasChildren() || widget->hasId() )
741  {
742  /*
743  * It wouldn't do any good to save the user input of any widget
744  * that doesn't have an ID since this ID is required to make use of
745  * this saved data later when playing the macro.
746  * Other than that, container widgets need to recurse over all
747  * their children.
748  */
749 
750  widget->saveUserInput( macroRecorder );
751  }
752  }
753 }
754 
755 
756 std::ostream & operator<<( std::ostream & stream, const YWidget * w )
757 {
758  if ( w )
759  {
760  stream << w->widgetClass();
761 
762  string debugLabel = w->debugLabel();
763 
764  if ( debugLabel.empty() )
765  {
766  if ( w->hasId() )
767  stream << " ID: \"" << w->id() << "\"";
768  }
769  else // Has debugLabel
770  {
771  stream << " \"" << debugLabel << "\"";
772  }
773 
774  stream << " at " << std::hex << (void *) w << std::dec;
775 
776 #if LOG_WIDGET_REP
777  if ( w->widgetRep() )
778  {
779  stream << " (widgetRep: "
780  << hex << w->widgetRep() << dec
781  << ")";
782  }
783 #endif
784  }
785  else
786  {
787  stream << "<NULL widget>";
788  }
789 
790  return stream;
791 }
YWidget::parent
YWidget * parent() const
Return this widget's parent or 0 if it doesn't have a parent.
Definition: YWidget.cc:271
YWidget::deleteChildren
void deleteChildren()
Delete all children and remove them from the children manager's list.
Definition: YWidget.cc:202
YWidget::setChildrenEnabled
void setChildrenEnabled(bool enabled)
Enable or disable all widgets in this widget tree.
Definition: YWidget.cc:643
YWidget::preferredSize
virtual int preferredSize(YUIDimension dim)
Preferred size of the widget in the specified dimension.
Definition: YWidget.cc:546
YPropertySet::add
void add(const YProperty &prop)
Add a property to this property set.
Definition: YProperty.cc:146
YWidget::functionKey
int functionKey() const
Return a function key number that is assigned to this widget.
Definition: YWidget.cc:324
YWidget
Abstract base class of all UI widgets.
Definition: YWidget.h:55
YUIWidgetNotFoundException
Exception class for "No widget found with that ID".
Definition: YUIException.h:456
YWidget::preferredHeight
virtual int preferredHeight()=0
Preferred height of the widget.
YWidget::setSendKeyEvents
void setSendKeyEvents(bool doSend)
Specify whether or not this widget should send key events.
Definition: YWidget.cc:306
YBothDim< bool >
YWidget::preferredWidth
virtual int preferredWidth()=0
Preferred width of the widget.
YWidget::setShortcutString
virtual void setShortcutString(const std::string &str)
Set the string of this widget that holds the keyboard shortcut, if any.
Definition: YWidget.cc:513
YWidget::hasId
bool hasId() const
Returns 'true' if this widget has an ID.
Definition: YWidget.cc:370
YWidgetID::toString
virtual std::string toString() const =0
Convert the ID value to string.
YWidget::findDialog
YDialog * findDialog()
Traverse up the widget hierarchy and find the dialog this widget belongs to.
Definition: YWidget.cc:376
YWidget::childrenEnd
YWidgetListIterator childrenEnd() const
Return an interator that points after the last child.
Definition: YWidget.h:218
YChildrenRejector
Children manager that rejects all children.
Definition: YChildrenManager.h:215
YWidgetID::isEqual
virtual bool isEqual(YWidgetID *otherID) const =0
Check if this ID is equal to another.
YWidget::addChild
virtual void addChild(YWidget *child)
Add a new child.
Definition: YWidget.cc:176
YWidget::saveUserInput
virtual void saveUserInput(YMacroRecorder *macroRecorder)
Recursively save the user input of all child widgets to a macro recorder:
Definition: YWidget.cc:719
YWidget::hasWeight
bool hasWeight(YUIDimension dim)
Return whether or not the widget has a weight in the specified dimension.
Definition: YWidget.cc:590
YWidget::id
YWidgetID * id() const
Returns this widget's ID.
Definition: YWidget.cc:355
YWidget::weight
virtual int weight(YUIDimension dim)
The weight is used in situations where all widgets can get their preferred size and yet space is avai...
Definition: YWidget.cc:578
YWidget::~YWidget
virtual ~YWidget()
Destructor.
Definition: YWidget.cc:137
YUI::ui
static YUI * ui()
Access the global UI.
Definition: YUI.cc:124
YWidget::setFunctionKey
virtual void setFunctionKey(int fkey_no)
Assign a function key to this widget (1 for F1, 2 for F2, etc.
Definition: YWidget.cc:336
YWidget::setChildrenManager
void setChildrenManager(YWidgetChildrenManager *manager)
Sets a new children manager for this widget.
Definition: YWidget.cc:166
YWidget::userInputProperty
virtual const char * userInputProperty()
The name of the widget property that will return user input, if there is any.
Definition: YWidget.h:576
YPropertySet
A set of properties to check names and types against.
Definition: YProperty.h:198
YWidget::contains
bool contains(YWidget *child) const
Checks if 'child' is a (direct!) child of this widget.
Definition: YWidget.h:256
YChildrenManager::add
virtual void add(T *child)
Add a new child.
Definition: YChildrenManager.h:128
YWidget::hasParent
bool hasParent() const
Return 'true' if this widget has a parent, 'false' if not.
Definition: YWidget.cc:278
YPropertySet::isEmpty
bool isEmpty() const
Returns 'true' if this property set does not contain anything.
Definition: YProperty.h:263
YUIInvalidChildException
Exception class for "invalid child".
Definition: YUIException.h:713
YPropertyValue::stringVal
std::string stringVal() const
Methods to get the value of this property.
Definition: YProperty.h:180
YWidget::autoShortcut
bool autoShortcut() const
Returns 'true' if a keyboard shortcut should automatically be assigned to this widget - without compl...
Definition: YWidget.cc:312
YWidget::hasFunctionKey
bool hasFunctionKey() const
Check if a function key is assigned to this widget.
Definition: YWidget.cc:330
YUIPropertyException
Abstract base class for widget property exceptions.
Definition: YUIException.h:507
YWidget::removeChild
virtual void removeChild(YWidget *child)
Remove a child.
Definition: YWidget.cc:191
YWidget::setEnabled
virtual void setEnabled(bool enabled=true)
Enable or disable this widget, i.e.
Definition: YWidget.cc:500
YChildrenManager::remove
virtual void remove(T *child)
Remove a child.
Definition: YChildrenManager.h:135
YWidget::beingDestroyed
bool beingDestroyed() const
Check if this widget is in the process of being destroyed.
Definition: YWidget.cc:258
YWidget::notify
bool notify() const
Returns whether the widget will notify, i.e.
Definition: YWidget.cc:534
YWidget::setWeight
void setWeight(YUIDimension dim, int weight)
Set a weight in the specified dimension.
Definition: YWidget.cc:584
YMacroRecorder::recordWidgetProperty
virtual void recordWidgetProperty(YWidget *widget, const char *propertyName)=0
Record one widget property.
YPropertyValue::type
YPropertyType type() const
Returns the type of this property value.
Definition: YProperty.h:169
YWidget::findWidget
YWidget * findWidget(YWidgetID *id, bool doThrow=true) const
Recursively find a widget by its ID.
Definition: YWidget.cc:607
YWidget::childrenManager
YWidgetChildrenManager * childrenManager() const
Returns this widget's children manager.
Definition: YWidget.cc:159
YWidget::sendKeyEvents
bool sendKeyEvents() const
Returns 'true' if this widget should send key events, i.e.
Definition: YWidget.cc:300
YWidget::getProperty
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
Definition: YWidget.cc:457
YWidget::setWidgetRep
void setWidgetRep(void *toolkitWidgetRep)
Set the pointer to the underlying toolkit's (Qt, ...) widget representing this abstract UI widget.
Definition: YWidget.cc:493
YWidget::setNotify
void setNotify(bool notify=true)
Sets the Notify property.
Definition: YWidget.cc:522
YUIInvalidDimensionException
Exception class for "value other than YD_HORIZ or YD_VERT used for dimension".
Definition: YUIException.h:793
YProperty
Class for widget properties.
Definition: YProperty.h:52
YWidget::dumpWidget
void dumpWidget(YWidget *w, int indentationLevel)
Helper function for dumpWidgetTree(): Dump one widget to the log file.
Definition: YWidget.cc:692
YWidget::setParent
void setParent(YWidget *newParent)
Set this widget's parent.
Definition: YWidget.cc:285
YWidget::setStretchable
void setStretchable(YUIDimension dim, bool newStretch)
Set the stretchable state to "newStretch" regardless of any hstretch or vstretch options.
Definition: YWidget.cc:560
YWidget::helpText
std::string helpText() const
Return the help text for this widget.
Definition: YWidget.cc:342
YWidget::setNotifyContextMenu
void setNotifyContextMenu(bool notifyContextMenu=true)
Sets the notifyContextMenu property.
Definition: YWidget.cc:528
YWidget::setAutoShortcut
void setAutoShortcut(bool _newAutoShortcut)
Sets the 'autoShortcut' flag.
Definition: YWidget.cc:318
YWidget::widgetClass
virtual const char * widgetClass() const
Returns a descriptive name of this widget class for logging, debugging etc.
Definition: YWidget.h:72
YWidget::isValid
bool isValid() const
Checks whether or not this object is valid.
Definition: YWidget.cc:244
YPropertySet::check
void check(const std::string &propertyName) const
Check if a property 'propertyName' exists in this property set.
Definition: YProperty.cc:88
YWidgetPrivate
Definition: YWidget.cc:57
YPropertyValue
Transport class for the value of simple properties.
Definition: YProperty.h:105
YWidget::setDefaultStretchable
void setDefaultStretchable(YUIDimension dim, bool newStretch)
Set the stretchable state to "newStretch".
Definition: YWidget.cc:566
YWidget::isEnabled
virtual bool isEnabled() const
Returns 'true' if this widget is enabled.
Definition: YWidget.cc:507
YWidgetID
Abstract base class for widget IDs.
Definition: YWidgetID.h:37
YShortcut::getShortcutString
virtual std::string getShortcutString()
Obtain the the shortcut property of this shortcut's widget - the string that contains "&" to designat...
Definition: YShortcut.cc:239
YWidget::hasChildren
bool hasChildren() const
Returns 'true' if this widget has any children.
Definition: YWidget.h:192
YWidget::dumpWidgetTree
void dumpWidgetTree(int indentationLevel=0)
Debugging function: Dump the widget tree from here on to the log file.
Definition: YWidget.cc:674
YWidget::setHelpText
void setHelpText(const std::string &helpText)
Set a help text for this widget.
Definition: YWidget.cc:348
YWidget::setId
void setId(YWidgetID *newId_disown)
Set this widget's ID.
Definition: YWidget.cc:361
YWidget::childrenBegin
YWidgetListIterator childrenBegin() const
Return an iterator that points to the first child or to childrenEnd() if there are no children.
Definition: YWidget.h:212
YUI::deleteNotify
virtual void deleteNotify(YWidget *widget)
Notification that a widget is being deleted.
Definition: YUI.h:185
YMacroRecorder
Abstract base class for macro recorders.
Definition: YMacroRecorder.h:39
YWidget::dumpDialogWidgetTree
void dumpDialogWidgetTree()
Debugging function: Dump the widget tree from this widget's dialog parent.
Definition: YWidget.cc:663
YShortcut::cleanShortcutString
std::string cleanShortcutString()
Returns the shortcut string ( from the widget's shortcut property ) without any "&" markers.
Definition: YShortcut.cc:93
YWidget::YWidget
YWidget(YWidget *parent)
Constructor.
Definition: YWidget.cc:106
YWidget::stretchable
virtual bool stretchable(YUIDimension dim) const
This is a boolean value that determines whether the widget is resizable beyond its preferred size in ...
Definition: YWidget.cc:572
YUIPropertyException::setWidget
void setWidget(YWidget *w)
Set the corresponding widget.
Definition: YUIException.h:533
YWidget::debugLabel
virtual std::string debugLabel() const
Returns a descriptive label of this widget instance.
Definition: YWidget.cc:223
YWidget::widgetRep
void * widgetRep() const
Return a pointer to the underlying toolkit's (Qt, ...) widget representing this abstract UI widget.
Definition: YWidget.cc:486
YWidget::setBeingDestroyed
void setBeingDestroyed()
Set the "being destroyed" flag, i.e.
Definition: YWidget.cc:264
YWidget::setProperty
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
Definition: YWidget.cc:432
YChildrenManager
Abstract base template class for children management, such as child widgets.
Definition: YChildrenManager.h:38
YUIException
Base class for UI Exceptions.
Definition: YUIException.h:298
YWidgetPrivate::YWidgetPrivate
YWidgetPrivate(YWidgetChildrenManager *manager, YWidget *parentWidget=0)
Constructor.
Definition: YWidget.cc:61
YChildrenManager::clear
virtual void clear()
Remove all children.
Definition: YChildrenManager.h:142
YWidget::setKeyboardFocus
virtual bool setKeyboardFocus()
Set the keyboard focus to this widget.
Definition: YWidget.cc:599
YWidget::notifyContextMenu
bool notifyContextMenu() const
Returns whether the widget will send an event when the user clicks selects the context menu e....
Definition: YWidget.cc:540
YDialog
A window in the desktop environment.
Definition: YDialog.h:48
YWidget::propertySet
virtual const YPropertySet & propertySet()
Return this class's property set.
Definition: YWidget.cc:395
YDialog::currentDialog
static YDialog * currentDialog(bool doThrow=true)
Return the current (topmost) dialog.
Definition: YDialog.cc:539