libyui  3.4.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 ID widget id as a read-only property
406  * @property std::string HelpText help text
407  * @property integer HWeight horizontal layout weight (same as `HWeight(widget())
408  * @property integer VWeight vertical layout weight (same as `VWeight(widget())
409  * @property boolean HStretch horizontally stretchable? (same as `opt(`hstretch))
410  * @property boolean VStretch vertically stretchable? (same as `opt(`vstretch))
411  **/
412 
413  propSet.add( YProperty( YUIProperty_Enabled, YBoolProperty ) );
414  propSet.add( YProperty( YUIProperty_Notify, YBoolProperty ) );
415  propSet.add( YProperty( YUIProperty_WidgetClass, YStringProperty, true ) ); // read-only
416  propSet.add( YProperty( YUIProperty_DebugLabel, YStringProperty, true ) ); // read-only
417  propSet.add( YProperty( YUIProperty_ID, YStringProperty, true ) ); // read-only
418  propSet.add( YProperty( YUIProperty_HelpText, YStringProperty ) );
419  propSet.add( YProperty( YUIProperty_HWeight, YIntegerProperty ) );
420  propSet.add( YProperty( YUIProperty_VWeight, YIntegerProperty ) );
421  propSet.add( YProperty( YUIProperty_HStretch, YBoolProperty ) );
422  propSet.add( YProperty( YUIProperty_VStretch, YBoolProperty ) );
423  }
424 
425  return propSet;
426 }
427 
428 
429 bool
430 YWidget::setProperty( const std::string & propertyName, const YPropertyValue & val )
431 {
432  try
433  {
434  propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch
435  }
436  catch( YUIPropertyException & exception )
437  {
438  exception.setWidget( this );
439  throw;
440  }
441 
442  if ( propertyName == YUIProperty_Enabled ) setEnabled( val.boolVal() );
443  else if ( propertyName == YUIProperty_Notify ) setNotify ( val.boolVal() );
444  else if ( propertyName == YUIProperty_HelpText ) setHelpText( val.stringVal() );
445  else if ( propertyName == YUIProperty_HWeight ) setWeight( YD_HORIZ, val.integerVal() );
446  else if ( propertyName == YUIProperty_VWeight ) setWeight( YD_VERT , val.integerVal() );
447  else if ( propertyName == YUIProperty_HStretch ) setStretchable( YD_HORIZ, val.boolVal() );
448  else if ( propertyName == YUIProperty_VStretch ) setStretchable( YD_VERT , val.boolVal() );
449 
450  return true; // success -- no special processing necessary
451 }
452 
453 
455 YWidget::getProperty( const std::string & propertyName )
456 {
457  try
458  {
459  propertySet().check( propertyName ); // throws exceptions if not found
460  }
461  catch( YUIPropertyException & exception )
462  {
463  exception.setWidget( this );
464  throw;
465  }
466 
467  if ( propertyName == YUIProperty_Enabled ) return YPropertyValue( isEnabled() );
468  if ( propertyName == YUIProperty_Notify ) return YPropertyValue( notify() );
469  if ( propertyName == YUIProperty_ContextMenu ) return YPropertyValue( notifyContextMenu() );
470  if ( propertyName == YUIProperty_WidgetClass ) return YPropertyValue( widgetClass() );
471  if ( propertyName == YUIProperty_HelpText ) return YPropertyValue( helpText() );
472  if ( propertyName == YUIProperty_DebugLabel ) return YPropertyValue( debugLabel() );
473  if ( propertyName == YUIProperty_HWeight ) return YPropertyValue( weight( YD_HORIZ ) );
474  if ( propertyName == YUIProperty_VWeight ) return YPropertyValue( weight( YD_VERT ) );
475  if ( propertyName == YUIProperty_HStretch ) return YPropertyValue( stretchable( YD_HORIZ ) );
476  if ( propertyName == YUIProperty_VStretch ) return YPropertyValue( stretchable( YD_VERT ) );
477  if ( propertyName == YUIProperty_ID && this->hasId() ) return YPropertyValue(this->id()->toString());
478 
479  return YPropertyValue( false ); // NOTREACHED
480 }
481 
482 
483 void *
485 {
486  return priv->toolkitWidgetRep;
487 }
488 
489 
490 void
492 {
493  priv->toolkitWidgetRep = rep;
494 }
495 
496 
497 void
498 YWidget::setEnabled( bool enabled )
499 {
500  priv->enabled = enabled;
501 }
502 
503 
504 bool
506 {
507  return priv->enabled;
508 }
509 
510 
511 void YWidget::setShortcutString( const std::string & str )
512 {
513  yuiError() << "Default setShortcutString() method called - "
514  << "this should be reimplemented in "
515  << widgetClass()
516  << std::endl;
517 }
518 
519 
521 {
522  priv->notify = notify;
523 }
524 
525 
527 {
528  priv->notifyContextMenu = notifyContextMenu;
529 }
530 
531 
532 bool YWidget::notify() const
533 {
534  return priv->notify;
535 }
536 
537 
539 {
540  return priv->notifyContextMenu;
541 }
542 
543 
544 int YWidget::preferredSize( YUIDimension dim )
545 {
546  switch ( dim )
547  {
548  case YD_HORIZ: return preferredWidth();
549  case YD_VERT : return preferredHeight();
550 
551  default:
552  YUI_THROW( YUIInvalidDimensionException() );
553  return 0;
554  }
555 }
556 
557 
558 void YWidget::setStretchable( YUIDimension dim, bool newStretch )
559 {
560  priv->stretch[ dim ] = newStretch;
561 }
562 
563 
564 void YWidget::setDefaultStretchable( YUIDimension dim, bool newStretch )
565 {
566  priv->stretch[ dim ] |= newStretch;
567 }
568 
569 
570 bool YWidget::stretchable( YUIDimension dim ) const
571 {
572  return priv->stretch[ dim ];
573 }
574 
575 
576 int YWidget::weight( YUIDimension dim )
577 {
578  return priv->weight[ dim ];
579 }
580 
581 
582 void YWidget::setWeight( YUIDimension dim, int weight )
583 {
584  priv->weight[ dim ] = weight;
585 }
586 
587 
588 bool YWidget::hasWeight( YUIDimension dim )
589 {
590  // DO NOT simply return priv->weight[ dim ] here
591  // since weight() might be overwritten in derived classes!
592 
593  return weight( dim ) > 0;
594 }
595 
596 
598 {
599  yuiWarning() << this << " cannot accept the keyboard focus." << std::endl;
600  return false;
601 }
602 
603 
604 YWidget *
605 YWidget::findWidget( YWidgetID * id, bool doThrow ) const
606 {
607  if ( ! id )
608  {
609  if ( doThrow )
610  YUI_THROW( YUIWidgetNotFoundException( "Null ID" ) );
611 
612  return 0;
613  }
614 
615  for ( YWidgetListConstIterator it = childrenBegin();
616  it != childrenEnd();
617  ++it )
618  {
619  YWidget * child = *it;
620  YUI_CHECK_WIDGET( child );
621 
622  if ( child->id() && child->id()->isEqual( id ) )
623  return child;
624 
625  if ( child->hasChildren() )
626  {
627  YWidget * found = child->findWidget( id, false );
628 
629  if ( found )
630  return found;
631  }
632  }
633 
634  if ( doThrow )
635  YUI_THROW( YUIWidgetNotFoundException( id->toString() ) );
636 
637  return 0;
638 }
639 
640 
641 void YWidget::setChildrenEnabled( bool enabled )
642 {
643  for ( YWidgetListConstIterator it = childrenBegin();
644  it != childrenEnd();
645  ++it )
646  {
647  YWidget * child = *it;
648 
649  if ( child->hasChildren() )
650  {
651  // yuiDebug() << "Recursing into " << child << std::endl;
652  child->setChildrenEnabled( enabled );
653  }
654 
655  // yuiDebug() << ( enabled ? "Enabling " : "Disabling " ) << child << std::endl;
656  child->setEnabled( enabled );
657  }
658 }
659 
660 
662 {
663  YWidget * dialog = findDialog();
664 
665  if ( dialog )
666  dialog->dumpWidgetTree();
667  else
668  dumpWidgetTree();
669 }
670 
671 
672 void YWidget::dumpWidgetTree( int indentationLevel )
673 {
674  dumpWidget( this, indentationLevel );
675 
676  for ( YWidgetListConstIterator it = childrenBegin();
677  it != childrenEnd();
678  ++it )
679  {
680  YWidget * child = *it;
681 
682  if ( child->hasChildren() )
683  child->dumpWidgetTree ( indentationLevel + 1 );
684  else
685  dumpWidget( child, indentationLevel + 1 );
686  }
687 }
688 
689 
690 void YWidget::dumpWidget( YWidget *w, int indentationLevel )
691 {
692  std::ostringstream str;
693 
694  std::string indentation ( indentationLevel * 4, ' ' );
695  str << "Widget tree: " << indentation << w;
696 
697  if ( w->widgetRep() )
698  {
699  str << " (widgetRep: "
700  << std::hex << w->widgetRep() << std::dec
701  << ")";
702  }
703 
704  std::string stretch;
705 
706  if ( w->stretchable( YD_HORIZ ) ) stretch += "hstretch ";
707  if ( w->stretchable( YD_VERT ) ) stretch += "vstretch";
708 
709  if ( ! stretch.empty() )
710  str << " ( " << stretch << " ) ";
711 
712  yuiMilestone() << str.str() << std::endl;
713 }
714 
715 
716 void
718 {
719  //
720  // Record this widget's user input property (if there is any)
721  //
722 
723  if ( userInputProperty() )
724  {
725  macroRecorder->recordWidgetProperty( this, userInputProperty() );
726  }
727 
728  //
729  // Record the child widgets' (if there are any) user input
730  //
731 
732  for ( YWidgetListConstIterator it = childrenBegin();
733  it != childrenEnd();
734  ++it )
735  {
736  YWidget *widget = *it;
737 
738  if ( widget->hasChildren() || widget->hasId() )
739  {
740  /*
741  * It wouldn't do any good to save the user input of any widget
742  * that doesn't have an ID since this ID is required to make use of
743  * this saved data later when playing the macro.
744  * Other than that, container widgets need to recurse over all
745  * their children.
746  */
747 
748  widget->saveUserInput( macroRecorder );
749  }
750  }
751 }
752 
753 
754 std::ostream & operator<<( std::ostream & stream, const YWidget * w )
755 {
756  if ( w )
757  {
758  stream << w->widgetClass();
759 
760  std::string debugLabel = w->debugLabel();
761 
762  if ( debugLabel.empty() )
763  {
764  if ( w->hasId() )
765  stream << " ID: \"" << w->id() << "\"";
766  }
767  else // Has debugLabel
768  {
769  stream << " \"" << debugLabel << "\"";
770  }
771 
772  stream << " at " << std::hex << (void *) w << std::dec;
773 
774 #if LOG_WIDGET_REP
775  if ( w->widgetRep() )
776  {
777  stream << " (widgetRep: "
778  << std::hex << w->widgetRep() << std::dec
779  << ")";
780  }
781 #endif
782  }
783  else
784  {
785  stream << "<NULL widget>";
786  }
787 
788  return stream;
789 }
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:498
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:588
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:661
void setNotifyContextMenu(bool notifyContextMenu=true)
Sets the notifyContextMenu property.
Definition: YWidget.cc:526
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:430
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:570
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:484
virtual bool isEnabled() const
Returns &#39;true&#39; if this widget is enabled.
Definition: YWidget.cc:505
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:532
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:672
bool notifyContextMenu() const
Returns whether the widget will send an event when the user clicks selects the context menu e...
Definition: YWidget.cc:538
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:605
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:544
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:717
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:582
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:455
void setWidgetRep(void *toolkitWidgetRep)
Set the pointer to the underlying toolkit&#39;s (Qt, ...) widget representing this abstract UI widget...
Definition: YWidget.cc:491
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:564
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:690
virtual bool setKeyboardFocus()
Set the keyboard focus to this widget.
Definition: YWidget.cc:597
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:641
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:511
void setNotify(bool notify=true)
Sets the Notify property.
Definition: YWidget.cc:520
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:558
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:576
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:119
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