/*****************************************************************************
 * $LastChangedDate: 2011-04-09 21:58:06 -0400 (Sat, 09 Apr 2011) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   GUI class.
 *//*
 * LEGAL:   COPYRIGHT (C) 2008 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#ifndef GUI_GUI_HH
#define GUI_GUI_HH 1

#include "base/singleton.hh"
#include "base/event.hh"
#include "base/time.hh"

// FLTK:
class Fl_Double_Window;
class Fl_Widget;
class Fl_Box;
class Fl_Float_Input;

namespace gui {

#define GET_GUI() (Gui::GetInstance())

////////////////////////////////////////////////////////////////////////////////
/// @brief GUI class (Singleton).
///
class Gui
{
PREVENT_COPYING(Gui)
private:
    Gui( void );
    ~Gui();

public:
                        DEFINE_GetInstance( Gui )  // Singleton
    void                Show( void );

private:
    void                Reset( void );
    void                ProcessEvents( void );
    void                ReadConfBin( void );
    CLASS_METHOD void   DestroyWindowCallback( Fl_Widget*, void* );
    CLASS_METHOD void   MissionCallback( Fl_Widget*, void* data );
    CLASS_METHOD void   AircraftCallback( Fl_Widget*, void* data );
    CLASS_METHOD void   LocationCallback( Fl_Widget*, void* data );
    CLASS_METHOD void   RestartCallback( Fl_Widget*, void* data );
    CLASS_METHOD string GetWidgetVal( SafePtr<Fl_Float_Input> widget );

private:
    CLASS_EVENT_LISTENER_BASIC( FrameListener, Void )

private:
    CLASS_VAR Gui*              msInstance;

    // FLTK:
    shptr<FrameListener>        mFrameListener;
    Fl_Double_Window*           mWindow;
    SafePtr<Fl_Float_Input>     mLatWidget, mLonWidget, mAltWidget;
    SafePtr<Fl_Box>             mScoreCrashesWidget, mScoreLandingsWidget, mScoreTargetsDestroyedWidget;

    // Misc:
    Milliseconds                mReadConfBinTimestamp;  // to skip most frames for speed

    // These form a command string to be enqueued into the sim's command queue:
    string                      mMissionName;
    string                      mAircraftName;
    string                      mLocationName;
};

} // namespace gui

#endif // GUI_GUI_HH
