/**** * * Test the Show and Hide functions of the View class. * */ #include "view.h" #include #include #include #include #ifndef HP700 #include #endif class OtherDialog : public View { public: OtherDialog(Screen* s); virtual void Compose(); }; class MainDialog : public View { public: MainDialog(Screen* s, OtherDialog* od, int argc, char** argv); virtual void Compose(); protected: OtherDialog* od; Coord x; Coord y; }; class ShowItButton : public PushButton { public: ShowItButton(OtherDialog* od, Coord x, Coord y); protected: virtual void Press(); OtherDialog* od; Coord x; Coord y; }; class HideItButton : public PushButton { public: HideItButton(OtherDialog* od); protected: virtual void Press(); OtherDialog* od; }; class HideMeButton : public PushButton { public: HideMeButton(OtherDialog* od); protected: virtual void Press(); OtherDialog* od; }; MainDialog::MainDialog(Screen* s, OtherDialog* od, int argc, char** argv) : View(s) { this->od = od; if (argc > 1) { x = atoi(argv[1]); y = atoi(argv[2]); } else { x = y = 0; } } void MainDialog::Compose() { w = new Tray( new HBox( new ShowItButton(od, x, y), new HGlue(round(0.5 * inch)), new HideItButton(od) ) ); } OtherDialog::OtherDialog(Screen* s) : View(s) { } void OtherDialog::Compose() { w = new HideMeButton(this); } ShowItButton::ShowItButton(OtherDialog* od, Coord x, Coord y) : PushButton("Show It", new ButtonState(), true) { this->od = od; this->x = x; this->y = y; }; void ShowItButton::Press() { if (x or y) od->Show(x, y); else od->Show(); } HideItButton::HideItButton(OtherDialog* od) : PushButton("Hide It", new ButtonState(), true) { this->od = od; }; void HideItButton::Press() { od->Hide(); } HideMeButton::HideMeButton(OtherDialog* od) : PushButton("Hide Me", new ButtonState(), true) { this->od = od; }; void HideMeButton::Press() { od->Hide(); } main(int argc, char** argv) { Screen* s = new Screen(); OtherDialog* od = new OtherDialog(s); MainDialog* sd = new MainDialog(s, od, argc, argv); od->Compose(); sd->Compose(); sd->Show(); sd->Run(); delete(sd); }