Difference between revisions of "API/UNO AWT/Grid Control"
From Apache OpenOffice Wiki
Line 6: | Line 6: | ||
[[Image:Overview_gridcontrol.png]] | [[Image:Overview_gridcontrol.png]] | ||
− | == | + | == Example == |
+ | |||
+ | Create new columns: | ||
+ | |||
+ | <source lang="java"> | ||
+ | // #1 column | ||
+ | Object column1Obj = xMultiComponentFactory.createInstanceWithContext( | ||
+ | "com.sun.star.awt.grid.GridColumn", m_xContext); | ||
+ | |||
+ | XGridColumn column1 = (XGridColumn) UnoRuntime.queryInterface( | ||
+ | XGridColumn.class, column1Obj); | ||
+ | |||
+ | column1.setTitle("Column1"); | ||
+ | |||
+ | // #2 column | ||
+ | Object column2Obj = xMultiComponentFactory.createInstanceWithContext( | ||
+ | "com.sun.star.awt.grid.GridColumn", m_xContext); | ||
+ | XGridColumn column2 = (XGridColumn) UnoRuntime.queryInterface( | ||
+ | XGridColumn.class, column2Obj); | ||
+ | |||
+ | column2.setTitle("Column2"); | ||
+ | </source> | ||
+ | |||
+ | Add the columns to the column model of the grid control: | ||
+ | |||
+ | <source lang="java"> | ||
+ | Object columnModel = xMultiComponentFactory.createInstanceWithContext( | ||
+ | "com.sun.star.awt.grid.DefaultGridColumnModel", m_xContext); | ||
+ | XGridColumnModel xGridColumnModel = (XGridColumnModel) UnoRuntime.queryInterface( | ||
+ | XGridColumnModel.class, columnModel); | ||
+ | |||
+ | xGridColumnModel.addColumn(column1); | ||
+ | xGridColumnModel.addColumn(column2); | ||
+ | </source> | ||
+ | |||
+ | Use the data model of the grid control to add rows: | ||
+ | |||
+ | <source lang="java"> | ||
+ | Object dataModel = xMultiComponentFactory.createInstanceWithContext( | ||
+ | "com.sun.star.awt.grid.DefaultGridDataModel", m_xContext); | ||
+ | XGridDataModel xGridDataModel = (XGridDataModel) UnoRuntime.queryInterface( | ||
+ | XGridDataModel.class, dataModel); | ||
+ | |||
+ | xGridDataModel.addRow("1", new String[] {"1,1","1,2"} ); | ||
+ | xGridDataModel.addRow("2", new String[] {"2,1","2,2"} ); | ||
+ | </source> | ||
+ | |||
+ | Create the grid model on assign the column and data model: | ||
+ | <source lang="java"> | ||
+ | Object gridModel = xMultiServiceFactory.createInstance( | ||
+ | "com.sun.star.awt.grid.UnoControlGridModel"); | ||
+ | XPropertySet xPSetButton = (XPropertySet) UnoRuntime.queryInterface( | ||
+ | XPropertySet.class, gridModel); | ||
+ | |||
+ | xPSetButton.setPropertyValue("PositionX", new Integer(50)); | ||
+ | xPSetButton.setPropertyValue("PositionY", new Integer(30)); | ||
+ | xPSetButton.setPropertyValue("Width", new Integer(400)); | ||
+ | xPSetButton.setPropertyValue("Height", new Integer(400)); | ||
+ | xPSetButton.setPropertyValue("Name", "GridControl"); | ||
+ | xPSetButton.setPropertyValue("TabIndex", new Short((short) 0)); | ||
+ | xPSetButton.setPropertyValue("ColumnModel", xGridColumnModel); | ||
+ | xPSetButton.setPropertyValue("DataModel", xGridDataModel); | ||
+ | </source> | ||
+ | |||
== Listener == | == Listener == | ||
==Feature Set== | ==Feature Set== |
Revision as of 09:26, 13 July 2009
Abstract
OpenOffice.org hasn't a Grid Control via UNO API today. The goal is to develop and implement an UNO Grid Control.
Overview
Example
Create new columns:
// #1 column
Object column1Obj = xMultiComponentFactory.createInstanceWithContext(
"com.sun.star.awt.grid.GridColumn", m_xContext);
XGridColumn column1 = (XGridColumn) UnoRuntime.queryInterface(
XGridColumn.class, column1Obj);
column1.setTitle("Column1");
// #2 column
Object column2Obj = xMultiComponentFactory.createInstanceWithContext(
"com.sun.star.awt.grid.GridColumn", m_xContext);
XGridColumn column2 = (XGridColumn) UnoRuntime.queryInterface(
XGridColumn.class, column2Obj);
column2.setTitle("Column2");
Add the columns to the column model of the grid control:
Object columnModel = xMultiComponentFactory.createInstanceWithContext(
"com.sun.star.awt.grid.DefaultGridColumnModel", m_xContext);
XGridColumnModel xGridColumnModel = (XGridColumnModel) UnoRuntime.queryInterface(
XGridColumnModel.class, columnModel);
xGridColumnModel.addColumn(column1);
xGridColumnModel.addColumn(column2);
Use the data model of the grid control to add rows:
Object dataModel = xMultiComponentFactory.createInstanceWithContext(
"com.sun.star.awt.grid.DefaultGridDataModel", m_xContext);
XGridDataModel xGridDataModel = (XGridDataModel) UnoRuntime.queryInterface(
XGridDataModel.class, dataModel);
xGridDataModel.addRow("1", new String[] {"1,1","1,2"} );
xGridDataModel.addRow("2", new String[] {"2,1","2,2"} );
Create the grid model on assign the column and data model:
Object gridModel = xMultiServiceFactory.createInstance(
"com.sun.star.awt.grid.UnoControlGridModel");
XPropertySet xPSetButton = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, gridModel);
xPSetButton.setPropertyValue("PositionX", new Integer(50));
xPSetButton.setPropertyValue("PositionY", new Integer(30));
xPSetButton.setPropertyValue("Width", new Integer(400));
xPSetButton.setPropertyValue("Height", new Integer(400));
xPSetButton.setPropertyValue("Name", "GridControl");
xPSetButton.setPropertyValue("TabIndex", new Short((short) 0));
xPSetButton.setPropertyValue("ColumnModel", xGridColumnModel);
xPSetButton.setPropertyValue("DataModel", xGridDataModel);
Listener
Feature Set
- Width for each column
- Height for each row
- Each cell has its own data type
- Column and row header
- Vertical and horizontal scrollbars
- Row selection ( Single, Multi, Range )
- Auto resizing
- A11y
Milestones
Iteration | Due date | Status | Comment | Description | Components |
1 | 2009-06-30 | in progress |
To do:
|
| |
2 | open |
To do:
|
| ||
3 | open |
To do:
|
| ||
4 | open |
To do:
|
| ||
5 | open |
To do:
|
|
Grid specification
- Selection
- only row selection is possible
- selection possibilities with the mouse
- mouse click in a cell: single row selection
- Ctrl + mouse click in a cell: multiple rows selection possible, if row has been already selected, deselects it
- Shift + mouse click in a cell: multiple rows selection, range is between current row and the chosen one
- selection possibilities with the keyboard
- Ctrl + Alt: single row selection, if row has been already selected, deselects it
- Shift + UP: multiple rows selection above current row, if rows above the current one have been already selected, they can be deselected one by one
- Shift + DOWN: multiple rows selection beneath current row, if rows beneath the current one have been already selected, they can be deselected one by one
- Shift + HOME: multiple row selection, range is between current row and top one
- Shift + END: multiple row selection, range is between current row and bottom one
- Keys
- Resizing