1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     TenKey.h
4 
5   Copyright (C)2009-2012 Nintendo Co., Ltd.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Rev: 46365 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NN_COMMON_SCENE_TENKEY_H_
17 #define NN_COMMON_SCENE_TENKEY_H_
18 
19 #include <nn.h>
20 #include <nn/util/util_SizedEnum.h>
21 #include "GuiControlManager.h"
22 
23 namespace scene
24 {
25 
26 class TenKey
27 {
28 public:
29     enum State
30     {
31         STATE_NORMAL,    // Normal
32         STATE_OK,        // OK
33         STATE_CANCELLED, // Cancel.
34 
35         STATE_MAX
36     };
37 
38 public:
39     /* Please see man pages for details
40 
41     */
42     TenKey();
43 
44     /* Please see man pages for details
45 
46     */
47     virtual ~TenKey();
48 
49     /* Please see man pages for details
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61     */
62     void Initialize(u32 length, u32 split = 0, const wchar_t* pInitial = NULL, u32 numLowestChars = 1, bool isPassword = false);
63 
64     /* Please see man pages for details
65 
66     */
67     void Finalize();
68 
69     /* Please see man pages for details
70 
71     */
72     void Update();
73 
74     /* Please see man pages for details
75 
76     */
77     void Draw();
78 
79     /* Please see man pages for details
80 
81 
82 
83 
84     */
85     void Reset(const wchar_t* pInitial = NULL);
86 
87     /* Please see man pages for details
88 
89 
90 
91     */
SetState(State state)92     void SetState(State state) {m_state = state;}
93 
94     /* Please see man pages for details
95 
96 
97 
98     */
IsOK()99     bool IsOK() const {return (m_state == STATE_OK);}
100 
101     /* Please see man pages for details
102 
103 
104 
105     */
IsCancelled()106     bool IsCancelled() const {return (m_state == STATE_CANCELLED);}
107 
108     /* Please see man pages for details
109 
110 
111 
112     */
GetInput()113     const wchar_t* GetInput() const {return m_pInput;}
114 
115     /* Please see man pages for details
116 
117 
118 
119     */
120     u32 GetInputInteger() const;
121 
122     /* Please see man pages for details
123 
124 
125 
126     */
GetCursor()127     u32 GetCursor() const {return m_cursor;}
128 
129 protected:
130     // Event callback
131     static void MyControlEventCallback(scene::ControlEvent event, scene::ControlBase* pControl, s16 x, s16 y, void* pParam);
132 
133 protected:
134     // vtable 4byte exists in this position (keep in mind when adjusting padding)
135 
136     // Input characters
137     wchar_t* m_pInput;
138     // Number of characters
139     u32 m_length;
140     // Separation position
141     u32 m_split;
142     // Minimum number of characters
143     u32 m_numLowestChars;
144     // cursor position
145     u32 m_cursor;
146     // Status
147     nn::util::SizedEnum4<State> m_state;
148     // Password?
149     bool m_isPassword;
150     NN_PADDING3;
151     // GUI manager
152     scene::ControlManager m_controlManager;
153 };
154 
155 } // namespace scene
156 
157 #endif // NN_COMMON_SCENE_TENKEY_H_
158