Re: [Re: [[gtkmm] New pangomm interface issue]]



Am 04.09.2002 15:54 schrieb(en) Murray Cumming:
Naofumi Yasufuku <naofumi yasufuku net> wrote:
> At Mon, 2 Sep 2002 10:56:35 +0200,
> Martin Schulze wrote:
> >
> > Am 31.08.2002 11:44 schrieb(en) Murray Cumming:
> > > Naofumi Yasufuku <naofumi yasufuku net> wrote:
> > > > Hi,
> > > >
> > > > In gtkmm-1.3.22, some pangomm interfaces have been changed, and
so
> > > > I'm faced with some problems.
> > > >
> > > > I want to call Pango::Font::get_matrics() with NULL language
argument
> > > > to indicate to get the metrics for the entire font.
> > > > But I cannot do it because new interface requires a const
reference
to
> > > > Language.
> > > >
> > > > pango C API allows pango_font_get_metrics(font, NULL), but
pangomm
> > > > doesn't allow it.
> > > >
> > > > I think Pango::Font should provide
> > > >
> > > >   FontMetrics Font::get_metrics()
> > > >   {
> > > >     return FontMetrics((pango_font_get_metrics(gobj(), 0)));
> > > >   }
> > > >
> > > > to support pango C API specification completely.
> >
> > Please wait with this change. In the process of documenting pangomm I
> > found that a default contructor for Pango::Language that creates an
> > invalid object (gobject_ = 0) is needed anyway. So this could also
> > be implemented with a default argument then:
> >
> > Pango::Font::get_metrics(const Language& lang = Language())
> >
> > What do you think is the better solution - Function overload or
> > default argument?
> >
>
> I think there are some solutions.
>
>  1. Implement Font::get_metrics() with no argument.
>
>       FontMetrics Font::get_metrics()
>       {
>         return FontMetrics((pango_font_get_metrics(gobj(), 0)));
>       }
>
>  2. Add default constructor Language::Language(), and implement
>     Font::get_metrics() with default argument.
>
>       FontMetrics Font::get_metrics(const Language& lang = Language())

I prefer 1. I see no need yet to implement an additional concept.

>  3. Fix Language::Language(const char* language) as follows.

There should be no "const char*" in pangomm, surely? Why aren't we using
std::string or Glib::ustring?


Sorry, I should have been more verbose. There is at least one function in
pango (I currently can't remember which) that returns a PangoLanguage*
that might be NULL in some cases. So we must allow Pango::Language to
have gobject_==0. To have

Pango::Language::Language() : gobject_(0) {}

seems to be the logical consequence. Given that, 2. is the simplest solution...

Regards,

  Martin



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