Has anyone done a spreadsheet-like morph?

Jeffrey J. Hallman m1jjh00 at frb.gov
Wed Sep 8 18:33:00 UTC 1999


I work a lot with matrices, and would like to either find or create a morph
to display and edit them.  I've been lurking here for a while and searched
high and low on the Squeak Swiki without luck.  If anyone can point me to
something, please do so.

Assuming that no one has done this yet, and remembering that I'm very much a
newbie just learning Morphic, let me ask a few questions that may help me
create one myself.  As a first pass, I'm looking at this:

ssdColumn := (AlignmentMorph newColumn minCellSize:15; position: 100 at 10). 
numbers := (101 to: 110). 
numbers do: [ :num | ssdColumn addMorphBack: (TextMorph new contents: num asString)].

ssdMatrix := (AlignmentMorph newRow minCellSize: 30; position: 10 at 10).
1 to: 10 do: [ :i | ssdMatrix addMorph: ssdColumn fullCopy].
ssdMatrix openInWorld

which gives me a morph that looks like this:

101  101  101  101  101  101  101  101  101  101
102  102  102  102  102  102  102  102  102  102
103  103  103  103  103  103  103  103  103  103
104  104  104  104  104  104  104  104  104  104
105  105  105  105  105  105  105  105  105  105
106  106  106  106  106  106  106  106  106  106
107  107  107  107  107  107  107  107  107  107
108  108  108  108  108  108  108  108  108  108
109  109  109  109  109  109  109  109  109  109
110  110  110  110  110  110  110  110  110  110

I can click in each cell and edit it, but the cells are liable to change size
on me when I do.  For example, if I click on the first cell in the second
column and try to change it to 101.2, the string '101.2' wraps and I get
something that looks like this:

101  101  101  101  101  101  101  101  101  101
102  .2   102  102  102  102  102  102  102  102
103  102  103  103  103  103  103  103  103  103
104  103  104  104  104  104  104  104  104  104
105  104  105  105  105  105  105  105  105  105
106  105  106  106  106  106  106  106  106  106
107  106  107  107  107  107  107  107  107  107
108  107  108  108  108  108  108  108  108  108
109  108  109  109  109  109  109  109  109  109
110  109  110  110  110  110  110  110  110  110
     110

So here are my questions (so far).  Answer as many or as few as you like.
Once I have something working, I will try to write something up for the Swiki
to help other newbies understand how this stuff works.

First question: Should I be using something other than TextMorphs for the
cells? (BTW, is there a document anywhere that explains what the various
Morphic classes are for?  For example, when I should  use a StringMorph instead
of a TextMorph, or a PluggableTextMorph, or a and so on?

Second question: How can I display the cells in a grid, i.e., something like

  +--------------------+
  | 101  |  101  | 101 |
  |--------------------|
  | 102  |  102  | 102 |
  |--------------------|
  | 103  |  103  | 103 |
  |--------------------|
  | 104  |  104  | 104 |
  |--------------------|
  | 105  |  105  | 105 |
  +--------------------+

Third question: Assuming I can fix the size of the cells, how can I tell how
wide each column should be and how tall each row should be?  Are there methods
that will tell me how many pixels high and wide a string will be when
displayed?

Fourth question: It would really be nice if I could resize rows and columns
by dragging their borders.  How do I do this?

Fifth question: How about aligning the numbers in a column on the decimal
point?

Sixth question: How to hook up arrow keys so that I can navigate from cell to
cell without using the mouse?

Seventh question: How to change the background color of the cell that has
focus?

Eighth question: How to make the matrix scroll within a viewport of some kind?

While I can think of more questions, I think I'm already imposing too much on
the kindness of the Squeak list.  Thanks in advance for your help.

Jeff





More information about the Squeak-dev mailing list