2 * Copyright 2004-2005, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
10 #include "BottomlineWindow.h"
11 #include "WindowPrivate.h"
17 BottomlineWindow::BottomlineWindow()
18 : BWindow(BRect(0, 0, 350, 16), "",
19 kLeftTitledWindowLook
,
20 B_FLOATING_ALL_WINDOW_FEEL
,
21 B_NOT_V_RESIZABLE
| B_NOT_CLOSABLE
| B_NOT_ZOOMABLE
| B_NOT_MINIMIZABLE
22 | B_AVOID_FOCUS
| B_WILL_ACCEPT_FIRST_CLICK
)
24 BRect textRect
= Bounds();
25 textRect
.OffsetTo(B_ORIGIN
);
26 textRect
.InsetBy(2,2);
27 fTextView
= new BTextView(Bounds(), "", textRect
, be_plain_font
,
28 NULL
, B_FOLLOW_ALL
, B_WILL_DRAW
| B_FRAME_EVENTS
);
31 fTextView
->SetText("");
33 BRect screenFrame
= (BScreen(B_MAIN_SCREEN_ID
).Frame());
36 pt
.y
= screenFrame
.Height()*2/3 - Bounds().Height()/2;
41 SERIAL_PRINT(("BottomlineWindow created\n"));
45 BottomlineWindow::~BottomlineWindow()
53 BottomlineWindow::MessageReceived(BMessage
*msg
)
58 BWindow::MessageReceived(msg
);
65 BottomlineWindow::QuitRequested()
72 BottomlineWindow::HandleInputMethodEvent(BMessage
* event
, EventList
& newEvents
)
76 PostMessage(event
, fTextView
);
81 if (event
->FindInt32("be:opcode", &opcode
) != B_OK
82 || opcode
!= B_INPUT_METHOD_CHANGED
83 || event
->FindBool("be:confirmed", &confirmed
) != B_OK
85 || event
->FindString("be:string", &string
) != B_OK
)
88 SERIAL_PRINT(("IME : %" B_PRId32
", %s\n", opcode
, string
));
89 SERIAL_PRINT(("IME : confirmed\n"));
91 int32 length
= strlen(string
);
95 while (offset
< length
) {
96 // this is supposed to go to the next UTF-8 character
97 for (++nextOffset
; (string
[nextOffset
] & 0xC0) == 0x80; ++nextOffset
)
100 BMessage
*newEvent
= new BMessage(B_KEY_DOWN
);
101 if (newEvent
!= NULL
) {
102 newEvent
->AddInt32("key", 0);
103 newEvent
->AddInt64("when", system_time());
104 BString
bytes(string
+ offset
, nextOffset
- offset
);
105 newEvent
->AddString("bytes", bytes
);
106 newEvent
->AddInt32("raw_char", 0xa);
107 newEvents
.AddItem(newEvent
);