#line 1 "/user/cvsspst/ees1cg/RAVL/RAVL-0.7/GUI/GTK/MenuCheck.hh"
// This file is part of RAVL, Recognition And Vision Library
// Copyright (C) 2001, University of Surrey
// This code may be redistributed under the terms of the GNU Lesser
// General Public License (LGPL). See the lgpl.licence file for details or
// see http://www.gnu.org/copyleft/lesser.html
// file-header-ends-here
#ifndef RAVLGUI_MENUCHECKITEM_HEADER
#define RAVLGUI_MENUCHECKITEM_HEADER 1
/////////////////////////////////////////////////////
//! rcsid="$Id: MenuCheck.hh,v 1.4 2002/08/02 08:04:45 craftit Exp $"
//! file="Ravl/GUI/GTK/MenuCheck.hh"
//! lib=RavlGUI
//! author="Charles Galambos"
//! docentry="Ravl.GUI.Control"
//! date="26/07/1999"
#include "Ravl/GUI/Menu.hh"
namespace RavlGUIN {
//! userlevel=Develop
//: Menu check item body
class MenuCheckItemBodyC
: public MenuItemBodyC
{
public:
MenuCheckItemBodyC(const StringC &lab,bool initActive= false);
//: Constructor.
virtual bool Create();
//: Create the widget.
bool IsActive() const;
//: Test if toggle is active.
bool GUISetActive(bool &val);
//: Set active.
// This will cause a 'SelectedToggle' signal to
// be issued.
// Should only be called by the GUI thread.
void SetActive(bool val);
//: Set active.
// This will cause a 'SelectedToggle' signal to
// be issued.
Signal1C &SelectedToggle()
{ return selectedToggle; }
//: Toggle select signal.
protected:
virtual void Destroy();
//: Undo all references
static int doSelected(GtkWidget *widget,Signal1C *data);
Signal1C selectedToggle;
bool active;
};
//! userlevel=Normal
//: Menu item
class MenuCheckItemC
: public MenuItemC
{
public:
MenuCheckItemC()
: MenuItemC(true)
{}
//: Default constructor
MenuCheckItemC(const StringC &name,bool initActive = false)
: MenuItemC(*new MenuCheckItemBodyC(name,initActive))
{}
//: Constructor
MenuCheckItemC(MenuCheckItemBodyC &bod)
: MenuItemC(bod)
{}
//: Body constructor
protected:
MenuCheckItemBodyC &Body()
{ return static_cast(WidgetC::Body()); }
//: Access body.
const MenuCheckItemBodyC &Body() const
{ return static_cast(WidgetC::Body()); }
//: Access body.
public:
bool IsActive() const
{ return Body().IsActive(); }
//: Test if toggle is active.
bool GUISetActive(bool &val)
{ return Body().GUISetActive(val); }
//: Set active status.
// This will cause a 'SelectedToggle' signal to
// be issued.
// GUI Thread only.
void SetActive(bool val)
{ Body().SetActive(val); }
//: Set active status.
// This will cause a 'SelectedToggle' signal to
// be issued.
// Thread safe.
Signal1C &SelectedToggle()
{ return Body().SelectedToggle(); }
//: Toggle select signal.
};
//: Call a function.
template
MenuCheckItemC MenuCheckItem(const StringC &label,bool (*func)(bool &, Data1T &),const Data1T &dat1 = Data1T())
{
MenuCheckItemC ret(label);
Connect(ret.SelectedToggle(),func,false,dat1);
return ret;
}
template
MenuCheckItemC MenuCheckItem(const StringC &label,const DataT &obj,bool (DataT::*func)(bool &))
{
MenuCheckItemC ret(label);
Connect(ret.SelectedToggle(),obj,func);
return ret;
}
template
MenuCheckItemC MenuCheckItemR(const StringC &label,DataT &obj,bool (DataT::*func)(bool &))
{
MenuCheckItemC ret(label);
ConnectRef(ret.SelectedToggle(),obj,func);
return ret;
}
//: Menu check item, call referenced class's method.
template
MenuCheckItemC MenuCheckItem(const StringC &label,bool initActive,const DataT &obj,bool (DataT::*func)(bool &))
{
MenuCheckItemC ret(label,initActive);
Connect(ret.SelectedToggle(),obj,func);
return ret;
}
template
MenuCheckItemC MenuCheckItemR(const StringC &label,bool initActive,DataT &obj,bool (DataT::*func)(bool &))
{
MenuCheckItemC ret(label,initActive);
ConnectRef(ret.SelectedToggle(),obj,func);
return ret;
}
}
#endif