xref: /trunk/main/fpicker/source/win32/filepicker/dialogcustomcontrols.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_fpicker.hxx"
30 
31 #ifndef _DIALOGCUSTOMCONTROLS_CXX_
32 #include "dialogcustomcontrols.hxx"
33 #endif
34 #include <osl/diagnose.h>
35 
36 //-----------------------------------
37 //
38 //-----------------------------------
39 
40 CDialogCustomControlBase::CDialogCustomControlBase(HWND aControlHandle, HWND aParentHandle) :
41     m_CustomControlHandle(aControlHandle),
42     m_ParentHandle(aParentHandle)
43 {
44 }
45 
46 //-----------------------------------
47 //
48 //-----------------------------------
49 
50 void SAL_CALL CDialogCustomControlBase::SetFont(HFONT hFont)
51 {
52     SendMessage(
53         m_CustomControlHandle,
54         WM_SETFONT,
55         (WPARAM)hFont,
56         (LPARAM)sal_True);
57 }
58 
59 //-----------------------------------
60 //
61 //-----------------------------------
62 
63 void SAL_CALL CDialogCustomControlBase::AlignToBuddy(HWND aBuddyHandle)
64 {
65     OSL_PRECOND(IsWindow(aBuddyHandle),"Invalid buddy window handle");
66 
67     RECT rcBuddy;
68     GetWindowRect(aBuddyHandle,&rcBuddy);
69 
70     POINT pt = {rcBuddy.left,rcBuddy.top};
71     ScreenToClient(m_ParentHandle,&pt);
72 
73     int cx_new = rcBuddy.right - rcBuddy.left;
74     int cy_new = rcBuddy.bottom - rcBuddy.top;
75 
76     // keep the vertical position because
77     // the Windows dialog controler does
78     // this job
79     RECT rcMe;
80     GetWindowRect(m_CustomControlHandle,&rcMe);
81 
82     POINT ptMe = {rcMe.left,rcMe.top};
83     ScreenToClient(m_ParentHandle,&ptMe);
84 
85     SetWindowPos(
86         m_CustomControlHandle,
87         HWND_TOP,
88         pt.x,
89         ptMe.y,
90         cx_new,
91         cy_new,
92         SWP_NOACTIVATE);
93 }
94 
95 //-----------------------------------
96 //
97 //-----------------------------------
98 
99 CDummyCustomControl::CDummyCustomControl(HWND, HWND)
100 {
101 }
102 
103 //-----------------------------------
104 //
105 //-----------------------------------
106 
107 void SAL_CALL CDummyCustomControl::Align()
108 {
109     // do nothing
110 }
111 
112 //-----------------------------------
113 //
114 //-----------------------------------
115 
116 void SAL_CALL CDummyCustomControl::SetFont(HFONT)
117 {
118     // do nothing
119 }
120 
121 //-----------------------------------
122 //
123 //-----------------------------------
124 
125 CStaticCustomControl::CStaticCustomControl(HWND aControlHandle, HWND aParentHandle) :
126     CDialogCustomControlBase(aControlHandle,aParentHandle)
127 {
128 }
129 
130 //-----------------------------------
131 // Align to the "File name" static
132 // text of the standard FileOpen dlg
133 //-----------------------------------
134 
135 void SAL_CALL CStaticCustomControl::Align()
136 {
137     AlignToBuddy(GetDlgItem(m_ParentHandle,stc3));
138 }
139 
140 //-----------------------------------
141 //
142 //-----------------------------------
143 
144 CPushButtonCustomControl::CPushButtonCustomControl(HWND aControlHandle, HWND aParentHandle) :
145     CDialogCustomControlBase(aControlHandle,aParentHandle)
146 {
147 }
148 
149 //-----------------------------------
150 // Align to the "OK" button of the
151 // standard FileOpen dlg
152 //-----------------------------------
153 
154 void SAL_CALL CPushButtonCustomControl::Align()
155 {
156     AlignToBuddy(GetDlgItem(m_ParentHandle,IDCANCEL));
157 }
158 
159 //-----------------------------------
160 //
161 //-----------------------------------
162 
163 CComboboxCustomControl::CComboboxCustomControl(HWND aControlHandle, HWND aParentHandle) :
164     CDialogCustomControlBase(aControlHandle,aParentHandle)
165 {
166 }
167 
168 //-----------------------------------
169 // Align to the "File name" combobox
170 // of the standard FileOpen dlg
171 //-----------------------------------
172 
173 void SAL_CALL CComboboxCustomControl::Align()
174 {
175     AlignToBuddy(GetDlgItem(m_ParentHandle,cmb1));
176 }
177 
178 //-----------------------------------
179 //
180 //-----------------------------------
181 
182 CCheckboxCustomControl::CCheckboxCustomControl(HWND aControlHandle, HWND aParentHandle) :
183     CDialogCustomControlBase(aControlHandle,aParentHandle)
184 {
185 }
186 
187 //-----------------------------------
188 // Align to the "File name" combobox
189 // of the standard FileOpen dlg
190 //-----------------------------------
191 
192 void SAL_CALL CCheckboxCustomControl::Align()
193 {
194     AlignToBuddy(GetDlgItem(m_ParentHandle,cmb1));
195 }
196