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