bin/pc: Mark non-returning function as void
[haiku.git] / src / servers / input / BottomlineWindow.cpp
blob49dc457c4ac573abee1475b7b094b680eaff5cd5
1 /*
2 * Copyright 2004-2005, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Jérôme Duval
7 */
10 #include "BottomlineWindow.h"
11 #include "WindowPrivate.h"
13 #include <String.h>
14 #include <TextView.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);
29 AddChild(fTextView);
31 fTextView->SetText("");
33 BRect screenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame());
34 BPoint pt;
35 pt.x = 100;
36 pt.y = screenFrame.Height()*2/3 - Bounds().Height()/2;
38 MoveTo(pt);
39 Show();
41 SERIAL_PRINT(("BottomlineWindow created\n"));
45 BottomlineWindow::~BottomlineWindow()
52 void
53 BottomlineWindow::MessageReceived(BMessage *msg)
55 switch(msg->what)
57 default:
58 BWindow::MessageReceived(msg);
59 break;
64 bool
65 BottomlineWindow::QuitRequested()
67 return true;
71 void
72 BottomlineWindow::HandleInputMethodEvent(BMessage* event, EventList& newEvents)
74 CALLED();
76 PostMessage(event, fTextView);
78 const char* string;
79 bool confirmed;
80 int32 opcode;
81 if (event->FindInt32("be:opcode", &opcode) != B_OK
82 || opcode != B_INPUT_METHOD_CHANGED
83 || event->FindBool("be:confirmed", &confirmed) != B_OK
84 || !confirmed
85 || event->FindString("be:string", &string) != B_OK)
86 return;
88 SERIAL_PRINT(("IME : %" B_PRId32 ", %s\n", opcode, string));
89 SERIAL_PRINT(("IME : confirmed\n"));
91 int32 length = strlen(string);
92 int32 offset = 0;
93 int32 nextOffset = 0;
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);
110 offset = nextOffset;