diff options
Diffstat (limited to 'Source/FLTKDialog/FLTKPropertyItemRow.cxx')
-rw-r--r-- | Source/FLTKDialog/FLTKPropertyItemRow.cxx | 81 |
1 files changed, 61 insertions, 20 deletions
diff --git a/Source/FLTKDialog/FLTKPropertyItemRow.cxx b/Source/FLTKDialog/FLTKPropertyItemRow.cxx index 87b20d0..c48cd5d 100644 --- a/Source/FLTKDialog/FLTKPropertyItemRow.cxx +++ b/Source/FLTKDialog/FLTKPropertyItemRow.cxx @@ -7,10 +7,12 @@ #include <Fl/Fl_Tile.H> #include <Fl/fl_ask.H> #include <Fl/fl_file_chooser.H> +#include <Fl/Fl_Color_Chooser.H> +#include <cstdio> namespace fltk { - + PropertyItemRow::PropertyItemRow( PropertyItem * pItem ):Fl_Tile(0,0,10,10,"") { @@ -18,6 +20,7 @@ PropertyItemRow::PropertyItemRow( PropertyItem * pItem ):Fl_Tile(0,0,10,10,"") m_ItemValue = new ItemValue; + const unsigned int fontsize = 11; const unsigned int nameWidth = 200; const unsigned int textWidth = 1400; const unsigned int checkWidth = textWidth; @@ -39,44 +42,50 @@ PropertyItemRow::PropertyItemRow( PropertyItem * pItem ):Fl_Tile(0,0,10,10,"") m_PropertyItem->m_propName.c_str() ); m_NameButton->align( FL_ALIGN_CLIP | FL_ALIGN_LEFT | FL_ALIGN_INSIDE ); - m_NameButton->labelsize(11); + m_NameButton->labelsize( fontsize ); 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: + case PropertyList::COMBO: + { + break; + } + case PropertyList::EDIT: { Fl_Input * input = new Fl_Input( secondColumn, 0, textWidth ,rowHeight ,""); input->value( m_PropertyItem->m_curValue.c_str() ); - input->textsize(11); + input->textsize( fontsize ); input->callback( InputTextCallback, (void *)m_PropertyItem ); input->when( FL_WHEN_CHANGED ); break; } - case 2: - { - break; - } - case 3: + case PropertyList::COLOR: { + Fl_Button * colorButton = new + Fl_Button( secondColumn, 0, textWidth ,rowHeight ,""); + colorButton->labelsize( fontsize ); + //colorButton->color(); + colorButton->callback( ColorSelectionCallback, (void *)m_PropertyItem ); + break; } - case 4: + case PropertyList::FILE: { Fl_Button * browseButton = new Fl_Button( secondColumn, 0, browseWidth ,rowHeight ,"..."); - browseButton->labelsize(11); + browseButton->labelsize( fontsize ); Fl_Input * input = new Fl_Input( secondColumn+browseWidth, 0, textWidth ,rowHeight ,""); input->value( m_PropertyItem->m_curValue.c_str() ); - input->textsize(11); + input->textsize( fontsize ); m_ItemValue->m_InputText = input; m_ItemValue->m_PropertyItem = m_PropertyItem; @@ -87,7 +96,7 @@ PropertyItemRow::PropertyItemRow( PropertyItem * pItem ):Fl_Tile(0,0,10,10,"") break; } - case 5: + case PropertyList::CHECKBOX: { Fl_Button * button = new Fl_Button( secondColumn, 0, checkWidth ,rowHeight ,""); @@ -105,26 +114,26 @@ PropertyItemRow::PropertyItemRow( PropertyItem * pItem ):Fl_Tile(0,0,10,10,"") button->value(0); } button->type( FL_TOGGLE_BUTTON ); - button->labelsize(11); + button->labelsize( fontsize ); break; } - case 6: + case PropertyList::PATH: { Fl_Button * browseButton = new Fl_Button( secondColumn, 0, browseWidth ,rowHeight ,"..."); - browseButton->labelsize(11); + browseButton->labelsize( fontsize ); Fl_Input * input = new Fl_Input( secondColumn+browseWidth, 0, textWidth ,rowHeight ,""); input->value( m_PropertyItem->m_curValue.c_str() ); - input->textsize(11); + input->textsize( fontsize ); m_ItemValue->m_InputText = input; m_ItemValue->m_PropertyItem = m_PropertyItem; browseButton->callback( BrowsePathCallback, (void *)m_ItemValue ); - input->callback( InputTextCallback, m_PropertyItem ); + input->callback( InputTextCallback, (void *)m_PropertyItem ); input->when( FL_WHEN_CHANGED ); break; @@ -138,7 +147,6 @@ PropertyItemRow::PropertyItemRow( PropertyItem * pItem ):Fl_Tile(0,0,10,10,"") end(); // Close the inclusion of widgets in the Tile object - } @@ -191,6 +199,38 @@ InputTextCallback( Fl_Widget * widget, void * data) +void +PropertyItemRow:: +ColorSelectionCallback( Fl_Widget * widget, void * data) +{ + Fl_Button * colorButton = (Fl_Button *)widget; + PropertyItem * propertyItem = (PropertyItem *)data; + + static Fl_Color colorIndex = FL_FREE_COLOR; + + unsigned char red = 0; + unsigned char blue = 0; + unsigned char green = 0; + fl_color_chooser("Please pick a color",red,green,blue); + char buffer[300]; + sprintf( buffer,"RGB(%d,%d,%d)", red, green, blue ); + propertyItem->m_curValue = buffer; + Fl::set_color( colorIndex, red, green, blue ); + colorButton->color( colorIndex ); + colorIndex = (Fl_Color)( colorIndex + 1 ); + if( colorIndex == FL_FREE_COLOR + FL_NUM_FREE_COLOR ) + { + fl_alert("Maximum number of free colors used, recycling..."); + colorIndex = FL_FREE_COLOR; + } + + colorButton->redraw(); + +} + + + + void @@ -213,13 +253,14 @@ BrowsePathCallback( Fl_Widget * widget, void * data) } + + int PropertyItemRow:: handle(int event) { int status = Fl_Tile::handle( event ); - switch( event ) { case FL_LEAVE: |