27 #define YUILogComponent "ui-dialog-spy"
30 #include <YDialogSpy.h>
31 #include <YWidgetFactory.h>
36 #include <YTreeItem.h>
37 #include <YLayoutBox.h>
38 #include <YAlignment.h>
39 #include <YButtonBox.h>
40 #include <YPushButton.h>
41 #include <YReplacePoint.h>
44 #define TREE_VWEIGHT 40
45 #define PROP_VWEIGHT 60
49 #define TREE_HEIGHT 10
52 #define PROP_HEIGHT 12
80 YWidget * widget()
const {
return _widget; }
87 std::ostringstream str;
98 YWidgetListConstIterator begin,
99 YWidgetListConstIterator end,
112 , propReplacePoint( 0 )
131 if ( ! targetDialog )
134 priv->targetDialog = targetDialog;
137 priv->spyDialog = fac->createPopupDialog();
138 YAlignment * diaMin = fac->createMinHeight( priv->spyDialog, DIA_HEIGHT );
139 YLayoutBox * vbox = fac->createVBox( diaMin );
141 YAlignment * minSize = fac->createMinSize( vbox, TREE_WIDTH, TREE_HEIGHT );
142 minSize->
setWeight( YD_VERT, TREE_VWEIGHT );
143 priv->widgetTree = fac->createTree( minSize,
"Widget &Tree",
false );
147 YUI_CHECK_NEW( rootItem );
149 priv->widgetTree->
addItem( rootItem );
152 YAlignment * alignment = fac->createLeft( vbox );
153 priv->propButton = fac->createPushButton( alignment,
"&Properties >>>" );
154 priv->propReplacePoint = fac->createReplacePoint( vbox );
155 fac->createEmpty( priv->propReplacePoint );
157 YButtonBox * buttonBox = fac->createButtonBox( vbox );
158 priv->closeButton = fac->createPushButton( buttonBox,
"&Close" );
159 priv->closeButton->
setRole( YOKButton );
165 if ( priv->spyDialog )
172 return priv->propTable != 0;
181 priv->propReplacePoint->
setWeight( YD_VERT, PROP_VWEIGHT );
184 YAlignment * minSize = fac->createMinSize( priv->propReplacePoint,
185 PROP_WIDTH, PROP_HEIGHT );
187 YUI_CHECK_NEW( header );
192 priv->propTable = fac->createTable( minSize, header );
195 priv->propButton->
setLabel(
"<<< &Properties" );
207 priv->propReplacePoint->
setWeight( YD_VERT, 0 );
211 priv->propButton->
setLabel(
"&Properties >>>" );
220 if ( ! priv->propTable )
229 items.reserve( propSet.
size() );
237 std::string propValStr;
239 switch ( prop.
type() )
241 case YStringProperty:
246 propValStr = propVal.boolVal() ?
"true" :
"false";
249 case YIntegerProperty:
251 std::ostringstream str;
252 str << propVal.integerVal();
253 propValStr = str.str();
263 YUI_CHECK_NEW( item );
264 items.push_back( item );
274 YWidgetListConstIterator begin,
275 YWidgetListConstIterator end,
278 for ( YWidgetListConstIterator it = begin; it != end; ++it )
291 YUI_CHECK_PTR( priv->spyDialog );
295 bool updateProp =
false;
302 if ( event->widget() == priv->closeButton ||
303 event->eventType() == YEvent::CancelEvent )
309 if ( event->widget() == priv->propButton )
320 if ( event->widget() == priv->widgetTree || updateProp )
323 yuiDebug() <<
"Highlighting " << item << std::endl;
327 priv->targetDialog->
highlight( item->widget() );
345 YUI_CAUGHT( exception );
static YWidgetFactory * widgetFactory()
Return the widget factory that provides all the createXY() methods for standard (mandatory, i.e.
YPropertyType type() const
Returns the type of this property.
Transport class for the value of simple properties.
std::vector< YItem * > YItemCollection
Collection of pointers to YItem.
void hideProperties()
Hide the "Properties" sub-window.
A set of properties to check names and types against.
Abstract base class for events to be returned upon UI::UserInput() and related functions.
const_iterator propertiesBegin() const
Returns an iterator that points to the first property in this set.
std::string stringVal() const
Methods to get the value of this property.
void showProperties()
Show the "Properties" sub-window.
bool propertiesShown() const
Return 'true' if the "Properties" sub-window is currently shown, 'false' if not.
Table: Selection list with multiple columns.
An interactive dialog debugger: Show the structure and content of a dialog and its widgets...
std::string name() const
Returns the name of this property.
int size() const
Returns the number of properties in this set.
Implementation of all the alignment widgets:
YTreeItem(const std::string &label, bool isOpen=false)
Constructors for toplevel items.
virtual ~YDialogSpy()
Destructor.
virtual void highlight(YWidget *child)
Highlight a child widget of this dialog.
YDialogSpy(YDialog *dialog=0)
Constructor: Create a YDialogSpy for the specified dialog.
Class for widget properties.
void setLabel(const std::string &newLabel)
Set this item's label.
static void showDialogSpy(YDialog *dialog=0)
Show a YDialogSpy for the specified dialog.
const_iterator propertiesEnd() const
Returns an iterator that points after the last property in this set.
void exec()
Execute the event loop.
bool isOpen() const
Return 'true' if this tree item should be displayed open (with its children visible) by default...
Tree: List box that displays a (scrollable) list of hierarchical items from which the user can select...
virtual void rebuildTree()=0
Rebuild the displayed tree from the internally stored YTreeItems.
virtual YTreeItem * parent() const
Returns this item's parent item or 0 if it is a toplevel item.
void recalcLayout()
Recalculate the layout of the dialog and of all its children after children have been added or remove...
Item class for YTable items.
static YDialog * topmostDialog(bool doThrow=true)
Alias for currentDialog().
Base class for UI Exceptions.
std::string typeAsStr() const
Returns the type of this property as string.
Item class for tree items.
bool destroy(bool doThrow=true)
Close and delete this dialog (and all its children) if it is the topmost dialog.
YEvent * waitForEvent(int timeout_millisec=0)
Wait for a user event.
virtual void showChild()
Show a newly added child.