Debian Codegraph @

src/af/xap/win/xap_Win32Dlg_WindowMore.cpp

raw
1 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
2
3 /* AbiSource Application Framework
4 * Copyright (C) 1998 AbiSource, Inc.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301 USA.
20 */
21
22 #include <windows.h>
23
24 #include "ut_string.h"
25 #include "ut_assert.h"
26 #include "ut_debugmsg.h"
27
28 #include "xap_App.h"
29 #include "xap_Win32App.h"
30 #include "xap_Win32FrameImpl.h"
31
32 #include "xap_Strings.h"
33 #include "xap_Dialog_Id.h"
34 #include "xap_Dlg_WindowMore.h"
35 #include "xap_Win32Dlg_WindowMore.h"
36
37 #include "xap_Win32Resources.rc2"
38
39 /*****************************************************************/
40 XAP_Dialog * XAP_Win32Dialog_WindowMore::static_constructor(XAP_DialogFactory * pFactory,
41 XAP_Dialog_Id id)
42 {
43 XAP_Win32Dialog_WindowMore * p = new XAP_Win32Dialog_WindowMore(pFactory,id);
44 return p;
45 }
46
47 XAP_Win32Dialog_WindowMore::XAP_Win32Dialog_WindowMore(XAP_DialogFactory * pDlgFactory,
48 XAP_Dialog_Id id)
49 : XAP_Dialog_WindowMore(pDlgFactory,id)
50 {
51 }
52
53 XAP_Win32Dialog_WindowMore::~XAP_Win32Dialog_WindowMore(void)
54 {
55 }
56
57 void XAP_Win32Dialog_WindowMore::runModal(XAP_Frame * pFrame)
58 {
59 UT_ASSERT(pFrame);
60 UT_ASSERT(m_id == XAP_DIALOG_ID_WINDOWMORE);
61
62 // NOTE: this work could be done in XP code
63 m_ndxSelFrame = m_pApp->findFrame(pFrame);
64 UT_ASSERT(m_ndxSelFrame >= 0);
65
66 // raise the dialog
67 setDialog(this);
68 createModal(pFrame, MAKEINTRESOURCEW(XAP_RID_DIALOG_WINDOWMORE));
69
70 }
71
72 BOOL XAP_Win32Dialog_WindowMore::_onInitDialog(HWND /*hWnd*/, WPARAM /*wParam*/, LPARAM /*lParam*/)
73 {
74 // localize controls
75 localizeDialogTitle(XAP_STRING_ID_DLG_MW_MoreWindows);
76
77 localizeControlText(XAP_RID_DIALOG_WINDOWMORE_TEXT_ACTIVATE, XAP_STRING_ID_DLG_MW_Activate);
78 localizeControlText(XAP_RID_DIALOG_WINDOWMORE_BTN_OK, XAP_STRING_ID_DLG_OK);
79 localizeControlText(XAP_RID_DIALOG_WINDOWMORE_BTN_CANCEL, XAP_STRING_ID_DLG_Cancel);
80
81 // load each frame name into the list
82 for (UT_sint32 i=0; i<m_pApp->getFrameCount(); i++)
83 {
84 XAP_Frame * f = m_pApp->getFrame(i);
85 UT_continue_if_fail(f);
86
87 int nIndex = addItemToList(XAP_RID_DIALOG_WINDOWMORE_LIST, f->getTitle().utf8_str());
88 setListDataItem(XAP_RID_DIALOG_WINDOWMORE_LIST, nIndex, (DWORD) i);
89 }
90
91 // select the one we're in
92 selectListItem(XAP_RID_DIALOG_WINDOWMORE_LIST, m_ndxSelFrame);
93
94 return 1; // 1 == we did not call SetFocus()
95 }
96
97 BOOL XAP_Win32Dialog_WindowMore::_onCommand(HWND hWnd, WPARAM wParam, LPARAM /*lParam*/)
98 {
99 WORD wId = LOWORD(wParam);
100 int nItem;
101
102 switch (wId)
103 {
104 case XAP_RID_DIALOG_WINDOWMORE_LIST:
105 switch (HIWORD(wParam))
106 {
107 case LBN_SELCHANGE:
108 // NOTE: we could get away with only grabbing this in IDOK case
109 nItem = getListSelectedIndex(wId);
110 m_ndxSelFrame = getListDataItem(wId, nItem);
111 return 1;
112
113 case LBN_DBLCLK:
114 nItem = getListSelectedIndex(wId);
115 m_ndxSelFrame = getListDataItem(wId, nItem);
116 EndDialog(hWnd,0);
117 return 1;
118
119 default:
120 return 0;
121 }
122 break;
123
124 case IDCANCEL: // also XAP_RID_DIALOG_WINDOWMORE_BTN_CANCEL
125 m_answer = a_CANCEL;
126 // fall through
127
128 case IDOK: // also XAP_RID_DIALOG_WINDOWMORE_BTN_OK
129 EndDialog(hWnd,0);
130 return 1;
131
132 default: // we did not handle this notification
133 UT_DEBUGMSG(("WM_Command for id %ld\n",wId));
134 return 0; // return zero to let windows take care of it.
135 }
136 }
137
138 BOOL XAP_Win32Dialog_WindowMore::_onDeltaPos(NM_UPDOWN * /*pnmud*/)
139 {
140 return FALSE;
141 }