Some basic questions: visibility of variables / grid propert

Hi all!

I have some basic questions about photon. I hope somebody can lend me a hand
on the following subjects:

  • Grid widget. I have a 26x26 grid. I would like to paint a cell in black
    color every time the user clicks over this cell. If the cell is empty, it is
    painted black. If the cell is black, the cell becomes empty. I suppose is
    easy to do, but I don’t see how… the help system of Photon is well
    structured, but very poor in practical examples!!

  • Let us say that I have a window with a button and a grid like the last
    one. Where do I have to declare a variable if I want to access and use this
    variable in both objects callbacks? In my case, the variable is a 26x26
    array of booleans and every time I click the grid I update the appropiate
    value in the array. After that, I press the OK button in order to process
    this array. Which is the best strategy to afford a situation like that?

TIA

Jordi Garcia Busquets
Girona. Catalunya. Spain

Jordi Garcia <jgbusquets@yahoo.com> wrote:
: Hi all!

: I have some basic questions about photon. I hope somebody can lend me a hand
: on the following subjects:

: - Grid widget. I have a 26x26 grid. I would like to paint a cell in black
: color every time the user clicks over this cell. If the cell is empty, it is
: painted black. If the cell is black, the cell becomes empty.

PtGrid is just a graphical widget, so you’ll need to set up clickable
widgets (e.g. a PtButton with no border) for each cell if you want to
select it. You’ll have to set the fill colour as appropriate when you
select/unselect a cell.

: I suppose is
: easy to do, but I don’t see how… the help system of Photon is well
: structured, but very poor in practical examples!!

Thanks for the feedback. I’d like to add more examples, but all our
writers are very busy these days. To paraphrase the hymn: O, for a thousand
pens to write…!

: - Let us say that I have a window with a button and a grid like the last
: one. Where do I have to declare a variable if I want to access and use this
: variable in both objects callbacks? In my case, the variable is a 26x26
: array of booleans and every time I click the grid I update the appropiate
: value in the array. After that, I press the OK button in order to process
: this array. Which is the best strategy to afford a situation like that?

You can declare them in a global header in your application and use them
as global variables in your code. The coding purists will shudder at this
thought. See “Global header file” in the Working with Code chapter of the
Photon Programmer’s guide.


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems