зеркало из https://github.com/mozilla/gecko-dev.git
171 строка
5.2 KiB
Plaintext
171 строка
5.2 KiB
Plaintext
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
*
|
|
* The contents of this file are subject to the Netscape Public
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
* except in compliance with the License. You may obtain a copy of
|
|
* the License at http://www.mozilla.org/NPL/
|
|
*
|
|
* Software distributed under the License is distributed on an "AS
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
* implied. See the License for the specific language governing
|
|
* rights and limitations under the License.
|
|
*
|
|
* The Original Code is mozilla.org code.
|
|
*
|
|
* The Initial Developer of the Original Code is Netscape
|
|
* Communications Corporation. Portions created by Netscape are
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
* Rights Reserved.
|
|
*
|
|
* Contributor(s):
|
|
*/
|
|
|
|
This document describes the following classes:
|
|
|
|
LTableHeader
|
|
LTableViewHeader
|
|
LTableRowSelector
|
|
LFlexTableGeometry
|
|
|
|
There is also a description of how they can all be used together at the end.
|
|
|
|
|
|
---- LTableHeader ----
|
|
|
|
This subclass of LView implements a table header with resizable and movable columns.
|
|
Column headers are individual panes within the view. These panes are always positioned
|
|
appropriately to be in line with their columns. The panes are resized horizontally to
|
|
touch the left and right edges of their columns.
|
|
|
|
The class also supports special appearance for the sorted column, chosen by clicking
|
|
on a column header.
|
|
|
|
The header does NOT scroll. Columns are always resized proportionally, though columns
|
|
can be marked as fixed width. The header's image size always matches its frame.
|
|
|
|
|
|
¥ Creation
|
|
|
|
The view has custom PPob and also requires a 'Cols' resource. The data in the PPob
|
|
specifies the following information:
|
|
|
|
header flags:
|
|
only 1, kHeaderCanHideColumns
|
|
|
|
2 bevel trait resource ids:
|
|
sorted column header, then unsorted
|
|
|
|
reverse modifiers:
|
|
an event record modifier mask that denotes a reverse-sort selection
|
|
|
|
'Cols' resource ID:
|
|
id of 'Cols' resource, with column initialization data, REQUIRED
|
|
|
|
|
|
The 'Cols' resource is used to initialize the size and positioning of the header's
|
|
columns. The header of the resource (SavedHeaderState) is defined in LTableHeader.h.
|
|
Following the header is an array of ColumnData (also in LTableHeader.h) records, 1
|
|
for each column.
|
|
|
|
The header of the resource specifies:
|
|
|
|
# of columns (1-based)
|
|
index of rightmost visible column (1-based)
|
|
index of sorted column (1-based, 0 if none)
|
|
|
|
|
|
Each ColumnData record specifies:
|
|
|
|
Pane ID of column header, 0 if none
|
|
|
|
Column Width
|
|
In pixels if fixed size, in % of non-fixed space if resizable
|
|
|
|
Column Position
|
|
Meaningless in saved state, ignore it.
|
|
|
|
ColumnFlags
|
|
kColumnDoesNotSort and/or kColumnDoesNotResize
|
|
|
|
|
|
¥ Header and Column Size
|
|
|
|
If a column is fixed-width, it will always have that width. Widths of resizable
|
|
columns are maintained as percentages of the non-fixed space in the header.
|
|
|
|
When a column is resized, all columns to its right resize proportionally.
|
|
|
|
|
|
¥ Hiding/Showing Columns
|
|
|
|
If the kHeaderCanHideColumns flag is set in the header flags, the view will have
|
|
a widget at the right edge for hiding and showing columns.
|
|
|
|
¥ Dragging/Resizing Columns
|
|
|
|
To change the rgn that gets dragged when resizing or moving a column, override
|
|
ComputeResizeDragRect or ComputeColumnDragRect respectively.
|
|
|
|
¥ Sorting
|
|
|
|
When the sorted column changes, LTableHeader broadcasts a msg_SortedColumnChanged
|
|
message, with TableHeaderSortChange parameter.
|
|
|
|
The method GetSortedColumn returns both the index and the header pane ID of the
|
|
sorted column.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---- LTableViewHeader ----
|
|
|
|
LTableViewHeader is a subclass of LTableHeader that coordinates changes in the header
|
|
with an LTableView.
|
|
|
|
When columns are hidden or shown in the header, this class removes/adds columns from/to
|
|
the table view.
|
|
|
|
When the image size of the header changes, the image size of the table is adjusted as well.
|
|
|
|
When columns are redrawn in the header, they are invalidated for refresh in the table view.
|
|
|
|
This class also overrides ComputeResizeDragRect and ComputeColumnDragRect to create more
|
|
useful regions when dragging and resizing columns.
|
|
|
|
|
|
|
|
|
|
---- LTableRowSelector ----
|
|
|
|
This subclass of LTableSelector selects entire rows. Individual cells cannot be selected.
|
|
It allows multiple selection and supports that standard shift and command key selection
|
|
extension semantics.
|
|
|
|
|
|
|
|
|
|
---- LFlexTableGeometry ----
|
|
|
|
This subclass of LTableGeometry works in concert with an LTableHeader to compute the position
|
|
of cells in a table. All rows are of uniform height, and column positions and widths
|
|
are determined by querying the associated LTableHeader view.
|
|
|
|
|
|
|
|
---- Using them together ----
|
|
|
|
The Dogbert mail window will use these classes all together. A subclass of LTableView
|
|
(CMessageTableView) sets its geometry to LFlexTableGeometry, and its selector to
|
|
LTableRowSelector.
|
|
|
|
When drawing a cell, CMessageTableView queries its associate LTableViewHeader to find the
|
|
pane ID of the column's header. The pane ID's denote which element of the row is drawn in
|
|
that cell. For instance, a column with header 'subj' contains the message subject. This
|
|
indirection allows the column order to be changed.
|
|
|
|
|
|
|
|
|