Skip navigation.
Home
The QNX Community Portal

View topic - Problem with custom widget creation

Problem with custom widget creation

Isn't the name clear?

Problem with custom widget creation

Postby cyvinay4 » Wed Aug 27, 2008 6:11 am

My custom widget can easily be created by draging and droping from the widget box but only while creating and realizing it through PtCreateWidget & PtReallizeWidget there appears a white dot at the top left corner of the window

i have tried setting the width and height. I set the width and height of the widget which is being passed as an argument to PtSuperclassDraw in the widgets draw function. All the widget resources values are printed same as what is set with PtSetArg and PtSetResource with printf statement from the widgets draw function. Still the out come is same
cyvinay4
New Member
 
Posts: 9
Joined: Mon Aug 25, 2008 5:15 am

RE: Problem with custom widget creation

Postby PeterHuber » Wed Aug 27, 2008 7:08 am

Hello cyvinay4,

I have written a lot of widgets and I can't remember any Photon specific problem causing your issue. So I guess there is a bug in your code and I think you will not get an answer here if you don't ask more specific.

Please do not open multiple threads for the same problem in this forum!

-Peter
PeterHuber
Active Member
 
Posts: 55
Joined: Sat Sep 01, 2007 11:11 am
Location: Switzerland

Problem with custom widget creation

Postby cyvinay4 » Thu Aug 28, 2008 10:09 am

The widget i have created is a class and not a structure as given in the help. Can this aspect ceate a problem with PtCreateWidget and PtRealizeWidget function
cyvinay4
New Member
 
Posts: 9
Joined: Mon Aug 25, 2008 5:15 am

RE: Problem with custom widget creation

Postby PeterHuber » Thu Aug 28, 2008 11:48 am

I suspect one of the problems is that PtCreateWidget doesn't call the class constructor of your custom widget "class".
I know there are solutions using photon with classes - but I think it's not as easy as simply replace the widget struct by a class.

-Peter
PeterHuber
Active Member
 
Posts: 55
Joined: Sat Sep 01, 2007 11:11 am
Location: Switzerland

Re:Problem with custom widget creation

Postby cyvinay4 » Thu Aug 28, 2008 1:38 pm

Following is the code to create a custom widget on button click i have used

Basicwidgets's position and its width and height i have set in my widget's draw function.Is it O.K?

Is there any problem with the code?
/* Standard headers */

#include <stdio.h>

#include <stdlib.h>

#include <unistd.h>

#include <string.h>



/* Local headers */

#include "ablibs.h"

#include "abimport.h"

#include "proto.h"





int

ShowMsg( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )



{



PtArg_t argt[1];

PtWidget_t *window;

int ret;



/* eliminate 'unreferenced' warnings */

widget = widget, apinfo = apinfo, cbinfo = cbinfo;



PtSetArg(&argt[0],SBW_NO_OF_BOXES,2,0);

window=PtCreateWidget(MyBox,(PtWidget_t *)ABW_base1,1,argt);



//PtSetArg(&argt[0],Pt_ARG_TEXT_STRING,"",0);

//window=PtCreateWidget(PtButton,(PtWidget_t *)ABW_base1,1,argt);



ret=PtRealizeWidget(window);

printf("\nResult:%d\n",ret);



return( Pt_CONTINUE );



}
cyvinay4
New Member
 
Posts: 9
Joined: Mon Aug 25, 2008 5:15 am

RE: Re:Problem with custom widget creation

Postby PeterHuber » Thu Aug 28, 2008 1:58 pm

No, it is not ok to change the size of the widget in it's draw function!

Please have a look at "Anatomy of a Widget" in the online help. Look for Pt_SET_EXTENT_F.

The code above seems ok - the typecast to (PtWidget_t*) for ABW_base1 is not necessary.

-Peter
PeterHuber
Active Member
 
Posts: 55
Joined: Sat Sep 01, 2007 11:11 am
Location: Switzerland


Return to GUI Programming

Who is online

Users browsing this forum: No registered users and 3 guests