hrev43750 adds 2 changesets to branch 'master' old head: 4ea3e0d3b8edc49382c8612c7957503d7145c914 new head: 484b565ad0fdcb239008c541f148ba5f8a4dc33a ---------------------------------------------------------------------------- d811612: CannaIM: can't display conversion candidate in KouhoWindow (#8300). * To display conversion candidate in KouhoWindow, we need to change skipping index bytes. In CannaInterface::GenerateKouhoString(), we have skipped 2 bytes as index before conversion candidate, but index is UTF8 FULL WIDTH NUMBERS, so we need to skip 3 bytes. * To show highlightRect correctly, change Invalidate(highlightRect) to Invalidate() in KouhoView::HighlightLine(). * Change BeOS's Haru font to VL PGothic (CannaLooper::ReadSettings() and KouhoWindow::KouhoWindow()). [ Murai Takashi <tmurai01@xxxxxxxxx> ] 484b565: CannaIM: style cleanup [ Jérôme Duval <jerome.duval@xxxxxxxxx> ] ---------------------------------------------------------------------------- 3 files changed, 150 insertions(+), 140 deletions(-) .../input_server/methods/canna/CannaInterface.cpp | 8 +- .../input_server/methods/canna/CannaLooper.cpp | 4 +- .../input_server/methods/canna/KouhoWindow.cpp | 278 ++++++++-------- ############################################################################ Commit: d8116125d1381d08510b36eedb20f1699fca9693 URL: http://cgit.haiku-os.org/haiku/commit/?id=d811612 Author: Murai Takashi <tmurai01@xxxxxxxxx> Date: Sat Feb 18 14:06:57 2012 UTC Committer: Jérôme Duval <jerome.duval@xxxxxxxxx> Commit-Date: Sat Feb 18 14:06:57 2012 UTC Ticket: https://dev.haiku-os.org/ticket/8300 CannaIM: can't display conversion candidate in KouhoWindow (#8300). * To display conversion candidate in KouhoWindow, we need to change skipping index bytes. In CannaInterface::GenerateKouhoString(), we have skipped 2 bytes as index before conversion candidate, but index is UTF8 FULL WIDTH NUMBERS, so we need to skip 3 bytes. * To show highlightRect correctly, change Invalidate(highlightRect) to Invalidate() in KouhoView::HighlightLine(). * Change BeOS's Haru font to VL PGothic (CannaLooper::ReadSettings() and KouhoWindow::KouhoWindow()). ---------------------------------------------------------------------------- diff --git a/src/add-ons/input_server/methods/canna/CannaInterface.cpp b/src/add-ons/input_server/methods/canna/CannaInterface.cpp index 3cdbbee..1fb2af3 100644 --- a/src/add-ons/input_server/methods/canna/CannaInterface.cpp +++ b/src/add-ons/input_server/methods/canna/CannaInterface.cpp @@ -593,14 +593,14 @@ SERIAL_PRINT(( "CannaInterface: GenerateKouhoStr() revPos = %d, revLen = %d, mod && kouhoRevLine != -1) || current_mode == CANNA_MODE_TourokuDicMode || current_mode == CANNA_MODE_BushuMode) { - // remove first index - memmove(kouhoUTF, kouhoUTF + 2, kouhoUTFLen - 1); + // remove first index (3 bytes) + memmove(kouhoUTF, kouhoUTF + 3, kouhoUTFLen - 2); - // convert full-space to LF + // convert full width space and following 3 bytes index to LF while ((index = strstr(kouhoUTF, "\xe3\x80\x80")) != NULL) { *index = '\x0a'; len = strlen(index); - memmove(index + 1, index + 5, len - 4); + memmove(index + 1, index + 6, len - 5); } kouhoUTFLen = strlen(kouhoUTF); } diff --git a/src/add-ons/input_server/methods/canna/CannaLooper.cpp b/src/add-ons/input_server/methods/canna/CannaLooper.cpp index 1d5641d..db7fc80 100644 --- a/src/add-ons/input_server/methods/canna/CannaLooper.cpp +++ b/src/add-ons/input_server/methods/canna/CannaLooper.cpp @@ -109,8 +109,8 @@ CannaLooper::ReadSettings(char* basePath) font_family family; font_style style; - strcpy(family, "Haru"); - strcpy(style, "Regular"); + strcpy(family, "VL PGothic"); + strcpy(style, "regular"); fKouhoFont.SetFamilyAndStyle(family, style); fKouhoFont.SetSize(12); diff --git a/src/add-ons/input_server/methods/canna/KouhoWindow.cpp b/src/add-ons/input_server/methods/canna/KouhoWindow.cpp index 2bc2f46..38cc36e 100644 --- a/src/add-ons/input_server/methods/canna/KouhoWindow.cpp +++ b/src/add-ons/input_server/methods/canna/KouhoWindow.cpp @@ -33,8 +33,8 @@ KouhoWindow::KouhoWindow( BFont *font, BLooper *looper ) font_family family; font_style style; - strcpy( family, "Haru" ); - strcpy( style, "Regular" ); + strcpy( family, "VL PGothic" ); + strcpy( style, "regular" ); indexfont.SetFamilyAndStyle( family, style ); indexfont.SetSize( 10 ); @@ -271,8 +271,7 @@ void KouhoView::HighlightLine( int32 line ) highlightRect = region.RectAt( 0 ); //extend highlihght region to right end highlightRect.right = Bounds().right; - Invalidate( highlightRect ); - + Invalidate(); } } ############################################################################ Revision: hrev43750 Commit: 484b565ad0fdcb239008c541f148ba5f8a4dc33a URL: http://cgit.haiku-os.org/haiku/commit/?id=484b565 Author: Jérôme Duval <jerome.duval@xxxxxxxxx> Date: Sat Feb 18 14:17:28 2012 UTC CannaIM: style cleanup ---------------------------------------------------------------------------- diff --git a/src/add-ons/input_server/methods/canna/KouhoWindow.cpp b/src/add-ons/input_server/methods/canna/KouhoWindow.cpp index 38cc36e..f25c208 100644 --- a/src/add-ons/input_server/methods/canna/KouhoWindow.cpp +++ b/src/add-ons/input_server/methods/canna/KouhoWindow.cpp @@ -16,13 +16,14 @@ #include "KouhoWindow.h" -KouhoWindow::KouhoWindow( BFont *font, BLooper *looper ) + +KouhoWindow::KouhoWindow(BFont *font, BLooper *looper) :BWindow( DUMMY_RECT, "kouho", B_MODAL_WINDOW_LOOK, B_FLOATING_ALL_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_AVOID_FOCUS | - B_NOT_ANCHORED_ON_ACTIVATE ) + B_NOT_ANCHORED_ON_ACTIVATE) { float fontHeight; BRect frame; @@ -33,59 +34,59 @@ KouhoWindow::KouhoWindow( BFont *font, BLooper *looper ) font_family family; font_style style; - strcpy( family, "VL PGothic" ); - strcpy( style, "regular" ); - indexfont.SetFamilyAndStyle( family, style ); - indexfont.SetSize( 10 ); + strcpy(family, "VL PGothic"); + strcpy(style, "regular"); + indexfont.SetFamilyAndStyle(family, style); + indexfont.SetSize(10); #ifdef DEBUG -SERIAL_PRINT(( "kouhoWindow: Constructor called.\n" )); +SERIAL_PRINT(("kouhoWindow: Constructor called.\n")); #endif //setup main pane - indexWidth = indexfont.StringWidth( "W" ) + INDEXVIEW_SIDE_MARGIN * 2; - minimumWidth = indexfont.StringWidth( "ギリシャ 100/100" ); + indexWidth = indexfont.StringWidth("W") + INDEXVIEW_SIDE_MARGIN * 2; + minimumWidth = indexfont.StringWidth("ギリシャ 100/100"); frame = Bounds(); frame.left = indexWidth + 2; frame.bottom -= INFOVIEW_HEIGHT; - kouhoView = new KouhoView( frame ); - BRect screenrect = BScreen( this ).Frame(); - kouhoView->SetTextRect( screenrect ); //big enough - kouhoView->SetFontAndColor( kouhoFont ); - kouhoView->SetWordWrap( false ); - AddChild( kouhoView ); + kouhoView = new KouhoView(frame); + BRect screenrect = BScreen(this).Frame(); + kouhoView->SetTextRect(screenrect); //big enough + kouhoView->SetFontAndColor(kouhoFont); + kouhoView->SetWordWrap(false); + AddChild(kouhoView); fontHeight = kouhoView->LineHeight(); frame = Bounds(); frame.right = indexWidth; frame.bottom = frame.bottom - INFOVIEW_HEIGHT + 1; - indexView = new KouhoIndexView( frame, fontHeight ); - indexView->SetFont( &indexfont ); - AddChild( indexView ); + indexView = new KouhoIndexView(frame, fontHeight); + indexView->SetFont(&indexfont); + AddChild(indexView); frame = Bounds(); frame.top = frame.bottom - INFOVIEW_HEIGHT + 1; - infoView = new KouhoInfoView( frame ); - infoView->SetFont( &indexfont ); - infoView->SetAlignment( B_ALIGN_RIGHT ); - AddChild( infoView ); + infoView = new KouhoInfoView(frame); + infoView->SetFont(&indexfont); + infoView->SetAlignment(B_ALIGN_RIGHT); + AddChild(infoView); } -void KouhoWindow::MessageReceived( BMessage* msg ) + +void +KouhoWindow::MessageReceived(BMessage* msg) { float height, width, x, y, w; BPoint point; BRect screenrect, frame; - switch( msg->what ) - { + switch(msg->what) { case KOUHO_WINDOW_HIDE: #ifdef DEBUG -SERIAL_PRINT(( "kouhoWindow: KOUHO_WINDOW_HIDE recieved.\n" )); +SERIAL_PRINT(("kouhoWindow: KOUHO_WINDOW_HIDE recieved.\n")); #endif - if ( !IsHidden() ) - { + if (!IsHidden()) { Hide(); standalone_mode = false; } @@ -93,7 +94,7 @@ SERIAL_PRINT(( "kouhoWindow: KOUHO_WINDOW_HIDE recieved.\n" )); case KOUHO_WINDOW_SHOW: #ifdef DEBUG -SERIAL_PRINT(( "kouhoWindow: KOUHO_WINDOW_SHOW recieved.\n" )); +SERIAL_PRINT(("kouhoWindow: KOUHO_WINDOW_SHOW recieved.\n")); #endif ShowWindow(); break; @@ -102,90 +103,88 @@ SERIAL_PRINT(( "kouhoWindow: KOUHO_WINDOW_SHOW recieved.\n" )); standalone_mode = true; frame = Frame(); screenrect = BScreen().Frame(); - frame.OffsetTo( gSettings.standalone_loc.x, gSettings.standalone_loc.y ); + frame.OffsetTo(gSettings.standalone_loc.x, gSettings.standalone_loc.y); x = screenrect.right - frame.right; y = screenrect.bottom - frame.bottom; - if ( x < 0 ) - frame.OffsetBy( x, 0 ); + if (x < 0) + frame.OffsetBy(x, 0); - if ( y < 0 ) - frame.OffsetBy( 0, y ); + if (y < 0) + frame.OffsetBy(0, y); gSettings.standalone_loc.x = frame.left; gSettings.standalone_loc.y = frame.top; point = frame.LeftTop(); - MoveTo( point ); + MoveTo(point); ShowWindow(); break; case KOUHO_WINDOW_SHOWAT: #ifdef DEBUG -SERIAL_PRINT(( "kouhoWindow: KOUHO_WINDOW_SHOWAT recieved.\n" )); +SERIAL_PRINT(("kouhoWindow: KOUHO_WINDOW_SHOWAT recieved.\n")); #endif - msg->FindPoint( "position", &point ); - msg->FindFloat( "height", &height ); - ShowAt( point, height ); + msg->FindPoint("position", &point); + msg->FindFloat("height", &height); + ShowAt(point, height); break; case KOUHO_WINDOW_SETTEXT: const char* newtext; bool hideindex, limitsize; - msg->FindString( "text", &newtext ); - kouhoView->SetText( newtext ); + msg->FindString("text", &newtext); + kouhoView->SetText(newtext); - msg->FindBool( "index", &hideindex ); - indexView->HideNumberDisplay( hideindex ); + msg->FindBool("index", &hideindex); + indexView->HideNumberDisplay(hideindex); - msg->FindBool( "limit", &limitsize ); - height = kouhoView->TextHeight( 0, kouhoView->TextLength() ); + msg->FindBool("limit", &limitsize); + height = kouhoView->TextHeight(0, kouhoView->TextLength()); height += INFOVIEW_HEIGHT; - msg->FindString( "info", &newtext ); - infoView->SetText( newtext ); + msg->FindString("info", &newtext); + infoView->SetText(newtext); // calculate widest line width width = 0; - for ( int32 line = 0, numlines = kouhoView->CountLines() ; - line < numlines ; line++ ) - { - w = kouhoView->LineWidth( line ); - if ( w > width ) + for (int32 line = 0, numlines = kouhoView->CountLines(); + line < numlines; line++) { + w = kouhoView->LineWidth(line); + if (w > width) width = w; } - if ( limitsize && width < minimumWidth ) + if (limitsize && width < minimumWidth) width = minimumWidth; - ResizeTo( width + indexWidth + KOUHOVIEW_SIDE_MARGIN, height ); + ResizeTo(width + indexWidth + KOUHOVIEW_SIDE_MARGIN, height); - if ( msg->HasBool( "partial" ) ) - { + if (msg->HasBool("partial")) { int32 begin, end; - msg->FindInt32( "revbegin", &begin ); - msg->FindInt32( "revend", &end ); - kouhoView->HighlightPartial( begin, end ); + msg->FindInt32("revbegin", &begin); + msg->FindInt32("revend", &end); + kouhoView->HighlightPartial(begin, end); #ifdef DEBUG -SERIAL_PRINT(( "kouhoWindow: KOUHO_WINDOW_SETTEXT(partial) received. rev = %d to %d\n", begin, end )); +SERIAL_PRINT(("kouhoWindow: KOUHO_WINDOW_SETTEXT(partial) received. rev = %d to %d\n", begin, end)); #endif - } - else - { + } else { int32 kouhorevline; - msg->FindInt32( "kouhorev", &kouhorevline ); - kouhoView->HighlightLine( kouhorevline ); + msg->FindInt32("kouhorev", &kouhorevline); + kouhoView->HighlightLine(kouhorevline); } break; case NUM_SELECTED_FROM_KOUHO_WIN: - cannaLooper->PostMessage( msg ); + cannaLooper->PostMessage(msg); break; default: - BWindow::MessageReceived( msg ); + BWindow::MessageReceived(msg); } } -void KouhoWindow::ShowAt( BPoint revpoint, float height ) + +void +KouhoWindow::ShowAt(BPoint revpoint, float height) { BRect screenrect; BPoint point; @@ -194,9 +193,9 @@ void KouhoWindow::ShowAt( BPoint revpoint, float height ) kouhowidth = Frame().IntegerWidth(); kouhoheight = Frame().IntegerHeight(); - screenrect = BScreen( this ).Frame(); + screenrect = BScreen(this).Frame(); #ifdef DEBUG -SERIAL_PRINT(( "KouhoWindow: ShowAt activated. point x= %f, y= %f, height= %f", revpoint.x, revpoint.y, height )); +SERIAL_PRINT(("KouhoWindow: ShowAt activated. point x= %f, y= %f, height= %f", revpoint.x, revpoint.y, height)); #endif //adjust to preferred position - considering window border & index //revpoint.y += WINDOW_BORDER_WIDTH; @@ -204,71 +203,73 @@ SERIAL_PRINT(( "KouhoWindow: ShowAt activated. point x= %f, y= %f, height= %f", point.x = revpoint.x - indexView->Frame().IntegerWidth() - INDEXVIEW_SIDE_MARGIN; - if ( point.y + kouhoheight > screenrect.bottom ) + if (point.y + kouhoheight > screenrect.bottom) point.y = revpoint.y - kouhoheight - WINDOW_BORDER_WIDTH_V; // else // point.y = revpoint.y + height; - if ( point.x + kouhowidth > screenrect.right ) - point.x = point.x - (screenrect.right - (point.x + kouhowidth )); + if (point.x + kouhowidth > screenrect.right) + point.x = point.x - (screenrect.right - (point.x + kouhowidth)); // point.x = revpoint.x -// - ( revpoint.x + kouhowidth + WINDOW_BORDER_WIDTH - screenrect.right ); +// - (revpoint.x + kouhowidth + WINDOW_BORDER_WIDTH - screenrect.right); // else // point.x = revpoint.x; - MoveTo( point ); + MoveTo(point); ShowWindow(); } + void -KouhoWindow::FrameMoved( BPoint screenPoint ) +KouhoWindow::FrameMoved(BPoint screenPoint) { - if ( standalone_mode ) + if (standalone_mode) gSettings.standalone_loc = screenPoint; - return; } + // ShowWindow() shows kouho window on current workspace // This is a bug fix for version 1.0 beta 2 void KouhoWindow::ShowWindow() { - if ( IsHidden() ) - { - SetWorkspaces( B_CURRENT_WORKSPACE ); + if (IsHidden()) { + SetWorkspaces(B_CURRENT_WORKSPACE); Show(); } } + /* KouhoView section */ -KouhoView::KouhoView( BRect rect ) - :BTextView( rect, "kouhoview", rect, B_FOLLOW_ALL, B_WILL_DRAW ) +KouhoView::KouhoView(BRect rect) + : BTextView(rect, "kouhoview", rect, B_FOLLOW_ALL, B_WILL_DRAW) { selection_color.red = 203; selection_color.green = 152; selection_color.blue = 255; } -void KouhoView::HighlightLine( int32 line ) + +void +KouhoView::HighlightLine(int32 line) { -//printf( "highlightLine set to :%d\n", line); +//printf("highlightLine set to :%d\n", line); int32 begin, end; BRegion region; - if ( line != -1 ) - { - begin = OffsetAt( line ); - if ( line == CountLines() - 1 ) + if (line != -1) { + begin = OffsetAt(line); + if (line == CountLines() - 1) end = TextLength() + 1; else - end = OffsetAt( line + 1 ) - 1; -//printf( "Highlight line:%d, offset %d-%d\n", line,begin,end); - GetTextRegion( begin, end, ®ion ); + end = OffsetAt(line + 1) - 1; +//printf("Highlight line:%d, offset %d-%d\n", line,begin,end); + GetTextRegion(begin, end, ®ion); //as hightlight is just one line, 0 is enough. - highlightRect = region.RectAt( 0 ); + highlightRect = region.RectAt(0); //extend highlihght region to right end highlightRect.right = Bounds().right; Invalidate(); @@ -276,67 +277,75 @@ void KouhoView::HighlightLine( int32 line ) } + void -KouhoView::HighlightPartial( int32 begin, int32 end ) +KouhoView::HighlightPartial(int32 begin, int32 end) { BRegion region; - GetTextRegion( begin, end, ®ion ); - highlightRect = region.RectAt( 0 ); - Invalidate( highlightRect ); + GetTextRegion(begin, end, ®ion); + highlightRect = region.RectAt(0); + Invalidate(highlightRect); } -void KouhoView::Draw( BRect rect ) + +void +KouhoView::Draw(BRect rect) { - BTextView::Draw( rect ); - rgb_color viewcolor = ViewColor(); - SetHighColor( selection_color ); - SetDrawingMode( B_OP_MIN ); - FillRect( highlightRect ); -// SetViewColor( viewcolor ); + BTextView::Draw(rect); +// rgb_color viewcolor = ViewColor(); + SetHighColor(selection_color); + SetDrawingMode(B_OP_MIN); + FillRect(highlightRect); +// SetViewColor(viewcolor); } -void KouhoView::MouseDown( BPoint point ) + +void +KouhoView::MouseDown(BPoint point) { KouhoIndexView *iview; - iview = (KouhoIndexView *)(Window()->FindView( "index" )); - if ( iview->IsNumberDisplayHidden() ) + iview = (KouhoIndexView *)(Window()->FindView("index")); + if (iview->IsNumberDisplayHidden()) return; int32 number; - number = LineAt( point ); - BMessage msg( NUM_SELECTED_FROM_KOUHO_WIN ); - msg.AddInt32( "modifiers", 0 ); - msg.AddInt8( "byte", (int8)number + '1' ); - Window()->PostMessage( &msg ); + number = LineAt(point); + BMessage msg(NUM_SELECTED_FROM_KOUHO_WIN); + msg.AddInt32("modifiers", 0); + msg.AddInt8("byte", (int8)number + '1'); + Window()->PostMessage(&msg); } + + /* KouhoIndexView section */ -KouhoIndexView::KouhoIndexView( BRect frame, float fontheight ) - :BBox( frame, "index", B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW ) +KouhoIndexView::KouhoIndexView(BRect frame, float fontheight) + : BBox(frame, "index", B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW) { font_height ht; float indexfontheight; lineHeight = fontheight; - be_plain_font->GetHeight( &ht ); + be_plain_font->GetHeight(&ht); indexfontheight = ht.ascent + ht.descent + ht.leading; - if ( indexfontheight < lineHeight ) + if (indexfontheight < lineHeight) fontOffset = (int32)((lineHeight - indexfontheight) / 2 + 1.5); -//printf("line height=%f, index font height=%f, offset=%d\n", lineHeight, indexfontheight, fontOffset ); +//printf("line height=%f, index font height=%f, offset=%d\n", lineHeight, indexfontheight, fontOffset); } -void KouhoIndexView::Draw( BRect rect ) + +void +KouhoIndexView::Draw(BRect rect) { - BBox::Draw( rect ); - for ( long i = 1; i < 17 ; i++ ) - { - MovePenTo( INDEXVIEW_SIDE_MARGIN + 2, lineHeight * i - fontOffset ); - if ( hideNumber ) - DrawString( "•" ); + BBox::Draw(rect); + for (long i = 1; i < 17; i++) { + MovePenTo(INDEXVIEW_SIDE_MARGIN + 2, lineHeight * i - fontOffset); + if (hideNumber) + DrawString("•"); else - DrawChar( '0' + i ); + DrawChar('0' + i); } } @@ -344,19 +353,21 @@ void KouhoIndexView::Draw( BRect rect ) // InfoView section // -KouhoInfoView::KouhoInfoView( BRect frame ) - :BStringView( frame, "infoview", "0/0", - B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM ) +KouhoInfoView::KouhoInfoView(BRect frame) + : BStringView(frame, "infoview", "0/0", + B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM) { } + void -KouhoInfoView::Draw( BRect rect ) +KouhoInfoView::Draw(BRect rect) { BPoint start, end; BRect bounds = Bounds(); start = B_ORIGIN; - end.Set( bounds.right, 0 ); - StrokeLine( start, end ); - BStringView::Draw( rect ); + end.Set(bounds.right, 0); + StrokeLine(start, end); + BStringView::Draw(rect); } +