ENH: Added help blobs that popup when the mouse is left on top of the

property name
This commit is contained in:
Luis Ibanez 2001-06-12 18:44:07 -04:00
parent 302907efe8
commit 8ef02a496a
3 changed files with 98 additions and 41 deletions

View File

@ -1,5 +1,8 @@
#include "FLTKPropertyItemRow.h"
#include <Fl/Fl.H>
#include <Fl/Fl_Window.H>
#include <Fl/Fl_Button.H>
#include <Fl/Fl_Box.H>
#include <Fl/Fl_Input.H>
#include <Fl/Fl_Tile.H>
#include <Fl/fl_ask.H>
@ -7,12 +10,14 @@
namespace fltk {
PropertyItemRow::PropertyItemRow( PropertyItem * pItem )
PropertyItemRow::PropertyItemRow( PropertyItem * pItem ):Fl_Tile(0,0,10,10,"")
{
m_PropertyItem = pItem;
m_PropertyItem = pItem;
m_ItemValue = new ItemValue;
const unsigned int nameWidth = 200;
const unsigned int textWidth = 1400;
const unsigned int checkWidth = textWidth;
@ -24,31 +29,31 @@ PropertyItemRow::PropertyItemRow( PropertyItem * pItem )
const unsigned int rowHeight = 20;
const unsigned int rowSpacing = 20;
Fl_Tile * group = new Fl_Tile(0,0,nameWidth+textWidth,rowHeight,"");
size( nameWidth + textWidth , rowHeight );
// Make the parent Fl_Pack widget at least a row wide.
group->parent()->size( nameWidth + textWidth , rowHeight );
parent()->size( nameWidth + textWidth , rowHeight );
Fl_Button * name = new
Fl_Button( firstColumn, 0, nameWidth, rowHeight,
pItem->m_propName.c_str() );
name->align( FL_ALIGN_CLIP | FL_ALIGN_LEFT | FL_ALIGN_INSIDE );
name->labelsize(11);
name->box( FL_DOWN_BOX );
name->callback( NameClickCallback, (void *)pItem );
switch( pItem->m_nItemType )
m_NameButton = new
PropertyNameButtonWithHelp( firstColumn, 0, nameWidth, rowHeight,
m_PropertyItem->m_propName.c_str() );
m_NameButton->align( FL_ALIGN_CLIP | FL_ALIGN_LEFT | FL_ALIGN_INSIDE );
m_NameButton->labelsize(11);
m_NameButton->box( FL_DOWN_BOX );
m_NameButton->SetHelpText( m_PropertyItem->m_HelpString.c_str() );
m_NameButton->size( secondColumn, rowHeight );
switch( m_PropertyItem->m_nItemType )
{
case 1:
{
name->size( secondColumn, rowHeight );
Fl_Input * input = new
Fl_Input( secondColumn, 0, textWidth ,rowHeight ,"");
input->value( pItem->m_curValue.c_str() );
input->value( m_PropertyItem->m_curValue.c_str() );
input->textsize(11);
input->callback( InputTextCallback, (void *)pItem );
input->callback( InputTextCallback, (void *)m_PropertyItem );
input->when( FL_WHEN_CHANGED );
break;
@ -64,21 +69,20 @@ PropertyItemRow::PropertyItemRow( PropertyItem * pItem )
case 4:
{
name->size( secondColumn, rowHeight );
Fl_Button * browseButton = new
Fl_Button( secondColumn, 0, browseWidth ,rowHeight ,"...");
browseButton->labelsize(11);
Fl_Input * input = new
Fl_Input( secondColumn+browseWidth, 0, textWidth ,rowHeight ,"");
input->value( pItem->m_curValue.c_str() );
input->value( m_PropertyItem->m_curValue.c_str() );
input->textsize(11);
m_ItemValue->m_InputText = input;
m_ItemValue->m_PropertyItem = pItem;
m_ItemValue->m_PropertyItem = m_PropertyItem;
browseButton->callback( BrowsePathCallback, (void *)m_ItemValue );
input->callback( InputTextCallback, pItem );
input->callback( InputTextCallback, m_PropertyItem );
input->when( FL_WHEN_CHANGED );
break;
@ -88,14 +92,14 @@ PropertyItemRow::PropertyItemRow( PropertyItem * pItem )
Fl_Button * button = new
Fl_Button( secondColumn, 0, checkWidth ,rowHeight ,"");
button->align( FL_ALIGN_INSIDE | FL_ALIGN_LEFT );
button->callback( CheckButtonCallback, (void *)pItem );
button->callback( CheckButtonCallback, (void *)m_PropertyItem );
if( pItem->m_curValue == "ON" )
if( m_PropertyItem->m_curValue == "ON" )
{
button->label(" ON ");
button->value(1);
}
else if( pItem->m_curValue == "OFF" )
else if( m_PropertyItem->m_curValue == "OFF" )
{
button->label(" OFF ");
button->value(0);
@ -107,42 +111,48 @@ PropertyItemRow::PropertyItemRow( PropertyItem * pItem )
case 6:
{
name->size( secondColumn, rowHeight );
Fl_Button * browseButton = new
Fl_Button( secondColumn, 0, browseWidth ,rowHeight ,"...");
browseButton->labelsize(11);
Fl_Input * input = new
Fl_Input( secondColumn+browseWidth, 0, textWidth ,rowHeight ,"");
input->value( pItem->m_curValue.c_str() );
input->value( m_PropertyItem->m_curValue.c_str() );
input->textsize(11);
m_ItemValue->m_InputText = input;
m_ItemValue->m_PropertyItem = pItem;
m_ItemValue->m_PropertyItem = m_PropertyItem;
browseButton->callback( BrowsePathCallback, (void *)m_ItemValue );
input->callback( InputTextCallback, pItem );
input->callback( InputTextCallback, m_PropertyItem );
input->when( FL_WHEN_CHANGED );
break;
}
break;
default:
fl_alert("Unkown item type %d",pItem->m_nItemType);
fl_alert("Unkown item type %d",m_PropertyItem->m_nItemType);
break;
}
group->end();
end(); // Close the inclusion of widgets in the Tile object
}
PropertyItemRow::~PropertyItemRow( )
{
delete m_ItemValue;
}
void
PropertyItemRow::
@ -167,13 +177,6 @@ CheckButtonCallback( Fl_Widget * widget, void * data)
}
void
PropertyItemRow::
NameClickCallback( Fl_Widget * widget, void * data)
{
PropertyItem * pItem = (PropertyItem *)data;
fl_message( pItem->m_HelpString.c_str() );
}
void
PropertyItemRow::
@ -186,6 +189,10 @@ InputTextCallback( Fl_Widget * widget, void * data)
}
void
PropertyItemRow::
BrowsePathCallback( Fl_Widget * widget, void * data)
@ -206,5 +213,27 @@ BrowsePathCallback( Fl_Widget * widget, void * data)
}
int
PropertyItemRow::
handle(int event)
{
int status = Fl_Tile::handle( event );
switch( event )
{
case FL_LEAVE:
m_NameButton->HideHelp();
status = 1;
break;
case FL_MOVE:
m_NameButton->HideHelp();
status = 1;
break;
}
return status;
}
} // end namespace fltk

View File

@ -1,30 +1,57 @@
#include "FLTKPropertyList.h"
#include <Fl/Fl_Widget.H>
#ifndef FLTKPropertyItemRow_h
#define FLTKPropertyItemRow_h
#include "FLTKPropertyList.h"
#include "FLTKPropertyNameButtonWithHelp.h"
#include <Fl/Fl_Tile.H>
#include <Fl/Fl_Input.H>
namespace fltk {
class PropertyItemRow
/**
Class to manage a GUI row corresponding to a property
*/
class PropertyItemRow : public Fl_Tile
{
// Helper class for passing data to callbacks
struct ItemValue
{
PropertyItem * m_PropertyItem;
Fl_Input * m_InputText;
};
public:
PropertyItemRow( PropertyItem * );
~PropertyItemRow();
int handle(int event);
private:
PropertyItem * m_PropertyItem;
ItemValue * m_ItemValue;
// Button that displays the property name and
// manages the popup help blob
PropertyNameButtonWithHelp * m_NameButton;
static void CheckButtonCallback( Fl_Widget *, void *);
static void NameClickCallback( Fl_Widget *, void *);
static void InputTextCallback( Fl_Widget *, void *);
static void BrowsePathCallback( Fl_Widget *, void *);
};
} // end namespace fltk
#endif

View File

@ -22,6 +22,7 @@ CMakeSetupGUIImplementation.o \
FLTKDialog.o \
FLTKPropertyItemRow.o \
FLTKPropertyList.o \
FLTKPropertyNameButtonWithHelp.o \
../cmCableClassSet.o \
../cmCacheManager.o \
../cmCommands.o \