9c898c777a3ecf8ab57b4bfde24e14b2819a491a
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / check-box-button-impl.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include "check-box-button-impl.h"
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/type-registry.h>
23
24 // INTERNAL INCLUDES
25 #include "check-box-button-default-painter-impl.h"
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 namespace Internal
34 {
35
36 namespace
37 {
38
39 BaseHandle Create()
40 {
41   return Toolkit::CheckBoxButton::New();
42 }
43
44 TypeRegistration mType( typeid(Toolkit::CheckBoxButton), typeid(Toolkit::Button), Create );
45
46 }
47
48 Dali::Toolkit::CheckBoxButton CheckBoxButton::New()
49 {
50   // Create the implementation, temporarily owned on stack
51   IntrusivePtr< CheckBoxButton > internalCheckBoxButton = new CheckBoxButton();
52
53   // Pass ownership to CustomActor
54   Dali::Toolkit::CheckBoxButton checkBoxButton( *internalCheckBoxButton );
55
56   // Second-phase init of the implementation
57   // This can only be done after the CustomActor connection has been made...
58   internalCheckBoxButton->Initialize();
59
60   return checkBoxButton;
61 }
62
63 CheckBoxButton::CheckBoxButton()
64 : Button()
65 {
66   // Creates specific painter.
67   ButtonPainterPtr painter = new CheckBoxButtonDefaultPainter();
68   SetPainter( painter );
69
70   SetTogglableButton( true );
71 }
72
73 CheckBoxButton::~CheckBoxButton()
74 {
75   SetPainter( NULL );
76 }
77
78 } // namespace Internal
79
80 } // namespace Toolkit
81
82 } // namespace Dali