soc.2009.vulture: c56f879b: Tab-switching now works properly.
gdick at soc.pidgin.im
gdick at soc.pidgin.im
Tue Jun 16 17:05:34 EDT 2009
-----------------------------------------------------------------
Revision: c56f879b4f37d4352ad4417d6f6aec4e57ec58fc
Ancestor: 50435feb4e7881f8320a5e74877be9bf1b8e2d29
Author: gdick at soc.pidgin.im
Date: 2009-06-16T18:47:39
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/c56f879b4f37d4352ad4417d6f6aec4e57ec58fc
Modified files:
vulture/vulture-res.rc vulture/vultureconv.c
ChangeLog:
Tab-switching now works properly.
-------------- next part --------------
============================================================
--- vulture/vulture-res.rc 44e88df5ff1abfae1d5322dbeab45ac11348e084
+++ vulture/vulture-res.rc 1c6366b107a31f81966e33f72127c6eae6a1ed62
@@ -82,7 +82,7 @@ IDD_IM DIALOG 0, 0, 325, 235
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
IDD_IM DIALOG 0, 0, 325, 235
-STYLE DS_3DLOOK | DS_CENTER | DS_SHELLFONT | WS_VISIBLE | WS_CHILDWINDOW
+STYLE DS_3DLOOK | DS_CENTER | DS_SHELLFONT | WS_CHILDWINDOW | WS_DISABLED
FONT 8, "Ms Shell Dlg"
{
CONTROL "", IDC_RICHEDIT_CONV, RICHEDIT_CLASS, WS_TABSTOP | WS_VSCROLL | WS_BORDER | ES_AUTOVSCROLL | ES_MULTILINE | ES_READONLY, 5, 35, 310, 150
============================================================
--- vulture/vultureconv.c f08946df5b39fd4cddab526e2109e799a22f6bac
+++ vulture/vultureconv.c b25a661d8a7cf28dd40611ce5d91e3a8a4a15be0
@@ -41,6 +41,7 @@ typedef struct _CONVCONTAINERDATA
typedef struct _CONVCONTAINERDATA
{
HWND hwndTabDlg;
+ int iSelectedTab;
} CONVCONTAINERDATA;
@@ -51,9 +52,10 @@ static INT_PTR CALLBACK IMDlgProc(HWND h
static INT_PTR CALLBACK ConvContTabDlgProc(HWND hwndDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
static void RecalcTabIndices(HWND hwndTabs);
static INT_PTR CALLBACK IMDlgProc(HWND hwndDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
-static void ResizeConversationWindows(HWND hwndConvContainer, HWND hwndTabs);
+static void ResizeActiveConversationWindow(HWND hwndConvContainer, HWND hwndTabs);
static void RepositionConvControls(HWND hwndConvDlg);
static LRESULT CALLBACK InputBoxSubclassProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
+static void EnableAppropriateConvWindow(CONVCONTAINERDATA *lpccd);
/**
@@ -126,16 +128,14 @@ static LRESULT CALLBACK ConvContainerWnd
switch(uiMsg)
{
case WM_CREATE:
- {
- RECT rcClient;
+ lpccd = (CONVCONTAINERDATA*)ProcHeapAlloc(sizeof(CONVCONTAINERDATA));
+ SetWindowLongPtr(hwnd, GWL_USERDATA, (LONG_PTR)lpccd);
- lpccd = (CONVCONTAINERDATA*)ProcHeapAlloc(sizeof(CONVCONTAINERDATA));
- SetWindowLongPtr(hwnd, GWL_USERDATA, (LONG_PTR)lpccd);
+ /* Create the tab control. */
+ lpccd->hwndTabDlg = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_CONVCONT), hwnd, ConvContTabDlgProc);
- /* Create the tab control. */
- GetClientRect(hwnd, &rcClient);
- lpccd->hwndTabDlg = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_CONVCONT), hwnd, ConvContTabDlgProc);
- }
+ /* No tab selected initially. */
+ lpccd->iSelectedTab = -1;
return 0;
@@ -162,10 +162,18 @@ static LRESULT CALLBACK ConvContainerWnd
lpvconv->iTabIndex = TabCtrl_InsertItem(hwndTabs, TabCtrl_GetItemCount(hwndTabs), &tcitem);
LeaveCriticalSection(&lpvconv->sync.cs);
- /* Create conversation dialogue. */
+ /* Create conversation dialogue. It is
+ * initially disabled and hidden.
+ */
lpvconv->hwndConv = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_IM), hwndTabs, IMDlgProc, (LPARAM)lpvconv);
+ SetWindowPos(lpvconv->hwndConv, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOREPOSITION | SWP_NOSIZE);
- ResizeConversationWindows(hwnd, hwndTabs);
+ /* Only strictly necessary if we're the only
+ * tab.
+ */
+ EnableAppropriateConvWindow(lpccd);
+
+ ResizeActiveConversationWindow(hwnd, hwndTabs);
}
break;
@@ -217,13 +225,8 @@ static LRESULT CALLBACK ConvContainerWnd
if(lpnmhdr->idFrom == IDC_TAB_CONVERSATIONS && lpnmhdr->code == TCN_SELCHANGE)
{
- TCITEM tcitem;
-
- tcitem.mask = TCIF_PARAM;
- TabCtrl_GetItem(lpnmhdr->hwndFrom, TabCtrl_GetCurSel(lpnmhdr->hwndFrom), &tcitem);
-
- SetWindowPos(((VULTURE_CONVERSATION*)tcitem.lParam)->hwndConv, HWND_TOP, 0, 0, 0, 0, SWP_NOREPOSITION | SWP_NOSIZE);
-
+ EnableAppropriateConvWindow((CONVCONTAINERDATA*)GetWindowLongPtr(hwnd, GWLP_USERDATA));
+ ResizeActiveConversationWindow(hwnd, lpnmhdr->hwndFrom);
return 0;
}
}
@@ -240,7 +243,7 @@ static LRESULT CALLBACK ConvContainerWnd
LOWORD(lParam),
HIWORD(lParam),
SWP_NOZORDER | SWP_NOACTIVATE);
- ResizeConversationWindows(hwnd, GetDlgItem(lpccd->hwndTabDlg, IDC_TAB_CONVERSATIONS));
+ ResizeActiveConversationWindow(hwnd, GetDlgItem(lpccd->hwndTabDlg, IDC_TAB_CONVERSATIONS));
return 0;
@@ -430,17 +433,16 @@ static INT_PTR CALLBACK IMDlgProc(HWND h
/**
- * Resizes all conversation dialogues to fit in the tabs.
+ * Resizes active conversation dialogue to fit in the tab.
*
* @param hwndConvContainer Conversation container window.
* @param hwndTabs Tab control.
*/
-static void ResizeConversationWindows(HWND hwndConvContainer, HWND hwndTabs)
+static void ResizeActiveConversationWindow(HWND hwndConvContainer, HWND hwndTabs)
{
- int i, iCount = TabCtrl_GetItemCount(hwndTabs);
TCITEM tcitem;
RECT rc;
- HDWP hdwp;
+ CONVCONTAINERDATA *lpccd = (CONVCONTAINERDATA*)GetWindowLongPtr(hwndConvContainer, GWLP_USERDATA);
tcitem.mask = TCIF_PARAM;
@@ -448,13 +450,10 @@ static void ResizeConversationWindows(HW
TabCtrl_AdjustRect(hwndTabs, FALSE, &rc);
MapWindowPoints(HWND_DESKTOP, hwndTabs, (LPPOINT)(void*)&rc, 2);
- hdwp = BeginDeferWindowPos(iCount);
-
- for(i = 0; i < iCount; i++)
+ if(lpccd->iSelectedTab >= 0)
{
- TabCtrl_GetItem(hwndTabs, i, &tcitem);
- hdwp = DeferWindowPos(
- hdwp,
+ TabCtrl_GetItem(hwndTabs, lpccd->iSelectedTab, &tcitem);
+ SetWindowPos(
((VULTURE_CONVERSATION*)tcitem.lParam)->hwndConv,
NULL,
rc.left,
@@ -463,8 +462,6 @@ static void ResizeConversationWindows(HW
rc.bottom - rc.top,
SWP_NOZORDER | SWP_NOACTIVATE);
}
-
- EndDeferWindowPos(hdwp);
}
@@ -575,3 +572,39 @@ void VultureFreeConvSend(VULTURE_CONV_SE
ProcHeapFree(lpvcsend->szMessage);
ProcHeapFree(lpvcsend);
}
+
+
+/**
+ * Enables and shows the conversation window for the selected tab, giving the
+ * focus to the input box.
+ *
+ * @param lpccd Container window data.
+ */
+static void EnableAppropriateConvWindow(CONVCONTAINERDATA *lpccd)
+{
+ TCITEM tcitem;
+ HWND hwndTabs = GetDlgItem(lpccd->hwndTabDlg, IDC_TAB_CONVERSATIONS);
+ HWND hwndConv;
+
+ tcitem.mask = TCIF_PARAM;
+
+ /* Disable old conversation. */
+ if(lpccd->iSelectedTab >= 0)
+ {
+ TabCtrl_GetItem(hwndTabs, lpccd->iSelectedTab, &tcitem);
+ hwndConv = ((VULTURE_CONVERSATION*)tcitem.lParam)->hwndConv;
+
+ EnableWindow(hwndConv, FALSE);
+ ShowWindow(hwndConv, SW_HIDE);
+ }
+
+ lpccd->iSelectedTab = TabCtrl_GetCurSel(hwndTabs);
+ TabCtrl_GetItem(hwndTabs, lpccd->iSelectedTab, &tcitem);
+ hwndConv = ((VULTURE_CONVERSATION*)tcitem.lParam)->hwndConv;
+
+ EnableWindow(hwndConv, TRUE);
+ SetWindowPos(hwndConv, HWND_TOP, 0, 0, 0, 0, SWP_NOREPOSITION | SWP_NOSIZE);
+ ShowWindow(hwndConv, SW_SHOW);
+
+ SetFocus(GetDlgItem(hwndConv, IDC_RICHEDIT_INPUT));
+}
More information about the Commits
mailing list