home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cell06d.zip
/
doc
/
cell.eng
next >
Wrap
Text File
|
1999-02-07
|
10KB
|
291 lines
Cell Toolkit.
v.06d
Copyright (C) 1998, 1999
Sergey I. Yevtushenko
Content.
1. Overview
2. Design concepts
3. Using toolkit
4. License
1. Overview.
Cell toolkit is a small library for OS/2 PM. It was designed to
simplify implementation of two important parts of user interface (UI):
- Split views
- Toolbars
What is split view? This is representation of information in one
window splitted vertically or horizontally into two or more parts
with splitbar which can be moved by user.
You can meet this technique in many popular applications, such as
PMMail, Netscape Navigator, ProNews and many more.
Second target - toolbars - is even more often used part of UI.
But most implementations of toolbars is limited in functionality and
flexibility.
2. Design concepts
Idea of Cell Toolkit is simple: any window can be split for two
parts. For example:
+---------+
| |
+---------+
| |
+---------+
or so:
+----+----+
| | |
| | |
| | |
+----+----+
Lets allow split parts of window too. Then we can get, for example,
following view:
+----+----+
| | |
+----+----+
| |
+---------+
This looks like news client in Netscape Navigator. And below is default
view of PMMail 2.0:
+---+-----+
| | |
| +-----+
| | |
+---+-----+
Lets examine above view.
+---------+
| | Main window
| |
| |
+---------+
/ \
/ \ +-----+ top pane
+---+ +---+ / | |
| | | | / +-----+
| | | | \ +-----+ bottom pane
| | | | \ | |
+---+ +---+ +-----+
left right
pane pane
Actually at this image does not mentioned important part of split view:
splitbar. Splitbar allows user to resize panels and make it more comfortable
for using.
But existence of splitbar is not necessary. You can meet less obvious
example of split views: status line. It can be resized, but it also
can be implemented using this approach.
In general, this approach allows us to cover almost any imaginable
combination of views.
3. Using toolkit
To simplify using of toolkit, API was designed using followin approach:
you create some structures filled with constants, call one function and get
a window created for you. Take a look at example code (simple.c):
CellDef cdLeftPane =
{
CELL_WINDOW,
WC_LISTBOX,
"List",
LS_NOADJUSTPOS | WS_VISIBLE,
ID_LPANE
};
This declaration defines one panel for a split view which will consist of
just a simple listbox. This listbox will have window ID ID_LPANE. Another
declaration:
CellDef cdRightPane =
{
CELL_WINDOW,
WC_MLE,
"SampleText",
MLS_BORDER | WS_VISIBLE,
ID_RPANE
};
This is also a simple MLE with window ID set to ID_RPANE, with border
(MLS_BORDER is set) and with text "Sample Text" in it. The third
declaration is more complicated:
CellDef mainClient =
{
CELL_VSPLIT | CELL_SPLITBAR | CELL_SPLIT30x70,
0,
"Simple",
FCF_TITLEBAR | FCF_SYSMENU | FCF_MENU |
FCF_MINMAX | FCF_TASKLIST | FCF_SIZEBORDER |
0,
MAIN_FRAME,
&cdLeftPane,
&cdRightPane,
0,
MainClientProc
};
This declaration will define the main application window. You can note the
difference in flags. Instead of CELL_WINDOW, we create a vertically split
window (CELL_VSPLIT), which will have a splitbar (CELL_SPLITBAR),
initially divided into 30/70% of the window width for left and right parts
of the window, respectively. Window class (second argument) have no
meaning for this case, it is always WC_FRAME. Also, instead of window
creation flags (fourth argument), there are frame creation flags. More
detailed explanations of meanings of these flags can be found in the
OS/2 PM reference book. This window will have ID MAIN_FRAME, two panels
(description for which is in cdLeftPane and cdRightPane respectively), and
have client window procedure "MainClientProc". Passing this parameter
instructs Cell toolkit to subclass main window client and replace
its window procedure with our one. But functionality of its window
procedure is important for Cell Toolkit. So, you need to call the subclassed
procedure at the end of message processing.
For this purpose you receive a pointer to structure WindowCellCtlData
(defined in cell.h) by issuing a call to WinQueryWindowULong. For now this
structure contains only one field, but you can add any necessary fields.
Because this structure will be allocated for you in the package code and
they need to know the size of it, you should recompile cell.c each time
you make changes in WindowCellCtlData. The rest of the fields will be
filled with 0 with the Cell Toolkit code at cell init time.
Now we ready to create the main window for the application. This is
done by calling CreateCell. This function takes three parameters:
definition of the window (explained above), a window handle for the parent
window and a window handle for the owner window. The last parameter for
the main window should be 0. In all other cases, this parameter should be
set to windows which will receive notification messages from other
windows. Usually this is the main window of the application. You should
note that the main application window definition does not have the flag
WS_VISIBLE set. This is important, because after creating windows, we may
need to do some other work before the application window will appear on
the screen.
What else do we need to do? We need fill controls with some data, add
the toolbar and set the main window position on the screen.
Creating the toolbar is similar to creating windows: you fill
structures, call a function and get a toolbar in your application. The
structure contains three elements:
- flags,
- toolbar ID,
- a pointer to an array of button ID's.
Note that the last element in this array is 0. This
marks the end of the toolbar button definitions. For all IDs listed in
the button array, you should define bitmaps in the resource file and
optionally an element in the stringtable. The element in the string table
is needed only if in the toolbar flags you set the flag TB_BUBBLE. If you
want to divide buttons into groups with gaps between them, you can use the
predefined resource ID TB_SEPARATOR. For this ID you do not need to define
bitmaps or stringtable elements (indeed, separators are not even buttons).
The function CreateToolbar receives two parameters: a pointer to the
toolbar definition structure and the handle of the parent window. Really,
this is just a window with which the toolbar will communicate when
attaching/detaching, and which will own (and receive messages from) the
buttons contained in the toolbar. A few words about toolbar flags: they
define the look of the toolbar only at the start of the application and
can be changed by user. The flags TB_ATTACHED_* define the side of the
parent window to which the toolbar will be attached initially:
TB_ATTACHED_LT - left
TB_ATTACHED_TP - top
TB_ATTACHED_RT - right
TB_ATTACHED_BT - bottom
If none of these are specified, the toolbar will float detached from the
parent window. Setting the flag TB_VERTICAL together with one of the TB
flags will be ignored. The user can at any time change the toolbar view.
- Toolbar have a "hand" for dragging, so the user can drag the attached
toolbar and detach it from the main window.
- By double-clicking with the left mouse button on this "hand" button,
the user can change the orientation of the detached toolbar
(horizontal/vertical).
- By double-clicking with the right mouse button on the "hand" user will
disable/enable bubble help, if it was enabled.
Short overview of functions available in Cell Toolkit.
- void ToolkitInit (HAB hab)
This function should be called before using Cell toolkit.
It registers some window classes used by toolkit.
- HWND CreateCell (CellDef* pCell, HWND hWndParent, HWND hWndOwner)
This functions creates cell for given definitions
- HWND CellWindowFromID(HWND hwndCell, ULONG ulID)
This function tries to wind subwindow with given ID.
Note that you should have unique window ID's to have it work
properly.
- HWND CellParentWindowFromID(HWND hwndCell, ULONG ulID)
Returned window handle is a HWND of frame which contains
control with given ID.
- void CreateToolbar(HWND hwndCell, TbDef* pTb)
Creates toolbar and attaches it to given cell window.
Note: this function assumes that given HWND is window
handle of Cell window created by call to CreateCell.
Passing other HWND may produce unpredictable results.
Some additional functions
- LONG GetSplit(HWND, LONG lID)
- LONG SetSplit(HWND, LONG lID, LONG lProp)
- void SetSplitType(HWND, LONG lID, LONG lType);
- LONG GetSplitType(HWND, LONG lID);
Functions above is used for saving/restoring split type
(horizontal/vertical) and proportions between parts of view.
Split type is the same as in cell definition. Proportions
should be given in range 0-100 (actually it will be limited
by bounds set with CELL_TOP_LIMIT, CELL_BOTTOM_LIMIT).
- void ShowCell(HWND hwnd, LONG lID, BOOL bAction)
This function allow to show/hide individual cells.
4. License
Well, this can be called a license, but this is just standard
disclaimer followed by one note.
Disclaimer:
SOFTWARE IS PROVIDED ATS 'AS IS' BASIS AND YOU CAN USE IT AT YOUR OWN RISK.
Note:
There is no limits on using library for commercial and/or non-commercial
purposes.
Comments and suggestions are welcome. You can reach me at:
e-mail: evsi@naverex.kiev.ua
FIDO : 2:463/114.69
Regards,
Sergey I. Yevtushenko.