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 #include <tchar.h>
28 #include "customcontrolfactory.hxx"
29 #include "customcontrolcontainer.hxx"
30 #include "dialogcustomcontrols.hxx"
31 #include <osl/diagnose.h>
32 
33 //-----------------------------------
34 //
35 //-----------------------------------
36 
CreateCustomControl(HWND aControlHandle,HWND aParentHandle)37 CCustomControl* CCustomControlFactory::CreateCustomControl(HWND aControlHandle, HWND aParentHandle)
38 {
39 	OSL_PRECOND(IsWindow(aControlHandle),"Invalid control handle");
40 	OSL_PRECOND(IsWindow(aControlHandle),"Invalid parent handle");
41 
42 	// get window class
43 	// if static text create static text control etc.
44 
45     TCHAR aClsName[256];
46 	ZeroMemory(aClsName,sizeof(aClsName));
47     if (GetClassName(aControlHandle,aClsName,sizeof(aClsName)) == 0) {
48         OSL_ENSURE(false,"Invalid window handle");
49     }
50 
51     if (0 == _tcsicmp(aClsName,TEXT("button")))
52     {
53 		// button means many things so we have
54         // to find out what button it is
55         LONG lBtnStyle = GetWindowLong(aControlHandle,GWL_STYLE);
56 
57         if (lBtnStyle & BS_CHECKBOX)
58 			return new CCheckboxCustomControl(aControlHandle,aParentHandle);
59 
60         if ( ((lBtnStyle & BS_PUSHBUTTON) == 0) || (lBtnStyle & BS_DEFPUSHBUTTON))
61             return new CPushButtonCustomControl(aControlHandle,aParentHandle);
62 
63 		return new CDummyCustomControl(aControlHandle,aParentHandle);
64     }
65 
66 	if (0 == _tcsicmp(aClsName,TEXT("listbox")) || 0 == _tcsicmp(aClsName,TEXT("combobox")))
67 		return new CComboboxCustomControl(aControlHandle,aParentHandle);
68 
69 	if (0 == _tcsicmp(aClsName,TEXT("static")))
70 		return new CStaticCustomControl(aControlHandle,aParentHandle);
71 
72 	return new CDummyCustomControl(aControlHandle,aParentHandle);
73 }
74 
75 //-----------------------------------
76 //
77 //-----------------------------------
78 
CreateCustomControlContainer()79 CCustomControl* CCustomControlFactory::CreateCustomControlContainer()
80 {
81 	return new CCustomControlContainer();
82 }
83