RASPI / FiveLinux y el alineamiento de los SAY

RASPI / FiveLinux y el alineamiento de los SAY

Postby George » Tue Feb 16, 2016 7:33 pm

Como alinear (justify) a la izquierda y a la derecha los textos creados con el comando SAY?
Lo que sucede es que los SAY creados con FiveLinux en Raspbian (Debian en Raspberry PI) siempre salen centralizados.


[url]Image[/url]
Añadi el siguiente codigo:
http://forums.fivetechsupport.com/viewtopic.php?f=11&t=10992 Sugerido por un compañero del foro, pero no me funciono.

Alguien ha podido alinear los textos en SAY ?
Alguna sugerencia?

Estoy usando la mas reciente version de harbour y fivelinux para Raspberry Pi sugerida por Antonio.

Saludos,

George
George
 
Posts: 724
Joined: Tue Oct 18, 2005 6:49 pm

Re: RASPI / FiveLinux y el alineamiento de los SAY

Postby Antonio Linares » Tue Feb 16, 2016 8:43 pm

George,

Cómo has llamado a la función SAYSETALIGN() ?

Que parámetros le has proporcionado ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: RASPI / FiveLinux y el alineamiento de los SAY

Postby George » Tue Feb 16, 2016 9:33 pm

Antonio,
Este es el codigo que he usado acorde a lo indicado en el post:
@ 14, 2 SAY oSayName PROMPT "Name:" OF oFormCompany SIZE 100,20 PIXEL
oSayName:SetAlignment(0.0, 0.5)
No se ejecuta ningun cambio en el alineamiento del texto y en la consola sale el siguiente mensaje:
(main:1803): Gtk-CRITICAL **: IA__gtk_misc_set_alignment: assertion 'GTK_IS_MISd


Saludos,

George
George
 
Posts: 724
Joined: Tue Oct 18, 2005 6:49 pm

Re: RASPI / FiveLinux y el alineamiento de los SAY

Postby Antonio Linares » Wed Feb 17, 2016 9:08 am

George,

Como has añadido el método SetAlignment() en la clase TSay ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: RASPI / FiveLinux y el alineamiento de los SAY

Postby George » Wed Feb 17, 2016 2:35 pm

Antonio,
Estos son los cambios que hice para agregar el nuevo metodo SetAlignment a la clase TSay:

SAY.PRG
Code: Select all  Expand view
#include "FiveLinux.ch"

//----------------------------------------------------------------------------//

CLASS TSay FROM TControl

   METHOD New( nRow, nCol, oWnd, cText, nWidth, nHeight, lUpdate, oFont,;
               lPixel, lDesign, cVarName )

   METHOD cGenPrg()

   METHOD SetText( cText ) INLINE SaySetText( ::hWnd, cText )

   METHOD GetText() INLINE SayGetText( ::hWnd )

   METHOD SetJustify( nType ) INLINE SaySetJustify( ::hWnd, nType ) // LEFT = 0, RIGHT = 1, CENTER = 2, FILL = 3

   METHOD setangle(nAngle) INLINE SaySetAngle(::hWnd,nAngle)
   
  // Added
   METHOD SetAlignment( fHAlign, fVAlign ) INLINE SaySetAlign( ::hWnd, fHAlign, fVAlign )
ENDCLASS

//----------------------------------------------------------------------------//

METHOD New( nRow, nCol, oWnd, cText, nWidth, nHeight, lUpdate, oFont,;
            lPixel, lDesign, cVarName ) CLASS TSay

   DEFAULT oWnd := GetWndDefault(), nWidth := 70, nHeight := 20,;
           lUpdate := .f., lPixel := .F., lDesign := .F.

   ::hWnd     = CreateSay( cText )
   ::lUpdate  = lUpdate
   ::lDrag    = lDesign
   ::cVarName = cVarName

   oWnd:AddControl( Self )

   SetParent( ::hWnd, oWnd:hWnd )
   ::SetPos( nRow * If( lPixel, 1, 10 ), nCol * If( lPixel, 1, 10 ) )
   ::SetSize( nWidth, nHeight )

   if oFont != nil
      ::SetFont( oFont )
   endif

   ::Link()
   ::Show()

return Self

//----------------------------------------------------------------------------//
 
METHOD cGenPrg() CLASS TSay
 
   local cCode := CRLF + "   @ " + Str( ::nTop, 3 ) + ", " + ;
                  Str( ::nLeft, 3 ) + " SAY " + ::cVarName + ;
                  ' PROMPT "' + ::GetText() + '"' + ;
                  ' SIZE ' + Str( ::nWidth, 3 ) + ", " + ;
                  Str( ::nHeight, 3 ) + " PIXEL OF " + ::oWnd:cVarName + CRLF
return cCode


SAY.C
Code: Select all  Expand view
[code]#include <hbapi.h>
#include <gtk/gtk.h>

gboolean button_press_event( GtkWidget * hWnd, GdkEventButton * event );
gboolean motion_notify_event( GtkWidget * hWnd, GdkEventMotion * event );

HB_FUNC( CREATESAY )
{
   GtkWidget * hWnd = gtk_label_new( hb_parc( 1 ) );
   GtkWidget * event_box = gtk_event_box_new();

   gtk_signal_connect( GTK_OBJECT( event_box ), "button_press_event",
                       ( GtkSignalFunc ) button_press_event, NULL );

   gtk_signal_connect( GTK_OBJECT( event_box ), "motion_notify_event",
                       ( GtkSignalFunc ) motion_notify_event, NULL );

   gtk_widget_set_events( event_box, GDK_EXPOSURE_MASK
             | GDK_LEAVE_NOTIFY_MASK
             | GDK_BUTTON_PRESS_MASK
             | GDK_POINTER_MOTION_MASK
             | GDK_POINTER_MOTION_HINT_MASK );

   gtk_container_add( GTK_CONTAINER( event_box ), hWnd );
   gtk_widget_show( hWnd );

   hb_retnl( ( HB_ULONG ) event_box );
}

HB_FUNC( SAYSETTEXT )
{
   GtkWidget * hWnd = ( GtkWidget * ) hb_parnl( 1 );
   GList * children = gtk_container_get_children( ( GtkContainer * ) hWnd );

   gtk_label_set_text( children->data, hb_parc( 2 ) );
}

HB_FUNC( SAYGETTEXT )
{
   GtkWidget * hWnd = ( GtkWidget * ) hb_parnl( 1 );
   GList * children = gtk_container_get_children( ( GtkContainer * ) hWnd );

   hb_retc( ( char * ) gtk_label_get_text( children->data ) );
}

HB_FUNC( SAYSETJUSTIFY )
{
   GtkWidget * hWnd = ( GtkWidget * ) hb_parnl( 1 );

   gtk_label_set_justify( ( GtkLabel * ) hWnd, ( GtkJustification ) hb_parnl( 2 ) );
}

HB_FUNC( SAYSETANGLE )
{
   GtkWidget * hWnd = ( GtkWidget * ) hb_parnl( 1 );
  GList * children = gtk_container_get_children( ( GtkContainer * ) hWnd );
   gtk_label_set_angle(  children->data ,  hb_parnl( 2 ) );
}

// Added
HB_FUNC( SAYSETALIGN )
{

   GtkWidget * hWnd = (GtkWidget * ) hb_parnl( 1 );

   gtk_misc_set_alignment( ( GtkMisc * ) hWnd, hb_parnd( 2 ), hb_parnd( 3 ) );
}
George
 
Posts: 724
Joined: Tue Oct 18, 2005 6:49 pm

Re: RASPI / FiveLinux y el alineamiento de los SAY

Postby Antonio Linares » Wed Feb 17, 2016 2:49 pm

George,

He encontrado esto al revisar la documentación de gtk_misc_set_alignment():

https://developer.gnome.org/gtk3/stable/GtkMisc.html#gtk-misc-set-alignment

gtk_misc_set_alignment has been deprecated since version 3.14 and should not be used in newly-written code.
Use GtkWidget's alignment (“halign” and “valign”) and margin properties or GtkLabel's “xalign” and “yalign” properties
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: RASPI / FiveLinux y el alineamiento de los SAY

Postby Antonio Linares » Wed Feb 17, 2016 2:58 pm

Para modificar esas propiedades prodriamos usar:

gtk_object_set_data()

Tienes ejemplos de uso en source\winapi\windows.c (fivelinux)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveLinux / FiveDroid (Android)

Who is online

Users browsing this forum: No registered users and 3 guests