Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages | Examples

timer.cpp

//
//  source generated by 'FastGL sourcer'
//

#include <fastgl/fastgl.h>
#include <fastgl/widgets.h>


fgl::FGWindow *Timer_examplePtr;
static int value=1000, cnt=0;
static fgl::FGTimer *tmr;

static unsigned int callback(unsigned int)
{
    Timer_examplePtr->printf(32, 168, "counts: %04d\n", cnt++);
    return value;
}

/*
  This procedure is called on activate of object
  argument is pointer (of type Control *, alias CallBack) to the object
  itself. You can ignore this value or use it to test who event generate
  REFERENCED FROM: 'Timer example' WINDOW
*/
static void settimer(fgl::CallBack)
{
    Timer_examplePtr->printf(168, 16, "%04d ms\n", value);
    tmr->SetTimer(value, callback);
}

/*
  This procedure handle all events generated by system and user input
  for all posible events see FastGL docs. I you don't want parse any
  events, you can remove this proc, and reference on it from Window CTOR
*/
static void Timer_exampleProc(fgl::FGEvent *p)
{
    switch(p->GetType()) {
        case fgl::INITEVENT:
            p->wnd->set_font(fgl::FONT2034);

            p->wnd->WindowBox(328, 0, 64, 240, fgl::CGRAY2);
            p->wnd->AddSlideBarV(352, 8, 100, 1500, 10, &value, settimer);
            p->wnd->WindowText(168, 16, "1000 ms", fgl::CGRAYED, fgl::CGRAY1);
            p->wnd->WindowText(32, 168, "counts: 0000", fgl::CBLACK, fgl::CGRAY1);
            break;
        case fgl::TERMINATEEVENT:
            fgl::FGApp::AppDone();
            break;
    }
}


int main(int argc, char **argv)
{
    fgl::FGApp MyApp(fgl::G640x480, argc, argv, fgl::CBLACK, fgl::APP_ENABLEALTX+fgl::APP_CFG);
    tmr = new fgl::FGTimer(callback);
    Timer_examplePtr = new fgl::FGWindow(&Timer_examplePtr, 376, 272, 394, 254, "Timer example", Timer_exampleProc, fgl::CBLACK, fgl::CGRAY1, fgl::WFRAMED|fgl::WTITLED|fgl::WMINIMIZE|fgl::WCENTRED|fgl::WESCAPE);
    MyApp.Run();
    delete tmr;
    if (Timer_examplePtr) delete Timer_examplePtr;
    return 0;
}

Generated on Wed Feb 9 11:31:34 2005 for OpenGUI by  doxygen 1.4.0