A question similar to one that Stefan Champailler asked around a week ago. I have a morph, and I want to force its redisplay. However, I want to avoid using the built-in stepping mechanism (as Karl Ramberg suggested in his reply to Stefan). What I really want is to send a message to the morph directly, with the sender being blocked until the morph has actually been redrawn. Looking through the protocol or "morph" didn't reveal anything obvious --- can anyone suggested an appropriate message, or if there is some indirect way of forcing an update?
thanks, David
On Mon, 2 Dec 2002, David Duke wrote:
A question similar to one that Stefan Champailler asked around a week ago. I have a morph, and I want to force its redisplay. However, I want to avoid using the built-in stepping mechanism (as Karl Ramberg suggested in his reply to Stefan). What I really want is to send a message to the morph directly, with the sender being blocked until the morph has actually been redrawn. Looking through the protocol or "morph" didn't reveal anything obvious --- can anyone suggested an appropriate message, or if there is some indirect way of forcing an update?
canvas := Display getCanvas. morph fullDrawOn: canvas. canvas forceToScreen: morph bounds.
But are you sure you need to do this? It obviously violates Morphic's idea of managing the World. Why isn't sending #changed to the morph enough? It could be followed by a #refreshWorld, if really needed.
-- Bert
On Monday 02 December 2002 03:14 am, David Duke wrote:
A question similar to one that Stefan Champailler asked around a week ago. I have a morph, and I want to force its redisplay. However, I want to avoid using the built-in stepping mechanism (as Karl Ramberg suggested in his reply to Stefan). What I really want is to send a message to the morph directly, with the sender being blocked until the morph has actually been redrawn. Looking through the protocol or "morph" didn't reveal anything obvious --- can anyone suggested an appropriate message, or if there is some indirect way of forcing an update?
You could send it #changed from within the UI Process. And it'll be refreshed at the next world cycle.
However, the stepping mechanism is by far the most comfortable to use.
The answer of what's best depends on your architecture. If you're doing this from another Process than the UI, you can use
WorldState addDeferredUIMessage: somethingValuable
where somethingValuable is something that responds to #value in a useful way.
somethingValuable will be sent #value from the UI process at the next refresh cycle.
Another way to do something synchronously with the UI process is to use Morphic alarms (see the WorldState alarms protocol).
Hi All
At first ... if this is the wrong place for asking those questions please tell me.
I have a RectangleMorph and a StringMorph. The String is Submorph of the Rectangle. I want that the String is in the top center of the Rectangle even when I resize the Rectangle. I played a little bit with TableLayout and ProportionalLayout, but didn't find what I need. Can you help me ?
minimum width: |theString| and bigger: | theString |
Regards Chris Burkert
Chris Burkert wrote:
Hi All
At first ... if this is the wrong place for asking those questions please tell me.
This is the place.
I have a RectangleMorph and a StringMorph. The String is Submorph of the Rectangle. I want that the String is in the top center of the Rectangle even when I resize the Rectangle. I played a little bit with TableLayout and ProportionalLayout, but didn't find what I need. Can you help me ?
minimum width: |theString| and bigger: | theString |
re _ RectangleMorph new. re addMorph:(StringMorph new). re layoutPolicy: TableLayout new. re wrapCentering: #center. re openInWorld
Karl
Chris,
This is exactly the right place to ask those questions. Here are two examples:
Version 1: Using a ProportionalLayout
| rectangle string frame | "set up the string" string := StringMorph new contents: 'This is a string'.
"this is the trick - set up a layout frame so that it will align the string at the top-center of the owner but offset left by half of the string's width" frame := LayoutFrame new. frame leftFraction: 0.5 offset: string width // -2. frame topFraction: 0 offset: 0.
"install it" string layoutFrame: frame.
"the container" rectangle := RectangleMorph new. rectangle layoutPolicy: ProportionalLayout new. rectangle addMorph: string.
"clip parent so string doesn't show outside" rectangle clipSubmorphs: true. rectangle openInHand.
Version 2: Using a TableLayout
| rectangle string | "the container" rectangle := RectangleMorph new.
"this is the trick - set up a layout so that it is oriented left to right and then center the entire list" rectangle layoutPolicy: TableLayout new. rectangle listDirection: #leftToRight. rectangle listCentering: #center.
"Note: the same effect could be achieved using: rectangle listDirection: #topToBottom. rectangle wrapCentering: #center. This may work better if the entire contents of the rectangle should be a vertical list"
"set up the string" string := StringMorph new contents: 'This is a string'. rectangle addMorph: string.
"clip parent so string doesn't show outside" rectangle clipSubmorphs: true. rectangle openInHand.
Which one to use?! It depends. Version 1 has the advantage that you can add other morphs to the container which may (or may not) be affected by the layout. It is not as good if your string varies in size since the offset needs to be recomputed each time. Version 2 has the advantage that it'll work even if the string is dynamically changed. It has the disadvantage that adding anything to the rectangle will be included in the layout (that is unless you set the #disableTableLayout property) and that it's left-aligned if the rectangle is smaller than the string (which may or may not be what you need...).
Cheers, - Andreas
-----Original Message----- From: squeak-dev-admin@lists.squeakfoundation.org [mailto:squeak-dev-admin@lists.squeakfoundation.org] On Behalf Of Chris Burkert Sent: Monday, December 02, 2002 10:37 PM To: squeak-dev@lists.squeakfoundation.org Subject: [Q] Morphic Layout
Hi All
At first ... if this is the wrong place for asking those questions please tell me.
I have a RectangleMorph and a StringMorph. The String is Submorph of the Rectangle. I want that the String is in the top center of the Rectangle even when I resize the Rectangle. I played a little bit with TableLayout and ProportionalLayout, but didn't find what I need. Can you help me ?
minimum width: |theString| and bigger: | theString |
Regards Chris Burkert
--
Student of applied Computer Science at Chemnitz University of Technology http://www.chrisburkert.de/ chbu@hrz.tu-chemnitz.de
"I invented the term Object-Oriented, and I can tell you I did not have C++ in mind." - Alan Kay --> http://www.squeak.org/
squeak-dev@lists.squeakfoundation.org