Re: Update of GtkRadioMenuItems wihtout emitting any signal



Paul Davis <pbd Op Net> writes:

> >    1) object->state() is an additional requirement on the Model
> >       object's public interface.  Conceptually, what business does a
> >       View widget have knowing about the Model?  It should just be
> >       told what to display.
> 
> well, it has to have access to whatever parts of the state are
> required to display the state. 

o Or, in my case, not.  I have a Model which knows about and tells a
  View what to display.  (I think) you have a View which knows about
  a Model and queries it for a value.  Either way there's a binding.

o From http://www.ootips.org/mvc-pattern.html (which I found via an
  archived thread of yours from over a year ago):

  > The model, viewport and controller are intimately related and in
  > constant contact. Therefore, they must reference each other.

o The discussion goes on about the strongly- and weakly-typed
  knowledge the classes have of each other.  See below.


> >o But for Model-to-View I just directly call the gtkmm methods:
> >
> >    Model::some_method()
> >    {
> >        _state1 = some_computation() ;
> >        _togglebutton1.set_active(_state1) ;
> >    }
> 
> that breaks the anonymity principle. a Model should have *zero*
> knowledge of the View or Controllers. if you don't do this, you cannot
> have multiple Views,

    Model::some_method()
    {
        _state1 = some_computation() ;
        _togglebutton1.set_active(_state1) ;
        _reverse_togglebutton2.set_active(!_state1) ;
    }


> for example, and you can't reimplement the View
> without reimplementing the Model. having the Model drive the View
> directly is not really MVC, and in my experience, not very good OOP either.

o Nomenclature, nomenclature.  I thought a Gtk::ToggleButton was a
  View (also a Controller).  My "Model::some_method()" above is
  really called "Gui::some_method()", so maybe what I've been calling
  Model is really a (composite) View.

o If not -- if Views are solely gtkmm widgets, not some class which
  contains them as member objects -- and:

> >o Bigger question: Do you use libsigc++ signals for *all* your MVC
> >  communication (both Controller-to-Model and Model-to-View)?
> 
> yes, for everything.


o And:

> I generally find that I have to connect to to button press/release
> and keypress signals and so forth, but i rarely override them.


o Then how do you change a togglebutton other than using
  Gtk::ToggleButton::set_active()?

o From "ootips":

  > By contrast, the viewport knows
  > exactly what kind of model it observes.


o How could a (stock, compiled-into-a-library, non-derived-from)
  Gtk::ToggleButton know anything about your Model?


--
MARK
markrubn pacbell net



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]