1 |
t-suwa |
5 |
/* -*- ObjC -*- |
2 |
|
|
|
3 |
|
|
MacOS X implementation of the SKK input method. |
4 |
|
|
|
5 |
|
|
Copyright (C) 2008 Tomotaka SUWA <t.suwa@mac.com> |
6 |
|
|
|
7 |
|
|
This program is free software; you can redistribute it and/or modify |
8 |
|
|
it under the terms of the GNU General Public License as published by |
9 |
|
|
the Free Software Foundation; either version 2 of the License, or |
10 |
|
|
any later version. |
11 |
|
|
|
12 |
|
|
This program is distributed in the hope that it will be useful, |
13 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
GNU General Public License for more details. |
16 |
|
|
|
17 |
|
|
You should have received a copy of the GNU General Public License |
18 |
|
|
along with this program; if not, write to the Free Software |
19 |
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 |
|
|
|
21 |
|
|
*/ |
22 |
|
|
|
23 |
|
|
#include "MacInputModeWindow.h" |
24 |
|
|
#include "SKKFrontEnd.h" |
25 |
|
|
#include "InputModeWindowController.h" |
26 |
|
|
#include <iostream> |
27 |
|
|
|
28 |
|
|
MacInputModeWindow::MacInputModeWindow(SKKFrontEnd* frontend) |
29 |
|
|
: active_(false), |
30 |
|
|
frontend_(frontend), |
31 |
|
|
mode_(HirakanaInputMode) { |
32 |
|
|
controller_ = [InputModeWindowController sharedController]; |
33 |
|
|
[controller_ changeMode:mode_]; |
34 |
|
|
} |
35 |
|
|
|
36 |
|
|
void MacInputModeWindow::SelectInputMode(SKKInputMode mode) { |
37 |
|
|
if(mode_ != mode) { |
38 |
|
|
mode_ = mode; |
39 |
|
|
|
40 |
|
|
if(active_) Activate(); |
41 |
|
|
} |
42 |
|
|
} |
43 |
|
|
|
44 |
|
|
void MacInputModeWindow::Show() { |
45 |
|
|
Activate(); |
46 |
|
|
} |
47 |
|
|
|
48 |
|
|
void MacInputModeWindow::Activate() { |
49 |
|
|
active_ = true; |
50 |
|
|
|
51 |
|
|
std::pair<int, int> position = frontend_->WindowPosition(); |
52 |
|
|
int level = frontend_->WindowLevel(); |
53 |
|
|
|
54 |
|
|
[controller_ changeMode:mode_]; |
55 |
|
|
[controller_ show:NSMakePoint(position.first, position.second) level:level]; |
56 |
|
|
} |
57 |
|
|
|
58 |
|
|
void MacInputModeWindow::Deactivate() { |
59 |
|
|
[controller_ hide]; |
60 |
|
|
|
61 |
|
|
active_ = false; |
62 |
|
|
} |