so the problem described above is solved …
Doing executable without mainfunction won´t work.
I put in a Main function now,
problem is, as soon as i include my subs, lets say creating an Label in dflts function, and including it in PtCreateWindows Args from my PtCompound-deriviate, makes SIGSEGVing the App …
I put my code now:
LabelCompound.h:
#ifndef __PT_LABEL_IMAGE_H_INCLUDED
#define __PT_LABEL_IMAGE_H_INCLUDED
#ifndef __PT_COMPOUND_H_INCLUDED
#include <photon/PtCompound.h>
#endif
#ifndef __PT_LABEL_H_INCLUDED
#include <photon/PtLabel.h>
#endif
#ifndef _PXIMAGE_H_INCLUDED
#include <photon/PxImage.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define PtLIWidget_t Pt_LabelImageWidget_t
extern PtWidgetClassRef_t *const PtLabelImage;
typedef struct Pt_LabelImage {
PtCompoundWidget_t compound; // Das Compound Widget immer als erstes!!!
PtWidget_t *clabelw;
} Pt_LabelImageWidget_t;
typedef union Pt_LabelImageUnion {
PtWidget_t core;
PtBasicWidget_t basic;
PtContainerWidget_t cntnr;
PtCompoundWidget_t cmpnd;
PtLabelWidget_t label;
Pt_LabelImageWidget_t li3w;
} Pt_LabelImageUnion_t;
PtLabelCompound.c
#include <string.h>
#include <stdlib.h>
#include <Pt.h>
#include <Ph.h>
#include "PtLabelCompound.h"
#include <string.h>
#include <Pt.h>
#include <Ph.h>
PtWidgetClass_t *PtCreateLIClass( void ); // Prototype Widget - Create Funktion
PtWidgetClassRef_t __Pt_LabelImage = { NULL, PtCreateLIClass };
PtWidgetClassRef_t * const PtLabelImage = &__Pt_LabelImage;
static void
dflts_f( PtWidget_t *widget )
{
PtLIWidget_t *li3 = (PtLIWidget_t *) widget;
PtArg_t argt[10];
int n = 0;
PtSetArg(&argt[n], Pt_ARG_TEXT_STRING, "Bla", 0 ); n++;
PtSetArg(&argt[n], Pt_ARG_FILL_COLOR, Pg_BLUE, 0 ); n++;
li3->clabelw = PtCreateWidget( PtLabel, widget, n, argt );
n=0;
}
static void
li_forwarding( PtWidget_t *widget, PtArg_t *argt )
{
// forward resources
PtLIWidget_t *li3 = (PtLIWidget_t * ) widget;
PtSetResources( li3->clabelw, 1, argt );
}
PtWidgetClass_t *PtCreateLIClass( void )
{
static PtResourceRec_t resources[] =
{
Pt_ARG_FILL_COLOR, li3_forwarding, 0, Pt_ARG_IS_NUMBER( PtBasicWidget_t, fill_color), 0,
Pt_ARG_TEXT_STRING, li3_forwarding, 0, Pt_ARG_IS_STRING( PtLabelWidget_t, string), 0
};
static ushort_t subs[] =
{
offsetof( Pt_LabelImageWidget_t, clabelw )
};
static ulong_t blocked[] = {
Pt_ARG_BALLOON_FILL_COLOR
};
// Crashes here in runtime, as soon as i include subs in args !!
static PtArg_t args[] = {
{ Pt_SET_VERSION, 110 },
{ Pt_SET_DFLTS_F, (long) dflts_f },
{ Pt_SET_NUM_RESOURCES, sizeof( resources ) / sizeof( resources[0] ) },
{ Pt_SET_RESOURCES, (long) resources, sizeof( resources ) / sizeof( resources[0] ) },
{ Pt_SET_NUM_SUBORDINATES, sizeof( subs ) / sizeof( subs[0] ) },
{ Pt_SET_SUBORDINATES, (long) subs, sizeof( subs ) / sizeof( subs[0] ) },
{ Pt_SET_NUM_BLOCKED_RESOURCES, sizeof( blocked )/ sizeof( blocked[0] ) },
{ Pt_SET_BLOCKED_RESOURCES, (long) blocked, sizeof( blocked ) / sizeof( blocked[0] ) },
};
int size = sizeof( args ) / sizeof(args[0]);
printf("Size: %d\n",size);
return( PtLabelImage->wclass =
PtCreateWidgetClass( PtCompound, 0, size, args )
);
}
int main( int argc, char **argv ) {
PtArg_t args[ 10 ];
PtWidget_t * mainw;
PtWidget_t * list;
PtAppContext_t app;
PtSetArg( &args[0], Pt_ARG_WINDOW_TITLE, "PtLI", 0 );
mainw = PtAppInit( &app, &argc, argv, 1, args );
if ( mainw == NULL ) {
return(EXIT_FAILURE);
}
PtSetArg( &args[0], Pt_ARG_TEXT_STRING, "Juhuu .. n Label", 0 );
PtSetArg( &args[1], Pt_ARG_FILL_COLOR, Pg_BLUE, 0 );
PtSetArg( &args[2], Pt_ARG_LABEL_TYPE, Pt_Z_STRING, 0 );
list = PtCreateWidget( PtLabelImage, mainw, 3, args );
// list = PtCreateWidget( PtLabel, mainw, 3, args );
PtRealizeWidget( mainw );
PtMainLoop();
return(EXIT_SUCCESS);
}
There may be some wired namings, since i changed and deleted a lot for posting, but in general thats all what is run through.
Thx for help[/code]