
Some parts of this message have been removed.
Learn more about Nabble's
security policy.
Hello all,
Question part one:
Based on previous comments & helps, I use the following method to embed a checkbox into table cell.
// FXCheckboxTableItem : public FXTableItem
FXCheckboxTableItem::FXCheckboxTableItem(FXApp* app, const FXString& label, bool isChecked, void* ptr/*=NULL*/)
: m_app(app), m_label(label), m_isChecked(isChecked)
{
checkbox_no_icon=new FXBMPIcon(m_app,checkbox_no_bmp,0,IMAGE_ALPHAGUESS);
checkbox_no_icon->create();
checkbox_yes_icon=new FXBMPIcon(m_app,checkbox_yes_bmp,0,IMAGE_ALPHAGUESS);
checkbox_yes_icon->create();
setIcon(checkbox_no_icon); // default icon is uncheck image
}
FXWindow *
FXCheckboxTableItem::getControlFor( FXTable* table )
{
register FXCheckButton *checkbox;
register FXuint justify=0;
checkbox=new FXCheckButton(table,m_label,this,NULL, ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP);
if(state&LEFT) justify|=JUSTIFY_LEFT;
if(state&RIGHT) justify|=JUSTIFY_RIGHT;
if(state&TOP) justify|=JUSTIFY_TOP;
if(state&BOTTOM) justify|=JUSTIFY_BOTTOM;
checkbox->create();
checkbox->setJustify(justify);
checkbox->setFont(table->getFont());
checkbox->setBackColor(table->getBackColor());
checkbox->setTextColor(table->getTextColor());
return checkbox;
}
void
FXCheckboxTableItem::setFromControl( FXWindow *control )
{
register FXCheckButton *check=static_cast<FXCheckButton*>(control);
m_isChecked = check->getCheck();
if (m_isChecked)
{
setIcon(checkbox_yes_icon); // a picture captured when a checkbox is check
}
else
{
setIcon(checkbox_no_icon); // a picture captured when a checkbox is uncheck
}
}
Now new problems are as follows:
Expected actions: whenever the user single-clicks the cell, then the icon switches between yes and no icons.
Current actions: The user has to double-click the cell in order to change the icon from yes to no or no to yes icons.
The major reason of this problem
is that when the user double-clicks the cell, then the cell enters Edit mode that in turn triggers the setFromControl and getControlFor.
Is there a way that I can use so that
1> double clicks the cell does nothing
2> single clicks the cell will switch between two icons
Question part two:
I also try to catch the selection event, however, the code is not called by the selection
FXDEFMAP(FXCheckboxTableItem) FXCheckboxTableItemMap[]={
FXMAPFUNC(SEL_LEFTBUTTONPRESS, 0, FXCheckboxTableItem::onItemSelected),
FXMAPFUNC(SEL_DESELECTED, 0, FXCheckboxTableItem::onItemDeselected),
};
// Object implementation
FXIMPLEMENT(FXCheckboxTableItem,FXTableItem,FXCheckboxTableItemMap,ARRAYNUMBER(FXCheckboxTableItemMap))
// Leave window
long FXCheckboxTableItem::onItemSelected(FXObject* sender,FXSelector sel,void*
ptr)
{
return 1;
}
// Leave window
long FXCheckboxTableItem::onItemDeselected(FXObject* sender,FXSelector sel,void* ptr)
{
return 1;
}
Thank you again.
------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org_______________________________________________
Foxgui-users mailing list
Foxgui-users@...
https://lists.sourceforge.net/lists/listinfo/foxgui-users