From: Daniel Stine <robodanny@...>
To: foxgui-users@...
Sent: Tuesday, June 23, 2009 6:19:17 AM
Subject: [Foxgui-users] New issue related to embed a checkbox into table cell
Feng,
It's funny, but I just recently solved this same problem in an
entirely different way.
I subclassed FXTableItem and embedded a real FXCheckbox in the item.
Works for
me.
//---------------------------------------------------------------
//
// Derived checkbox table item
//
//---------------------------------------------------------------
class CheckTableItem : public FXTableItem
{
FXDECLARE(CheckTableItem)
protected:
CheckTableItem() {}
private:
FXTable *Table;
FXObject *Target;
FXSelector Selector;
FXCheckButton *check;
virtual void drawContent(const FXTable* table,FXDC& dc,FXint
x,FXint y,FXint w,FXint h) const;
public:
long onCheck(FXObject *, FXSelector, void *);
enum {
ID_CHECK = 1,
ID_LAST
};
public:
CheckTableItem(FXTable *table, FXIcon *ic=NULL, void *ptr=NULL);
virtual ~CheckTableItem(void) { delete check; }
void setCheck(FXbool state=TRUE, FXbool notify=FALSE) {
check->setCheck(state, notify); }
FXbool getCheck() const { return check->getCheck(); }
};
//---------------------------------------------------------------
// CheckTableItem
//---------------------------------------------------------------
FXDEFMAP(CheckTableItem) CheckTableItemMap[] = {
FXMAPFUNC(SEL_COMMAND, CheckTableItem::ID_CHECK, CheckTableItem::onCheck),
};
FXIMPLEMENT(CheckTableItem, FXTableItem, CheckTableItemMap,
ARRAYNUMBER(CheckTableItemMap))
// Construct new table item
CheckTableItem::CheckTableItem(FXTable *table, FXIcon *ic, void *ptr):
FXTableItem(FXString::null,ic,ptr)
{
Table = table;
Target = table->getTarget();
Selector = table->getSelector();
check = new FXCheckButton(table, FXString::null, this, ID_CHECK);
check->setBackColor(table->getBackColor());
check->create();
}
//
// drawContent - override
//
void CheckTableItem::drawContent(const FXTable *table, FXDC &dc,
FXint x, FXint y, FXint w, FXint h) const
{
check->position(x+1,y+1,w-2,h-2);
return;
}
//
// onCheck
//
long CheckTableItem::onCheck(FXObject *, FXSelector, void *vp)
{
if (Target) {
FXTableRange tablerange;
tablerange.fm.row = tablerange.to.row = Table->rowAtY(check->getY());
tablerange.fm.col = tablerange.to.col = Table->colAtX(check->getX());
//fxmessage("[%d,%d] = %p\n", tablerange.fm.row, tablerange.fm.col, vp);
Target->handle(this, FXSEL(SEL_REPLACED,Selector), &tablerange);
}
return 1;
}
> Date: Mon, 22 Jun 2009 09:20:46 -0700 (PDT)
> From: Feng Feng <
askfoxtoolkit@...>
> Subject: [Foxgui-users] New issue related to embed a checkbox into
> table cell
> To:
foxgui-users@...> Message-ID: <
711576.78275.qm@...>
> Content-Type: text/plain; charset="us-ascii"
>
> Hello all,
>
> Question part one:
> Based on previous comments & helps, I use the following method to embed a checkbox into table cell.
>
------------------------------------------------------------------------------
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