OpenQNX :: The QNX Community Portal

Oct 07, 2008 - 11:37 AM
Google
  Web openqnx.com   
     Create an account Home · Submit News · QNX Forums · QNX Download · Search   
_
Main Menu
Who's Online
There are 46 unlogged users and 1 registered user online.

You can log-in or register for a user account here.

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
steven_lougheed
Post subject: Retrieving Widget Names  PostPosted: Jul 26, 2007 - 06:41 PM
Active Member


Joined: Feb 23, 2007
Posts: 16

Is there a way to retrieve the name of a widget generated by PhAB within a callback?

For example:

I have two label widgets named "label_widget_0" and "label_widget_1" both using the same realized callback "realized_callback@file.cc". I'd like to be able to determine which widget is being realized in the callback without using the user data or comparing against the PhAB generated ABW index. (i.e. I could do if(widget == ABW_label_widget_0) but that requires a hard coded solution).

Since we enforce a naming scheme within PhAB it would be much more convenient to parse the name string so I could determine that it was widget 0 or 1 that was being realized.

Anyone know if this text is stored somewhere or is it only used by PhAB to generate the ABW index name?
 
 View user's profile Send private message  
Reply with quote Back to top
bedmond
Post subject: RE: Retrieving Widget Names  PostPosted: Jul 26, 2007 - 08:17 PM
Active Member


Joined: Apr 17, 2007
Posts: 12

I don't know of any way to get the string. Usually ApName() is used to this type of thing but it is not much different than using the ABW_ value:

if ( ApName( widget ) == ABN_widget1 ) {
/* do widget1 processing */
}

Phab stores the widgets as indexs and defines when it generates the code.
 
 View user's profile Send private message  
Reply with quote Back to top
ingraham
Post subject:   PostPosted: Jul 26, 2007 - 09:39 PM
Active Member


Joined: Nov 05, 2003
Posts: 87
Location: Texas
ApInstanceName() might do what you want.

char *generated_string....
if (strcmp(ApInstanceName(widget), generated_string) == 0)...

Make sure you look at the ApInstanceName() documentation. The strings aren't retained by default, so you have to change a setting in PhAB.


Incidentally, I handle this problem slightly differently. At startup, we assign all the ABW_xxx pointers into an array. Then we put a value corresponding to the index in Pt_ARG_USER_DATA. Pull the number out of Pt_ARG_USER_DATA and then you can directly use widget_array[widget_index]. This adds the work of dealing with Pt_ARG_USER_DATA, but saves the work of dealing with strings and the space of storing the strings in the running project.

-James Ingraham
Sage Automation, Inc.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
steven_lougheed
Post subject:   PostPosted: Jul 27, 2007 - 02:01 PM
Active Member


Joined: Feb 23, 2007
Posts: 16

Excellent. Thanks that's exactly what I was looking for.

I think I will take your suggestion and assign the USER_DATA at runtime. We had been doing something similar, but backwards i.e. assigning the USER_DATA in PhAB and then hardcoding an array of widgets that would line up with these numbers. Your solution makes a lot more sense.

Just in case anyone is reading this post later looking for the option in PhAB to store the strings, it is the aptly named "Store Names for ApInstanceName()" under the "Generate Options" tab in Project Properties. The document is here: http://www.qnx.com/developers/docs/6.3.0/photon/prog_guide/applications.html#OtherOptions
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
All logos and trademarks in this site are property of their respective owners. The comments are property of their posters.
Powered by OpenQNX: The QNX Community Portal Site
QNX and the QNX logo are registered trademarks of QNX Software Systems.