Entrar
¿Nuevo usuario? Inscribirme
squeakRos
? ¿Ya estás suscrito? Entra a Yahoo!

Consejos

¿Sabías que...?
Podés hacer búsquedas de antiguos mensajes del grupo.

Mensajes

  Mensajes Ayuda
Avanzado
Tutorial morphic y datos imagen   Lista de mensajes  
Responder | Reenviar Mensaje #520 de 3316 |
Eduardo:
Trataré de ayudarte a construir tu programa.
Espero que hayas leído lo que tenemos en Internet y que hayas bajado los
libros SmalltalkByExample y Smalltalk with Style del sitio de Ducasse.

Hay una lista de links en el sitio, te mando una mas actualizada a[parte.
No te molestes en buscar en Internet, lo que deseas no existe. (hay muchos
tutoriales parciales a distintas cosas, dispersos por ahí_
Lo mas cercano sería el primer libro de Mark Guzdial.
Pero a no desesperarse, aquí te ayudaremos.

No sé como serán las bibliotecas en España, imagino que mucho mas modernas.
Aquí las bibliotecas tienen un salón grande con muchos ficheros metálicos
con rótulos y que contienen montones de fichas con datos como nombre,
título, clave.
No tienen fotos.

Pero eso no importa.
Quisiera saber como has "importado" o visto tu .jpg dentro de Squeak.
Hay muchas formas de hacerlo.

Así que te dare una posible solución al problema que deberás ver si te
sirve.

Como el Squeak va cambiando, usar el 3.8b 6548
Hagamos una clase libro (Ver página web)
Hagamos que sus variables de instancia sean autor, titulo, clave , foto.
Con el nombre de la clase seleccionado, hacer que aparezca el menú,
seleccionar "more" y luego create inst var accessor (ver fotito).
Aquí tienes tu clase, pero no como poner los datos o verlos.
La forma clásica es usar el Workspace y el Transcript,
A los alumnos que se encuentran con Smalltalk por primera vez , generalmente
no se les deja hacer otra cosa (ni usan Squeak)
Como quieres una forma visual y usar Morph, veremos entonces como hacer una
especie de "form" de Visualbasic en Squeak.
Combinaremos la forma manual y codificaremos.
Mi estilo es usar siempore contenedores, asi que la "ficha" de carton de la
biblioteca, será un BorderedMorph.
En el Worspace hacemos
ficha := BorderedMorph new openInWorld
Saldra un pequeño rectangulo azul en el vertice superior de la pantalla.
Con el "halo", lo podemos manipular a gusto para que tenga el tamaño y color
que deseemos.
Con los inspectores podemos ver los valores de todo lo que deseamos tenga
nuestro objeto.
Ahora, al código,
Es costumbre que todos los objetos tengan una forma de "nacer" dentro del
sistema, esto se realiza solo una vez con el metodo initialize y como somos
ordenados (ja ja ja) ponemos el metodo initialize dentro de la categoria de
metodos initialization.

initialize
super initialize.
self extent: 512 @ 342;color: Color paleYellow.

Ahora vamos a necesitar "algo" para ingresar los datos.
Otra vez en el Workspace hacemos

campo _ TextMorph borderedPrototype openInWorld
Y veremos un texto transparente con letra grande aparecer en el vertice
superior de la pantalla.
Si seleccionamos con doble click borderedPrototype ya hacemos control m
(Alt m en Windows) nos sale una ventana con los implementadores del método,
buscamos el de TextMorph.

| t |
t _ TextMorph authoringPrototype.
t fontName: 'Accuny' pointSize: 12.
t autoFit: false; extent: 100@20.
t borderWidth: 1;color: Color red;
backgroundColor: Color paleBlue.
t openInWorld

Este es mas lindo, perdona si soy incoherente, pero lo voy haciendo y
escribiendo.
Pero te ira dando una pista de como se puede hacer algo.
Lo probas manualmente o con el Workspace y cuando te gusta lo transformas en
una clase.
Asi creariamos un clase Campo (al estilo de las viejas bases de datos o del
Pascal o Cobol)

Ahora necesitamos algo para las fotos.
Como esto es medio bravo y largo de explicar, te mando el código y si no
entendes algo pregunta.
Por ahora , baste saber que tenemos algo llamado MiFotoMiniatura que te
permitira visualizar tus jpg en tamaño miniatura.

Y para que todo funcione , hay que ensamblar todos estos elementos en un
todo.
A los morph se les pueden adicionar otros morphs hasta.
Así que tenemos nuestro contenedor Libro, nuestro Campo para ingresar texto
y nuesto visualizador de fotos MiFotoMiniatura.
Faltaria agregar estos elementos.

agregarCampos

self autor: Campo new.
autor topLeft: self topLeft + (10@10) asPoint.
self addMorph: autor.
titulo _ Campo new.
self addMorph: titulo.
titulo topLeft: self topLeft +( 10@30) asPoint.
clave _ Campo new.
self addMorph: clave.
clave topLeft: self topLeft + (10@50) asPoint.
foto _ MiFotoMiniatura new.
self addMorph: foto.
foto topLeft: self topLeft + (10@75) asPoint.

Donde llamar a agregarCampos ?
En el último renglon de initialize.
Te mando el st del ejercicio, para que lo veas y juegues un poco.
Seguramente te quedarán infinitas dudas, bienvenido al club.
Prometo mañana hacer otro para que veas como conectar esta "ficha" visual
con tu "negocio" o datos .
Manda foto de que se ve desde tu ventana, aqui somos curiosos.
Chau y espero no haberte cansado.

Edgar
.






Vie, 14 de Ene, 2005 12:45 pm

edgardec2001
Sin conexión Sin conexión
Enviar correo Enviar correo

TextMorph subclass: #Campo instanceVariableNames: 'nombre'
classVariableNames: '' poolDictionaries: '' category: 'LibrosEduardo'! !Campo
methodsFor: 'initialization' stamp: 'edc 1/14/2005 09:31'! initialize super
initialize. self contents: 'tipear aqui' translated asText. self fontName:
'Accuny' pointSize: 12. self autoFit: false; extent: 100@20. self borderWidth:
1;color: Color red; backgroundColor: Color paleBlue. ! ! BorderedMorph
subclass: #Libro instanceVariableNames: 'autor titulo clave foto'
classVariableNames: '' poolDictionaries: '' category: 'LibrosEduardo'! !Libro
commentStamp: 'edc 1/14/2005 07:23' prior: 0! Tomar esto como una primera
aproximación ! !Libro methodsFor: 'accessing' stamp: 'edc 1/14/2005 07:23'!
autor "Answer the value of autor" ^ autor! ! !Libro methodsFor: 'accessing'
stamp: 'edc 1/14/2005 07:23'! autor: anObject "Set the value of autor" autor
_ anObject! ! !Libro methodsFor: 'accessing' stamp: 'edc 1/14/2005 07:23'!
clave "Answer the value of clave" ^ clave! ! !Libro methodsFor: 'accessing'
stamp: 'edc 1/14/2005 07:23'! clave: anObject "Set the value of clave" clave
_ anObject! ! !Libro methodsFor: 'accessing' stamp: 'edc 1/14/2005 07:23'! foto
"Answer the value of foto" ^ foto! ! !Libro methodsFor: 'accessing' stamp:
'edc 1/14/2005 07:23'! foto: anObject "Set the value of foto" foto _
anObject! ! !Libro methodsFor: 'accessing' stamp: 'edc 1/14/2005 07:23'! titulo
"Answer the value of titulo" ^ titulo! ! !Libro methodsFor: 'accessing'
stamp: 'edc 1/14/2005 07:23'! titulo: anObject "Set the value of titulo"
titulo _ anObject! ! !Libro methodsFor: 'initialize-release' stamp: 'edc
1/14/2005 09:35'! agregarCampos self autor: Campo new. autor topLeft: self
topLeft + (10@10) asPoint. self addMorph: autor. titulo _ Campo new. self
addMorph: titulo. titulo topLeft: self topLeft +( 10@30) asPoint. clave _ Campo
new. self addMorph: clave. clave topLeft: self topLeft + (10@50) asPoint. foto _
MiFotoMiniatura new. self addMorph: foto. foto topLeft: self topLeft + (10@75)
asPoint. .! ! !Libro methodsFor: 'initialize-release' stamp: 'edc 1/14/2005
09:28'! initialize super initialize. self extent: 512 @ 342;color: Color
paleYellow. self agregarCampos. ! ! ImageMorph subclass: #MiFotoMiniatura
instanceVariableNames: 'index' classVariableNames: '' poolDictionaries: ''
category: 'LibrosEduardo'! !MiFotoMiniatura methodsFor: 'menus' stamp: 'EDC
8/22/2002 11:30'! addCustomMenuItems: aCustomMenu hand: aHandMorph "Include
our modest command set in the ctrl-menu" super addCustomMenuItems: aCustomMenu
hand: aHandMorph. aCustomMenu addLine. self addMenuItemsTo: aCustomMenu hand:
aHandMorph! ! !MiFotoMiniatura methodsFor: 'menus' stamp: 'edc 10/1/2003
10:22'! addMenuItemsTo: aMenu hand: aHandMorph | menu | menu _ MenuMorph new.
menu color: (Color r: 0.4 g: 0.4 b: 0.4). menu color: (menu
color alpha: 0.5). menu add: 'rotar contra reloj ' target: self action:
#rotarCCW. menu add: 'rotar sentido reloj ' target: self action:
#rotarCW. menu add: 'ver Original ' target: self action: #verOriginal.
menu items do: [:i | i color: Color red; font: (StrikeFont
familyName: 'Comic Bold' size: 12 emphasized: 1)]. menu
invokeModal! ! !MiFotoMiniatura methodsFor: 'menus' stamp: 'edc 10/2/2003
07:12'! initializarCon: unaImagen numero: unEntero | rect text f frame | f _
Form fromFileNamed: unaImagen. f _ f scaledToSize: 80 @ 60. self image: f.
self index: unEntero. rect _ RectangleMorph authoringPrototype
useRoundedCorners color: (Color r: 0.4 g: 0.4 b: 0.4
alpha: 0.5); borderWidth: 2. text _ TextMorph new contents: unEntero
asString; textColor: Color red; fontName: #ComicBold size: 9. rect
extent: text extent + (8 @ 6) asPoint. frame _ LayoutFrame new. frame
leftFraction: 0.5 offset: text width // -2. frame topFraction: 0 offset: 0.
text layoutFrame: frame. rect layoutPolicy: ProportionalLayout new. rect
addMorph: text. rect openInWorld. rect topLeft: self bottomLeft. self
addMorph: rect. self openInWorld! ! !MiFotoMiniatura methodsFor: 'menus'
stamp: 'edc 10/2/2003 08:49'! redraw | m | m _ submorphs at: 1. self
privateRemoveMorph: (submorphs at: 1). m topLeft: self bottomLeft. self
addMorph: m. ! ! !MiFotoMiniatura methodsFor: 'menus' stamp: 'edc 10/2/2003
08:51'! rotarCW | f | f _ self image rotateBy: #right centerAt: self center.
self image: f. self redraw! ! !MiFotoMiniatura methodsFor: 'event handling'
stamp: 'edc 10/1/2003 09:24'! handlesMouseDown: anEvent ^ Smalltalk isMorphic
not or: [anEvent yellowButtonPressed]! ! !MiFotoMiniatura methodsFor: 'event
handling' stamp: 'edc 10/1/2003 10:21'! mouseDown: evt evt yellowButtonPressed
ifTrue: [self processYellowButton: evt] ifFalse: [^ evt hand
waitForClicksOrDrag: self event: evt]! ! !MiFotoMiniatura methodsFor: 'event
handling' stamp: 'edc 10/1/2003 09:48'! processYellowButton | s | s _ MiStack
allInstances detect: [:each | each world == ActiveWorld]. s loadImage: self
index! ! !MiFotoMiniatura methodsFor: 'event handling' stamp: 'edc 10/1/2003
10:21'! processYellowButton: evt | menu | menu _ MenuMorph new defaultTarget:
self. self addMenuItemsTo: menu hand: evt hand. menu popUpEvent: evt in:
self world.! ! !MiFotoMiniatura methodsFor: 'accessing' stamp: 'edc 9/29/2003
09:34'! index "Answer the value of index" ^ index! ! !MiFotoMiniatura
methodsFor: 'accessing' stamp: 'edc 9/29/2003 09:34'! index: anObject "Set the
value of index" index _ anObject! ! !MiFotoMiniatura methodsFor: 'menu
commands' stamp: 'edc 10/2/2003 08:48'! rotarCCW | f | f _ self image
rotateBy: #left centerAt: self center. self image: f. self redraw! !
!MiFotoMiniatura methodsFor: 'menu commands' stamp: 'edc 3/25/2004 10:36'!
verOriginal | s | s _ MiStack allInstances last. s isInWorld ifTrue: [s
loadImage: self index]! !

Archivo adjunto
Libros2.jpg
Tipo:
image/jpeg
Archivo adjunto
Libros3.tiff
Tipo:
application/octet-stream
Reenviar Mensaje #520 de 3316 |
Desplegar mensajes Autor Ordenar por fecha

Eduardo: Trataré de ayudarte a construir tu programa. Espero que hayas leído lo que tenemos en Internet y que hayas bajado los libros SmalltalkByExample y...
Lic. Edgar J. De Cleene
edgardec2001
Sin conexión Enviar correo
14 de Ene, 2005
12:46 pm
Avanzado

Copyright © 2009 Yahoo! de Argentina S.R.L. Todos los derechos reservados.
Política de privacidad - Condiciones del Servicio - Reglas de la comunidad de Yahoo! - Ayuda