PtMultiText and colors


I am using a PtMultiText widget to display log events. I would like to print one event per line in the widget and to associate a color to distinguish events.
I wonder if there is an easy way to colorize the full line (beyond text wrap limit) instead of text (text_color attribute), because I am not statified with the graphical result. Because each line of text does not have the same width, this is not harmonious. Or maybe is there a way to add columns to the widget and to colorize each cells separately.

Here is a snippet of code:

[code]/** Check code event to determine if FAULT, ALARM or INFO type
PtMultiTextAttributes_t lattributes;
char lstatus[10];
lattributes.font = Pt_DEFAULT_FONT;
if ([lcindex].code < 100) {
if ([lcindex].code == 6) {
lattributes.background_color = Pg_RED;
lattributes.text_color = Pg_DEFAULT_WM_COLOR;
strncpy(lstatus, "[ALARM] ", sizeof(lstatus));
} else {
lattributes.background_color = Pg_GRAY;
lattributes.text_color = Pg_DEFAULT_WM_COLOR;
strncpy(lstatus, "[STATUS] ", sizeof(lstatus));
} else if (([lcindex].code < 400)
&& ([lcindex].code >= 100)) {

    lattributes.background_color = Pg_YELLOW;
    lattributes.text_color = Pg_DEFAULT_WM_COLOR;
    strncpy(lstatus, "[FAULT]  ", sizeof(lstatus));
  } else if ([lcindex].code >= 400) {

    lattributes.background_color = Pg_CYAN;
    lattributes.text_color = Pg_DEFAULT_WM_COLOR;
    strncpy(lstatus, "[INFO]   ", sizeof(lstatus));

  PtMultiTextModifyText(ABW_PtMultiTextEvents, insertion_pt, insertion_pt,
      insertion_pt, lstatus, 9, &lattributes, Pt_MT_FONT | Pt_MT_BACKGROUND
  lattributes.background_color = Pg_DEFAULT_WM_COLOR;
  lattributes.text_color = Pg_DEFAULT_WM_COLOR;
  PtGetResource(ABW_PtMultiTextEvents, Pt_ARG_CURSOR_POSITION, &cursor, 0);
  insertion_pt = *cursor;
  PtMultiTextModifyText(ABW_PtMultiTextEvents, insertion_pt, insertion_pt,
      insertion_pt, str, sizeof(str), &lattributes, Pt_MT_FONT

Any tip would be great !


You’ve probably looked at the documentation already, so I suspect that the PtMultiText Widget is not going to do what you want. Have you considered using a container or list containing text widgets?

Thank for the quick answer.

I can’t use text widgets nor containers because I have up to 1000 events to display!
That’s why I use this widget with a scrollbar.
I tried some tricks like strings with spaces padding but unfortunately it doens’t do the work :neutral_face:
My lines have not the same size …

I figure someone has already try to do something similar and looking for tips aroun here!


Why is that a problem?

Well I don’t know where to start, never used list in Photon before.
Should I use a PtList, a PtRawlist ?

A small example would be great to help me figure this out.

For example if I have a list widget. How do I add a PtText with specific background color and text to it ?

I’ve posted an answer to that yesterday but the response is still not published for a reason I ignore.
Do you have an example with list and text widget added dynamically ?


All I asked was for you to explain this statement. Why is 1000 events a problem?

I infer from your response that 1000 is not the problem, but that you don’t know how to deal with lists.

The place to start is the documentation. It might help to focus on the fact that QNX widgets
are hierarchical. To know what a widget is capable of you, have to check it’s properties in the documentation, and the properties of it’s ancestors.
All widgets descend from a PtWidget which has basic properties. Widgets that will display on the screen also descend from a PtBasic (which descends from a PtWidget).

The most basic container widget is a PtContainer. This widget adds the ability to contain other widgets.
PtList and PtRawList are descendants of PtContainer so they too can contain widgets. They each add features which may or may not be useful to your application. To find out, you will have to look at their properties.

Given what I know, I think the most straight forward solution for you would be start with a PtScrollContainer, and add PtText widgets to it. You create the PtText widgets using PtCreateWidget() giving them the PtScrollContainer as the parent. There are args, nargs parameters to PtCreateWidget() which allow you to set the text and background color at creation time. You will need to position the text widgets yourself in the scroll widget. You can use either the Pt_ARG_AREA or Pt_ARG_POS properties to set this.

I mentioned PtList because I think it handles the positioning for you, but that doesn’t mean it’s the right choice.

Do you know that Photon is to be deprecated in the next release.


What would you think if I told you that I figured out a way to make Photon programs work beyond 6.5?


Thanks! I’ll look into it

Yes I do but as far as I know, Qt is not part of momentics IDE yet and I was short of time at the time to try Qt and compile the GUI separately from momentics.
That’s the reason why I started with Photon on this project.

Do you know when momentics will add Qt projects ?

I would be interested to know more about it! :stuck_out_tongue:

It will be interesting if they do. A Qt project is a C++ project using the Qt libraries. So you can make a Qt program with the IDE. The reason I say interesting is that along with the different versions of Qt, there are two major branches. One branch has a GNU license. The other has a commercial license. So which would QNX provide?

On top of this, the current port of Qt works on top of the gf layer. This will change with the next version of QNX as both Photon and gf are going away.

I’ve just figured something. I just need to use a fixed-width font such as Courrier or Textfont.
What was I thinking at the time :unamused:

Problem solved :bulb: