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][/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
RASPI / FiveLinux y el alineamiento de los SAY
- Antonio Linares
- Site Admin
- Posts: 42425
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 15 times
- Been thanked: 48 times
- Contact:
Re: RASPI / FiveLinux y el alineamiento de los SAY
George,
Cómo has llamado a la función SAYSETALIGN() ?
Que parámetros le has proporcionado ?
Cómo has llamado a la función SAYSETALIGN() ?
Que parámetros le has proporcionado ?
Re: RASPI / FiveLinux y el alineamiento de los SAY
Antonio,
Este es el codigo que he usado acorde a lo indicado en el post:
Saludos,
George
Este es el codigo que he usado acorde a lo indicado en el post:
No se ejecuta ningun cambio en el alineamiento del texto y en la consola sale el siguiente mensaje:@ 14, 2 SAY oSayName PROMPT "Name:" OF oFormCompany SIZE 100,20 PIXEL
oSayName:SetAlignment(0.0, 0.5)
(main:1803): Gtk-CRITICAL **: IA__gtk_misc_set_alignment: assertion 'GTK_IS_MISd
Saludos,
George
- Antonio Linares
- Site Admin
- Posts: 42425
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 15 times
- Been thanked: 48 times
- Contact:
Re: RASPI / FiveLinux y el alineamiento de los SAY
George,
Como has añadido el método SetAlignment() en la clase TSay ?
Como has añadido el método SetAlignment() en la clase TSay ?
Re: RASPI / FiveLinux y el alineamiento de los SAY
Antonio,
Estos son los cambios que hice para agregar el nuevo metodo SetAlignment a la clase TSay:
SAY.PRG
SAY.C
Estos son los cambios que hice para agregar el nuevo metodo SetAlignment a la clase TSay:
SAY.PRG
Code: Select all | Expand
#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
[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 ) );}// AddedHB_FUNC( SAYSETALIGN ){ GtkWidget * hWnd = (GtkWidget * ) hb_parnl( 1 ); gtk_misc_set_alignment( ( GtkMisc * ) hWnd, hb_parnd( 2 ), hb_parnd( 3 ) );}
- Antonio Linares
- Site Admin
- Posts: 42425
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 15 times
- Been thanked: 48 times
- Contact:
Re: RASPI / FiveLinux y el alineamiento de los SAY
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
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
- Antonio Linares
- Site Admin
- Posts: 42425
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 15 times
- Been thanked: 48 times
- Contact:
Re: RASPI / FiveLinux y el alineamiento de los SAY
Para modificar esas propiedades prodriamos usar:
gtk_object_set_data()
Tienes ejemplos de uso en source\winapi\windows.c (fivelinux)
gtk_object_set_data()
Tienes ejemplos de uso en source\winapi\windows.c (fivelinux)