[Pharo-users] How to wrap text in labels?

2016-08-08 Thread Tommaso Dal Sasso

Hello everybody,

I was wondering, is there a way to wrap text inside a Morphic/Bloc label?
I am building a list of text elements, but I am not able to wrap the 
text to match the width of the widget.


For the moment I solved the issue by instantiating a Rubric text area 
for each text element, but it becomes much more resource expensive and 
slower.


Is there a better widget to manage that?

Thanks,
Tommaso




Re: [Pharo-users] How to wrap text in labels?

2016-08-08 Thread Nicolai Hess
2016-08-08 12:27 GMT+02:00 Tommaso Dal Sasso :

> Hello everybody,
>
> I was wondering, is there a way to wrap text inside a Morphic/Bloc label?
> I am building a list of text elements, but I am not able to wrap the text
> to match the width of the widget.
>
> For the moment I solved the issue by instantiating a Rubric text area for
> each text element, but it becomes much more resource expensive and slower.
>
> Is there a better widget to manage that?
>
> Thanks,
> Tommaso
>
>
Hi Tommaso,

can you use a TextMorph with a panel or an other morph for the background,
and set the full owners shape and wrap-flag ?
I think the default label widgets (StringMorph/LabelMorph) do not support
text wrapping.

Morph new color: Color white; addMorph:(TextMorph new contents:'Hello World
Hello World Hello World';wrapFlag:true;fillsOwner:true;yourself);openInHand.


[Pharo-users] using glorp and active record

2016-08-08 Thread Sean Glazier
Hi,

I have been trying to get glorp using active record working in pharo 5.

I have a descriptor class for it and the classes inherit from active Record.

I describe the table as:
tableForAnswer: aTable
| vistorId questionId |
(aTable createFieldNamed: 'id' type: platform serial) bePrimaryKey.
questionId := aTable createFieldNamed: 'questionId' type: platform integer.
vistorId := aTable createFieldNamed: 'vistorId' type: platform integer.
aTable createFieldNamed: 'answer' type: platform text.
aTable
addForeignKeyFrom: vistorId
to: ((self tableNamed: 'VISITORS') fieldNamed: 'ID')
suffixExpression:
'MATCH SIMPLE
  ON UPDATE NO ACTION ON DELETE CASCADE'.
aTable
addForeignKeyFrom: questionId
to: ((self tableNamed: 'QUESTIONS') fieldNamed: 'ID')
suffixExpression:
'MATCH SIMPLE
  ON UPDATE NO ACTION ON DELETE CASCADE'


the table in the DB was preexisting.

when I do Answer findAll

I get and error that it is expecting a number for the id field.

in the PostgresSQLPlaform serial is defined thusly.
serial
"For postgresql, we use sequences, and explicitly get the values ourselves,
so just tell the database that they're integers."

^self typeNamed: #serial ifAbsentPut: [GlorpSerialType new typeString:
'integer'].

What the DB hands back is 'nextval('answers_id_seq'::regclass)' which
seems correct if it is telling me that there exists a sequence for
this field and that is the correct command to issue for the field.

am I defining this table incorrectly? or should I bag using active Record.
I kind of liked it when working in Visualworks because there were also
tools that would read in and describe the tables and then tools to assit
when you needed to migrate to another version and do the changes etc.

FYI this is the query that is being run that fails.
SELECT t1.table_name, t1.table_schema, t1.column_name, t1.is_nullable,
t1.data_type, t1.column_default, t1.character_maximum_length,  EXISTS
(SELECT DISTINCT 'x'
 FROM ((INFORMATION_SCHEMA.table_constraints s1t1 INNER JOIN
INFORMATION_SCHEMA.key_column_usage s1t3 ON ((s1t1.table_name =
s1t3.table_name) AND ((s1t1.table_schema = s1t3.table_schema) AND
(s1t1.constraint_name = s1t3.constraint_name INNER JOIN
INFORMATION_SCHEMA.columns s1t2 ON (((s1t3.column_name = s1t2.column_name)
AND (s1t3.table_schema = s1t2.table_schema)) AND (s1t3.table_name =
s1t2.table_name)))
 WHERE ((s1t1.constraint_type = 'PRIMARY KEY') AND ((s1t2.column_name =
t1.column_name) AND (((s1t2.table_schema = t1.table_schema) AND
(s1t2.table_name = t1.table_name)) AND ((s1t2.table_schema =
t1.table_schema) AND (s1t2.table_name = t1.table_name))
 FROM INFORMATION_SCHEMA.columns t1
 WHERE ((t1.table_name = 'answers') AND (t1.table_schema = 'public'))



it looks as though it is reading in the schema and is expecting and integer
because we told it to in the serial method on the PostgesSQLPlatform.

As much as I love diving into these frameworks to figure out the deep inner
workings, I really need to be getting data in and out without a fuss.

Should I follow the DBX example where the descriptor is orthogonal to the
model and one does not subclass from active record?

I also note that not all the glorp tests pass. I think the were rather
minor fails like timezone issues or something. It took a while but the test
created a number of tables in the DB.

So again Have I done something Obtuse that I qught to be slapped for here?

thanks


Re: [Pharo-users] using glorp and active record

2016-08-08 Thread Esteban A. Maringolo
How did you create the tables? There is a sequence for the ID in the database?
Also, I don't understand why you call it "ActiveRecord".

If you can share some code, DDL of the table, I'll be able to help you better.

Regards,

Esteban A. Maringolo

ps: I'm cross replying to the Glorp mailing list.

2016-08-08 11:02 GMT-03:00 Sean Glazier :
> Hi,
>
> I have been trying to get glorp using active record working in pharo 5.
>
> I have a descriptor class for it and the classes inherit from active Record.
>
> I describe the table as:
> tableForAnswer: aTable
> | vistorId questionId |
> (aTable createFieldNamed: 'id' type: platform serial) bePrimaryKey.
> questionId := aTable createFieldNamed: 'questionId' type: platform integer.
> vistorId := aTable createFieldNamed: 'vistorId' type: platform integer.
> aTable createFieldNamed: 'answer' type: platform text.
> aTable
> addForeignKeyFrom: vistorId
> to: ((self tableNamed: 'VISITORS') fieldNamed: 'ID')
> suffixExpression:
> 'MATCH SIMPLE
>   ON UPDATE NO ACTION ON DELETE CASCADE'.
> aTable
> addForeignKeyFrom: questionId
> to: ((self tableNamed: 'QUESTIONS') fieldNamed: 'ID')
> suffixExpression:
> 'MATCH SIMPLE
>   ON UPDATE NO ACTION ON DELETE CASCADE'
>
>
> the table in the DB was preexisting.
>
> when I do Answer findAll
>
> I get and error that it is expecting a number for the id field.
>
> in the PostgresSQLPlaform serial is defined thusly.
> serial
> "For postgresql, we use sequences, and explicitly get the values ourselves,
> so just tell the database that they're integers."
>
> ^self typeNamed: #serial ifAbsentPut: [GlorpSerialType new typeString:
> 'integer'].
>
> What the DB hands back is 'nextval('answers_id_seq'::regclass)' which seems
> correct if it is telling me that there exists a sequence for this field and
> that is the correct command to issue for the field.
>
> am I defining this table incorrectly? or should I bag using active Record. I
> kind of liked it when working in Visualworks because there were also tools
> that would read in and describe the tables and then tools to assit when you
> needed to migrate to another version and do the changes etc.
>
> FYI this is the query that is being run that fails.
> SELECT t1.table_name, t1.table_schema, t1.column_name, t1.is_nullable,
> t1.data_type, t1.column_default, t1.character_maximum_length,  EXISTS
> (SELECT DISTINCT 'x'
>  FROM ((INFORMATION_SCHEMA.table_constraints s1t1 INNER JOIN
> INFORMATION_SCHEMA.key_column_usage s1t3 ON ((s1t1.table_name =
> s1t3.table_name) AND ((s1t1.table_schema = s1t3.table_schema) AND
> (s1t1.constraint_name = s1t3.constraint_name INNER JOIN
> INFORMATION_SCHEMA.columns s1t2 ON (((s1t3.column_name = s1t2.column_name)
> AND (s1t3.table_schema = s1t2.table_schema)) AND (s1t3.table_name =
> s1t2.table_name)))
>  WHERE ((s1t1.constraint_type = 'PRIMARY KEY') AND ((s1t2.column_name =
> t1.column_name) AND (((s1t2.table_schema = t1.table_schema) AND
> (s1t2.table_name = t1.table_name)) AND ((s1t2.table_schema =
> t1.table_schema) AND (s1t2.table_name = t1.table_name))
>  FROM INFORMATION_SCHEMA.columns t1
>  WHERE ((t1.table_name = 'answers') AND (t1.table_schema = 'public'))
>
>
>
> it looks as though it is reading in the schema and is expecting and integer
> because we told it to in the serial method on the PostgesSQLPlatform.
>
> As much as I love diving into these frameworks to figure out the deep inner
> workings, I really need to be getting data in and out without a fuss.
>
> Should I follow the DBX example where the descriptor is orthogonal to the
> model and one does not subclass from active record?
>
> I also note that not all the glorp tests pass. I think the were rather minor
> fails like timezone issues or something. It took a while but the test
> created a number of tables in the DB.
>
> So again Have I done something Obtuse that I qught to be slapped for here?
>
> thanks



[Pharo-users] generating function keys

2016-08-08 Thread Peter Uhnak
Hi,

how can one generate function keys? (F1 to F12)

I've made a morph for testing

~~
c := Morph subclass: #MyKeyMorph.

c compile: 'handlesKeyboard: evt
^ true'.

c compile: 'handleKeystroke: evt
self logCr: evt'.

c compile: 'handleKeyUp: evt
self logCr: evt'.

c compile: 'handleKeyDown: evt
self logCr: evt'.

m := c new.
m openInWindow.
m takeKeyboardFocus
~~

However the functions keys are not being generated.

Is this something that would have to be done in the VM?
I'm using linux btw, but ideally it should work on all platforms.

Thanks,
Peter



Re: [Pharo-users] generating function keys

2016-08-08 Thread Nicolai Hess
2016-08-08 19:39 GMT+02:00 Peter Uhnak :

> Hi,
>
> how can one generate function keys? (F1 to F12)
>
> I've made a morph for testing
>
> ~~
> c := Morph subclass: #MyKeyMorph.
>
> c compile: 'handlesKeyboard: evt
> ^ true'.
>
> c compile: 'handleKeystroke: evt
> self logCr: evt'.
>
> c compile: 'handleKeyUp: evt
> self logCr: evt'.
>
> c compile: 'handleKeyDown: evt
> self logCr: evt'.
>
> m := c new.
> m openInWindow.
> m takeKeyboardFocus
> ~~
>
> However the functions keys are not being generated.
>
> Is this something that would have to be done in the VM?
>

Yes, function do not generate any events on the pharo linux vm (for
Windows, at least keydown/keyup events, bot no keystroke events).


> I'm using linux btw, but ideally it should work on all platforms.
>
> Thanks,
> Peter
>
>