🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.interviews
Article #1660

Re: Scrolling

#1660
From: Bill Poitras
Date: Tue, 12 Jan 1993 19:09
89 lines
2869 bytes
A couple people have asked for me for an example of a string selector.  Here is the code in my stuff.  It may not be usable out the box, but should be enought to get you started.

--
Telltale* timsStringSelectorImpl::makeTelltale(
	const char* str, TelltaleState* ts)
{
  WidgetKit* kit = WidgetKit::instance();
  kit->style(_style);

  LayoutKit* layout = LayoutKit::instance();

  Glyph* label = new Target(
    layout->h_margin(
      kit->fancy_label(str),
      3.0, 0.0, 0.0, 15.0, fil, 0.0
    ),
    TargetPrimitiveHit
  );
  Telltale* telltale = new ChoiceItem(
    ts,
    label,
    kit->bright_inset_frame(label)
  );
  return telltale;
}
//
void timsStringSelectorImpl::make()
{
    LayoutKit* layout = LayoutKit::instance();
    WidgetKit* kit = WidgetKit::instance();
    kit->style(_style);

    const Font* f = kit->font();
    FontBoundingBox fbox;
    f->font_bbox(fbox);

    long r = 10;
    (void)getAttribute("rows",r);
    Coord height = r * ( fbox.ascent() + fbox.descent()) + 1.0;

    long w = 10;
    (void)getAttribute("columns",w);
    Coord width = w * fbox.width();

    long s = -1;
    if (_browser != nil) 
      s = _browser->selected();


    _browser = new FileBrowser(
      kit,
      new ActionCallback(timsStringSelectorImpl)(
	 this, &timsStringSelectorImpl::accept
      ),
      new ActionCallback(timsStringSelectorImpl)(
	 this, &timsStringSelectorImpl::reject
      )
    );

    for (ListUpdater(StringList) i(*_list);i.more();i.next())
    {
      TelltaleState* ts = new TelltaleState(TelltaleState::is_enabled);
      Telltale* t = makeTelltale(i.cur(),ts);
      _browser->append_selectable(ts);
      _browser->append(t);
    }

    _browser->select(s);

    Glyph* g = layout->hbox(
      layout->vcenter(
        kit->inset_frame(
          layout->margin(
            layout->natural_span(_browser, width, height), 1.0
          )
        ),
        1.0
      ),
      kit->inset_frame( kit->vscroll_bar(_browser->adjustable()))
    );

    body(g);
 }
--
+-----------------+-------------------------------+-------------------------+
| Bill Poitras    | Molecular Simulations Inc.    | Tel (408)522-9229       |
| (bill)          | Sunnyvale, CA USA             |                         | 
|                 | FAX (408)732-0831             | bill@west.msi.com       |
+-----------------+-------------------------------+-------------------------+
Technical Details
Message-ID: <9301121909.AA25007@snoopy.west.msi.com.west.msi.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!msi.com!bill

Show Full Headers
Complete Article Headers
Newsgroups: comp.windows.interviews
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!msi.com!bill
From: bill@msi.com (Bill Poitras)
Subject: Re: Scrolling
Message-ID: <9301121909.AA25007@snoopy.west.msi.com.west.msi.com>
Sender: news@shelby.stanford.edu (USENET News System)
Organization: Internet-USENET Gateway at Stanford University
Date: Tue, 12 Jan 1993 19:09:36 GMT
Lines: 90