1*b557fc96SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b557fc96SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b557fc96SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b557fc96SAndrew Rist  * distributed with this work for additional information
6*b557fc96SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b557fc96SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b557fc96SAndrew Rist  * "License"); you may not use this file except in compliance
9*b557fc96SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b557fc96SAndrew Rist  *
11*b557fc96SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b557fc96SAndrew Rist  *
13*b557fc96SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b557fc96SAndrew Rist  * software distributed under the License is distributed on an
15*b557fc96SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b557fc96SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b557fc96SAndrew Rist  * specific language governing permissions and limitations
18*b557fc96SAndrew Rist  * under the License.
19*b557fc96SAndrew Rist  *
20*b557fc96SAndrew Rist  *************************************************************/
21*b557fc96SAndrew Rist 
22*b557fc96SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_fpicker.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <tchar.h>
28cdf0e10cSrcweir #include "customcontrolfactory.hxx"
29cdf0e10cSrcweir #include "customcontrolcontainer.hxx"
30cdf0e10cSrcweir #include "dialogcustomcontrols.hxx"
31cdf0e10cSrcweir #include <osl/diagnose.h>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir //-----------------------------------
34cdf0e10cSrcweir //
35cdf0e10cSrcweir //-----------------------------------
36cdf0e10cSrcweir 
CreateCustomControl(HWND aControlHandle,HWND aParentHandle)37cdf0e10cSrcweir CCustomControl* CCustomControlFactory::CreateCustomControl(HWND aControlHandle, HWND aParentHandle)
38cdf0e10cSrcweir {
39cdf0e10cSrcweir 	OSL_PRECOND(IsWindow(aControlHandle),"Invalid control handle");
40cdf0e10cSrcweir 	OSL_PRECOND(IsWindow(aControlHandle),"Invalid parent handle");
41cdf0e10cSrcweir 
42cdf0e10cSrcweir 	// get window class
43cdf0e10cSrcweir 	// if static text create static text control etc.
44cdf0e10cSrcweir 
45cdf0e10cSrcweir     TCHAR aClsName[256];
46cdf0e10cSrcweir 	ZeroMemory(aClsName,sizeof(aClsName));
47cdf0e10cSrcweir     if (GetClassName(aControlHandle,aClsName,sizeof(aClsName)) == 0) {
48cdf0e10cSrcweir         OSL_ENSURE(false,"Invalid window handle");
49cdf0e10cSrcweir     }
50cdf0e10cSrcweir 
51cdf0e10cSrcweir     if (0 == _tcsicmp(aClsName,TEXT("button")))
52cdf0e10cSrcweir     {
53cdf0e10cSrcweir 		// button means many things so we have
54cdf0e10cSrcweir         // to find out what button it is
55cdf0e10cSrcweir         LONG lBtnStyle = GetWindowLong(aControlHandle,GWL_STYLE);
56cdf0e10cSrcweir 
57cdf0e10cSrcweir         if (lBtnStyle & BS_CHECKBOX)
58cdf0e10cSrcweir 			return new CCheckboxCustomControl(aControlHandle,aParentHandle);
59cdf0e10cSrcweir 
60cdf0e10cSrcweir         if ( ((lBtnStyle & BS_PUSHBUTTON) == 0) || (lBtnStyle & BS_DEFPUSHBUTTON))
61cdf0e10cSrcweir             return new CPushButtonCustomControl(aControlHandle,aParentHandle);
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 		return new CDummyCustomControl(aControlHandle,aParentHandle);
64cdf0e10cSrcweir     }
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 	if (0 == _tcsicmp(aClsName,TEXT("listbox")) || 0 == _tcsicmp(aClsName,TEXT("combobox")))
67cdf0e10cSrcweir 		return new CComboboxCustomControl(aControlHandle,aParentHandle);
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 	if (0 == _tcsicmp(aClsName,TEXT("static")))
70cdf0e10cSrcweir 		return new CStaticCustomControl(aControlHandle,aParentHandle);
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	return new CDummyCustomControl(aControlHandle,aParentHandle);
73cdf0e10cSrcweir }
74cdf0e10cSrcweir 
75cdf0e10cSrcweir //-----------------------------------
76cdf0e10cSrcweir //
77cdf0e10cSrcweir //-----------------------------------
78cdf0e10cSrcweir 
CreateCustomControlContainer()79cdf0e10cSrcweir CCustomControl* CCustomControlFactory::CreateCustomControlContainer()
80cdf0e10cSrcweir {
81cdf0e10cSrcweir 	return new CCustomControlContainer();
82cdf0e10cSrcweir }
83