🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.interviews
Article #725

Re: Help! Image, raster, redraw (maybe a bug in Image?)

#725
From: Can Keskin
Date: Fri, 02 Oct 1992 22:48
83 lines
2444 bytes
I modified your program a little. I used a deck to flip betwen the images, 
which IMHO is really what you should do.
This works under 3.1beta2 (and should work under beta3) but I never got
anything to run correctly under beta1. So it still might not work under beta1.

--------------------------------CUT HERE---------------------------------------
#include <IV-look/kit.h>
#include <InterViews/layout.h>
#include <InterViews/session.h>
#include <InterViews/window.h>
#include <InterViews/tiff.h>
#include <InterViews/image.h>
#include <InterViews/patch.h>

class App {
public:
  App(int argc, char** argv);
  Glyph* make(WidgetKit&);
  void action();
private:
  Patch* patch_;
  Deck* deck_;
  Raster* one;
  Raster* two;
};

declareActionCallback(App)
implementActionCallback(App)

App::App(int, char** argv)
{
  one = TIFFRaster::load(argv[1]);
  two = TIFFRaster::load(argv[2]);
}

Glyph* App::make(WidgetKit&) 
{
  LayoutKit &layout = *LayoutKit::instance();

  deck_ = layout.deck();
  deck_->append(new Image(one));
  deck_->append(new Image(two));
  deck_->flip_to(0);

  patch_ = new Patch( deck_);
  return patch_;
}

void App::action ()
{
  deck_->flip_to((deck_->card()+1)%2);
  patch_->redraw();
}

int 
main(int argc, char** argv) 
{
  Session* session = new Session("Image", argc, argv);
  WidgetKit& kit = *WidgetKit::instance();
  const LayoutKit& layout = *LayoutKit::instance();

  App* a = new App(argc, argv);
  session->run_window(
    new ApplicationWindow(
      layout.vcenter(
        kit.outset_frame(
          layout.margin(
            layout.vbox(
                kit.push_button(
                  "pushme",
	          new ActionCallback(App) (a, &App::action)
                ),
              layout.vglue(),
	      a->make(kit)
            ),
            5.0
          )
         ),
         1.0
       )
    )
  );
}
Technical Details
Message-ID: <1992Oct2.224802.26351@ulowell.ulowell.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!ulowell!img.ulowell.edu!ckeskin
References: <1992Oct2.201127.27325@chpc.org>

Show Full Headers
Complete Article Headers
Newsgroups: comp.windows.interviews
Path: arc1-ca.pugleaf.net!sparky!uunet!ulowell!img.ulowell.edu!ckeskin
From: ckeskin@cs.ulowell.edu (Can Keskin)
Subject: Re: Help! Image, raster, redraw (maybe a bug in Image?)
Message-ID: <1992Oct2.224802.26351@ulowell.ulowell.edu>
Sender: usenet@ulowell.ulowell.edu (News manager - ulowell)
Organization: Interactive Media Group - University of Massachusetts at Lowell
References:  <1992Oct2.201127.27325@chpc.org>
Distribution: na
Date: Fri, 2 Oct 1992 22:48:02 GMT
Lines: 86