Hi,
we are having problems deriving our own widget class from PtComboBox. Has anyone ever successfully done a thing like that? And, if so, how?
Given below is a listing of a minimal program illustrating the problems. The derived combo box will exhibit a really poor focus handling, and after some playing around, the program will terminate from a SIGSEGV.
Any advice ? - thanks in advance,
Thomas Haupt,
BitCtrl Systems GmbH, Leipzig
/* Standard headers */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
/* Toolkit headers */
#include <Ph.h>
#include <Pt.h>
#include <Ap.h>
#include <photon/PtComboBox.h>
extern PtWidgetClassRef_t *MyCbx;
typedef
struct MyCbxWidget_struct
{
PtComboBoxWidget_t base;
}
MyCbxWidget_t;
static PtWidgetClass_t *create_class( void )
{
static const PtArg_t args[] =
{
{ Pt_SET_VERSION, 110 },
{ Pt_SET_STATE_LEN, sizeof( MyCbxWidget_t ) },
};
return( MyCbx->wclass = PtCreateWidgetClass( PtComboBox, 0,
sizeof args / sizeof args[0], args ) );
}
#ifndef _PHSLIB
static PtWidgetClass_t *create_class();
static PtWidgetClassRef_t MyCbx_def = { NULL, create_class };
PtWidgetClassRef_t *MyCbx = &MyCbx_def;
#endif
void main( int argc, char *argv[] )
{
PtWidget_t *win, *widget;
PhArea_t win_area = { { 10, 10 }, { 220, 200 } };
PhArea_t area = { { 10, 10 }, { 200, 17 } };
PtArg_t args[10];
char *items[] = { “alpha”, “romeo”, “juliet”, };
int n;
n = 0;
PtSetArg( args+n++, Pt_ARG_AREA, &win_area, 0 );
win = PtAppInit( NULL, &argc, argv, n, args );
n = 0;
PtSetArg( args+n++, Pt_ARG_AREA, &area, 0 );
PtSetArg( args+n++, Pt_ARG_ITEMS, items, sizeof items / sizeof items[0] );
PtSetArg( args+n++, Pt_ARG_CBOX_SEL_ITEM, 1, 0 );
widget = PtCreateWidget( MyCbx, win, n, args );
area.pos.y += 40;
widget = PtCreateWidget( PtComboBox, win, n, args );
area.pos.y += 40;
widget = PtCreateWidget( PtComboBox, win, n, args );
PtRealizeWidget( win );
PtMainLoop( );
}