nsIMsgCustomColumnHandler 编辑

The nsIMsgCustomColumnHandler interface allows you to create custom handlers for columns. It can be used in the Thunderbird threadpane for extensions to overlay their own columns.


mailnews/base/public/nsIMsgCustomColumnHandler.idlScriptable Please add a summary to this article.   Last changed in Gecko 1.9 (Firefox 3)

Inherits from: nsITreeView

This interface is meant to be implemented by extensions, as shown in the tutorial. The interface inherits from nsITreeView, however when you're implementing a custom handler in Javascript its not necessary to implement all of nsITreeView's methods. You must implement:

  1. nsITreeView.isEditable()
  2. nsITreeView.GetCellProperties()
  3. nsITreeView.GetImageSrc()
  4. nsITreeView.GetCellText()
  5. nsITreeView.cycleCell()
  6. nsIMsgCustomColumnHandler.getSortStringForRow()
  7. nsIMsgCustomColumnHandler.getSortLongForRow()
  8. nsIMsgCustomColumnHandler.isString()

and optionally: nsITreeView.GetRowProperties()

From C++ you must implement all of nsITreeView and nsIMsgCustomColumnHandler.

Example Implementation

An example Javascript implementation that does nothing:

var columnHandler = {
   isEditable: function(aRow, aCol) {return false;},
   cycleCell: function(aRow, aCol) { },
   getCellText: function(aRow, aCol) { },
   getSortStringForRow: function(aHdr) { return ""; },
   isString:            function() {return true;},
   getCellProperties:   function(aRow, aCol, aProps) { },
   getRowProperties:    function(aRow, aProps) { },
   getImageSrc:         function(aRow, aCol) {return null;},
   getSortLongForRow:   function(aHdr) {return 0;}
}

to attach it use the nsIMsgDBView.addColumnHandler() method (recall gDBView is the global nsIMsgDBView in Thunderbird):

 gDBView.addColumnHandler("newColumn", columnHandler);

after which it can be retrieved using the nsIMsgDBView.getColumnHandler() method:

 var handler = gDBView.getColumnHandler("newColumn");

and removed using the nsIMsgDBView.removeColumnHandler() method:

 gDBView.removeColumnHandler("newColumn");

Method overview

AString getSortStringForRow(in nsIMsgDBHdr aHdr);
unsigned long getSortLongForRow(in nsIMsgDBHdr aHdr);
boolean isString();

Methods

getSortStringForRow()

If the column displays a string, this will return the string that the column should be sorted by.

 AString getSortStringForRow(in nsIMsgDBHdr aHdr);
Parameters
aHdr
The message's nsIMsgDBHdr.
Return value

The string value that sorting will be done with.

getSortLongForRow()

If the column displays a number, this will return the number that the column should be sorted by.

 unsigned long getSortLongForRow(in nsIMsgDBHdr aHdr);
Parameters
aHdr
The message's nsIMsgDBHdr.
Return value

The long value that sorting will be done with.

isString()

 boolean isString();
Parameters

None.

Return value

true if the column displays a string value. false otherwise.

This affects whether getSortStringForRow or getSortLongForRow is used to determine the sort key for the column. It does not affect whether getCellText vs. getImageSrc is used to determine what to display.

See Also

Extensions:Thunderbird:Creating_a_Custom_Column

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:82 次

字数:7374

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文