1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_fpicker.hxx"
26 
27 #ifndef _DIALOGCUSTOMCONTROLS_CXX_
28 #include "dialogcustomcontrols.hxx"
29 #endif
30 #include <osl/diagnose.h>
31 
32 //-----------------------------------
33 //
34 //-----------------------------------
35 
CDialogCustomControlBase(HWND aControlHandle,HWND aParentHandle)36 CDialogCustomControlBase::CDialogCustomControlBase(HWND aControlHandle, HWND aParentHandle) :
37 	m_CustomControlHandle(aControlHandle),
38 	m_ParentHandle(aParentHandle)
39 {
40 }
41 
42 //-----------------------------------
43 //
44 //-----------------------------------
45 
SetFont(HFONT hFont)46 void SAL_CALL CDialogCustomControlBase::SetFont(HFONT hFont)
47 {
48 	SendMessage(
49 		m_CustomControlHandle,
50 		WM_SETFONT,
51 		(WPARAM)hFont,
52 		(LPARAM)sal_True);
53 }
54 
55 //-----------------------------------
56 //
57 //-----------------------------------
58 
AlignToBuddy(HWND aBuddyHandle)59 void SAL_CALL CDialogCustomControlBase::AlignToBuddy(HWND aBuddyHandle)
60 {
61 	OSL_PRECOND(IsWindow(aBuddyHandle),"Invalid buddy window handle");
62 
63 	RECT rcBuddy;
64 	GetWindowRect(aBuddyHandle,&rcBuddy);
65 
66 	POINT pt = {rcBuddy.left,rcBuddy.top};
67 	ScreenToClient(m_ParentHandle,&pt);
68 
69 	int cx_new = rcBuddy.right - rcBuddy.left;
70 	int cy_new = rcBuddy.bottom - rcBuddy.top;
71 
72 	// keep the vertical position because
73 	// the Windows dialog controler does
74 	// this job
75 	RECT rcMe;
76 	GetWindowRect(m_CustomControlHandle,&rcMe);
77 
78 	POINT ptMe = {rcMe.left,rcMe.top};
79 	ScreenToClient(m_ParentHandle,&ptMe);
80 
81 	SetWindowPos(
82 		m_CustomControlHandle,
83 		HWND_TOP,
84 		pt.x,
85 		ptMe.y,
86 		cx_new,
87 		cy_new,
88 		SWP_NOACTIVATE);
89 }
90 
91 //-----------------------------------
92 //
93 //-----------------------------------
94 
CDummyCustomControl(HWND,HWND)95 CDummyCustomControl::CDummyCustomControl(HWND, HWND)
96 {
97 }
98 
99 //-----------------------------------
100 //
101 //-----------------------------------
102 
Align()103 void SAL_CALL CDummyCustomControl::Align()
104 {
105 	// do nothing
106 }
107 
108 //-----------------------------------
109 //
110 //-----------------------------------
111 
SetFont(HFONT)112 void SAL_CALL CDummyCustomControl::SetFont(HFONT)
113 {
114 	// do nothing
115 }
116 
117 //-----------------------------------
118 //
119 //-----------------------------------
120 
CStaticCustomControl(HWND aControlHandle,HWND aParentHandle)121 CStaticCustomControl::CStaticCustomControl(HWND aControlHandle, HWND aParentHandle) :
122 	CDialogCustomControlBase(aControlHandle,aParentHandle)
123 {
124 }
125 
126 //-----------------------------------
127 // Align to the "File name" static
128 // text of the standard FileOpen dlg
129 //-----------------------------------
130 
Align()131 void SAL_CALL CStaticCustomControl::Align()
132 {
133 	AlignToBuddy(GetDlgItem(m_ParentHandle,stc3));
134 }
135 
136 //-----------------------------------
137 //
138 //-----------------------------------
139 
CPushButtonCustomControl(HWND aControlHandle,HWND aParentHandle)140 CPushButtonCustomControl::CPushButtonCustomControl(HWND aControlHandle, HWND aParentHandle) :
141 	CDialogCustomControlBase(aControlHandle,aParentHandle)
142 {
143 }
144 
145 //-----------------------------------
146 // Align to the "OK" button of the
147 // standard FileOpen dlg
148 //-----------------------------------
149 
Align()150 void SAL_CALL CPushButtonCustomControl::Align()
151 {
152 	AlignToBuddy(GetDlgItem(m_ParentHandle,IDCANCEL));
153 }
154 
155 //-----------------------------------
156 //
157 //-----------------------------------
158 
CComboboxCustomControl(HWND aControlHandle,HWND aParentHandle)159 CComboboxCustomControl::CComboboxCustomControl(HWND aControlHandle, HWND aParentHandle) :
160 	CDialogCustomControlBase(aControlHandle,aParentHandle)
161 {
162 }
163 
164 //-----------------------------------
165 // Align to the "File name" combobox
166 // of the standard FileOpen dlg
167 //-----------------------------------
168 
Align()169 void SAL_CALL CComboboxCustomControl::Align()
170 {
171 	AlignToBuddy(GetDlgItem(m_ParentHandle,cmb1));
172 }
173 
174 //-----------------------------------
175 //
176 //-----------------------------------
177 
CCheckboxCustomControl(HWND aControlHandle,HWND aParentHandle)178 CCheckboxCustomControl::CCheckboxCustomControl(HWND aControlHandle, HWND aParentHandle) :
179 	CDialogCustomControlBase(aControlHandle,aParentHandle)
180 {
181 }
182 
183 //-----------------------------------
184 // Align to the "File name" combobox
185 // of the standard FileOpen dlg
186 //-----------------------------------
187 
Align()188 void SAL_CALL CCheckboxCustomControl::Align()
189 {
190 	AlignToBuddy(GetDlgItem(m_ParentHandle,cmb1));
191 }
192