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 )
228 YItemCollection items;
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()
YPropertyType type() const
const_iterator propertiesBegin() const
std::string stringVal() const
bool propertiesShown() const
YTreeItem(const std::string &label, bool isOpen=false)
virtual void highlight(YWidget *child)
YDialogSpy(YDialog *dialog=0)
void setLabel(const std::string &newLabel)
static void showDialogSpy(YDialog *dialog=0)
const_iterator propertiesEnd() const
virtual void rebuildTree()=0
virtual YTreeItem * parent() const
static YDialog * topmostDialog(bool doThrow=true)
std::string typeAsStr() const
bool destroy(bool doThrow=true)
YEvent * waitForEvent(int timeout_millisec=0)