00001
00026 #ifndef _MGUI_CTRL_ITEMVIEW_H
00027 #define _MGUI_CTRL_ITEMVIEW_H
00028
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032
00043 #define NCSCTRL_ITEMVIEW NCSCLASSNAME("itemview")
00044
00045 typedef struct _mItemView mItemView;
00046 typedef struct _mItemViewClass mItemViewClass;
00047 typedef struct _mItemViewRenderer mItemViewRenderer;
00048
00053 typedef int (*NCS_CB_INITITEM)(mItemView *self, HITEM hItem);
00054
00059 typedef void (*NCS_CB_DSTRITEM)(mItemView *self, HITEM hItem);
00060
00065 typedef void (*NCS_CB_DRAWITEM)(mItemView *self, HITEM hItem, HDC hdc, RECT *rcDraw);
00066
00071 typedef struct _NCS_CB_ITEMOPS
00072 {
00076 NCS_CB_INITITEM initItem;
00080 NCS_CB_DSTRITEM destroyItem;
00084 NCS_CB_DRAWITEM drawItem;
00085 } NCS_CB_ITEMOPS;
00086
00091 #define NCSS_ITEMV_AUTOSORT (0x0002<<NCSS_SWGT_SHIFT)
00092
00097 #define NCSS_ITEMV_LOOP (0x0004<<NCSS_SWGT_SHIFT)
00098
00103 #define NCSS_ITEMV_SINGLE (0x0000<<NCSS_SWGT_SHIFT)
00104
00109 #define NCSS_ITEMV_MULTIPLE (0x0008<<NCSS_SWGT_SHIFT)
00110
00115 #define NCSS_ITEMV_SHIFT (NCSS_SWGT_SHIFT+4)
00116
00117 #define pItemList (self->itemList)
00118
00119 #define mItemViewHeader(className) \
00120 mScrollWidgetHeader(className) \
00121 NCS_CB_ITEMOPS itemOps; \
00122 mItemManager *itemList; \
00123 int defItemHeight;
00124
00140 struct _mItemView
00141 {
00142 mItemViewHeader(mItemView)
00143 };
00144
00145 #define mItemViewClassHeader(clsName, parentClass) \
00146 mScrollWidgetClassHeader(clsName, parentClass) \
00147 int (*onRButtonDown)(clsName*, int x, int y, DWORD keyFlags); \
00148 int (*onRButtonUp)(clsName*, int x, int y, DWORD keyFlags); \
00149 int (*onLButtonDBClk)(clsName*, int x, int y, DWORD keyFlags); \
00150 NCS_CB_DRAWITEM (*setItemDraw)(clsName*, NCS_CB_DRAWITEM func); \
00151 NCS_CB_INITITEM (*setItemInit)(clsName*, NCS_CB_INITITEM func); \
00152 NCS_CB_DSTRITEM (*setItemDestroy)(clsName*, \
00153 NCS_CB_DSTRITEM func); \
00154 \
00155 NCS_CB_CMPITEM (*setItemCmpFunc)(clsName*, NCS_CB_CMPITEM func); \
00156 HWND (*createItem)(clsName*, HITEM prev, HITEM next, int index, \
00157 int height, const char* text, DWORD addData, int *pos, BOOL adjust); \
00158 int (*insertItem)(clsName*, HITEM hItem, HITEM prev, HITEM next, \
00159 int index, int *pos); \
00160 int (*removeItem)(clsName*, HITEM hItem); \
00161 int (*inItem)(clsName*, int mouseX, int mouseY, HITEM *pRet, POINT *pt);\
00162 NCS_CB_CMPSTR (*setStrCmpFunc)(clsName*, NCS_CB_CMPSTR func); \
00163 NCS_CB_CMPSTR (*getStrCmpFunc)(clsName*); \
00164 void (*setAutoSortItem)(clsName*, BOOL sort); \
00165 int (*getTotalHeight)(clsName*); \
00166 int (*adjustItemsHeight)(clsName*, int diff); \
00167 void (*freeze)(clsName*, BOOL lock); \
00168 BOOL (*isFrozen)(clsName*); \
00169 list_t* (*getQueue)(clsName*); \
00170 HITEM (*getListEntry)(clsName*, list_t* entry); \
00171 HITEM (*getFirstItem)(clsName*); \
00172 int (*isEmpty)(clsName*); \
00173 void (*sortItems)(clsName*, NCS_CB_CMPITEM func); \
00174 BOOL (*removeAll)(clsName*); \
00175 int (*indexOf)(clsName*, HITEM hItem); \
00176 int (*setItemHeight)(clsName*, HITEM hItem, int height); \
00177 int (*getItemHeight)(clsName*, HITEM hItem); \
00178 HITEM (*getNext)(clsName*, HITEM hItem); \
00179 HITEM (*getPrev)(clsName*, HITEM hItem); \
00180 HITEM (*getItem)(clsName*, int index); \
00181 BOOL (*isSelected)(clsName*, HITEM hItem); \
00182 BOOL (*isEnabled)(clsName*, HITEM hItem); \
00183 BOOL (*enable)(clsName*, HITEM hItem, BOOL enable); \
00184 void (*selectAll)(clsName*); \
00185 void (*deselectAll)(clsName*); \
00186 int (*hilight)(clsName*, HITEM hItem); \
00187 HITEM (*getHilight)(clsName*); \
00188 BOOL (*isHilight)(clsName*, HITEM hItem); \
00189 int (*getItemCount)(clsName*); \
00190 DWORD (*getAddData)(clsName*, HITEM hItem); \
00191 void (*setAddData)(clsName*, HITEM hItem, DWORD addData); \
00192 void (*setImage)(clsName*, HITEM hItem, DWORD image); \
00193 DWORD (*getImage)(clsName*, HITEM hItem); \
00194 void (*setFlags)(clsName*, HITEM hItem, DWORD flags); \
00195 DWORD (*getFlags)(clsName*, HITEM hItem); \
00196 BOOL (*setText)(clsName*, HITEM hItem, const char* text); \
00197 const char* (*getText)(clsName*, HITEM hItem); \
00198 int (*getTextLen)(clsName*, HITEM hItem); \
00199 int (*getSelectionCount)(clsName*); \
00200 BOOL (*getSelection)(clsName*, HITEM *pRet, int count); \
00201 \
00202 BOOL (*select)(clsName*, HITEM hItem); \
00203 BOOL (*deselect)(clsName*, HITEM hItem); \
00204 BOOL (*setTextByIdx)(clsName*, int index, const char* text); \
00205 const char* (*getTextByIdx)(clsName*, int index); \
00206 \
00207 int (*getFirstVisItem)(clsName*); \
00208 void (*resetContent)(clsName*); \
00209 int (*getRect)(clsName*, HITEM hItem, RECT *rcItem, BOOL bConv); \
00210 int (*getCurSel)(clsName*); \
00211 int (*setCurSel)(clsName*, int newSel); \
00212 void (*refreshItem)(clsName*, HITEM hItem, const RECT *rcInv); \
00213 BOOL (*showItemByIdx)(clsName*, int index); \
00214 BOOL (*showItem)(clsName*, HITEM hItem);
00215
00503 struct _mItemViewClass
00504 {
00505 mItemViewClassHeader(mItemView, mScrollWidget)
00506 };
00507
00508 #define mItemViewRendererHeader(clsName, parentClass) \
00509 mScrollWidgetRendererHeader(clsName, parentClass)
00510
00516 struct _mItemViewRenderer {
00517 mItemViewRendererHeader(mItemView, mScrollWidget)
00518 };
00519
00526 MGNCS_EXPORT extern mItemViewClass g_stmItemViewCls;
00527
00532 enum mItemViewProp
00533 {
00537 NCSP_ITEMV_DEFITEMHEIGHT = NCSP_SWGT_MAX + 1,
00538
00542 NCSP_ITEMV_ITEMCOUNT,
00546 NCSP_ITEMV_MAX,
00547 };
00548
00553 enum mItemViewNotify {
00557 NCSN_ITEMV_CLICKED = NCSN_WIDGET_CLICKED,
00558
00562 NCSN_ITEMV_SELCHANGING = NCSN_SWGT_MAX + 1,
00563
00567 NCSN_ITEMV_SELCHANGED,
00568
00572 NCSN_ITEMV_ENTER,
00573
00577 NCSN_ITEMV_SETFOCUS,
00578
00582 NCSN_ITEMV_KILLFOCUS,
00583
00587 NCSN_ITEMV_MAX
00588 };
00589
00591 #ifdef __cplusplus
00592 }
00593 #endif
00594
00595 #endif