文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>RCP中TableViewer自定义选择一行时样式

RCP中TableViewer自定义选择一行时样式

时间:2011-01-04  来源:轻剑

Lines 1-2:
Creates a display and shell.

Lines 3-4:
Obtains the system's red and yellow colors, which will be used for drawing the custom selection.

Lines 5-6:
Creates the table and sets its header to be visible. The table's style is specified to be SWT.FULL_SELECTION since the custom-drawn selection will span the full table width.

Lines 7-9:
Creates three table columns and sets the initial width of each to 100 pixels.

Lines 10-15:
Creates the table's items.

Line 16:
Packs the table to its preferred size.

Lines 17-18:
Adds an SWT.EraseItem listener to the table, which will be invoked whenever the background of a cell is about to be drawn.

Line 19:
Clears the SWT.HOT bit from the event's detail field to ensure that hover backgrounds are not natively drawn.

Line 20:
Checks the detail field for the SWT.SELECTED bit, and returns out of the listener if it is not there since there is no selection to draw.

Line 21:
Gets the table's client width, to be used for drawing the cell's selection.

Lines 22-24:
Obtains the GC to draw on from the event and stores its foreground and background colors for the purpose of restoring them later.

Lines 25-27:
Draws the custom selection rectangle using a gradient that spans from red to yellow. Line 26 specifies the full width of the item as the gradient bounds so that the color range will span the table width properly. Since the GC's clipping is pre-configured to the bounds of the cell, only this portion of this gradient drawing will appear.

Lines 28-29:
Restores the GC's foreground and background colors to their previous values.

Line 30:
Clears the SWT.SELECTED bit from the event's detail field to indicate that the default selection should not be drawn for this cell. Note that this item is still considered to be logically selected in the table.

Lines 33-38:
Packs and opens the shell, runs the event loop until the shell has been disposed, and disposes the display just before exiting.

 

http://www.eclipse.org/articles/article.php?file=Article-CustomDrawingTableAndTreeItems/index.html 

 

相关阅读 更多 +
排行榜 更多 +
谷歌卫星地图免费版下载

谷歌卫星地图免费版下载

生活实用 下载
谷歌卫星地图免费版下载

谷歌卫星地图免费版下载

生活实用 下载
kingsofpool官方正版下载

kingsofpool官方正版下载

赛车竞速 下载