Mailinglist Archive: yast-commit (490 mails)

< Previous Next >
[yast-commit] r38296 - in /branches/tmp/sh/mod-ui/core/libyui/src: Makefile.am YUIException.cc YUIException.h YUI_core.cc YWidget.cc
  • From: sh-sh-sh@xxxxxxxxxxxxxxxx
  • Date: Tue, 05 Jun 2007 14:51:51 -0000
  • Message-id: <20070605145151.F1A359C9F3@xxxxxxxxxxxxxxxx>
Author: sh-sh-sh
Date: Tue Jun  5 16:51:51 2007
New Revision: 38296

URL: http://svn.opensuse.org/viewcvs/yast?rev=38296&view=rev
Log:
children management classes

Modified:
    branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am
    branches/tmp/sh/mod-ui/core/libyui/src/YUIException.cc
    branches/tmp/sh/mod-ui/core/libyui/src/YUIException.h
    branches/tmp/sh/mod-ui/core/libyui/src/YUI_core.cc
    branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc

Modified: branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am?rev=38296&r1=38295&r2=38296&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am Tue Jun  5 16:51:51 2007
@@ -82,6 +82,7 @@
        YPackageSelectorPlugin.h                \
        YUIException.h                          \
        YProperty.h                             \
+       YChildrenManager.h                      \
        ImplPtr.h                               \
                                                \
        YAlignment.h                            \

Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUIException.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YUIException.cc?rev=38296&r1=38295&r2=38296&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YUIException.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YUIException.cc Tue Jun  5 16:51:51 2007
@@ -19,7 +19,6 @@
 
 /-*/
 
-#include <iostream>
 #include <sstream>
 #include <string.h>      // strerror()
 
@@ -160,7 +159,7 @@
 
     if ( widget() )
        widgetClass = std::string( widget()->widgetClass() ) + "::";
-       
+
     return str << "Property type mismatch: "
               << widgetClass
               << property().name()
@@ -179,10 +178,12 @@
 
     if ( widget() )
        widgetClass = std::string( widget()->widgetClass() ) + "::";
-       
+
     return str << "Property "
               << widgetClass
               << property().name()
               << "is read-only!"
               << endl;
 }
+
+

Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUIException.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YUIException.h?rev=38296&r1=38295&r2=38296&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YUIException.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YUIException.h Tue Jun  5 16:51:51 2007
@@ -24,7 +24,7 @@
 
 
 #include <cerrno>
-#include <iosfwd>
+#include <iostream>
 #include <stdexcept>
 
 #include "YProperty.h"
@@ -471,6 +471,103 @@
 };
 
 
+/**
+ * Exception class for "too many children":
+ * Attempt to add a child to a widget class that can't handle children
+ * (YPushButton etc.) or just one child (YFrame, YDialog).
+ **/
+template<class YWidget> class YUITooManyChildrenException: public YUIException
+{
+public:
+
+    YUITooManyChildrenException( YWidget * container )
+       : YUIException( "Too many children" )
+       , _container( container )
+       {}
+
+    /**
+     * Returns the container widget that can't handle that many children.
+     **/
+    YWidget * container() const { return _container; }
+
+protected:
+
+    /**
+     * Write proper error message with all relevant data.
+     * Reimplemented from YUIException.
+     **/
+    virtual ostream & dumpOn( ostream & str ) const
+    {
+       std::string widgetClass =
+           container() ? container()->widgetClass() :
+           "widget";
+
+       return str << "Too many children for "
+                  << widgetClass
+                  << std::endl;
+    }
+
+private:
+
+    YWidget * _container;
+};
+
+
+/**
+ * Exception class for "invalid child":
+ * Attempt to remove a child from a children manager that is not in that
+ * manager's children list.
+ **/
+template<class YWidget> class YUIInvalidChildException: public YUIException
+{
+public:
+
+    YUIInvalidChildException( YWidget * container,
+                             YWidget * child = 0 )
+       : YUIException( "Invalid child" )
+       , _container( container )
+       , _child( child )
+       {}
+
+    /**
+     * Returns the container widget whose child should be removed etc.
+     **/
+    YWidget * container() const { return _container; }
+
+    /**
+     * Returns the child widget.
+     **/
+    YWidget * child() const { return _child; }
+    
+protected:
+
+    /**
+     * Write proper error message with all relevant data.
+     * Reimplemented from YUIException.
+     **/
+    virtual ostream & dumpOn( ostream & str ) const
+    {
+       std::string containerWidgetClass =
+           container() ? container()->widgetClass() :
+           "widget";
+
+       std::string childWidgetClass =
+           child() ? child()->widgetClass() :
+           "<Null>";
+
+       return str << childWidgetClass
+                  << " is not a child of "
+                  << containerWidgetClass
+                  << std::endl;
+    }
+    
+private:
+
+    YWidget * _container;
+    YWidget * _child;
+};
+
+
 //
 // Helper templates
 //

Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUI_core.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YUI_core.cc?rev=38296&r1=38295&r2=38296&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YUI_core.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YUI_core.cc Tue Jun  5 16:51:51 2007
@@ -394,6 +394,8 @@
 
 YRadioButtonGroup * YUI::findRadioButtonGroup( YContainerWidget * root, YWidget * widget, bool * contains )
 {
+    // FIXME: this function is very likely very obsolete
+    
     YCPValue root_id = root->id();
 
 #if VERBOSE_FIND_RADIO_BUTTON_GROUP

Modified: branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc?rev=38296&r1=38295&r2=38296&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc Tue Jun  5 16:51:51 2007
@@ -35,6 +35,8 @@
 #include "YDialog.h"
 #include "YUIException.h"
 
+#include "YChildrenManager.h"
+
 using std::string;
 
 #define MAX_DEBUG_LABEL_LEN    50

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages