# 其他高级控件类 # Chapter 14 of Part 2 Other Advanced Control Classes ## 其他高级控件类简介 ## Brief Introduction of Other Advanced Control Classes 该类控件主要是视图系列控件,多用于显示各种不同类型的列表项信息。 其他高级控件类的类继承关系如下: The class of controls are mainly view series controls, mainly used to display list item information of different types. Class inheritance relations of other advanced control classes are as below: - [mWidget](MStudioMGNCSV1dot0PGP2C3#mWidget) - [mScrollWidget](MStudioMGNCSV1dot0PGP2C7#m_ScrollWidget) * [mItemView](MStudioMGNCSV1dot0PGP2C14#mItemView) * [mListBox](MStudioMGNCSV1dot0PGP2C14#mListBox) * [mScrollView](MStudioMGNCSV1dot0PGP2C14#mScrollView) * [mIconview](MStudioMGNCSV1dot0PGP2C14#mIconView) * [mListview](MStudioMGNCSV1dot0PGP2C14#mListView) 在高级控件类中将列表项作为一个对象来管理,不同控件使用到的列表项对象不同,各自的继承关系如下: In the advanced control class, list item is managed as an object. Different controls use different list item objects, and the inheritance relations are as below: - [mObject](MStudioMGNCSV1dot0PGP2C3#mObject) - [mItem](MStudioMGNCSV1dot0PGP2C14#mItem) * [mItemManager](MStudioMGNCSV1dot0PGP2C14#mItemManager) * [mListItem](MStudioMGNCSV1dot0PGP2C14#mListItem) * [mListColumn](MStudioMGNCSV1dot0PGP2C14#mListColumn) 我们首先介绍各列表项对象,再具体介绍各控件类。 Let’s firstly introduce the list item objects, and then concretely introduce the control classes. ## mItem mItem 对象是所有列表项的基类,提供一系列基本的访问方法。直接使用该对象的有 mListBox, mScrollView 和 mIconView 等控件类。 mItem object is the basic class of all list items, providing a series of basic accessing methods. Control classes such as mListBox, mScrollView and mIconView etc. directly use this object. ### mItem 状态 ### Status of mItem |* 状态名 * | *说明* | | NCSF_ITEM_NORMAL | 条目状态:正常 | | NCSF_ITEM_SELECTED | 条目状态:选中 | | NCSF_ITEM_DISABLED | 条目状态:禁用 | | NCSF_ITEM_USEBITMAP | 条目状态:包含位图,与NCSF_ITEM_USEICON 互斥 | | NCSF_ITEM_USEICON | 条目状态:包含图标,与 NCSF_ITEM_USEBITMAP 互斥 | |* Status name * | *Explanation* | | NCSF_ITEM_NORMAL | Item status: normal | | NCSF_ITEM_SELECTED | Item status: selected | | NCSF_ITEM_DISABLED | Item status: banned | | NCSF_ITEM_USEBITMAP | Item status: contain bit map, and mutually exclude with NCSF_ITEM_USEICON | | NCSF_ITEM_USEICON | Item status: contain icon, and mutually exclude with NCSF_ITEM_USEBITMAP | ### mItem 属性 ### Property of mItem |* 属性ID *| *类型* | *权限* |* 说明 *| | NCSP_ITEM_HEIGHT | int | RW | 条目当前高度 | | NCSP_ITEM_FLAGS | DWORD | RW | 条目状态 | | *Property* | *Type* | *Authority* | *Explanation* | | NCSP_ITEM_HEIGHT | int | RW | Item current height | | NCSP_ITEM_FLAGS | DWORD | RW | Item status | ### mItem 方法 ### Method of mItem 继承自[mObject的方法](MStudioMGNCSV1dot0PGP2C3#mObject) It is inherited from [the method of mObject](MStudioMGNCSV1dot0PGP2C3#mObject) 一个条目可以包含多种内容信息,如文本、图片等等。提供的基础方法主要有: An item can contain multiple kinds of content information, such as text and image etc. Basic methods provided are: ```cplusplus BOOL isSelectedItem(mItem *self); BOOL isEnabledItem(mItem *self); void setItemEditor(mItem *self, hEditor editor); hEditor getItemEditor(mItem *self); void setItemAddData(mItem *self, DWORD addData); DWORD getItemAddData(mItem *self); void setItemImage(mItem *self, DWORD image); DWORD getItemImage(mItem *self); void setItemFlags(mItem *self, DWORD flags); DWORD getItemFlags(mItem *self); BOOL setItemHeight(mItem *self, int height); int getItemHeight(mItem *self); BOOL setItemString(mItem *self, const char* string); char* getItemString(mItem *self); ``` - isSelectedItem:判断当前条目是否处于选中状态。 - isEnabledItem:判断当前条目是否处于使能状态。 - setItemString:设置条目文本。 - getItemString:获取条目当前文本。 - setItemHeight:设置条目高度。 - getItemHeight:获取条目高度。 - setItemFlags:设置条目状态。 - getItemFlags:获取条目状态。 - setItemImage:设置条目图标。 - getItemImage:获取条目图标。 - setItemAddData:设置条目附加数据。 - getItemAddData:获取条目附加数据。 - setItemEditor:设置条目编辑器。 - getItemEditor:获取条目编辑器。 - isSelectedItem:judge if the current item is in selected status.。 - isEnabledItem:judge if the current item is in enabled status. - setItemString: set item text. - getItemString: get item current text. - setItemHeight:set item height. - getItemHeight:get item height. - setItemFlags:set item status - getItemFlags:get item status. - setItemImage:set item icon. - getItemImage:get item icon. - setItemAddData:set item additional data. - getItemAddData:get item additional data. - setItemEditor:set item editor. - getItemEditor:get item editor. ## mItemManager 通过链表管理 mItem 及其子类的基类管理器,提供对列表项的添加、删除和设置等方法。 Basic class manager managing mItem and its child class through linked list, providing methods of addling, removing and setting list items. ### mItemManager 状态 ### Status of mItemManager 继承自 mItem 状态 It is inherited from the status of mItem |* 状态名 * | *说明* | | NCSF_ITMMNG_AUTOSORT | 条目插入时自动排序 | | NCSF_ITMMNG_FROZEN | 禁止或使能条目刷新功能 | |* Status name * | *Explanation* | | NCSF_ITMMNG_AUTOSORT | Automatic sorting when the item is inserted | | NCSF_ITMMNG_FROZEN | Forbidden or enabled item refreshing function | ### mItemManager 属性 ### Property of mItemManager 继承自 mItem 属性 It is inherited from the property of mItem |* 属性ID *| *类型* | *权限* |* 说明 *| | NCSP_ITMMNG_ITEMCOUNT | int | RO | 包含的条目数 | | NCSP_ITMMNG_FLAGS | DWORD | RW | 条目状态 | | NCSP_ITMMNG_TOTALHEIGHT | int | RO | 所有条目总高度 | | *Property* | *Type* | *Authority* | *Explanation* | | NCSP_ITMMNG_ITEMCOUNT | int | RO | Item number contained | | NCSP_ITMMNG_FLAGS | DWORD | RW | Item status | | NCSP_ITMMNG_TOTALHEIGHT | int | RO | Total height of all the items | ### mItemManager 方法 ### Method of mItemManager 继承自 mItem 方法 It is inherited from the method of mItem ---++++ 回调方法 ---++++ Callback Method mItemManager 类支持根据列表项或列表项字符串进行比较的2个回调方法。其中根据列表项比较的方法优先于根据列表项字符串比较的方法。 mItemManager class supports the two callback methods of carrying out comparison according to list item or list item character string. The method of carrying out comparison according to list item prevails to the method of carrying out comparison according to list item character string. ```cplusplus typedef int (*NCS_CB_CMPITEM) (mItemManager *manager, HITEM hItem1, HITEM hItem2); typedef int (*NCS_CB_CMPSTR) (const char* s1, const char* s2, size_t n); NCS_CB_CMPITEM setItemCmpFunc(mItemManager *self, NCS_CB_CMPITEM func); NCS_CB_CMPSTR setStrCmpFunc(mItemManager *self, NCS_CB_CMPSTR func); NCS_CB_CMPSTR getStrCmpFunc(mItemManager *self); ``` - setItemCmpFunc:用于设置根据列表项自身进行比较的回调方法,同时返回先前设置的方法。 - setStrCmpFunc:用于设置根据列表项字符串进行比较的回调方法,同时返回先前设置或默认的方法。 - getStrCmpFunc:用于获取当前使用的字符串比较方法。 - setItemCmpFunc:used to set the callback method of carrying out comparison according to the list item itself, and at the same time, previous setting method is returned. - setStrCmpFunc:used to set the callback method of carrying out comparison according to the list item character string, and at the same time, the previous setting or default method is returned. - getStrCmpFunc:used to get the character string comparison method in current use. ---++++ 排序方法 ---++++ Sorting Method ```cplusplus void setAutoSortItem(mItemManager *self, BOOL sort); int sortItems(mItemManager *self, NCS_CB_CMPITEM pfn); ``` - setAutoSortItem:在添加所有列表项前设置或取消排序标记。当排序标记设置成功后,在其后添加的所有列表项将和已有的列表项进行相应比较后确定插入位置。 - sortItems:按照指定的列表项比较方法对所有列表项进行重新排序。 - setAutoSortItem: set or cancel sorting symbol before adding all the list items. After the sorting symbol setting is successful, all the list items added afterwards will be compared to the existing list items and insert location is determined. - sortItems: sort all the list items again according to the specified list item comparison method. ---++++ 刷新方法 ---++++ Refreshing Method ```cplusplus BOOL freeze(mItemManager *self, BOOL lock); BOOL isFrozen(mItemManager *self); int adjustItemsHeight(mItemManager *self, int diff); ``` - freeze:冻结或恢复对列表项的刷新。 - isFrozen:判断当前是否处于可刷新状态。 - adjustItemsHeight:调整列表项总高度变化值,在管理器处理可刷新状态时,该方法在调整完大小后会将变化立即反映到 UI 上,否则将不刷新 UI。 - freeze: freeze or recover refreshment to the list item.。 - isFrozen: judge if it is in refreshable status currently. - adjustItemsHeight: adjust the list item total height change value. When the manager handles refreshable status, after the method adjusts the size, it will immediately reflect the changes to UI, otherwise UI will not be refreshed. ---++++ 创建/删除/移动列表项 ---++++ Create/Remove/Move List Items 在对列表项进行插入时,首先确认是否是自动排序支持,如果是,则按照自动排序算法计算排序插入位置;否则根据前、后列表项或指定索引依次进行插入尝试,尝试成功则返回正确位置。 When inserting the list item, firstly confirm if it is automatic sorting supported, if so, calculate the sorting insert location according the automatic sorting calculation method; otherwise, conduct insert tries by sequence according to front and back list items or specified index, if the try is successful, return to the correct location. ```cplusplus HITEM createItem(mItemManager *self, HITEM prev, HITEM next, int index, int *pos); int insertItem(mItemManager *self, HITEM hItem, HITEM prev, HITEM next, int index, int *pos); int moveItem(mItemManager *self, mItem *curItem, int count, mItem* prevItem); int removeItem(mItemManager *self, HITEM hItem); BOOL removeAll(mItemManager *self); ``` - createItem:创建一个新的列表项并插入到指定位置,同时通过最后的参量返回已插入的位置。 - insertItem:将已创建的列表项插入到管理器镮的指定位置,同时通过最后的参量返回已插入的位置。 - moveItem:将当前列表项及其后指定数目的列表项移动到某一列表项位置之后。 - removeItem:删除某一指定列表项。 - removeAll:删除所有列表项。 - createItem: create a new list item and insert to the specified location, and at the same time, return to the inserted location through the final parameter. - insertItem: insert the created list item to the specified location of the manager, and at the same time, return to the inserted location through the final parameter. - moveItem: move the current list items and the list items of specified number afterwards to behind a certain list item location. - removeItem: remove a certain specified list item - removeAll: remove all the list items. ---++++ 遍历列表项 ---++++ Traverse List Items ```cplusplus list_t* getQueue(mItemManager *self); HITEM getListEntry(list_t* entry); HITEM getFirstItem(mItemManager *self); HITEM getNext(mItemManager *self, HITEM hItem); HITEM getPrev(mItemManager *self, HITEM hItem); ``` - getQueue:获取管理器的列表项列首。 - getListEntry:获取指定链表项的列表项指针。 - getFirstItem:获取管理器中的第一个列表项。 - getNext:获取指定列表项的后一个列表项。 - getPrev:获取指定列表项的前一个列表项。 - getQueue: get the list item column header of the manager. - getListEntry: get the list item pointer of the specified linked list item. - getFirstItem: get the first list item in the manager. - getNext: get the next list item of the specified list item. - getPrev: get the previous list item of the specified list item. ---++++ 获取列表项信息 ---++++ Get List Item Information ```cplusplus HITEM getItem(mItemManager *self, int index); int indexOf(mItemManager *self, HITEM hItem); int inItem(mItemManager *self, int mouseX, int mouseY, HITEM *pRet, POINT *pt); int getItemYPos(mItemManager *self, HITEM hItem); int getTotalHeight(mItemManager *self); int getItemCount(mItemManager *self); int isEmpty(mItemManager *self); BOOL getSelection(mItemManager *self, HITEM *pRet, int count); int getSelectionCount(mItemManager *self); ``` - getItem:获取指定索引的列表项。 - indexOf:获取指定列表项的索引。 - inItem:获取指定鼠标位置下的列表项,并返回列表项的起始位置。 - getItemYPos:获取指定列表项的起始纵向坐标。 - getTotalHeight:获取列表项管理器的整体高度。 - getItemCount:获取列表项总数目。 - isEmpty:判断列表项是否为空。 - getSelectionCount:获取选中列表项数目。 - getSelection:获取指定数目的选中列表项信息。 - getItem: get the list item of the specified index. - indexOf: get index of the specified list item. - inItem: get list item under the specified mouse location, and return to the starting location of the list item. - getItemYPos: get starting vertical coordinate of the specified list item. - getTotalHeight: get total height of the list item manager. - getItemCount: get total number of the list items.。 - isEmpty: judge if the list item is empty. - getSelectionCount: get number of the selected list items. - getSelection: get information of the selected list items of specified number. ---++++ 设置/获取列表项状态 ---++++ Set/Get List Item Status ```cplusplus BOOL isEnabled(mItemManager *self, HITEM hItem); BOOL enable(mItemManager *self, HITEM hItem, BOOL enable); BOOL isSelected(mItemManager *self, HITEM hItem); BOOL select(mItemManager *self, HITEM hItem, BOOL sel); void selectAll(mItemManager *self); void deselectAll(mItemManager *self); HITEM hilight(mItemManager *self, HITEM hItem); HITEM getHilight(mItemManager *self); BOOL isHilight(mItemManager *self, HITEM hItem); int setHeight(mItemManager *self, HITEM hItem, int height); int getHeight(mItemManager *self, HITEM hItem); void setAddData(mItemManager *self, HITEM hItem, DWORD addData); DWORD getAddData(mItemManager *self, HITEM hItem); void setImage(mItemManager *self, HITEM hItem, DWORD image); DWORD getImage(mItemManager *self, HITEM hItem); void setFlags(mItemManager *self, HITEM hItem, DWORD flags); DWORD getFlags(mItemManager *self, HITEM hItem); BOOL setText(mItemManager *self, HITEM hItem, const char* text); const char* getText(mItemManager *self, HITEM hItem); int getTextLen(mItemManager *self, HITEM hItem); ``` - isEnabled:判断指定列表项是否处于使能状态。 - enable:使能或禁止指定列表项。 - isSelected:判断指定列表项是否处于选择状态。 - select:选择或取消选择指定列表项。 - selectAll:选中所有列表项。 - deselectAll:取消所有列表项的选中状态。 - hilight:高亮选择指定的列表项。 - getHilight:获取当前高亮选择列表项。 - isHilight:判断指定列表项是否处于高亮状态。 - setHeight:设置列表项高度。 - getHeight:获取列表项高度。 - setAddData:设置列表项附加数据。 - getAddData:获取列表项附加数据。 - setImage:设置列表项位图信息。 - getImage:获取列表项位图信息。 - setFlags:设置列表项状态标志。 - getFlags:获取列表项状态标志。 - setText:设置列表项文本字符串。 - getText:获取列表项文本字符串。 - getTextLen:获取列表项文本字符串长度。 - isEnabled: judge if the specified list item is in enabled status.。 - enable: enable of forbid the specified list item. - isSelected: judge if the specified list item is in selected status. - select: select or deselect the specified list item. - selectAll: select all the list items. - deselectAll: Cancel the selected status of all the list items. - hilight: high light select the specified list item. - getHilight: get the current high light selected list item. - isHilight: judge if the specified list item is in high light status. - setHeight: set height of the list item. - getHeight: get height of the list item. - setAddData: set additional data of the list item. - getAddData: get additional data of the list item. - setImage: set bit map information of the list item. - getImage: get bit map information of the list item. - setFlags: set status symbol of the list item. - getFlags: get status symbol of the list item. - setText: set text character string of the list item. - getText: get text character string of the list item. - getTextLen: get length of the text character string of the list item. ## mListItem ## mListItem mListItem 对象用于描述 mListView 控件的行对象。 mListItem object is used to describe the row object of mListView control. ### mListItem 状态 ### Status of mListItem 继承自 mItemManger 状态 It is inherited from the status of mItemManger |* 状态名 * | *说明* | | NCSF_LSTITM_FOLD | 折叠条目 | | NCSF_LSTITM_PRIVBKCOL | 条目包含私有背景色 | | NCSF_LSTITM_PRIVBKCOL | 条目包含私有前景色 | |* Status name * | *Explanation* | | NCSF_LSTITM_FOLD | Folded item | | NCSF_LSTITM_PRIVBKCOL | The item contains private background color | | NCSF_LSTITM_PRIVBKCOL | The item contains private foreground color | ### mListItem 属性 ### Property of mListItem 继承自 mItemManager 属性 It is inherited from the property of mItemManager |* 属性ID *| *类型* | *权限* |* 说明 *| | NCSP_LSTITM_NRCHILD | int | RO | 包含的子条目数 | | NCSP_LSTITM_DEPTH | int | RO | 条目的深度 | | NCSP_LSTITM_RHEIGHT | int | RO | 条目可见时的实际高度 | | *Property* | *Type* | *Authority* | *Explanation* | | NCSP_LSTITM_NRCHILD | int | RO | Child item number contained | | NCSP_LSTITM_DEPTH | int | RO | Depth of the item | | NCSP_LSTITM_RHEIGHT | int | RO | Actual height when the item is visible | ### mListItem 方法 ### Method of mListItem 继承自 mItemManager 方法 It is inherited from the method of mItemManager mListItem 对象提供了一系列操作方法: mListItem object provides a series of operation methods: ```cplusplus void setBackground(mListItem *self, int index, int *color); void setForeground(mListItem *self, int index, int *color); int getBackground(mListItem *self, int index, int *color); int getForeground(mListItem *self, int index, int *color); BOOL addChild(mListItem *self, mListItem *child); BOOL delChild(mListItem *self, mListItem *child); BOOL setFold(mListItem *self, BOOL fold); mListItem* getParent(mListItem *self); int getChildCount(mListItem *self); int getDepth(mListItem *self); BOOL isFold(mListItem *self); ``` - setBackground:用于设置单元背景色。当 _color_ 为空时对原设置进行清空处理;当 _index_ 索引无效时,设置默认行背景色,否则设置指定单元背景色。 - getBackground:用于获取单元背景色。当 _index_ 索引无效时,通过 _color_ 返回默认行背景色,否则返回指定单元背景色。 - setForeground:用于设置单元前景色。当 _color_ 为空时对原设置进行清空处理;当 _index_ 索引无效时,设置默认行前景色,否则设置指定单元前景色。 - getForeground:用于获取单元前景色, 当 _index_ 索引无效时,通过 _color_ 返回默认行前景色,否则返回指定单元前景色。 - addChild:添加指定的子条目。 - delChild:删除指定的子条目。 - setFold:用于折叠或展开指定条目。 - getparent:用于获取指定条目的父条目。 - getChildCount:获取包含的子条目数目。 - getDepth:获取条目深度。 - isFold:判断条目是否处于折叠状态。 - setBackground: used to set unit background color. When the color is empty, empty the original setting; when the index is invalid, set default row background color, otherwise set the specified unit background color. - getBackground: used to get unit background color. When the index is invalid, return the default row background color through color, otherwise return the specified unit background color. - setForeground: used to set unit foreground color. When the color is empty, empty the original setting; when the index is invalid, set the default row foreground color, otherwise set the specified unit foreground color. - getForeground: used to get the unit foreground color. When the index is invalid, return the default row foreground color through color, otherwise return the specified unit foreground color. - addChild: add the specified child item. - delChild: delete the specified child item. - setFold: used to fold or unfold the specified item. - getparent: used to get the parent item of the specified item. - getChildCount: get the number of the child item contained. - getDepth: get the item depth. - isFold: judge if the item is in folded status. ## mListColumn mListColumn 对象用于描述 mListView 控件的列对象。 mListColumn object is used to describe the column object of mListView Control. ### mListColumn 状态 ### Status of mListColumn 继承自 mItem 状态 It is inherited from the status of mItem |* 状态名 * | *说明* | | NCSF_LSTCLM_LEFTALIGN | 文本对齐方式:左对齐 | | NCSF_LSTCLM_RIGHTALIGN | 文本对齐方式:右对齐 | | NCSF_LSTCLM_CENTERALIGN | 文本对齐方式:居中对齐 | |* Status name * | *Explanation* | | NCSF_LSTCLM_LEFTALIGN | Text alignment mode: left aligned | | NCSF_LSTCLM_RIGHTALIGN | Text alignment mode: right aligned | | NCSF_LSTCLM_CENTERALIGN | Text alignment mode: center aligned | ### mListColumn 属性 ### Property of mListColumn 继承自 mItem 属性 It is inherited from the property of mItem |* 属性ID *| *类型* | *权限* |* 说明 *| | NCSP_LSTCLM_POSX | int | RW | 列起始位置横坐标 | | NCSP_LSTCLM_WIDTH | int | RW | 列宽 | | NCSP_LSTCLM_SORTTYPE | ncsLstClmSortType | RW | 列表项排序方式:值为升序、降序或不排序三者选其一 | | NCSP_LSTCLM_CMPFUNC | NCS_CB_LISTV_CMPCLM | RW | 两列表项比较的回调方法 | | *Property* | *Type* | *Authority* | *Explanation* | | NCSP_LSTCLM_POSX | int | RW | Column starting position horizontal coordinate | | NCSP_LSTCLM_WIDTH | int | RW | Column width | | NCSP_LSTCLM_SORTTYPE | ncsLstClmSortType | RW | List item sorting mode: the values are ascending, descending or not sorted | | NCSP_LSTCLM_CMPFUNC | NCS_CB_LISTV_CMPCLM | RW | Callback method of comparison of the two list items | 下面是属性中涉及的数据结构定义: The following is the data structure definition involved in the property ```cplusplus typedef enum { NCSID_LSTCLM_NOTSORTED = 0, //不排序// Not sorted NCSID_LSTCLM_HISORTED, //升序// Ascending NCSID_LSTCLM_LOSORTED //降序// Descending }ncsLstClmSortType; typedef struct _NCS_LSTCLM_SORTDATA { int column; //排序列索引// Sorted column index int losorted; //排序列排序方式// Sorted column sorting mode mWidget *obj; //包含比较项的控件类// Control class containing comparison items }NCS_LSTCLM_SORTDATA; typedef int (*NCS_CB_LISTV_CMPCLM)(HITEM nItem1, HITEM nItem2, NCS_LSTCLM_SORTDATA *sortData); ``` ## mItemView 基类,不允许直接使用。 Basic class, direct use is not allowed ### mItemView 风格 ### Style of mItemView 继承自[mScrollWidget的风格](MStudioMGNCSV1dot0PGP2C3#mScrollWidget) It is inherited from [the style of mScrollWidget](MStudioMGNCSV1dot0PGP2C3#mScrollWidget) |* 风格名 * | *mStudio属性名* | *说明* | | NCSS_ITEMV_AUTOSORT | - | 条目自动排序 | | NCSS_ITEMV_LOOP | - | 条目可循环浏览 | | NCSS_ITEMV_SINGLE | - | 条目单选支持,默认风格 | | NCSS_ITEMV_MULTIPLE | - | 条目多选支持 | | *Style name* | *mstudio property name* | *Explanation* | | NCSS_ITEMV_AUTOSORT | - | Item automatic sorting | | NCSS_ITEMV_LOOP | - | Item circulative browsing | | NCSS_ITEMV_SINGLE | - | Item single selection supported, default style | | NCSS_ITEMV_MULTIPLE | - | Item multi selection supported | ### mItemView 属性 ### Property of mItemView 继承自[mScrollWidget的属性](MStudioMGNCSV1dot0PGP2C3#mScrollWidget) Inherited from [the property of mScrollWidget](MStudioMGNCSV1dot0PGP2C3#mScrollWidget) |* 属性ID *| *mStudio 名*| *类型* | *权限* |* 说明 *| | NCSP_ITEMV_DEFITEMHEIGHT | - | int | RW | 条目默认高度 | | NCSP_ITEMV_ITEMCOUNT | - | int | RO | 条目总数目 | | *Property ID* | *mstudio name* | *Type* | *Authority* | *Explanation* | | NCSP_ITEMV_DEFITEMHEIGHT | - | int | RW | Item default height | | NCSP_ITEMV_ITEMCOUNT | - | int | RO | Item total number | ### mItemView 事件 ### Event of mItemView 继承自[mScrollWidget的事件](MStudioMGNCSV1dot0PGP2C3#mScrollWidget) It is inherited from [the event of mScrollWidget](MStudioMGNCSV1dot0PGP2C3#mScrollWidget) |* 事件通知码 *|* 说明 *|* 参数 *| | NCSN_ITEMV_CLICKED | 鼠标点击事件 | 被点击的条目句柄 | | NCSN_ITEMV_SELCHANGING | 正在改变选择的条目 | 处于高亮状态的条目句柄 | | NCSN_ITEMV_SELCHANGED | 选择条目已改变 | 新的选择条目句柄 | | NCSN_ITEMV_ENTER | Enter 键被按下 | - | | NCSN_ITEMV_SETFOCUS | 获取焦点 | - | | NCSN_ITEMV_KILLFOCUS | 失去焦点 | - | |* Event notification code *|* Explanation *|* Parameter *| | NCSN_ITEMV_CLICKED | Mouse clicking event | Clicked item sentence handle | | NCSN_ITEMV_SELCHANGING | Item changing selection | Item sentence handle in high light status | | NCSN_ITEMV_SELCHANGED | The selected item has changed | New selected item sentence handle | | NCSN_ITEMV_ENTER | Enter key is pressed down | - | | NCSN_ITEMV_SETFOCUS | Get focus | - | | NCSN_ITEMV_KILLFOCUS | Lose focus | - | ### mItemView 方法 ### Method of mItemView 继承自[mScrollWidget的方法](MStudioMGNCSV1dot0PGP2C3#mScrollWidget) It is inherited from [the method of mScrollWidget](MStudioMGNCSV1dot0PGP2C3#mScrollWidget) ---++++ 回调方法 ---++++ Callback Method mItemView 提供了初始化、绘制和销毁列表项3个回调方法,同时还有比较列表项的回调方法。 mItemView provides three callback methods, initialization, drawing and destroying list item, at the same time, there is the callback method of comparing list items. ```cplusplus typedef int (*NCS_CB_INITITEM)(mItemView *self, HITEM hItem); typedef void (*NCS_CB_DSTRITEM)(mItemView *self, HITEM hItem); typedef void (*NCS_CB_DRAWITEM)(mItemView *self, HITEM hItem, HDC hdc, RECT *rcDraw); NCS_CB_DRAWITEM setItemDraw(mItemView *self, NCS_CB_DRAWITEM func); NCS_CB_INITITEM setItemInit(mItemView *self, NCS_CB_INITITEM func); NCS_CB_DSTRITEM setItemDestroy(mItemView *self, NCS_CB_DSTRITEM func); NCS_CB_CMPITEM setItemCmpFunc(mItemView *self, NCS_CB_CMPITEM func); NCS_CB_CMPSTR setStrCmpFunc(mItemView *self, NCS_CB_CMPSTR func); NCS_CB_CMPSTR getStrCmpFunc(mItemView *self); ``` ---++++ 排序方法 ---++++ Sorting Method ```cplusplus void setAutoSortItem(mItemView *self, BOOL sort); int sortItems(mItemView *self, NCS_CB_CMPITEM pfn); ``` - setAutoSortItem:在添加所有列表项前设置或取消排序标记。当排序标记设置成功后,在其后添加的所有列表项将和已有的列表项进行相应比较后确定插入位置。 - sortItems:按照指定的列表项比较方法对所有列表项进行重新排序。 - setAutoSortItem: Set or cancel sorting symbol before adding all the list items. After the sorting symbol setting is successful, after comparing all the list items added afterwards and the existing list items, confirm the insert position. - sortItems: according to the specified list item comparison method, sort all the list items again. ---++++ 刷新方法 ---++++ Refreshing Method ```cplusplus void freeze(mItemView *self, BOOL lock); BOOL isFrozen(mItemView *self); int adjustItemsHeight(mItemView *self, int diff); ``` - freeze:冻结或恢复对列表项的刷新。 - isFrozen:判断当前是否处于可刷新状态。 - adjustItemsHeight:调整列表项总高度变化值,该方法在控件调整完列表项大小后会将变化立即反映到 UI 上,否则将不刷新 UI。 - freeze: Freeze or recover refreshment to the list item.。 - isFrozen: judge if it is in refreshable status currently. - adjustItemsHeight: adjust the list item total height change value. The method will immediately reflect the change to UI after the control adjusts the list item size, otherwise UI will not be refreshed. ---++++ 创建/删除/移动列表项 ---++++ Create/Remove/Move List Item 在对列表项进行插入时,首先确认是否是自动排序支持,如果是,则按照自动排序算法计算排序插入位置;否则根据前、后列表项或指定索引依次进行插入尝试,尝试成功则返回正确位置。 When inserting to the list item, firstly determine if it is automatic sorting supported, if so, calculate the sorting insert position according to the automatic sorting calculation method; otherwise conduct insert tries by sequence according to the front and back list item or specified index; after the try is successful, return to the correct position. ```cplusplus HWND createItem(mItemView *self, HITEM prev, HITEM next, int index, int height, DWORD addData, int *pos, BOOL adjust); int insertItem(mItemView *self, HITEM hItem, HITEM prev, HITEM next, int index, int *pos); int removeItem(mItemView *self, HITEM hItem); BOOL removeAll(mItemView *self); ``` - createItem:创建一个新的列表项并插入到指定位置,同时通过最后的参量返回已插入的位置。 - insertItem:将已创建的列表项插入到管理器镮的指定位置,同时通过最后的参量返回已插入的位置。 - removeItem:删除某一指定列表项。 - removeAll:删除所有列表项。 - createItem: create a new list item and insert to the specified position, and at the same time, return to the inserted position according to the final parameter. - insertItem: insert the created list item to the specified position of the manager, and at the same time, return to the inserted position according to the final parameter. - removeItem: remove certain specified list item. - removeAll: remove all the list items. ---++++ 遍历列表项 ---++++ Traverse List Item ```cplusplus list_t* getQueue(mItemView *self); HITEM getListEntry(mItemView *self, list_t* entry); HITEM getFirstItem(mItemView *self); HITEM getNext(mItemView *self, HITEM hItem); HITEM getPrev(mItemView *self, HITEM hItem); ``` - getQueue:获取管理器的列表项列首。 - getListEntry:获取指定链表项的列表项指针。 - getFirstItem:获取管理器中的第一个列表项。 - getNext:获取指定列表项的后一个列表项。 - getPrev:获取指定列表项的前一个列表项。 - getQueue: get the list item column header of the manager.。 - getListEntry: get the list item pointer of the specified linked list item. - getFirstItem: get the first list item in the manager. - getNext: get the next list item of the specified list item. - getPrev: get the previous list item of the specified list item. ---++++ 获取列表项信息 ---++++ Get List Item Information ```cplusplus HITEM getItem(mItemView *self, int index); int indexOf(mItemView *self, HITEM hItem); int inItem(mItemView *self, int mouseX, int mouseY, HITEM *pRet, POINT *pt); int getTotalHeight(mItemView *self); int getItemCount(mItemView *self); int isEmpty(mItemView *self); int getSelectionCount(mItemView *self); BOOL getSelection(mItemView *self, HITEM *pRet, int count); ``` - getItem:获取指定索引的列表项。 - indexOf:获取指定列表项的索引。 - inItem:获取指定鼠标位置下的列表项,并返回列表项的起始位置。 - getTotalHeight:获取列表项管理器的整体高度。 - getItemCount:获取列表项总数目。 - isEmpty:判断列表项是否为空。 - getSelectionCount:获取选中列表项数目。 - getSelection:获取指定数目的选中列表项信息。 - getItem: get list item of the specified index. - indexOf: get index of the specified list item. - inItem: get the list item under the specified mouse position, and return to the starting position of the list item. - getTotalHeight: get the total height of the list item manager. - getItemCount: get the total number of the list items. - isEmpty: judge if the list item is empty. - getSelectionCount: get number of the selected list items. - getSelection: get the selected list item information of specified number. ---++++ 设置/获取列表项状态 ---++++ Set/Get List Item Status ```cplusplus BOOL isEnabled(mItemView *self, HITEM hItem); BOOL enable(mItemView *self, HITEM hItem, BOOL enable); BOOL isSelected(mItemView *self, HITEM hItem); BOOL select(mItemView *self, HITEM hItem); BOOL deselect(mItemView *self, HITEM hItem); void selectAll(mItemView *self); void deselectAll(mItemView *self); int hilight(mItemView *self, HITEM hItem); HITEM getHilight(mItemView *self); BOOL isHilight(mItemView *self, HITEM hItem); int setItemHeight(mItemView *self, HITEM hItem, int height); int getItemHeight(mItemView *self, HITEM hItem); DWORD getAddData(mItemView *self, HITEM hItem); void setAddData(mItemView *self, HITEM hItem, DWORD addData); void setImage(mItemView *self, HITEM hItem, DWORD image); DWORD getImage(mItemView *self, HITEM hItem); void setFlags(mItemView *self, HITEM hItem, DWORD flags); DWORD getFlags(mItemView *self, HITEM hItem); BOOL setText(mItemView *self, HITEM hItem, const char* text); const char* getText(mItemView *self, HITEM hItem); int getTextLen(mItemView *self, HITEM hItem); ``` - isEnabled:判断指定列表项是否处于使能状态。 - enable:使能或禁止指定列表项。 - isSelected:判断指定列表项是否处于选择状态。 - select:选择指定的列表项。 - deselect:取消选择指定的列表项。 - selectAll:选中所有列表项。 - deselectAll:取消所有列表项的选中状态。 - hilight:高亮选择指定的列表项。 - getHilight:获取当前高亮选择列表项。 - isHilight:判断指定列表项是否处于高亮状态。 - setItemHeight:设置列表项高度。 - getItemHeight:获取列表项高度。 - setAddData:设置列表项附加数据。 - getAddData:获取列表项附加数据。 - setImage:设置列表项位图信息。 - getImage:获取列表项位图信息。 - setFlags:设置列表项状态标志。 - getFlags:获取列表项状态标志。 - setText:设置列表项文本字符串。 - getText:获取列表项文本字符串。 - getTextLen:获取列表项文本字符串长度。 - isEnabled: judge if the specified list item is in enabled status. - enable: enable or forbid specified list item. - isSelected: judge if the specified list item is in selected status. - select: select specified list item. - deselect: deselect the specified list item. - selectAll: select all the list items. - deselectAll: cancel the selected status of all the list items. - hilight: high light select the specified list item. - getHilight: get the currently high light selected list item. - isHilight: judge if the specified list item is in high light status. - setItemHeight: set height of the list item. - getItemHeight: get height of the list item. - setAddData: set additional data of the list item. - getAddData: get additional data of the list item. - setImage: set bit map information of the list item. - getImage: get bit map information of the list item. - setFlags: set status symbol of the list item. - getFlags: get status symbol of the list item. - setText: set text character string of the list item. - getText: get text character string of the list item. - getTextLen: get length of the text character string of the list item. ---++++ 其它 ---++++ Others ```cplusplus int getFirstVisItem(mItemView *self); void resetContent(mItemView *self); int getRect(mItemView *self, HITEM hItem, RECT *rcItem, BOOL bConv); int getCurSel(mItemView *self); int setCurSel(mItemView *self, int newSel); void refreshItem(mItemView *self, HITEM hItem, const RECT *rcInv); BOOL showItemByIdx(mItemView *self, int index); BOOL showItem(mItemView *self, HITEM hItem); ``` - getFirstVisItem:获取第一个可见的列表项。 - resetContent:删除所有列表项,并恢复所有信息配置到初始值。 - getRect:获取指定列表项的矩形区域,并通过最后参数决定是否将坐标转换为相对于屏幕的坐标。 - getCurSel:获取当前选中列表项索引。 - setCurSel:对通过索引设置指定列表项为选中项并将其显示出来,成功返回0,失败返回-1。 - refreshItem:刷新指定列表项的指定区域,若指定区域为空,则刷新整个列表项。 - showItemByIdx:根据索引显示指定列表项。 - showItem:显示指定列表项。 - getFirstVisItem: get the first visible list item. - resetContent: remove all the list items, and reset all the information configuration to the initial value. - getRect: get the rectangular region of the specified list item, and decide if converting the coordinate to the coordinate relative to the screen through the final parameter. - getCurSel: get the currently selected list item index. - setCurSel: set the specified list item as selected item through index and display it, if it is successful, return 0; if it is failed, return -1. - refreshItem: refresh the specified region of the specified list item; if the specified region is empty, refresh the whole list item. - showItemByIdx: show the specified list item according to the index. - showItem: show the specified list item ## mScrollView - *控件窗口类*: NCSCTRL_SCROLLVIEW - *控件英文名*: ScrollView - *简介*: 用于显示和处理列表项,其中列表项的内容绘制完全是由应用程序自己确定。 - *示意图*: - *Control window class*: NCSCTRL_SCROLLVIEW - *Control English name*: ScrollView - *Brief introduction*: Used to show and handle list item, and content drawing of the list item is decided by the applications themselves. - *Schematic diagram*: ### mScrollView 风格 ### Style of mScrollView 继承自 mItemView 风格 It is inherited from the style of mItemView |* 风格名 * | *mStudio属性名* | *说明* | | NCSS_SCRLV_LOOP | - | 条目可循环浏览 | | NCSS_SCRLV_SORT | - | 条目自动排序 | | *Style name* | *mstudio property name* | *Explanation* | | NCSS_SCRLV_LOOP | - | Item circulative browsing | | NCSS_SCRLV_SORT | - | Item automatic sorting | ### mScrollView 属性 ### Property of mScrollView 继承自 mItemView 属性 it is inherited from the property of mItemView ### mScrollView 事件 ### Event of mScrollView 继承自 mItemView 事件 It is inherited from the event of mItemView |* 事件通知码 *|* 说明 *|* 参数 *| | NCSN_SCRLV_CLICKED | 鼠标点击事件 | 被点击的条目句柄 | | NCSN_SCRLV_SELCHANGING | 正在改变选择的条目 | 处于高亮状态的条目句柄 | | NCSN_SCRLV_SELCHANGED | 选择条目已改变 | 新的选择条目句柄 | |* Event notification code *|* Explanation *|* Parameter *| | NCSN_SCRLV_CLICKED | Mouse clicking event | Clicked item sentence handle | | NCSN_SCRLV_SELCHANGING | Item changing selection | Item sentence handle in high light status | | NCSN_SCRLV_SELCHANGED | The selected item has changed | New selected item sentence handle | ### mScrollView 方法 ### Method of mScrollView 继承自 mItemView 方法 It is inherited from the method of mItemView mScrollView 继承自 mItemView,提供了控件自身的 addItem 方法,该方法通过列表项信息创建并插入列表项,同时返回插入位置给接口调用者。 mScrollView in inherited from mItemView, which provides addItem method of the control itself. The method creates and inserts list item through list item information, and at the same time, returns the insert position to the interface caller. ```cplusplus typedef struct _NCS_SCRLV_ITEMINFO { int index; int height; DWORD addData; }NCS_SCRLV_ITEMINFO; HITEM addItem(mScrollView *self, NCS_SCRLV_ITEMINFO *info, int *pos); ``` 在添加列表项内容前通过进行一些基础回调方法的设置等内容,如: Before adding list item content, carry out setting of some basic callback method, such as: ```cplusplus %INCLUDE{"%ATTACHURL%/scrollview" pattern="^.*?// START_OF_ADDITEMS(.*?)// END_OF_ADDITEMS.*"}% ``` ### mScrollView 实例 ### Instance of mScrollView
图 p2c6-1 scrollview 程序的输出
Figure p2c6-1 Output of scrollview Program
清单 p214-1 scrollview.c
List p214-1 scrollview.c
```cplusplus %INCLUDE{"%ATTACHURL%/scrollview"}% ``` ## mListBox - *控件窗口类*: NCSCTRL_LISTBOX - *控件英文名*: ListBox - *简介*: 将用户提供的一系列可选项显示在可滚动的子窗口中,用户可通过键盘及鼠标操作来选中某一项或者多个项,选中的列表项通常高亮显示。列表框的最典型用法就是文件打开对话框。 - *示意图*: - *Control window class*: NCSCTRL_LISTBOX - *Control English name*: ListBox - *Brief introduction*: Display a series of options provided by the users in the child window that can scroll. Users can select certain item or multiple items through keyboard and mouse operation, and the selected list item is usually high light displayed. The most typical usage of list box is file opening dialog box. - *Schematic diagram*:
图 p2c6-1 listbox 程序的输出
Figure p2c6-1 Output of listbox Program
清单 p2c14-3 listbox.c
List p2c14-3 listbox.c
```cplusplus %INCLUDE{"%ATTACHURL%/listbox"}% ``` ## mIconView - *控件窗口类*: NCSCTRL_ICONVIEW - *控件英文名*: IconView - *简介*: 将用户提供的一系列可选项以图标加标签文字的方式供其浏览,用户可通过键盘及鼠标操作来选中某一项或者多个项,选中的列表项通常高亮显示。标型控件的典型用法是作为桌面图标的容器和目录下文件的显示。 - *示意图*: - *Control window class*: NCSCTRL_ICONVIEW - *Control English name*: IconView - *Brief introduction*: a series of options provided by the users is offered in the mode of icon plus label literal for browsing. Users can select certain item or multiple items through keyboard and mouse operation, and the selected item is usually high light displayed. The typical usage of icon control is as the display of the container of desktop icon and documents under the directory. - *Schematic diagram*:
图 p2c6-1 iconview 程序的输出
Figure p2c6-1 Output of iconview Program
清单 p2c14-3 iconview.c
List p2c14-3 iconview.c
```cplusplus %INCLUDE{"%ATTACHURL%/iconview"}% ``` ## mListView - *控件窗口类*: NCSCTRL_LISTVIEW - *控件英文名*: ListView - *简介*: 以列表的方式显示一系列的数据项(列表项),不同列表项的相同类型子项以列的方式组织,列表型控件的表头(header)内容通常反映了列表项不同子项的意义。列表型控件经常用来作为文件浏览框,它可以在一个区域内显示包括文件名、文件类型、大小和修改日期在内的诸多文件属性。 - *示意图*: - *Control window class*: NCSCTRL_LISTVIEW - *Control English name*: ListView - *Brief introduction*:Display a series of data items (list items) in the list mode. Same type of child items of different list items are organized in the column mode, and content of the header of the list control usually reflect the meanings of different child items of the list item. List control is usually used as file browsing box, which can show many file properties including file name, file type, size and modification date in a region. - *Schematic diagram*:
图 p2c6-1 listview 程序的输出
Figure p2c6-1 Output of listview Program
清单 p2c14-4 listview.c
List p2c14-4 listview.c
```cplusplus %INCLUDE{"%ATTACHURL%/listview"}% ``` [Next](MStudioMGNCSV1dot0PGP2C13][Previous]] < [[MStudioMGNCSV1dot0PG][Index]] > [[MStudioMGNCSV1dot0PGP2C15) -- Main.XiaodongLi - 22 Feb 2010