Hello, 

In my search of the position parameters of the cursor owned by the local 
Input Method in tabular, footnote and note insets, I've got now some results 
and a couple of questions. 
First, the results: I can now put local Input method cursor at the right 
position on those three insets. Furthermore, I have figured out how to put 
the local cursor on the embedded insets. But as the the number of layers of 
embedding gets large, the code gets long and I need some advice from expert 
coders of how to make the code simpler. Attached is the code with which I can 
put local cursor at the right position on up to 2 layers of embedded 
insets. The problem is how to generalize to arbitrary number of layers.

My second problem is with regard to the tabular inset. When the table menu 
is clicked, table appears on the lyx main window. And at this moment, no 
"red square" appears on any of the tabular cells. However when I press, 
for example, "a" key, the signal from the keyboard opens the default cell, 
which is the first cell, with the "red circle" and the letter 'a' is put 
inside the "red circle". However, this does not work when I try to input 
CJK-characters. In this case, the keyboard signals does not directly enter 
the lyx, but goes to local Input Method server to precompose 
CJK-characters, and when the precomposition is done I hit "space bar" key, 
which triggers two signals(the composed CJK-chars and the 'space bar') 
enter the lyx. I find that somehow in this process, the composed CJK-chars 
miss the tabular cell and is put on the lyx main window(just outside of 
the first cell), while the second 'space bar' signal opens the default 
cell with the "red sqaure" on it. Do I make myself clear here?

Angus, you know about these two signal thing, right? Have any idea how to 
solve ?

Any kind of inputs, suggestion, advice, hints and even questions are 
heartedly welcome!


Regards,



cghan
          
void LyXIM::SpotandFont()
{
     UpdatableInset * inset = current_view->theLockingInset();

     if(inset)
     {
        LyXCursor const & cursor(BufferView *);

        if(inset->lyxCode()==Inset::TABULAR_CODE) {

           InsetTabular * inset_tab = static_cast<InsetTabular *>(inset);
           int actcell = inset_tab->getActCell();
           UpdatableInset * tab_inset = static_cast<UpdatableInset 
*>(inset_tab->tabular->GetCellInset(actcell));

           if(tab_inset->getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
           InsetTabular * tab_inset_tab = static_cast<InsetTabular *>(tab_inset->
                                                               
getFirstLockingInsetOfType(Inset::TABULAR_CODE));
           int tab_actcell = tab_inset_tab->getActCell();
           Inset * tab_tab_inset = tab_inset_tab->tabular->GetCellInset(tab_actcell);
           LyXText * lt = tab_tab_inset->getLyXText(current_view);

           preeditspot.x  = current_view->xpos() + tab_tab_inset->x() + 
lt->cursor.ix() + 2 ;
           preeditspot.y  = current_view->ypos() + tab_tab_inset->y() + lt->cursor.y() 
- lt->cursor.irow()->ascent_of_text();
           }
           else if (inset_tab->getFirstLockingInsetOfType(Inset::IGNORE_CODE)!=0) {
             Inset * inset_tab_no 
=inset_tab->getFirstLockingInsetOfType(Inset::IGNORE_CODE);
             LyXText * lt = inset_tab_no->getLyXText(current_view);
             preeditspot.x  = current_view->xpos() + inset_tab_no->x() + 
lt->cursor.ix() + 2;
             preeditspot.y  = current_view->ypos() + inset_tab_no->y() + 
lt->cursor.iy() + lt->cursor.irow()->height()- lt->cursor.irow()->baseline() + 3;
             }
           else if (inset_tab->getFirstLockingInsetOfType(Inset::FOOT_CODE)!=0) {
             Inset * inset_tab_foot 
=inset_tab->getFirstLockingInsetOfType(Inset::FOOT_CODE);
             LyXText * lt = inset_tab_foot->getLyXText(current_view);
             preeditspot.x  = current_view->xpos() + inset_tab_foot->x() + 
lt->cursor.ix() + 2;
             preeditspot.y  = current_view->ypos() + inset_tab_foot->y() + 
lt->cursor.iy() + lt->cursor.irow()->height()- lt->cursor.irow()->baseline() + 3;
             }
           else {
           int actcell = inset_tab->getActCell();
           Inset * tab_inset = inset_tab->tabular->GetCellInset(actcell);
           LyXText * lt = tab_inset->getLyXText(current_view);

           preeditspot.x  = current_view->xpos() + tab_inset->x() + lt->cursor.ix() + 
2 ;
           preeditspot.y  = current_view->ypos() + tab_inset->y() + lt->cursor.y() - 
lt->cursor.irow()->ascent_of_text();

          }
        }
        else if(inset->getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
           InsetTabular * inset_tab = static_cast<InsetTabular *>(inset->
                                                               
getFirstLockingInsetOfType(Inset::TABULAR_CODE));
           int actcell = inset_tab->getActCell();
           Inset * tab_inset = inset_tab->tabular->GetCellInset(actcell);
           LyXText * lt = tab_inset->getLyXText(current_view);

           preeditspot.x  = current_view->xpos() + tab_inset->x() + lt->cursor.ix() + 
2 ;
           preeditspot.y  = current_view->ypos() + tab_inset->y() + lt->cursor.y() - 
lt->cursor.irow()->ascent_of_text();
          }
        else if (inset->lyxCode()==Inset::IGNORE_CODE) {
             UpdatableInset * inset_no =inset;

             if (inset_no->getFirstLockingInsetOfType(Inset::IGNORE_CODE)!=0) {
             Inset * inset_no_no 
=inset_no->getFirstLockingInsetOfType(Inset::IGNORE_CODE);
             LyXText * lt = inset_no_no->getLyXText(current_view);
             preeditspot.x  = current_view->xpos() + inset_no_no->x() + 
lt->cursor.ix() + 2;
             preeditspot.y  = current_view->ypos() + inset_no_no->y() + 
lt->cursor.iy() + lt->cursor.irow()->height()- lt->cursor.irow()->baseline() + 3;
             }
             if (inset_no->getFirstLockingInsetOfType(Inset::FOOT_CODE)!=0) {
             Inset * inset_no_foot 
=inset_no->getFirstLockingInsetOfType(Inset::FOOT_CODE);
             LyXText * lt = inset_no_foot->getLyXText(current_view);
             preeditspot.x  = current_view->xpos() + inset_no_foot->x() + 
lt->cursor.ix() + 2;
             preeditspot.y  = current_view->ypos() + inset_no_foot->y() + 
lt->cursor.iy() + lt->cursor.irow()->height()- lt->cursor.irow()->baseline() + 3;
            }
            else {
             LyXText * lt = inset_no->getLyXText(current_view);
             preeditspot.x  = current_view->xpos() + inset_no->x() + lt->cursor.ix() + 
2;
             preeditspot.y  = current_view->ypos() + inset_no->y() + lt->cursor.iy() + 
lt->cursor.irow()->height()- lt->cursor.irow()->baseline() + 3;
            }
        }
        else if (inset->lyxCode()==Inset::FOOT_CODE) {
             UpdatableInset * inset_foot =inset;

             if (inset_foot->getFirstLockingInsetOfType(Inset::IGNORE_CODE)!=0) {
             Inset * inset_foot_no 
=inset_foot->getFirstLockingInsetOfType(Inset::IGNORE_CODE);
             LyXText * lt = inset_foot_no->getLyXText(current_view);
             preeditspot.x  = current_view->xpos() + inset_foot_no->x() + 
lt->cursor.ix() + 2;
             preeditspot.y  = current_view->ypos() + inset_foot_no->y() + 
lt->cursor.iy() + lt->cursor.irow()->height()- lt->cursor.irow()->baseline() + 3;
             }
             else {

             LyXText * lt = inset_foot->getLyXText(current_view);
             preeditspot.x  = current_view->xpos() + inset_foot->x() + lt->cursor.ix() 
+ 2;
             preeditspot.y  = current_view->ypos() + inset_foot->y() + lt->cursor.iy() 
+ lt->cursor.irow()->height()- lt->cursor.irow()->baseline() + 3;
            }
        }
        else if (inset->getFirstLockingInsetOfType(Inset::IGNORE_CODE)!=0) {
             Inset * inset_no =inset->getFirstLockingInsetOfType(Inset::IGNORE_CODE);
             LyXText * lt = inset_no->getLyXText(current_view);
             preeditspot.x  = current_view->xpos() + inset_no->x() + lt->cursor.ix() + 
2;
             preeditspot.y  = current_view->ypos() + inset_no->y() + lt->cursor.iy() + 
lt->cursor.irow()->height()- lt->cursor.irow()->baseline() + 3;
            }
        else if (inset->getFirstLockingInsetOfType(Inset::FOOT_CODE)!=0) {
             Inset * inset_foot =inset->getFirstLockingInsetOfType(Inset::FOOT_CODE);
             LyXText * lt = inset_foot->getLyXText(current_view);
             preeditspot.x  = current_view->xpos() + inset_foot->x() + lt->cursor.ix() 
+ 2;
             preeditspot.y  = current_view->ypos() + inset_foot->y() + lt->cursor.iy() 
+ lt->cursor.irow()->height()- lt->cursor.irow()->baseline() + 3;
            }
        else {

                 LyXText * lt = inset->getLyXText(current_view);
                 preeditspot.x  = current_view->xpos() + inset->x() + lt->cursor.ix() 
+ 2;
                 preeditspot.y  = current_view->ypos() + inset->y() + lt->cursor.iy() 
+ lt->cursor.irow()->height()- lt->cursor.irow()->baseline() + 3;
            }
        }

   else{


        preeditspot.x  =  current_view->text->cursor.x() + current_view->xpos();
        preeditspot.y  = current_view->text->cursor.y() + current_view->ypos()
            - current_view->text->first_y;
     }

        current_font = current_view->text->real_current_font;
        current_fontset= fontloader.load(current_font.family(),current_font.series(),
                                                
current_font.shape(),current_font.size());
}

Reply via email to