summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin10/lib/mir_core.libbin328368 -> 328512 bytes
-rw-r--r--bin10/lib/mir_core64.libbin330114 -> 330264 bytes
-rw-r--r--bin12/lib/mir_core.libbin328368 -> 328512 bytes
-rw-r--r--bin12/lib/mir_core64.libbin330114 -> 330264 bytes
-rw-r--r--include/m_gui.h512
-rw-r--r--src/mir_core/src/mir_core.def10
-rw-r--r--src/mir_core/src/mir_core64.def10
-rw-r--r--src/mir_core/src/ui_utils.cpp268
-rw-r--r--src/modules/clist/contacts.cpp108
-rw-r--r--src/modules/clist/genmenuopt.cpp89
-rw-r--r--src/modules/clist/protocolorder.cpp39
11 files changed, 525 insertions, 511 deletions
diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib
index 4ebfa5430c..5c42c3fcea 100644
--- a/bin10/lib/mir_core.lib
+++ b/bin10/lib/mir_core.lib
Binary files differ
diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib
index aaf5ce9a5a..076048fe5f 100644
--- a/bin10/lib/mir_core64.lib
+++ b/bin10/lib/mir_core64.lib
Binary files differ
diff --git a/bin12/lib/mir_core.lib b/bin12/lib/mir_core.lib
index 7f9f517ba9..bef3f2344e 100644
--- a/bin12/lib/mir_core.lib
+++ b/bin12/lib/mir_core.lib
Binary files differ
diff --git a/bin12/lib/mir_core64.lib b/bin12/lib/mir_core64.lib
index dd54fe16c3..01adcae79d 100644
--- a/bin12/lib/mir_core64.lib
+++ b/bin12/lib/mir_core64.lib
Binary files differ
diff --git a/include/m_gui.h b/include/m_gui.h
index 5b52c95840..c850d8c18b 100644
--- a/include/m_gui.h
+++ b/include/m_gui.h
@@ -338,11 +338,14 @@ public:
__forceinline HWND GetHwnd() const { return m_hwnd; }
__forceinline int GetCtrlId() const { return m_idCtrl; }
__forceinline CDlgBase *GetParent() { return m_parentWnd; }
+ __forceinline bool IsChanged() const { return m_bChanged; }
void Enable(int bIsEnable = true);
__forceinline void Disable() { Enable(false); }
BOOL Enabled(void) const;
+ void NotifyChange();
+
LRESULT SendMsg(UINT Msg, WPARAM wParam, LPARAM lParam);
void SetText(const TCHAR *text);
@@ -367,8 +370,10 @@ public:
virtual void OnInit();
virtual void OnDestroy();
- virtual void OnApply() {}
- virtual void OnReset() {}
+ virtual void OnApply();
+ virtual void OnReset();
+
+ CCallback<CCtrlBase> OnChange;
static int cmp(const CCtrlBase *c1, const CCtrlBase *c2)
{
@@ -382,6 +387,7 @@ protected:
int m_idCtrl;
CCtrlBase* m_next;
CDlgBase* m_parentWnd;
+ bool m_bChanged;
virtual LRESULT CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam);
void Subclass();
@@ -447,52 +453,52 @@ class MIR_CORE_EXPORT CCtrlClc : public CCtrlBase
public:
CCtrlClc(CDlgBase *dlg, int ctrlId);
- void AddContact(MCONTACT hContact);
- void AddGroup(HANDLE hGroup);
- void AutoRebuild();
- void DeleteItem(HANDLE hItem);
- void EditLabel(HANDLE hItem);
- void EndEditLabel(bool save);
- void EnsureVisible(HANDLE hItem, bool partialOk);
- void Expand(HANDLE hItem, DWORD flags);
- HANDLE FindContact(MCONTACT hContact);
- HANDLE FindGroup(HANDLE hGroup);
- COLORREF GetBkColor();
- bool GetCheck(HANDLE hItem);
- int GetCount();
- HWND GetEditControl();
- DWORD GetExpand(HANDLE hItem);
- int GetExtraColumns();
- BYTE GetExtraImage(HANDLE hItem, int iColumn);
+ void AddContact(MCONTACT hContact);
+ void AddGroup(HANDLE hGroup);
+ void AutoRebuild();
+ void DeleteItem(HANDLE hItem);
+ void EditLabel(HANDLE hItem);
+ void EndEditLabel(bool save);
+ void EnsureVisible(HANDLE hItem, bool partialOk);
+ void Expand(HANDLE hItem, DWORD flags);
+ HANDLE FindContact(MCONTACT hContact);
+ HANDLE FindGroup(HANDLE hGroup);
+ COLORREF GetBkColor();
+ bool GetCheck(HANDLE hItem);
+ int GetCount();
+ HWND GetEditControl();
+ DWORD GetExpand(HANDLE hItem);
+ int GetExtraColumns();
+ BYTE GetExtraImage(HANDLE hItem, int iColumn);
HIMAGELIST GetExtraImageList();
- HFONT GetFont(int iFontId);
- HANDLE GetSelection();
- HANDLE HitTest(int x, int y, DWORD *hitTest);
- void SelectItem(HANDLE hItem);
- void SetBkBitmap(DWORD mode, HBITMAP hBitmap);
- void SetBkColor(COLORREF clBack);
- void SetCheck(HANDLE hItem, bool check);
- void SetExtraColumns(int iColumns);
- void SetExtraImage(HANDLE hItem, int iColumn, int iImage);
- void SetExtraImageList(HIMAGELIST hImgList);
- void SetFont(int iFontId, HANDLE hFont, bool bRedraw);
- void SetIndent(int iIndent);
- void SetItemText(HANDLE hItem, char *szText);
- void SetHideEmptyGroups(bool state);
- void SetGreyoutFlags(DWORD flags);
- bool GetHideOfflineRoot();
- void SetHideOfflineRoot(bool state);
- void SetUseGroups(bool state);
- void SetOfflineModes(DWORD modes);
- DWORD GetExStyle();
- void SetExStyle(DWORD exStyle);
- int GetLefrMargin();
- void SetLeftMargin(int iMargin);
- HANDLE AddInfoItem(CLCINFOITEM *cii);
- int GetItemType(HANDLE hItem);
- HANDLE GetNextItem(HANDLE hItem, DWORD flags);
- COLORREF GetTextColot(int iFontId);
- void SetTextColor(int iFontId, COLORREF clText);
+ HFONT GetFont(int iFontId);
+ HANDLE GetSelection();
+ HANDLE HitTest(int x, int y, DWORD *hitTest);
+ void SelectItem(HANDLE hItem);
+ void SetBkBitmap(DWORD mode, HBITMAP hBitmap);
+ void SetBkColor(COLORREF clBack);
+ void SetCheck(HANDLE hItem, bool check);
+ void SetExtraColumns(int iColumns);
+ void SetExtraImage(HANDLE hItem, int iColumn, int iImage);
+ void SetExtraImageList(HIMAGELIST hImgList);
+ void SetFont(int iFontId, HANDLE hFont, bool bRedraw);
+ void SetIndent(int iIndent);
+ void SetItemText(HANDLE hItem, char *szText);
+ void SetHideEmptyGroups(bool state);
+ void SetGreyoutFlags(DWORD flags);
+ bool GetHideOfflineRoot();
+ void SetHideOfflineRoot(bool state);
+ void SetUseGroups(bool state);
+ void SetOfflineModes(DWORD modes);
+ DWORD GetExStyle();
+ void SetExStyle(DWORD exStyle);
+ int GetLefrMargin();
+ void SetLeftMargin(int iMargin);
+ HANDLE AddInfoItem(CLCINFOITEM *cii);
+ int GetItemType(HANDLE hItem);
+ HANDLE GetNextItem(HANDLE hItem, DWORD flags);
+ COLORREF GetTextColor(int iFontId);
+ void SetTextColor(int iFontId, COLORREF clText);
struct TEventInfo
{
@@ -514,7 +520,7 @@ public:
CCallback<TEventInfo> OnClick;
protected:
- BOOL OnNotify(int idCtrl, NMHDR *pnmh);
+ virtual BOOL OnNotify(int idCtrl, NMHDR *pnmh);
};
/////////////////////////////////////////////////////////////////////////////////////////
@@ -526,13 +532,7 @@ class MIR_CORE_EXPORT CCtrlData : public CCtrlBase
public:
CCtrlData(CDlgBase *dlg, int ctrlId);
-
- virtual ~CCtrlData()
- {
- if (m_dbLink) delete m_dbLink;
- }
-
- __inline bool IsChanged() const { return m_changed; }
+ virtual ~CCtrlData();
void CreateDbLink(const char* szModuleName, const char* szSetting, BYTE type, DWORD iValue);
void CreateDbLink(const char* szModuleName, const char* szSetting, TCHAR* szValue);
@@ -540,14 +540,8 @@ public:
virtual void OnInit();
- // Events
- CCallback<CCtrlData> OnChange;
-
protected:
CDataLink *m_dbLink;
- bool m_changed;
-
- void NotifyChange();
__inline BYTE GetDataType() { return m_dbLink ? m_dbLink->GetDataType() : DBVT_DELETED; }
__inline DWORD LoadInt() { return m_dbLink ? m_dbLink->LoadInt() : 0; }
@@ -565,20 +559,10 @@ class MIR_CORE_EXPORT CCtrlCheck : public CCtrlData
public:
CCtrlCheck(CDlgBase *dlg, int ctrlId);
- virtual BOOL OnCommand(HWND /*hwndCtrl*/, WORD /*idCtrl*/, WORD /*idCode*/) { NotifyChange(); return TRUE; }
- virtual void OnInit()
- {
- CSuper::OnInit();
- OnReset();
- }
- virtual void OnApply()
- {
- SaveInt(GetState());
- }
- virtual void OnReset()
- {
- SetState(LoadInt());
- }
+ virtual BOOL OnCommand(HWND /*hwndCtrl*/, WORD /*idCtrl*/, WORD /*idCode*/);
+
+ virtual void OnApply();
+ virtual void OnReset();
int GetState();
void SetState(int state);
@@ -593,38 +577,10 @@ class MIR_CORE_EXPORT CCtrlEdit : public CCtrlData
public:
CCtrlEdit(CDlgBase *dlg, int ctrlId);
- virtual BOOL OnCommand(HWND /*hwndCtrl*/, WORD /*idCtrl*/, WORD idCode)
- {
- if (idCode == EN_CHANGE)
- NotifyChange();
- return TRUE;
- }
- virtual void OnInit()
- {
- CSuper::OnInit();
- OnReset();
- }
- virtual void OnApply()
- {
- if (GetDataType() == DBVT_TCHAR)
- {
- int len = GetWindowTextLength(m_hwnd) + 1;
- TCHAR *buf = (TCHAR *)_alloca(sizeof(TCHAR) * len);
- GetWindowText(m_hwnd, buf, len);
- SaveText(buf);
- }
- else if (GetDataType() != DBVT_DELETED)
- {
- SaveInt(GetInt());
- }
- }
- virtual void OnReset()
- {
- if (GetDataType() == DBVT_TCHAR)
- SetText(LoadText());
- else if (GetDataType() != DBVT_DELETED)
- SetInt(LoadInt());
- }
+ virtual BOOL OnCommand(HWND /*hwndCtrl*/, WORD /*idCtrl*/, WORD idCode);
+
+ virtual void OnApply();
+ virtual void OnReset();
};
/////////////////////////////////////////////////////////////////////////////////////////
@@ -675,49 +631,10 @@ class MIR_CORE_EXPORT CCtrlCombo : public CCtrlData
public:
CCtrlCombo(CDlgBase *dlg, int ctrlId);
- virtual BOOL OnCommand(HWND /*hwndCtrl*/, WORD /*idCtrl*/, WORD idCode)
- {
- switch (idCode)
- {
- case CBN_CLOSEUP: OnCloseup(this); break;
- case CBN_DROPDOWN: OnDropdown(this); break;
-
- case CBN_EDITCHANGE:
- case CBN_EDITUPDATE:
- case CBN_SELCHANGE:
- case CBN_SELENDOK:
- NotifyChange();
- break;
- }
- return TRUE;
- }
-
- virtual void OnInit()
- {
- CSuper::OnInit();
- OnReset();
- }
- virtual void OnApply()
- {
- if (GetDataType() == DBVT_TCHAR)
- {
- int len = GetWindowTextLength(m_hwnd) + 1;
- TCHAR *buf = (TCHAR *)_alloca(sizeof(TCHAR) * len);
- GetWindowText(m_hwnd, buf, len);
- SaveText(buf);
- }
- else if (GetDataType() != DBVT_DELETED)
- {
- SaveInt(GetInt());
- }
- }
- virtual void OnReset()
- {
- if (GetDataType() == DBVT_TCHAR)
- SetText(LoadText());
- else if (GetDataType() != DBVT_DELETED)
- SetInt(LoadInt());
- }
+ virtual BOOL OnCommand(HWND /*hwndCtrl*/, WORD /*idCtrl*/, WORD idCode);
+ virtual void OnInit();
+ virtual void OnApply();
+ virtual void OnReset();
// Control interface
int AddString(const TCHAR *text, LPARAM data = 0);
@@ -754,147 +671,136 @@ public:
CCtrlListView(CDlgBase *dlg, int ctrlId);
// Classic LV interface
- DWORD ApproximateViewRect(int cx, int cy, int iCount);
- void Arrange(UINT code);
- void CancelEditLabel();
+ DWORD ApproximateViewRect(int cx, int cy, int iCount);
+ void Arrange(UINT code);
+ void CancelEditLabel();
HIMAGELIST CreateDragImage(int iItem, LPPOINT lpptUpLeft);
- void DeleteAllItems();
- void DeleteColumn(int iCol);
- void DeleteItem(int iItem);
- HWND EditLabel(int iItem);
- int EnableGroupView(BOOL fEnable);
- BOOL EnsureVisible(int i, BOOL fPartialOK);
- int FindItem(int iStart, const LVFINDINFO *plvfi);
- COLORREF GetBkColor();
- void GetBkImage(LPLVBKIMAGE plvbki);
- UINT GetCallbackMask();
- BOOL GetCheckState(UINT iIndex);
- void GetColumn(int iCol, LPLVCOLUMN pcol);
- void GetColumnOrderArray(int iCount, int *lpiArray);
- int GetColumnWidth(int iCol);
- int GetCountPerPage();
- HWND GetEditControl();
- //void GetEmptyText(PWSTR pszText, UINT cchText);
- DWORD GetExtendedListViewStyle();
- INT GetFocusedGroup();
- //void GetFooterInfo(LVFOOTERINFO *plvfi);
- //void GetFooterItem(UINT iItem, LVFOOTERITEM *pfi);
- //void GetFooterItemRect(UINT iItem, RECT *prc);
- //void GetFooterRect(RECT *prc);
- int GetGroupCount();
- //HIMAGELIST GetGroupHeaderImageList();
- void GetGroupInfo(int iGroupId, PLVGROUP pgrp);
- void GetGroupInfoByIndex(int iIndex, PLVGROUP pgrp);
- void GetGroupMetrics(LVGROUPMETRICS *pGroupMetrics);
- //BOOL GetGroupRect(int iGroupId, RECT *prc);
- UINT GetGroupState(UINT dwGroupId, UINT dwMask);
- HWND GetHeader();
- HCURSOR GetHotCursor();
- INT GetHotItem();
- DWORD GetHoverTime();
+ void DeleteAllItems();
+ void DeleteColumn(int iCol);
+ void DeleteItem(int iItem);
+ HWND EditLabel(int iItem);
+ int EnableGroupView(BOOL fEnable);
+ BOOL EnsureVisible(int i, BOOL fPartialOK);
+ int FindItem(int iStart, const LVFINDINFO *plvfi);
+ COLORREF GetBkColor();
+ void GetBkImage(LPLVBKIMAGE plvbki);
+ UINT GetCallbackMask();
+ BOOL GetCheckState(UINT iIndex);
+ void GetColumn(int iCol, LPLVCOLUMN pcol);
+ void GetColumnOrderArray(int iCount, int *lpiArray);
+ int GetColumnWidth(int iCol);
+ int GetCountPerPage();
+ HWND GetEditControl();
+ DWORD GetExtendedListViewStyle();
+ INT GetFocusedGroup();
+ int GetGroupCount();
+ void GetGroupInfo(int iGroupId, PLVGROUP pgrp);
+ void GetGroupInfoByIndex(int iIndex, PLVGROUP pgrp);
+ void GetGroupMetrics(LVGROUPMETRICS *pGroupMetrics);
+ UINT GetGroupState(UINT dwGroupId, UINT dwMask);
+ HWND GetHeader();
+ HCURSOR GetHotCursor();
+ INT GetHotItem();
+ DWORD GetHoverTime();
HIMAGELIST GetImageList(int iImageList);
- BOOL GetInsertMark(LVINSERTMARK *plvim);
- COLORREF GetInsertMarkColor();
- int GetInsertMarkRect(LPRECT prc);
- BOOL GetISearchString(LPSTR lpsz);
- void GetItem(LPLVITEM pitem);
- int GetItemCount();
- //void GetItemIndexRect(LVITEMINDEX *plvii, LONG iSubItem, LONG code, LPRECT prc);
- void GetItemPosition(int i, POINT *ppt);
- void GetItemRect(int i, RECT *prc, int code);
- DWORD GetItemSpacing(BOOL fSmall);
- UINT GetItemState(int i, UINT mask);
- void GetItemText(int iItem, int iSubItem, LPTSTR pszText, int cchTextMax);
- int GetNextItem(int iStart, UINT flags);
- //BOOL GetNextItemIndex(LVITEMINDEX *plvii, LPARAM flags);
- BOOL GetNumberOfWorkAreas(LPUINT lpuWorkAreas);
- BOOL GetOrigin(LPPOINT lpptOrg);
- COLORREF GetOutlineColor();
- UINT GetSelectedColumn();
- UINT GetSelectedCount();
- INT GetSelectionMark();
- int GetStringWidth(LPCSTR psz);
- BOOL GetSubItemRect(int iItem, int iSubItem, int code, LPRECT lpRect);
- COLORREF GetTextBkColor();
- COLORREF GetTextColor();
- void GetTileInfo(PLVTILEINFO plvtinfo);
- void GetTileViewInfo(PLVTILEVIEWINFO plvtvinfo);
- HWND GetToolTips();
- int GetTopIndex();
- BOOL GetUnicodeFormat();
- DWORD GetView();
- BOOL GetViewRect(RECT *prc);
- void GetWorkAreas(INT nWorkAreas, LPRECT lprc);
- BOOL HasGroup(int dwGroupId);
- int HitTest(LPLVHITTESTINFO pinfo);
- int HitTestEx(LPLVHITTESTINFO pinfo);
- int InsertColumn(int iCol, const LPLVCOLUMN pcol);
- int InsertGroup(int index, PLVGROUP pgrp);
- void InsertGroupSorted(PLVINSERTGROUPSORTED structInsert);
- int InsertItem(const LPLVITEM pitem);
- BOOL InsertMarkHitTest(LPPOINT point, LVINSERTMARK *plvim);
- BOOL IsGroupViewEnabled();
- UINT IsItemVisible(UINT index);
- UINT MapIDToIndex(UINT id);
- UINT MapIndexToID(UINT index);
- BOOL RedrawItems(int iFirst, int iLast);
- void RemoveAllGroups();
- int RemoveGroup(int iGroupId);
- BOOL Scroll(int dx, int dy);
- BOOL SetBkColor(COLORREF clrBk);
- BOOL SetBkImage(LPLVBKIMAGE plvbki);
- BOOL SetCallbackMask(UINT mask);
- void SetCheckState(UINT iIndex, BOOL fCheck);
- BOOL SetColumn(int iCol, LPLVCOLUMN pcol);
- BOOL SetColumnOrderArray(int iCount, int *lpiArray);
- BOOL SetColumnWidth(int iCol, int cx);
- void SetExtendedListViewStyle(DWORD dwExStyle);
- void SetExtendedListViewStyleEx(DWORD dwExMask, DWORD dwExStyle);
- //HIMAGELIST SetGroupHeaderImageList(HIMAGELIST himl);
- int SetGroupInfo(int iGroupId, PLVGROUP pgrp);
- void SetGroupMetrics(PLVGROUPMETRICS pGroupMetrics);
- void SetGroupState(UINT dwGroupId, UINT dwMask, UINT dwState);
- HCURSOR SetHotCursor(HCURSOR hCursor);
- INT SetHotItem(INT iIndex);
- void SetHoverTime(DWORD dwHoverTime);
- DWORD SetIconSpacing(int cx, int cy);
+ BOOL GetInsertMark(LVINSERTMARK *plvim);
+ COLORREF GetInsertMarkColor();
+ int GetInsertMarkRect(LPRECT prc);
+ BOOL GetISearchString(LPSTR lpsz);
+ void GetItem(LPLVITEM pitem);
+ int GetItemCount();
+ void GetItemPosition(int i, POINT *ppt);
+ void GetItemRect(int i, RECT *prc, int code);
+ DWORD GetItemSpacing(BOOL fSmall);
+ UINT GetItemState(int i, UINT mask);
+ void GetItemText(int iItem, int iSubItem, LPTSTR pszText, int cchTextMax);
+ int GetNextItem(int iStart, UINT flags);
+ BOOL GetNumberOfWorkAreas(LPUINT lpuWorkAreas);
+ BOOL GetOrigin(LPPOINT lpptOrg);
+ COLORREF GetOutlineColor();
+ UINT GetSelectedColumn();
+ UINT GetSelectedCount();
+ INT GetSelectionMark();
+ int GetStringWidth(LPCSTR psz);
+ BOOL GetSubItemRect(int iItem, int iSubItem, int code, LPRECT lpRect);
+ COLORREF GetTextBkColor();
+ COLORREF GetTextColor();
+ void GetTileInfo(PLVTILEINFO plvtinfo);
+ void GetTileViewInfo(PLVTILEVIEWINFO plvtvinfo);
+ HWND GetToolTips();
+ int GetTopIndex();
+ BOOL GetUnicodeFormat();
+ DWORD GetView();
+ BOOL GetViewRect(RECT *prc);
+ void GetWorkAreas(INT nWorkAreas, LPRECT lprc);
+ BOOL HasGroup(int dwGroupId);
+ int HitTest(LPLVHITTESTINFO pinfo);
+ int HitTestEx(LPLVHITTESTINFO pinfo);
+ int InsertColumn(int iCol, const LPLVCOLUMN pcol);
+ int InsertGroup(int index, PLVGROUP pgrp);
+ void InsertGroupSorted(PLVINSERTGROUPSORTED structInsert);
+ int InsertItem(const LPLVITEM pitem);
+ BOOL InsertMarkHitTest(LPPOINT point, LVINSERTMARK *plvim);
+ BOOL IsGroupViewEnabled();
+ UINT IsItemVisible(UINT index);
+ UINT MapIDToIndex(UINT id);
+ UINT MapIndexToID(UINT index);
+ BOOL RedrawItems(int iFirst, int iLast);
+ void RemoveAllGroups();
+ int RemoveGroup(int iGroupId);
+ BOOL Scroll(int dx, int dy);
+ BOOL SetBkColor(COLORREF clrBk);
+ BOOL SetBkImage(LPLVBKIMAGE plvbki);
+ BOOL SetCallbackMask(UINT mask);
+ void SetCheckState(UINT iIndex, BOOL fCheck);
+ BOOL SetColumn(int iCol, LPLVCOLUMN pcol);
+ BOOL SetColumnOrderArray(int iCount, int *lpiArray);
+ BOOL SetColumnWidth(int iCol, int cx);
+ void SetExtendedListViewStyle(DWORD dwExStyle);
+ void SetExtendedListViewStyleEx(DWORD dwExMask, DWORD dwExStyle);
+ int SetGroupInfo(int iGroupId, PLVGROUP pgrp);
+ void SetGroupMetrics(PLVGROUPMETRICS pGroupMetrics);
+ void SetGroupState(UINT dwGroupId, UINT dwMask, UINT dwState);
+ HCURSOR SetHotCursor(HCURSOR hCursor);
+ INT SetHotItem(INT iIndex);
+ void SetHoverTime(DWORD dwHoverTime);
+ DWORD SetIconSpacing(int cx, int cy);
HIMAGELIST SetImageList(HIMAGELIST himl, int iImageList);
- BOOL SetInfoTip(PLVSETINFOTIP plvSetInfoTip);
- BOOL SetInsertMark(LVINSERTMARK *plvim);
- COLORREF SetInsertMarkColor(COLORREF color);
- BOOL SetItem(const LPLVITEM pitem);
- void SetItemCount(int cItems);
- void SetItemCountEx(int cItems, DWORD dwFlags);
- //HRESULT SetItemIndexState(LVITEMINDEX *plvii, UINT data, UINT mask);
- BOOL SetItemPosition(int i, int x, int y);
- void SetItemPosition32(int iItem, int x, int y);
- void SetItemState(int i, UINT state, UINT mask);
- void SetItemText(int i, int iSubItem, TCHAR *pszText);
- COLORREF SetOutlineColor(COLORREF color);
- void SetSelectedColumn(int iCol);
- INT SetSelectionMark(INT iIndex);
- BOOL SetTextBkColor(COLORREF clrText);
- BOOL SetTextColor(COLORREF clrText);
- BOOL SetTileInfo(PLVTILEINFO plvtinfo);
- BOOL SetTileViewInfo(PLVTILEVIEWINFO plvtvinfo);
- HWND SetToolTips(HWND ToolTip);
- BOOL SetUnicodeFormat(BOOL fUnicode);
- int SetView(DWORD iView);
- void SetWorkAreas(INT nWorkAreas, LPRECT lprc);
- int SortGroups(PFNLVGROUPCOMPARE pfnGroupCompare, LPVOID plv);
- BOOL SortItems(PFNLVCOMPARE pfnCompare, LPARAM lParamSort);
- BOOL SortItemsEx(PFNLVCOMPARE pfnCompare, LPARAM lParamSort);
- INT SubItemHitTest(LPLVHITTESTINFO pInfo);
- INT SubItemHitTestEx(LPLVHITTESTINFO plvhti);
- BOOL Update(int iItem);
+ BOOL SetInfoTip(PLVSETINFOTIP plvSetInfoTip);
+ BOOL SetInsertMark(LVINSERTMARK *plvim);
+ COLORREF SetInsertMarkColor(COLORREF color);
+ BOOL SetItem(const LPLVITEM pitem);
+ void SetItemCount(int cItems);
+ void SetItemCountEx(int cItems, DWORD dwFlags);
+ BOOL SetItemPosition(int i, int x, int y);
+ void SetItemPosition32(int iItem, int x, int y);
+ void SetItemState(int i, UINT state, UINT mask);
+ void SetItemText(int i, int iSubItem, TCHAR *pszText);
+ COLORREF SetOutlineColor(COLORREF color);
+ void SetSelectedColumn(int iCol);
+ INT SetSelectionMark(INT iIndex);
+ BOOL SetTextBkColor(COLORREF clrText);
+ BOOL SetTextColor(COLORREF clrText);
+ BOOL SetTileInfo(PLVTILEINFO plvtinfo);
+ BOOL SetTileViewInfo(PLVTILEVIEWINFO plvtvinfo);
+ HWND SetToolTips(HWND ToolTip);
+ BOOL SetUnicodeFormat(BOOL fUnicode);
+ int SetView(DWORD iView);
+ void SetWorkAreas(INT nWorkAreas, LPRECT lprc);
+ int SortGroups(PFNLVGROUPCOMPARE pfnGroupCompare, LPVOID plv);
+ BOOL SortItems(PFNLVCOMPARE pfnCompare, LPARAM lParamSort);
+ BOOL SortItemsEx(PFNLVCOMPARE pfnCompare, LPARAM lParamSort);
+ INT SubItemHitTest(LPLVHITTESTINFO pInfo);
+ INT SubItemHitTestEx(LPLVHITTESTINFO plvhti);
+ BOOL Update(int iItem);
// Additional APIs
HIMAGELIST CreateImageList(int iImageList);
- void AddColumn(int iSubItem, TCHAR *name, int cx);
- void AddGroup(int iGroupId, TCHAR *name);
- int AddItem(TCHAR *text, int iIcon, LPARAM lParam = 0, int iGroupId = -1);
- void SetItem(int iItem, int iSubItem, TCHAR *text, int iIcon = -1);
- LPARAM GetItemData(int iItem);
+ void AddColumn(int iSubItem, TCHAR *name, int cx);
+ void AddGroup(int iGroupId, TCHAR *name);
+ int AddItem(TCHAR *text, int iIcon, LPARAM lParam = 0, int iGroupId = -1);
+ void SetItem(int iItem, int iSubItem, TCHAR *text, int iIcon = -1);
+ LPARAM GetItemData(int iItem);
// Events
struct TEventInfo {
@@ -916,15 +822,12 @@ public:
CCallback<TEventInfo> OnBeginRDrag;
CCallback<TEventInfo> OnBeginScroll;
CCallback<TEventInfo> OnColumnClick;
- //CCallback<TEventInfo> OnColumnDropdown;
- //CCallback<TEventInfo> OnColumnOverflowClick;
CCallback<TEventInfo> OnDeleteAllItems;
CCallback<TEventInfo> OnDeleteItem;
CCallback<TEventInfo> OnDoubleClick;
CCallback<TEventInfo> OnEndLabelEdit;
CCallback<TEventInfo> OnEndScroll;
CCallback<TEventInfo> OnGetDispInfo;
- //CCallback<TEventInfo> OnGetEmptyMarkup;
CCallback<TEventInfo> OnGetInfoTip;
CCallback<TEventInfo> OnHotTrack;
CCallback<TEventInfo> OnIncrementalSearch;
@@ -933,12 +836,11 @@ public:
CCallback<TEventInfo> OnItemChanged;
CCallback<TEventInfo> OnItemChanging;
CCallback<TEventInfo> OnKeyDown;
- //CCallback<TEventInfo> OnLinkClick;
CCallback<TEventInfo> OnMarqueeBegin;
CCallback<TEventInfo> OnSetDispInfo;
protected:
- BOOL OnNotify(int idCtrl, NMHDR *pnmh);
+ virtual BOOL OnNotify(int idCtrl, NMHDR *pnmh);
};
/////////////////////////////////////////////////////////////////////////////////////////
@@ -947,6 +849,9 @@ protected:
#undef GetNextSibling
#undef GetPrevSibling
+#define MTREE_CHECKBOX 0x0001
+#define MTREE_DND 0x0002
+
class MIR_CORE_EXPORT CCtrlTreeView : public CCtrlBase
{
typedef CCtrlBase CSuper;
@@ -954,6 +859,8 @@ class MIR_CORE_EXPORT CCtrlTreeView : public CCtrlBase
public:
CCtrlTreeView(CDlgBase *dlg, int ctrlId);
+ void SetFlags(uint32_t dwFlags); // MTREE_* combination
+
// Classic TV interface
HIMAGELIST CreateDragImage(HTREEITEM hItem);
void DeleteAllItems();
@@ -1020,16 +927,17 @@ public:
HTREEITEM FindNamedItem(HTREEITEM hItem, const TCHAR *name);
void GetItem(HTREEITEM hItem, TVITEMEX *tvi);
void GetItem(HTREEITEM hItem, TVITEMEX *tvi, TCHAR *szText, int iTextLength);
+ void InvertCheck(HTREEITEM hItem);
// Events
struct TEventInfo {
CCtrlTreeView *treeviewctrl;
union {
- NMHDR *nmhdr;
- NMTREEVIEW *nmtv;
- NMTVDISPINFO *nmtvdi;
- NMTVGETINFOTIP *nmtvit;
- NMTVKEYDOWN *nmtvkey;
+ NMHDR *nmhdr;
+ NMTREEVIEW *nmtv;
+ NMTVKEYDOWN *nmtvkey;
+ NMTVDISPINFO *nmtvdi;
+ NMTVGETINFOTIP *nmtvit;
};
};
@@ -1049,7 +957,17 @@ public:
CCallback<TEventInfo> OnSingleExpand;
protected:
- BOOL OnNotify(int idCtrl, NMHDR *pnmh);
+ virtual BOOL OnNotify(int idCtrl, NMHDR *pnmh);
+
+ union {
+ uint32_t m_dwFlags;
+ struct {
+ bool m_bDndEnabled : 1;
+ bool m_bDragging : 1;
+ bool m_bCheckBox : 1;
+ };
+ };
+ HTREEITEM m_hDragItem; // valid if m_bDragging == true
};
/////////////////////////////////////////////////////////////////////////////////////////
@@ -1069,7 +987,7 @@ public:
protected:
- BOOL OnNotify(int idCtrl, NMHDR *pnmh);
+ virtual BOOL OnNotify(int idCtrl, NMHDR *pnmh);
void OnInit();
void OnDestroy();
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index 9234c6236a..4e55fce8cf 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -870,7 +870,7 @@ mir_wstrcmpi @280
?GetTextBkColor@CCtrlListView@@QAEKXZ @869 NONAME
?GetTextColor@CCtrlListView@@QAEKXZ @870 NONAME
?GetTextColor@CCtrlTreeView@@QAEKXZ @871 NONAME
-?GetTextColot@CCtrlClc@@QAEKH@Z @872 NONAME
+?GetTextColor@CCtrlClc@@QAEKH@Z @872 NONAME
?GetTileInfo@CCtrlListView@@QAEXPAUtagLVTILEINFO@@@Z @873 NONAME
?GetTileViewInfo@CCtrlListView@@QAEXPAUtagLVTILEVIEWINFO@@@Z @874 NONAME
?GetToolTips@CCtrlListView@@QAEPAUHWND__@@XZ @875 NONAME
@@ -897,7 +897,7 @@ mir_wstrcmpi @280
?InsertMarkHitTest@CCtrlListView@@QAEHPAUtagPOINT@@PAULVINSERTMARK@@@Z @896 NONAME
?InsertString@CCtrlCombo@@QAEHPA_WHJ@Z @897 NONAME
?InsertString@CCtrlListBox@@QAEHPA_WHJ@Z @898 NONAME
-?IsChanged@CCtrlData@@QBE_NXZ @899 NONAME
+?IsChanged@CCtrlBase@@QBE_NXZ @899 NONAME
?IsGroupViewEnabled@CCtrlListView@@QAEHXZ @900 NONAME
?IsInitialized@CDlgBase@@QBE_NXZ @901 NONAME
?LoadInt@CCtrlData@@IAEKXZ @902 NONAME
@@ -908,7 +908,7 @@ mir_wstrcmpi @280
?MakePush@CCtrlMButton@@QAEXXZ @907 NONAME
?MapIDToIndex@CCtrlListView@@QAEII@Z @908 NONAME
?MapIndexToID@CCtrlListView@@QAEII@Z @909 NONAME
-?NotifyChange@CCtrlData@@IAEXXZ @910 NONAME
+?NotifyChange@CCtrlBase@@QAEXXZ @910 NONAME
?NotifyControls@CDlgBase@@AAEXP8CCtrlBase@@AEXXZ@Z @911 NONAME
?OnApply@CCtrlBase@@UAEXXZ @912 NONAME
?OnApply@CCtrlCheck@@UAEXXZ @913 NONAME
@@ -930,10 +930,8 @@ mir_wstrcmpi @280
?OnDestroy@CDlgBase@@MAEXXZ @929 NONAME
?OnDrawItem@CCtrlBase@@UAEHPAUtagDRAWITEMSTRUCT@@@Z @930 NONAME
?OnInit@CCtrlBase@@UAEXXZ @931 NONAME
-?OnInit@CCtrlCheck@@UAEXXZ @932 NONAME
?OnInit@CCtrlCombo@@UAEXXZ @933 NONAME
?OnInit@CCtrlData@@UAEXXZ @934 NONAME
-?OnInit@CCtrlEdit@@UAEXXZ @935 NONAME
?OnInit@CCtrlMButton@@UAEXXZ @936 NONAME
?OnInit@CCtrlPages@@MAEXXZ @937 NONAME
?OnInitDialog@CDlgBase@@MAEXXZ @938 NONAME
@@ -1077,3 +1075,5 @@ Proto_RegisterModule @1074 NONAME
?Find@CDlgBase@@SAPAV1@PAUHWND__@@@Z @1076 NONAME
?SetCaption@CDlgBase@@QAEXPB_W@Z @1077 NONAME
?NotifyChange@CDlgBase@@QAEXXZ @1078 NONAME
+?InvertCheck@CCtrlTreeView@@QAEXPAU_TREEITEM@@@Z @1079 NONAME
+?SetFlags@CCtrlTreeView@@QAEXI@Z @1080 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index cea83c2f8a..6da78214f5 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -870,7 +870,7 @@ mir_wstrcmpi @280
?GetTextBkColor@CCtrlListView@@QEAAKXZ @869 NONAME
?GetTextColor@CCtrlListView@@QEAAKXZ @870 NONAME
?GetTextColor@CCtrlTreeView@@QEAAKXZ @871 NONAME
-?GetTextColot@CCtrlClc@@QEAAKH@Z @872 NONAME
+?GetTextColor@CCtrlClc@@QEAAKH@Z @872 NONAME
?GetTileInfo@CCtrlListView@@QEAAXPEAUtagLVTILEINFO@@@Z @873 NONAME
?GetTileViewInfo@CCtrlListView@@QEAAXPEAUtagLVTILEVIEWINFO@@@Z @874 NONAME
?GetToolTips@CCtrlListView@@QEAAPEAUHWND__@@XZ @875 NONAME
@@ -897,7 +897,7 @@ mir_wstrcmpi @280
?InsertMarkHitTest@CCtrlListView@@QEAAHPEAUtagPOINT@@PEAULVINSERTMARK@@@Z @896 NONAME
?InsertString@CCtrlCombo@@QEAAHPEA_WH_J@Z @897 NONAME
?InsertString@CCtrlListBox@@QEAAHPEA_WH_J@Z @898 NONAME
-?IsChanged@CCtrlData@@QEBA_NXZ @899 NONAME
+?IsChanged@CCtrlBase@@QEBA_NXZ @899 NONAME
?IsGroupViewEnabled@CCtrlListView@@QEAAHXZ @900 NONAME
?IsInitialized@CDlgBase@@QEBA_NXZ @901 NONAME
?LoadInt@CCtrlData@@IEAAKXZ @902 NONAME
@@ -908,7 +908,7 @@ mir_wstrcmpi @280
?MakePush@CCtrlMButton@@QEAAXXZ @907 NONAME
?MapIDToIndex@CCtrlListView@@QEAAII@Z @908 NONAME
?MapIndexToID@CCtrlListView@@QEAAII@Z @909 NONAME
-?NotifyChange@CCtrlData@@IEAAXXZ @910 NONAME
+?NotifyChange@CCtrlBase@@QEAAXXZ @910 NONAME
?NotifyControls@CDlgBase@@AEAAXP8CCtrlBase@@EAAXXZ@Z @911 NONAME
?OnApply@CCtrlBase@@UEAAXXZ @912 NONAME
?OnApply@CCtrlCheck@@UEAAXXZ @913 NONAME
@@ -930,10 +930,8 @@ mir_wstrcmpi @280
?OnDestroy@CDlgBase@@MEAAXXZ @929 NONAME
?OnDrawItem@CCtrlBase@@UEAAHPEAUtagDRAWITEMSTRUCT@@@Z @930 NONAME
?OnInit@CCtrlBase@@UEAAXXZ @931 NONAME
-?OnInit@CCtrlCheck@@UEAAXXZ @932 NONAME
?OnInit@CCtrlCombo@@UEAAXXZ @933 NONAME
?OnInit@CCtrlData@@UEAAXXZ @934 NONAME
-?OnInit@CCtrlEdit@@UEAAXXZ @935 NONAME
?OnInit@CCtrlMButton@@UEAAXXZ @936 NONAME
?OnInit@CCtrlPages@@MEAAXXZ @937 NONAME
?OnInitDialog@CDlgBase@@MEAAXXZ @938 NONAME
@@ -1077,3 +1075,5 @@ Proto_RegisterModule @1074 NONAME
?Find@CDlgBase@@SAPEAV1@PEAUHWND__@@@Z @1076 NONAME
?SetCaption@CDlgBase@@QEAAXPEB_W@Z @1077 NONAME
?NotifyChange@CDlgBase@@QEAAXXZ @1078 NONAME
+?InvertCheck@CCtrlTreeView@@QEAAXPEAU_TREEITEM@@@Z @1079 NONAME
+?SetFlags@CCtrlTreeView@@QEAAXI@Z @1080 NONAME
diff --git a/src/mir_core/src/ui_utils.cpp b/src/mir_core/src/ui_utils.cpp
index 8df0253782..700dd30f67 100644
--- a/src/mir_core/src/ui_utils.cpp
+++ b/src/mir_core/src/ui_utils.cpp
@@ -280,6 +280,51 @@ CCtrlCombo::CCtrlCombo(CDlgBase* dlg, int ctrlId) :
{
}
+BOOL CCtrlCombo::OnCommand(HWND, WORD, WORD idCode)
+{
+ switch (idCode) {
+ case CBN_CLOSEUP: OnCloseup(this); break;
+ case CBN_DROPDOWN: OnDropdown(this); break;
+
+ case CBN_EDITCHANGE:
+ case CBN_EDITUPDATE:
+ case CBN_SELCHANGE:
+ case CBN_SELENDOK:
+ NotifyChange();
+ break;
+ }
+ return TRUE;
+}
+
+void CCtrlCombo::OnInit()
+{
+ CSuper::OnInit();
+ OnReset();
+}
+
+void CCtrlCombo::OnApply()
+{
+ CSuper::OnApply();
+
+ if (GetDataType() == DBVT_TCHAR) {
+ int len = GetWindowTextLength(m_hwnd) + 1;
+ TCHAR *buf = (TCHAR *)_alloca(sizeof(TCHAR) * len);
+ GetWindowText(m_hwnd, buf, len);
+ SaveText(buf);
+ }
+ else if (GetDataType() != DBVT_DELETED) {
+ SaveInt(GetInt());
+ }
+}
+
+void CCtrlCombo::OnReset()
+{
+ if (GetDataType() == DBVT_TCHAR)
+ SetText(LoadText());
+ else if (GetDataType() != DBVT_DELETED)
+ SetInt(LoadInt());
+}
+
int CCtrlCombo::AddString(const TCHAR *text, LPARAM data)
{
int iItem = SendMessage(m_hwnd, CB_ADDSTRING, 0, (LPARAM)text);
@@ -484,14 +529,30 @@ CCtrlCheck::CCtrlCheck(CDlgBase* dlg, int ctrlId) :
{
}
-int CCtrlCheck::GetState()
+BOOL CCtrlCheck::OnCommand(HWND, WORD, WORD)
{
- return SendMessage(m_hwnd, BM_GETCHECK, 0, 0);
+ NotifyChange();
+ return TRUE;
}
-void CCtrlCheck::SetState(int state)
+void CCtrlCheck::OnApply()
{
- SendMessage(m_hwnd, BM_SETCHECK, state, 0);
+ CSuper::OnApply();
+
+ SaveInt(GetState());
+}
+
+void CCtrlCheck::OnReset()
+{
+ SetState(LoadInt());
+}
+
+int CCtrlCheck::GetState()
+{ return SendMessage(m_hwnd, BM_GETCHECK, 0, 0);
+}
+
+void CCtrlCheck::SetState(int state)
+{ SendMessage(m_hwnd, BM_SETCHECK, state, 0);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -502,31 +563,55 @@ CCtrlEdit::CCtrlEdit(CDlgBase* dlg, int ctrlId) :
{
}
+BOOL CCtrlEdit::OnCommand(HWND, WORD, WORD idCode)
+{
+ if (idCode == EN_CHANGE)
+ NotifyChange();
+ return TRUE;
+}
+
+void CCtrlEdit::OnApply()
+{
+ CSuper::OnApply();
+
+ if (GetDataType() == DBVT_TCHAR) {
+ int len = GetWindowTextLength(m_hwnd) + 1;
+ TCHAR *buf = (TCHAR *)_alloca(sizeof(TCHAR) * len);
+ GetWindowText(m_hwnd, buf, len);
+ SaveText(buf);
+ }
+ else if (GetDataType() != DBVT_DELETED) {
+ SaveInt(GetInt());
+ }
+}
+
+void CCtrlEdit::OnReset()
+{
+ if (GetDataType() == DBVT_TCHAR)
+ SetText(LoadText());
+ else if (GetDataType() != DBVT_DELETED)
+ SetInt(LoadInt());
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// CCtrlData class
CCtrlData::CCtrlData(CDlgBase *wnd, int idCtrl) :
CCtrlBase(wnd, idCtrl),
- m_dbLink(NULL),
- m_changed(false)
+ m_dbLink(NULL)
{
}
-void CCtrlData::OnInit()
+CCtrlData::~CCtrlData()
{
- CCtrlBase::OnInit();
+ if (m_dbLink)
+ delete m_dbLink;
}
-void CCtrlData::NotifyChange()
+void CCtrlData::OnInit()
{
- if (!m_parentWnd || m_parentWnd->IsInitialized()) m_changed = true;
- if (m_parentWnd) {
- m_parentWnd->OnChange(this);
- if (m_parentWnd->IsInitialized())
- ::SendMessage(::GetParent(m_parentWnd->GetHwnd()), PSM_CHANGED, 0, 0);
- }
-
- OnChange(this);
+ CCtrlBase::OnInit();
+ OnReset();
}
void CCtrlData::CreateDbLink(const char* szModuleName, const char* szSetting, BYTE type, DWORD iValue)
@@ -814,7 +899,7 @@ HANDLE CCtrlClc::GetNextItem(HANDLE hItem, DWORD flags)
{ return (HANDLE)SendMessage(m_hwnd, CLM_GETNEXTITEM, (WPARAM)flags, (LPARAM)hItem);
}
-COLORREF CCtrlClc::GetTextColot(int iFontId)
+COLORREF CCtrlClc::GetTextColor(int iFontId)
{ return (COLORREF)SendMessage(m_hwnd, CLM_GETTEXTCOLOR, (WPARAM)iFontId, 0);
}
@@ -1272,9 +1357,6 @@ BOOL CCtrlListView::SortItemsEx(PFNLVCOMPARE pfnCompare, LPARAM lParamSort)
INT CCtrlListView::SubItemHitTest(LPLVHITTESTINFO pInfo)
{ return ListView_SubItemHitTest(m_hwnd, pInfo);
}
-//INT CCtrlListView::SubItemHitTestEx(LPLVHITTESTINFO plvhti)
-//{ return ListView_SubItemHitTestEx(m_hwnd, plvhti);
-//}
BOOL CCtrlListView::Update(int iItem)
{ return ListView_Update(m_hwnd, iItem);
}
@@ -1283,8 +1365,21 @@ BOOL CCtrlListView::Update(int iItem)
// CCtrlTreeView
CCtrlTreeView::CCtrlTreeView(CDlgBase* dlg, int ctrlId):
- CCtrlBase(dlg, ctrlId)
+ CCtrlBase(dlg, ctrlId),
+ m_dwFlags(0)
+{
+}
+
+void CCtrlTreeView::SetFlags(uint32_t dwFlags)
{
+ if (dwFlags & MTREE_CHECKBOX)
+ m_bCheckBox = true;
+
+ if (dwFlags & MTREE_DND) {
+ m_bDndEnabled = true;
+ m_bDragging = false;
+ m_hDragItem = NULL;
+ }
}
BOOL CCtrlTreeView::OnNotify(int, NMHDR *pnmh)
@@ -1292,25 +1387,55 @@ BOOL CCtrlTreeView::OnNotify(int, NMHDR *pnmh)
TEventInfo evt = { this, pnmh };
switch (pnmh->code) {
- case TVN_BEGINDRAG: OnBeginDrag(&evt); return TRUE;
- case TVN_BEGINLABELEDIT: OnBeginLabelEdit(&evt); return TRUE;
- case TVN_BEGINRDRAG: OnBeginRDrag(&evt); return TRUE;
- case TVN_DELETEITEM: OnDeleteItem(&evt); return TRUE;
- case TVN_ENDLABELEDIT: OnEndLabelEdit(&evt); return TRUE;
- case TVN_GETDISPINFO: OnGetDispInfo(&evt); return TRUE;
- case TVN_GETINFOTIP: OnGetInfoTip(&evt); return TRUE;
- case TVN_ITEMEXPANDED: OnItemExpanded(&evt); return TRUE;
- case TVN_ITEMEXPANDING: OnItemExpanding(&evt); return TRUE;
- case TVN_KEYDOWN: OnKeyDown(&evt); return TRUE;
- case TVN_SELCHANGED: OnSelChanged(&evt); return TRUE;
- case TVN_SELCHANGING: OnSelChanging(&evt); return TRUE;
- case TVN_SETDISPINFO: OnSetDispInfo(&evt); return TRUE;
- case TVN_SINGLEEXPAND: OnSingleExpand(&evt); return TRUE;
+ case TVN_BEGINDRAG: OnBeginDrag(&evt); return TRUE;
+ case TVN_BEGINLABELEDIT: OnBeginLabelEdit(&evt); return TRUE;
+ case TVN_BEGINRDRAG: OnBeginRDrag(&evt); return TRUE;
+ case TVN_DELETEITEM: OnDeleteItem(&evt); return TRUE;
+ case TVN_ENDLABELEDIT: OnEndLabelEdit(&evt); return TRUE;
+ case TVN_GETDISPINFO: OnGetDispInfo(&evt); return TRUE;
+ case TVN_GETINFOTIP: OnGetInfoTip(&evt); return TRUE;
+ case TVN_ITEMEXPANDED: OnItemExpanded(&evt); return TRUE;
+ case TVN_ITEMEXPANDING: OnItemExpanding(&evt); return TRUE;
+ case TVN_SELCHANGED: OnSelChanged(&evt); return TRUE;
+ case TVN_SELCHANGING: OnSelChanging(&evt); return TRUE;
+ case TVN_SETDISPINFO: OnSetDispInfo(&evt); return TRUE;
+ case TVN_SINGLEEXPAND: OnSingleExpand(&evt); return TRUE;
+
+ case TVN_KEYDOWN:
+ if (m_bCheckBox && evt.nmtvkey->wVKey == VK_SPACE)
+ InvertCheck(GetSelection());
+
+ OnKeyDown(&evt);
+ return TRUE;
+ }
+
+ if (m_bCheckBox && pnmh->code == NM_CLICK) {
+ TVHITTESTINFO hti;
+ hti.pt.x = (short)LOWORD(GetMessagePos());
+ hti.pt.y = (short)HIWORD(GetMessagePos());
+ ScreenToClient(pnmh->hwndFrom, &hti.pt);
+ if (HitTest(&hti))
+ if (hti.flags & TVHT_ONITEMICON)
+ InvertCheck(hti.hItem);
}
return FALSE;
}
+void CCtrlTreeView::InvertCheck(HTREEITEM hItem)
+{
+ TVITEMEX tvi;
+ tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
+ tvi.hItem = hItem;
+ if (!GetItem(&tvi))
+ return;
+
+ tvi.iImage = tvi.iSelectedImage = !tvi.iImage;
+ SetItem(&tvi);
+
+ NotifyChange();
+}
+
void CCtrlTreeView::TranslateItem(HTREEITEM hItem)
{
TVITEMEX tvi;
@@ -1651,14 +1776,12 @@ void CCtrlPages::AddPage(TCHAR *ptszName, HICON hIcon, CCallback<void> onCreate,
info->m_param = param;
info->m_pDlg = NULL;
- TCITEM tci = {0};
- tci.mask = TCIF_PARAM|TCIF_TEXT;
+ TCITEM tci = { 0 };
+ tci.mask = TCIF_PARAM | TCIF_TEXT;
tci.lParam = (LPARAM)info;
tci.pszText = ptszName;
- if (hIcon)
- {
- if (!m_hIml)
- {
+ if (hIcon) {
+ if (!m_hIml) {
m_hIml = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 1);
TabCtrl_SetImageList(m_hwnd, m_hIml);
}
@@ -1675,7 +1798,7 @@ void CCtrlPages::AttachDialog(int iPage, CDlgBase *pDlg)
if ((iPage < 0) || (iPage >= TabCtrl_GetItemCount(m_hwnd)))
return;
- TCITEM tci = {0};
+ TCITEM tci = { 0 };
tci.mask = TCIF_PARAM;
TabCtrl_GetItem(m_hwnd, iPage, &tci);
@@ -1701,7 +1824,7 @@ void CCtrlPages::ShowPage(CDlgBase *pDlg)
GetClientRect(m_hwnd, &rc);
TabCtrl_AdjustRect(m_hwnd, FALSE, &rc);
MapWindowPoints(m_hwnd, ::GetParent(m_hwnd), (LPPOINT)&rc, 2);
- SetWindowPos(pDlg->GetHwnd(), HWND_TOP, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, SWP_SHOWWINDOW);
+ SetWindowPos(pDlg->GetHwnd(), HWND_TOP, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_SHOWWINDOW);
}
void CCtrlPages::ActivatePage(int iPage)
@@ -1715,7 +1838,7 @@ BOOL CCtrlPages::OnNotify(int /*idCtrl*/, NMHDR *pnmh)
switch (pnmh->code) {
case TCN_SELCHANGING:
{
- TCITEM tci = {0};
+ TCITEM tci = { 0 };
tci.mask = TCIF_PARAM;
TabCtrl_GetItem(m_hwnd, TabCtrl_GetCurSel(m_hwnd), &tci);
@@ -1730,7 +1853,7 @@ BOOL CCtrlPages::OnNotify(int /*idCtrl*/, NMHDR *pnmh)
case TCN_SELCHANGE:
{
- TCITEM tci = {0};
+ TCITEM tci = { 0 };
tci.mask = TCIF_PARAM;
TabCtrl_GetItem(m_hwnd, TabCtrl_GetCurSel(m_hwnd), &tci);
@@ -1754,8 +1877,8 @@ BOOL CCtrlPages::OnNotify(int /*idCtrl*/, NMHDR *pnmh)
void CCtrlPages::OnDestroy()
{
int count = TabCtrl_GetItemCount(m_hwnd);
- for (int i=0; i < count; i++) {
- TCITEM tci = {0};
+ for (int i = 0; i < count; i++) {
+ TCITEM tci = { 0 };
tci.mask = TCIF_PARAM;
TabCtrl_GetItem(m_hwnd, i, &tci);
@@ -1778,10 +1901,11 @@ void CCtrlPages::OnDestroy()
/////////////////////////////////////////////////////////////////////////////////////////
// CCtrlBase
-CCtrlBase::CCtrlBase(CDlgBase *wnd, int idCtrl) :
- m_parentWnd(wnd),
+CCtrlBase::CCtrlBase(CDlgBase *wnd, int idCtrl)
+ : m_parentWnd(wnd),
m_idCtrl(idCtrl),
- m_hwnd(NULL)
+ m_hwnd(NULL),
+ m_bChanged(false)
{
if (wnd) {
m_next = wnd->m_first;
@@ -1800,6 +1924,15 @@ void CCtrlBase::OnDestroy()
m_hwnd = NULL;
}
+void CCtrlBase::OnApply()
+{
+ m_bChanged = false;
+}
+
+void CCtrlBase::OnReset()
+{
+}
+
void CCtrlBase::Enable(int bIsEnable)
{
::EnableWindow(m_hwnd, bIsEnable);
@@ -1810,6 +1943,20 @@ BOOL CCtrlBase::Enabled() const
return (m_hwnd) ? IsWindowEnabled(m_hwnd) : FALSE;
}
+void CCtrlBase::NotifyChange()
+{
+ if (!m_parentWnd || m_parentWnd->IsInitialized())
+ m_bChanged = true;
+
+ if (m_parentWnd) {
+ m_parentWnd->OnChange(this);
+ if (m_parentWnd->IsInitialized())
+ ::SendMessage(::GetParent(m_parentWnd->GetHwnd()), PSM_CHANGED, 0, 0);
+ }
+
+ OnChange(this);
+}
+
LRESULT CCtrlBase::SendMsg(UINT Msg, WPARAM wParam, LPARAM lParam)
{
return ::SendMessage(m_hwnd, Msg, wParam, lParam);
@@ -1827,7 +1974,7 @@ void CCtrlBase::SetTextA(const char *text)
void CCtrlBase::SetInt(int value)
{
- TCHAR buf[32] = {0};
+ TCHAR buf[32] = { 0 };
mir_sntprintf(buf, SIZEOF(buf), _T("%d"), value);
SetWindowText(m_hwnd, buf);
}
@@ -1851,14 +1998,14 @@ char* CCtrlBase::GetTextA()
TCHAR* CCtrlBase::GetText(TCHAR *buf, int size)
{
GetWindowText(m_hwnd, buf, size);
- buf[size-1] = 0;
+ buf[size - 1] = 0;
return buf;
}
char* CCtrlBase::GetTextA(char *buf, int size)
{
GetWindowTextA(m_hwnd, buf, size);
- buf[size-1] = 0;
+ buf[size - 1] = 0;
return buf;
}
@@ -1897,7 +2044,7 @@ LRESULT CALLBACK CCtrlBase::GlobalSubclassWndProc(HWND hwnd, UINT msg, WPARAM wP
void CCtrlBase::Subclass()
{
mir_subclassWindow(m_hwnd, GlobalSubclassWndProc);
-
+
mir_cslock lck(csCtrl);
arControls.insert(this);
}
@@ -1978,12 +2125,13 @@ void CDbLink::SaveText(TCHAR *value)
/////////////////////////////////////////////////////////////////////////////////////////
// Base protocol dialog
-CProtoIntDlgBase::CProtoIntDlgBase(PROTO_INTERFACE *proto, int idDialog, bool show_label) :
- CDlgBase(::ProtoGetInstance(proto->m_szModuleName), idDialog),
+CProtoIntDlgBase::CProtoIntDlgBase(PROTO_INTERFACE *proto, int idDialog, bool show_label)
+ : CDlgBase(::ProtoGetInstance(proto->m_szModuleName), idDialog),
m_proto_interface(proto),
m_show_label(show_label),
m_hwndStatus(NULL)
-{}
+{
+}
void CProtoIntDlgBase::CreateLink(CCtrlData& ctrl, char *szSetting, BYTE type, DWORD iValue)
{
@@ -2041,7 +2189,7 @@ INT_PTR CProtoIntDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
if (m_hwndStatus) {
RECT rcStatus; GetWindowRect(m_hwndStatus, &rcStatus);
RECT rcClient; GetClientRect(m_hwnd, &rcClient);
- SetWindowPos(m_hwndStatus, NULL, 0, rcClient.bottom-(rcStatus.bottom-rcStatus.top), rcClient.right, (rcStatus.bottom-rcStatus.top), SWP_NOZORDER);
+ SetWindowPos(m_hwndStatus, NULL, 0, rcClient.bottom - (rcStatus.bottom - rcStatus.top), rcClient.right, (rcStatus.bottom - rcStatus.top), SWP_NOZORDER);
UpdateStatusBar();
}
break;
@@ -2103,7 +2251,7 @@ void CProtoIntDlgBase::UpdateStatusBar()
ReleaseDC(m_hwndStatus, hdc);
RECT rcStatus; GetWindowRect(m_hwndStatus, &rcStatus);
- int parts[] = { rcStatus.right-rcStatus.left - sz.cx, -1 };
+ int parts[] = { rcStatus.right - rcStatus.left - sz.cx, -1 };
SendMessage(m_hwndStatus, SB_SETPARTS, 2, (LPARAM)parts);
SendMessage(m_hwndStatus, SB_SETICON, 1, (LPARAM)LoadSkinnedProtoIcon(m_proto_interface->m_szModuleName, m_proto_interface->m_iStatus));
SendMessage(m_hwndStatus, SB_SETTEXT, 1, (LPARAM)m_proto_interface->m_tszUserName);
diff --git a/src/modules/clist/contacts.cpp b/src/modules/clist/contacts.cpp
index d370239c84..204dc3221c 100644
--- a/src/modules/clist/contacts.cpp
+++ b/src/modules/clist/contacts.cpp
@@ -433,66 +433,68 @@ public:
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
+ TVHITTESTINFO hti;
+
switch (msg) {
case WM_MOUSEMOVE:
- if (dragging) {
- TVHITTESTINFO hti;
- hti.pt.x = (short)LOWORD(lParam);
- hti.pt.y = (short)HIWORD(lParam);
- ClientToScreen(m_hwnd, &hti.pt);
- ScreenToClient(m_nameOrder.GetHwnd(), &hti.pt);
+ if (!dragging)
+ break;
+
+ hti.pt.x = (short)LOWORD(lParam);
+ hti.pt.y = (short)HIWORD(lParam);
+ ClientToScreen(m_hwnd, &hti.pt);
+ ScreenToClient(m_nameOrder.GetHwnd(), &hti.pt);
+ m_nameOrder.HitTest(&hti);
+ if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) {
+ hti.pt.y -= m_nameOrder.GetItemHeight() / 2;
m_nameOrder.HitTest(&hti);
- if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) {
- hti.pt.y -= m_nameOrder.GetItemHeight() / 2;
- m_nameOrder.HitTest(&hti);
- m_nameOrder.SetInsertMark(hti.hItem, 1);
- }
- else {
- if (hti.flags & TVHT_ABOVE) m_nameOrder.SendMsg(WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
- if (hti.flags & TVHT_BELOW) m_nameOrder.SendMsg(WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
- m_nameOrder.SetInsertMark(NULL, 0);
- }
+ m_nameOrder.SetInsertMark(hti.hItem, 1);
+ }
+ else {
+ if (hti.flags & TVHT_ABOVE) m_nameOrder.SendMsg(WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
+ if (hti.flags & TVHT_BELOW) m_nameOrder.SendMsg(WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
+ m_nameOrder.SetInsertMark(NULL, 0);
}
break;
case WM_LBUTTONUP:
- if (dragging) {
- m_nameOrder.SetInsertMark(NULL, 0);
- dragging = 0;
- ReleaseCapture();
-
- TVHITTESTINFO hti;
- hti.pt.x = (short)LOWORD(lParam);
- hti.pt.y = (short)HIWORD(lParam);
- ClientToScreen(m_hwnd, &hti.pt);
- ScreenToClient(m_nameOrder.GetHwnd(), &hti.pt);
- hti.pt.y -= m_nameOrder.GetItemHeight() / 2;
- m_nameOrder.HitTest(&hti);
- if (hDragItem == hti.hItem)
- break;
-
- TVITEMEX tvi;
- tvi.mask = TVIF_HANDLE | TVIF_PARAM;
- tvi.hItem = hti.hItem;
- m_nameOrder.GetItem(&tvi);
- if (tvi.lParam == SIZEOF(nameOrderDescr) - 1)
- break;
-
- if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) {
- TCHAR name[128];
- TVINSERTSTRUCT tvis = { 0 };
- tvis.itemex.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_PARAM;
- tvis.itemex.stateMask = 0xFFFFFFFF;
- tvis.itemex.pszText = name;
- tvis.itemex.cchTextMax = SIZEOF(name);
- tvis.itemex.hItem = hDragItem;
- m_nameOrder.GetItem(&tvis.itemex);
- m_nameOrder.DeleteItem(hDragItem);
- tvis.hParent = NULL;
- tvis.hInsertAfter = hti.hItem;
- m_nameOrder.SelectItem(m_nameOrder.InsertItem(&tvis));
- NotifyChange();
- }
+ if (!dragging)
+ break;
+
+ m_nameOrder.SetInsertMark(NULL, 0);
+ dragging = 0;
+ ReleaseCapture();
+
+ hti.pt.x = (short)LOWORD(lParam);
+ hti.pt.y = (short)HIWORD(lParam);
+ ClientToScreen(m_hwnd, &hti.pt);
+ ScreenToClient(m_nameOrder.GetHwnd(), &hti.pt);
+ hti.pt.y -= m_nameOrder.GetItemHeight() / 2;
+ m_nameOrder.HitTest(&hti);
+ if (hDragItem == hti.hItem)
+ break;
+
+ TVITEMEX tvi;
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM;
+ tvi.hItem = hti.hItem;
+ m_nameOrder.GetItem(&tvi);
+ if (tvi.lParam == SIZEOF(nameOrderDescr) - 1)
+ break;
+
+ if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) {
+ TCHAR name[128];
+ TVINSERTSTRUCT tvis = { 0 };
+ tvis.itemex.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_PARAM;
+ tvis.itemex.stateMask = 0xFFFFFFFF;
+ tvis.itemex.pszText = name;
+ tvis.itemex.cchTextMax = SIZEOF(name);
+ tvis.itemex.hItem = hDragItem;
+ m_nameOrder.GetItem(&tvis.itemex);
+ m_nameOrder.DeleteItem(hDragItem);
+ tvis.hParent = NULL;
+ tvis.hInsertAfter = hti.hItem;
+ m_nameOrder.SelectItem(m_nameOrder.InsertItem(&tvis));
+ NotifyChange();
}
break;
}
diff --git a/src/modules/clist/genmenuopt.cpp b/src/modules/clist/genmenuopt.cpp
index 054ac75072..60f8b6962f 100644
--- a/src/modules/clist/genmenuopt.cpp
+++ b/src/modules/clist/genmenuopt.cpp
@@ -41,7 +41,7 @@ struct MenuItemOptData : public MZeroedObject
ptrT defname;
ptrA uniqname;
- bool bShow, bIsSelected;
+ bool bIsSelected;
int id;
PMO_IntMenuItem pimi;
@@ -65,7 +65,7 @@ class CGenMenuOptionsPage : public CDlgBase
TVITEMEX tvi;
tvi.hItem = m_menuItems.GetRoot();
tvi.cchTextMax = SIZEOF(idstr);
- tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_HANDLE;
+ tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_HANDLE | TVIF_IMAGE;
tvi.pszText = idstr;
int count = 0;
@@ -87,7 +87,7 @@ class CGenMenuOptionsPage : public CDlgBase
GetMenuItemName(iod->pimi, menuItemName, sizeof(menuItemName));
mir_snprintf(DBString, SIZEOF(DBString), "%s_visible", menuItemName);
- db_set_b(NULL, MenuNameItems, DBString, iod->bShow);
+ db_set_b(NULL, MenuNameItems, DBString, tvi.iImage != 0);
mir_snprintf(DBString, SIZEOF(DBString), "%s_pos", menuItemName);
db_set_dw(NULL, MenuNameItems, DBString, runtimepos);
@@ -102,7 +102,7 @@ class CGenMenuOptionsPage : public CDlgBase
runtimepos += 100;
}
- if (iod->name && !_tcscmp(iod->name, STR_SEPARATOR) && iod->bShow)
+ if (iod->name && !_tcscmp(iod->name, STR_SEPARATOR) && tvi.iImage)
runtimepos += SEPARATORPOSITIONINTERVAL;
tvi.hItem = m_menuItems.GetNextSibling(tvi.hItem);
@@ -152,7 +152,14 @@ class CGenMenuOptionsPage : public CDlgBase
char menuItemName[256], MenuNameItems[256];
mir_snprintf(MenuNameItems, SIZEOF(MenuNameItems), "%s_Items", pimo->pszName);
- LIST<MenuItemOptData> arItems(20, NumericKeySortT);
+ m_menuItems.SendMsg(WM_SETREDRAW, FALSE, 0);
+ int lastpos = 0;
+ bool bIsFirst = TRUE;
+
+ TVINSERTSTRUCT tvis;
+ tvis.hParent = NULL;
+ tvis.hInsertAfter = TVI_LAST;
+ tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
for (PMO_IntMenuItem p = pimo->m_items.first; p != NULL; p = p->next) {
if (p->mi.root != (HGENMENU)-1 && p->mi.root != NULL)
@@ -175,7 +182,7 @@ class CGenMenuOptionsPage : public CDlgBase
PD->defname = mir_tstrdup(GetMenuItemText(p));
mir_snprintf(buf, SIZEOF(buf), "%s_visible", menuItemName);
- PD->bShow = db_get_b(NULL, MenuNameItems, buf, 1) != 0;
+ int bShow = db_get_b(NULL, MenuNameItems, buf, 1) != 0;
if (bReread) {
mir_snprintf(buf, SIZEOF(buf), "%s_pos", menuItemName);
@@ -188,35 +195,21 @@ class CGenMenuOptionsPage : public CDlgBase
if (p->UniqName)
PD->uniqname = mir_strdup(p->UniqName);
- arItems.insert(PD);
- }
-
- m_menuItems.SendMsg(WM_SETREDRAW, FALSE, 0);
- int lastpos = 0;
- bool bIsFirst = TRUE;
+ if (PD->pos - lastpos >= SEPARATORPOSITIONINTERVAL) {
+ MenuItemOptData *sep = new MenuItemOptData();
+ sep->id = -1;
+ sep->name = mir_tstrdup(STR_SEPARATOR);
+ sep->pos = PD->pos - 1;
- TVINSERTSTRUCT tvis;
- tvis.hParent = NULL;
- tvis.hInsertAfter = TVI_LAST;
- tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- for (int i = 0; i < arItems.getCount(); i++) {
- auto p = arItems[i];
- if (p->pos - lastpos >= SEPARATORPOSITIONINTERVAL) {
- MenuItemOptData *PD = new MenuItemOptData();
- PD->id = -1;
- PD->name = mir_tstrdup(STR_SEPARATOR);
- PD->pos = p->pos - 1;
- PD->bShow = true;
-
- tvis.item.lParam = (LPARAM)PD;
- tvis.item.pszText = PD->name;
- tvis.item.iImage = tvis.item.iSelectedImage = PD->bShow;
+ tvis.item.lParam = (LPARAM)sep;
+ tvis.item.pszText = sep->name;
+ tvis.item.iImage = tvis.item.iSelectedImage = 1;
m_menuItems.InsertItem(&tvis);
}
- tvis.item.lParam = (LPARAM)p;
- tvis.item.pszText = p->name;
- tvis.item.iImage = tvis.item.iSelectedImage = p->bShow;
+ tvis.item.lParam = (LPARAM)PD;
+ tvis.item.pszText = PD->name;
+ tvis.item.iImage = tvis.item.iSelectedImage = bShow;
HTREEITEM hti = m_menuItems.InsertItem(&tvis);
if (bIsFirst) {
@@ -224,7 +217,7 @@ class CGenMenuOptionsPage : public CDlgBase
bIsFirst = false;
}
- lastpos = p->pos;
+ lastpos = PD->pos;
}
m_menuItems.SendMsg(WM_SETREDRAW, TRUE, 0);
@@ -252,7 +245,7 @@ class CGenMenuOptionsPage : public CDlgBase
HTREEITEM MoveItemAbove(HTREEITEM hItem, HTREEITEM hInsertAfter)
{
TVITEMEX tvi = { 0 };
- tvi.mask = TVIF_HANDLE | TVIF_PARAM;
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_IMAGE;
tvi.hItem = hItem;
if (!m_menuItems.GetItem(&tvi))
return NULL;
@@ -268,7 +261,7 @@ class CGenMenuOptionsPage : public CDlgBase
tvis.itemex.pszText = name;
tvis.itemex.cchTextMax = SIZEOF(name);
tvis.itemex.hItem = hItem;
- tvis.itemex.iImage = tvis.itemex.iSelectedImage = ((MenuItemOptData*)tvi.lParam)->bShow;
+ tvis.itemex.iImage = tvis.itemex.iSelectedImage = tvi.iImage;
if (!m_menuItems.GetItem(&tvis.itemex))
return NULL;
@@ -309,7 +302,8 @@ public:
m_btnDefault.OnClick = Callback(this, &CGenMenuOptionsPage::btnDefault_Clicked);
m_menuObjects.OnSelChanged = Callback(this, &CGenMenuOptionsPage::onMenuObjectChanged);
-
+
+ m_menuItems.SetFlags(MTREE_CHECKBOX);
m_menuItems.OnSelChanged = Callback(this, &CGenMenuOptionsPage::onMenuItemChanged);
m_menuItems.OnBeginDrag = Callback(this, &CGenMenuOptionsPage::onMenuItemBeginDrag);
}
@@ -386,13 +380,12 @@ public:
MenuItemOptData *PD = new MenuItemOptData();
PD->id = -1;
PD->name = mir_tstrdup(STR_SEPARATOR);
- PD->bShow = true;
PD->pos = ((MenuItemOptData *)tvi.lParam)->pos - 1;
TVINSERTSTRUCT tvis = { 0 };
tvis.item.lParam = (LPARAM)(PD);
tvis.item.pszText = PD->name;
- tvis.item.iImage = tvis.item.iSelectedImage = PD->bShow;
+ tvis.item.iImage = tvis.item.iSelectedImage = 1;
tvis.hInsertAfter = hti;
tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
m_menuItems.InsertItem(&tvis);
@@ -559,20 +552,6 @@ public:
return 0;
}
- void OnClickCheckbox(HTREEITEM hItem)
- {
- TVITEMEX tvi;
- tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
- tvi.hItem = hItem;
- m_menuItems.GetItem(&tvi);
-
- tvi.iImage = tvi.iSelectedImage = !tvi.iImage;
- ((MenuItemOptData *)tvi.lParam)->bShow = tvi.iImage != 0;
- m_menuItems.SetItem(&tvi);
-
- NotifyChange();
- }
-
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
TVHITTESTINFO hti;
@@ -669,11 +648,6 @@ public:
SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, onMenuItemDraw((LPNMTVCUSTOMDRAW)phdr));
return TRUE;
- case TVN_KEYDOWN:
- if (((LPNMLVKEYDOWN)phdr)->wVKey == VK_SPACE)
- OnClickCheckbox(m_menuItems.GetSelection());
- break;
-
case NM_CLICK:
TVHITTESTINFO hti;
hti.pt.x = (short)LOWORD(GetMessagePos());
@@ -682,9 +656,6 @@ public:
if (!m_menuItems.HitTest(&hti))
break;
- if (hti.flags & TVHT_ONITEMICON)
- OnClickCheckbox(hti.hItem);
-
/*--------MultiSelection----------*/
if (hti.flags & TVHT_ONITEMLABEL) {
/// LabelClicked Set/unset selection
diff --git a/src/modules/clist/protocolorder.cpp b/src/modules/clist/protocolorder.cpp
index bab4380b61..a454793de3 100644
--- a/src/modules/clist/protocolorder.cpp
+++ b/src/modules/clist/protocolorder.cpp
@@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
struct ProtocolData
{
char *RealName;
- int show, enabled;
+ int enabled;
};
int isProtoSuitable(PROTO_INTERFACE* ppi)
@@ -125,11 +125,10 @@ class CProtocolOrderOpts : public CDlgBase
ProtocolData *PD = (ProtocolData*)mir_alloc(sizeof(ProtocolData));
PD->RealName = pa->szModuleName;
PD->enabled = Proto_IsAccountEnabled(pa) && isProtoSuitable(pa->ppro);
- PD->show = PD->enabled ? pa->bIsVisible : 100;
tvis.item.lParam = (LPARAM)PD;
tvis.item.pszText = pa->tszAccountName;
- tvis.item.iImage = tvis.item.iSelectedImage = PD->show;
+ tvis.item.iImage = tvis.item.iSelectedImage = PD->enabled ? pa->bIsVisible : 100;
m_order.InsertItem(&tvis);
}
}
@@ -150,6 +149,7 @@ public:
{
m_btnReset.OnClick = Callback(this, &CProtocolOrderOpts::onReset_Click);
+ m_order.SetFlags(MTREE_CHECKBOX);
m_order.OnBeginDrag = Callback(this, &CProtocolOrderOpts::onOrder_BeginDrag);
m_order.OnDeleteItem = Callback(this, &CProtocolOrderOpts::onOrder_DeleteItem);
}
@@ -170,7 +170,7 @@ public:
TVITEMEX tvi;
tvi.hItem = m_order.GetRoot();
- tvi.mask = TVIF_PARAM | TVIF_HANDLE;
+ tvi.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_IMAGE;
while (tvi.hItem != NULL) {
m_order.GetItem(&tvi);
@@ -182,7 +182,7 @@ public:
idx++;
pa->iOrder = idx++;
if (ppd->enabled)
- pa->bIsVisible = ppd->show != 0;
+ pa->bIsVisible = tvi.iImage != 0;
}
}
@@ -230,31 +230,6 @@ public:
TVHITTESTINFO hti;
switch (msg) {
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->code) {
- case NM_CLICK:
- hti.pt.x = (short)LOWORD(GetMessagePos());
- hti.pt.y = (short)HIWORD(GetMessagePos());
- ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt);
- if (m_order.HitTest(&hti)) {
- if (hti.flags & TVHT_ONITEMICON) {
- TVITEMEX tvi;
- tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- tvi.hItem = hti.hItem;
- m_order.GetItem(&tvi);
-
- ProtocolData *pData = (ProtocolData*)tvi.lParam;
- if (pData->enabled) {
- tvi.iImage = tvi.iSelectedImage = !tvi.iImage;
- pData->show = tvi.iImage;
- m_order.SetItem(&tvi);
- NotifyChange();
- }
- }
- }
- }
- break;
-
case WM_MOUSEMOVE:
if (!m_bDragging)
break;
@@ -300,7 +275,7 @@ public:
hti.hItem = TVI_FIRST;
TVITEMEX tvi;
- tvi.mask = TVIF_HANDLE | TVIF_PARAM;
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_IMAGE;
tvi.hItem = m_hDragItem;
m_order.GetItem(&tvi);
if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT) || (hti.hItem == TVI_FIRST)) {
@@ -311,7 +286,7 @@ public:
tvis.itemex.pszText = name;
tvis.itemex.cchTextMax = SIZEOF(name);
tvis.itemex.hItem = m_hDragItem;
- tvis.itemex.iImage = tvis.itemex.iSelectedImage = ((ProtocolData *)tvi.lParam)->show;
+ tvis.itemex.iImage = tvis.itemex.iSelectedImage = tvi.iImage;
m_order.GetItem(&tvis.itemex);
// the pointed lParam will be freed inside TVN_DELETEITEM