Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!solo!vaxb.acs.unt.edu!ie15 From: ie15@vaxb.acs.unt.edu Newsgroups: comp.os.os2.programmer Subject: Re: Spread Sheets in PM Message-ID: <1990Dec23.200416.44153@vaxb.acs.unt.edu> Date: 23 Dec 90 19:58:16 GMT References: <1990Dec17.173811.4382@thunder.mcrcim.mcgill.edu> Lines: 73 In article <1990Dec17.173811.4382@thunder.mcrcim.mcgill.edu>, marco@damrod.McRCIM.McGill.EDU (Marco Petroni) writes:> > I am developping an application in PM which is to have the look and feel > similar to a spread sheet with rows and columns of data. The rows and columns > should be similar to text entry fields where the user can type in data. > Now, what I want to do is to be able to select an entire row, or column > or, groups of rows or columns at a time. Additionally, I would like to > be able to display the selected rows or columns of the "spread sheet" > as being highlighted, say, in reverse video. > > I have been thinking of a number of different possibilites: > > 1) A conventional PM list box with text fields. > - Selected items in a list box do get highlighted in reverse video, > but can one make a 2-D grid in a list box? (None of the literature > mentions 2-D grids in list boxes). > > 2) A dialog window with a 2-D grid of text entry fields. > - PM does not seem to allow you to set the colors of an individual > (or many for that matter) text entry field object(s). > > 3) Defining my own object class (similar to what Petzold does with > the square button) > - Probably the best and only way of doing this, but I haven't jumped > into the details yet. Any way you do it a window full of controls is bad news. Way too slow and a resource management problem for OS/2. Programmer guidelines say an app shouldn't have more than 100 windows created at once, a simple 10x10 spread sheet would reach that too quickly. I wrote a sample spread sheet which had an array of entry fields in the client area thinking how easy it was, but too many windows can get created. I friend of mine tried subclassing the listbox control to make what he called a 'multi-columned listbox'. This would set individual fonts, colors, handle cross-hair grids, etc. By the time he was finished the subclassing was so deep he started over. The best approach would be to clone EXCEL which has 1 data entry entry-field at the top and the bottom 90% of the client area is merely GpiCharStrAt() calls to write the data out in row/column format. With mouse control a GpiBox() can be drawn around the text to simulate a cursor-bar-selector for individual cells. As the the box is moved around the client area the cells' contents is echoed in the main-entry-field for editing. If you want the user to be able to "enter right into the cells' then move a single entryfield around the client area shadowing WM_MOUSEMOVES and WM_BUTTON1DOWNS. WinSetWindowPos() will work for that. To set the entryfield's colors use the WinSetPresParam() API only available in OS/2 1.2 and up. VOID SetEntryF( hwnd hwndEF) { LONG color; color =CLR_BLUE; WinSetPresParam( hwndEF, PP_BACKGROUNDCOLORINDEX, sizeof( LONG), &color); color =CLR_YELLOW; WinSetPresParam( hwndEF, PP_FOREGROUNDCOLORINDEX, sizeof( LONG), &color); } ... for instance. These are briefly mentioned in the IBM Programmers Guide on pages 13-2 and 13-3. If you handle all of the end-presentation of the data thru the client window you can easily support nice font touches like italics and underline that entry fields won't. wisdom and fun, Ken Tabor OS/2 Graphics Guru in Training IE15@UNTVAX.BITNET IE15@vaxa.acs.unt.edu