"ä«»Ï" <[EMAIL PROTECTED]> writes:

| Hi.
| 
| The patch was split in two according to the instruction of Mr. Abdel.
| 
| "support_dashed_underline.patch" is a patch to
| support "dashed underline" and "reverse video".
| Moreover, "support_on_the_spot.patch" is a patch to support "on the
| spot" in cjk.

Index: src/frontends/Painter.h
===================================================================
--- src/frontends/Painter.h     (ƒŠƒrƒWƒ‡ƒ“ 17389)
+++ src/frontends/Painter.h     (ì‹ÆƒRƒs[)
@@ -162,6 +162,10 @@
        void underline(LyXFont const & f,
                int x, int y, int width);
 
+       /// check the font, and if set, draw an dashed underline
+       void dashedUnderline(LyXFont const &f,
+               int x, int y, int width);
+

Space after '&' please.

Index: src/frontends/qt4/QLPainter.C
===================================================================
--- src/frontends/qt4/QLPainter.C       (ƒŠƒrƒWƒ‡ƒ“ 17389)
+++ src/frontends/qt4/QLPainter.C       (ì‹ÆƒRƒs[)
@@ -52,19 +52,29 @@
 
 
 void QLPainter::setQPainterPen(LColor_color col,
-       Painter::line_style ls, Painter::line_width lw)
+       Painter::line_style ls, Painter::line_width lw, bool rv)
 {
-       if (col == current_color_ && ls == current_ls_ && lw == current_lw_)
+       // rv seems 'reverse video'.

Hmm da hmm... I realize that the other args to this function have
really terse names, but I do not think that is something to mimic.
Please change the whole variable name to be 'reverseVideo'.


+       static bool last_rv=false;

Spaces at both sides of '='

@@ -229,10 +239,16 @@
 
        QLFontInfo & fi = guiApp->guiFontLoader().fontinfo(f);
 
-       int textwidth;
+       int textwidth=fi.metrics->width(str);

ditto
 
+       if (f.dashedUnderbar() == LyXFont::ON) {
+               fillRectangle(x, y-fi.metrics->maxAscent(), textwidth, 
fi.metrics->maxHeight(), LColor::background);

Spaces at both sides of '-'

+       }
+       if (f.reverseVideo() == LyXFont::ON) {
+               fillRectangle(x, y-fi.metrics->maxAscent(), textwidth, 
fi.metrics->maxHeight(), f.realColor());

ditto

+       }
        if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
-               setQPainterPen(f.realColor());
+               setQPainterPen(f.realColor(), line_solid, line_thin,  
f.reverseVideo()==LyXFont::ON);

Spaces at both sides of '=='

                if (font() != fi.font)
                        setFont(fi.font);
                // We need to draw the text as LTR as we use our own bidi code.
@@ -261,11 +277,15 @@
                // Here we use the font width cache instead of
                //   textwidth = fontMetrics().width(str);
                // because the above is awfully expensive on MacOSX
-               textwidth = fi.metrics->width(str);
+//             textwidth = fi.metrics->width(str);

If the line is not wanted anymore, is wrong etc. We should just remove
the whole thing.

        } else {
                textwidth = smallCapsText(x, y, str, f);
        }
 
+       if (f.dashedUnderbar() == LyXFont::ON) {
+               dashedUnderline(f, x, y, textwidth);
+       }
+       else

'else' and 'if' on the same line please.

        if (f.underbar() == LyXFont::ON) {
                underline(f, x, y, textwidth);
        }

Index: src/lyxfont.h
===================================================================
--- src/lyxfont.h       (ƒŠƒrƒWƒ‡ƒ“ 17389)
+++ src/lyxfont.h       (ì‹ÆƒRƒs[)
@@ -182,6 +182,10 @@
                FONT_MISC_STATE noun;
                ///
                FONT_MISC_STATE number;
+               ///
+               FONT_MISC_STATE dashedUnderbar;
+               ///
+               FONT_MISC_STATE reverse;

reverseVideo

        };
        ///
        LyXFont();
 



Index: src/frontends/qt4/GuiWorkArea.C
===================================================================
--- src/frontends/qt4/GuiWorkArea.C     (ƒŠƒrƒWƒ‡ƒ“ 17389)
+++ src/frontends/qt4/GuiWorkArea.C     (ì‹ÆƒRƒs[)
@@ -206,6 +208,8 @@
        // Enables input methods for asian languages.
        // Must be set when creating custom text editing widgets.
        setAttribute(Qt::WA_InputMethodEnabled, true);
+
+       preedit_lines_ = 1;

Is this in the constructor? If so I guess the assignment should be put
in the initialization list.

 }
 
 
@@ -572,6 +578,11 @@
 void GuiWorkArea::inputMethodEvent(QInputMethodEvent * e)
 {
        QString const & text = e->commitString();
+       QString const & text2 = e->preeditString();

I'd really like a more descriptive name for the preedit string instead
of just 'text2'. 'preedString' perhaps? (or 'preedText')


@@ -598,9 +609,135 @@
                        keyPressEvent(&ev);
                }
        }
+
+       // FIXME M. Iwami 03/01/07: Just about everything support for Japanese,
+       // and maybe can support for CJK.
+       // But this code is not follow the object-orientation.
+       // Please fix me.
+
+       // Hide the cursor while the kana-kanji transformation. 
+       if (text2.isEmpty())
+               startBlinkingCursor();
+       else
+               stopBlinkingCursor();
+
+       // if last_width is last length of preedit string. 
+       static int last_width = 0;
+       if (last_width || !text2.isEmpty()) {
+               QLPainter pain(&screen_);
+               buffer_view_->updateMetrics(false);
+               paintText(*buffer_view_, pain);
+               LyXFont font(buffer_view_->cursor().getFont());
+               FontMetrics const & fm(theFontMetrics(font));
+               lyx::docstring text3(qstring_to_ucs4(text2));

Ahh 'text3' :-) Better name please. And drop the 'lyx::' prefix, also
prefere 'string a = "foo";' over 'string a("foo")', it is most often
easier to read. esp when the args gets complicated.
(same goes for 'font' above)

+               int ascent=fm.maxAscent();
+               int descent=fm.maxDescent();
+               int height=fm.maxHeight();

Spaces on boths sides of '='.

+               int cur_x = cursor_->rect().left();
+               int cur_y = cursor_->rect().bottom();
+
+               // redraw area of preedit string.
+               update(0, cur_y-height, GuiWorkArea::width(),
(height+1)*preedit_lines_);

Spaces on both sides of '-', '+' and '*'

+
+               if (!text2.isEmpty()) {
+                       last_width = 1;
+                       int cur_pos=0;
+                       int rStart=0;
+                       int rLength=0;
+                       int cur_visible=0;

of '=' as well.

+                       const QList<QInputMethodEvent::Attribute> & 
att(e->attributes());
+
+                       // get attributes of curor that related input method.
+                       for (int i = 0; i < att.size(); ++i) {
+                               if (att.at(i).type == 
QInputMethodEvent::Cursor) {
+                                       cur_pos = att.at(i).start;
+                                       cur_visible = att.at(i).length;
+                                       break;
+                               }
+                       }
+                       // get possition of selected in input method.
+                       if (cur_pos < e->preeditString().length()) {

Has 'e' changed? Isn't this 'e->preeditString()' still the same as
text2?

[... snip ...]

+                       }
+                       else {
+                               rStart = cur_pos;
+                               rLength = 0;
+                       }
+
+                       int rightMargin = lyx::rightMargin();

I think this can be const.

+                       docstring::const_iterator begin = text3.begin();
+                       docstring::const_iterator end = text3.end();
+                       docstring::const_iterator cit = text3.begin();
+                       font.setDashedUnderbar(LyXFont::ON);
+                       font.setReverseVideo(LyXFont::OFF);
+                       for (preedit_lines_ = 1; cit != end; ++cit) {
+                               // preedit strings display with dashed 
underline.
+                               // and  partial strings are reverse video that 
selecting in input method.
+                               if (cit >= begin + rStart &&
+                                       cit < begin + rStart + rLength) {
+                                               
font.setReverseVideo(LyXFont::ON);
+                               }
+                               else {
+                                       font.setReverseVideo(LyXFont::OFF);
+                               }
+                               if (cur_pos < rLength && rLength ==
text3.length() )

extra space after ')', just remove it.

+                                       font.setReverseVideo(LyXFont::OFF);
+                               if (cit == begin + cur_pos) {
+                                       font.setUnderbar(LyXFont::ON);
+                                       font.setDashedUnderbar(LyXFont::OFF);
+                               }
+                               else {
+                                       font.setUnderbar(LyXFont::OFF);
+                                       font.setDashedUnderbar(LyXFont::ON);
+                               }
+
+                               // if make it to right extremity, go to next 
line.
+                               if (cur_x + fm.width(*cit) > 
GuiWorkArea::width() - rightMargin) {
+                                       cur_x = rightMargin;
+                                       cur_y += height+1;

space around '+'

+                                       ++preedit_lines_;
+                               }
+                               // draw one character and update cur_x.
+                               cur_x += pain.text(cur_x, cur_y-descent+1, 
*cit, font);

space around '-' and '+'

+                       }
+                       // redraw preedit strings.
+                       update(0, cur_y-preedit_lines_*height, 
GuiWorkArea::width(), (height+1)*preedit_lines_);

ditto + '*'

+               } else {
+                       last_width = 0;
+                       preedit_lines_ = 1;
+               }
+       }
+
        e->accept();
 }
 
+QVariant GuiWorkArea::inputMethodQuery(Qt::InputMethodQuery query) const
+{
+       QRect cur_r(0,0,0,0);
+       switch (query) {
+               // this is nomination window possition.

I do not quite understand this comment, can you expand a bit on it
please?

+               // return lower right of cursor in LyX.
+               case Qt::ImMicroFocus:
+                       cur_r = cursor_->rect();
+                       if (preedit_lines_ != 1)
+                               cur_r.moveLeft(10);
+                       cur_r.moveBottom(cur_r.bottom() + 
cur_r.height()*preedit_lines_);

space on both sides of '*',  please.

+                       return cur_r;
+               default:
+                       return QWidget::inputMethodQuery(query);
+       }
+}
+
 } // namespace frontend
 } // namespace lyx
 
-- 
        Lgb

Reply via email to