/* * A "hello world" program for an InterViews button. */ #include #include #include /* * To add a button to an interface, first declare a new class that is a * subclass of InterViews' PushButton class. */ class HelloButton : public PushButton { public: HelloButton(const char* label, ButtonState* bs, int flag) : PushButton(label, bs, flag) {}; protected: void Press(); }; /* * To make something happen when the button is pressed, implement the virtual * Press function. */ void HelloButton::Press() { printf("Hello world.\n"); } /* * Now build a standard InterViews application program. In order to build a * new button, the constructor must be supplied its name, a button state * object, and an initial state value. The name is the string that will appear * inside the button. For now, we don't need to worry about the button state * and initial value, so we'll just supply dummy values for these. */ main() { World* world = new World; ButtonState* dummyState = new ButtonState; world->InsertApplication( new HelloButton("Hello Button", dummyState, true)); /* ^^^^^^^^^^^^^^^^ standard for now */ world->Run(); delete world; return 0; }