Hello,

I have some questions about the use of PG_GROP_TEXT for the
implementation the Waba (http://waba.sourceforge.net) port to
PicoGUI.

- pgSizeText(). After some tests, I think it compute not in a
  correct way. To have correct size, we have to substract a
  w_nothing value calculate with :
  pgSizeText( &w_nothing, &h, theFont, pgNewString( "" ).

- when writing a text, we always have a small space just before
  it (corresponding to w_nothing / 2 ).

- color selection for text doesn't work. Or I don't understand
  how to use.

Attached to this email is a small sample with all the points.

The main question is "Is this the real way of use, or is this
a bug ? (for the position/size problems), and How to use color ?"

Thanks in advance.

                Olivier
-- 
Olivier Bornet                      SMARTDATA SA
[EMAIL PROTECTED]         Centre du Parc
http://www.smartdata.ch             av. des Prés-Beudin 20
Phone +41-27-723'55'03              1920 Martigny
Fax   +41-27-723'55'19              Phone +41-27-723'55'18
#include <picogui.h>

#define MY_TEXT1 "Hello, crual World"
#define MY_TEXT2 "Hello, "
#define MY_TEXT3        "crual"
#define POS_X    50
#define POS_Y    50

#define RED   0x00FF0000
#define GREEN 0x0000FF00
#define BLUE  0x000000FF
#define BLACK 0x00000000

int main(int argc,char **argv) {
   pghandle w;
   int width_nothing;
   int height, width;

   /* init */
   pgInit( argc, argv );
   pgRegisterApp( PG_APP_NORMAL, "Canvas Text", 0 );
   w = pgNewWidget( PG_WIDGET_CANVAS, 0, 0 );
  
   /* write the text */
   pgWriteCmd( w, PGCANVAS_GROP, 5, PG_GROP_TEXT, POS_X, POS_Y, 1, 1 );
   pgWriteCmd( w, PGCANVAS_SETGROP, 3, pgNewString( MY_TEXT1 ), 0, BLACK );
   pgWriteCmd( w, PGCANVAS_COLORCONV, 1, 4);

   /* get the size of nothing and the 1st part of the text */
   pgSizeText( &width_nothing, &height, PGFONT_ANY, pgNewString( "" ));
   pgSizeText( &width, &height, PGFONT_ANY, pgNewString( MY_TEXT2 ));

   /* write the 2n part of the text in red */
   pgWriteCmd( w, PGCANVAS_GROP, 5, PG_GROP_TEXT, POS_X + width - width_nothing, POS_Y 
+ 10 , 1, 1 );
   pgWriteCmd( w, PGCANVAS_SETGROP, 3, pgNewString( MY_TEXT3 ), 0, RED );
   pgWriteCmd( w, PGCANVAS_COLORCONV, 1, 4);

   /* draw lines representing size of MY_TEXT3 ...*/

   /* ... horizontal */
   pgWriteCmd( w, PGCANVAS_GROP, 5, PG_GROP_LINE, POS_Y, POS_Y - 5, width, 0 );
   pgWriteCmd( w, PGCANVAS_SETGROP, 1, BLUE );
   pgWriteCmd( w, PGCANVAS_COLORCONV, 1, 1 );

   /* ... vertical */
   pgWriteCmd( w, PGCANVAS_GROP, 5, PG_GROP_LINE, POS_X - 5, POS_Y, 0, height );
   pgWriteCmd( w, PGCANVAS_SETGROP, 1, BLUE );
   pgWriteCmd( w, PGCANVAS_COLORCONV, 1, 1 );

   /* draw horizontal line representing width of nothing */
   pgWriteCmd( w, PGCANVAS_GROP, 5, PG_GROP_LINE, POS_X, POS_Y - 10, width_nothing, 0 
);
   pgWriteCmd( w, PGCANVAS_SETGROP, 1, RED );
   pgWriteCmd( w, PGCANVAS_COLORCONV, 1, 1 );

   /* draw a small cross at the position where to write the text */
   pgWriteCmd( w, PGCANVAS_GROP, 5, PG_GROP_LINE, POS_X, POS_Y - 3, 0, 6 );
   pgWriteCmd( w, PGCANVAS_SETGROP, 1, GREEN );
   pgWriteCmd( w, PGCANVAS_COLORCONV, 1, 1 );
   pgWriteCmd( w, PGCANVAS_GROP, 5, PG_GROP_LINE, POS_X - 3, POS_Y, 6, 0 );
   pgWriteCmd( w, PGCANVAS_SETGROP, 1, GREEN );
   pgWriteCmd( w, PGCANVAS_COLORCONV, 1, 1 );

   /* main loop */
   pgEventLoop();

}

Reply via email to