]> git.lyx.org Git - features.git/commitdiff
InsetText draw-update fixes, implemented edit-table-menu, patch from Baruch.
authorJürgen Vigna <jug@sad.it>
Tue, 1 Aug 2000 09:35:42 +0000 (09:35 +0000)
committerJürgen Vigna <jug@sad.it>
Tue, 1 Aug 2000 09:35:42 +0000 (09:35 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@942 a592a061-630c-0410-9148-cb99ea01b6c8

12 files changed:
ChangeLog
lib/ui/default.ui
src/LyXAction.C
src/commandtags.h
src/frontends/xforms/Makefile.am
src/frontends/xforms/RadioButtonGroup.C
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/lyxfunc.C
src/text.C
src/text2.C

index bfd2adaed4c6cda83e06d07cbe6985c4441d6302..320c9c8afe72ad0138cedc83229bdd4ba96fe949 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2000-08-01  Juergen Vigna  <jug@sad.it>
+
+       * src/commandtags.h: 
+       * src/LyXAction.C (init): added LFUN_LAYOUT_TABULAR and
+       LFUN_TABULAR_FEATURES.
+
+       * src/lyxfunc.C (getStatus): implemented LFUN_TABULAR_FEATURES and
+       LFUN_LAYOUT_TABULAR.
+
+       * src/insets/insettabular.C (getStatus): implemented helper function.
+
+       * lib/ui/default.ui: implemented edit-table-menu and layout-tabular.
+
+2000-07-31  Juergen Vigna  <jug@sad.it>
+
+       * src/text.C (draw): fixed screen update problem for text-insets.
+
+       * src/text2.C (SetParagrpah): call an update of the inset-owner when
+       something changed probably this has to be added in various other
+       functions too.
+
+       * src/insets/insettext.C (cy): fixed to give back the right cursor.y().
+
+2000-07-31  Baruch Even <baruch.even@writeme.com>
+
+       * src/frontends/xforms/RadioButtonGroup.C: Changed to use home-brew
+       templates to satisfy compaq cxx.
+
+
 2000-07-31  Lars Gullik Bjønnes  <larsbj@lyx.org>
 
        * src/support/translator.h (equal_1st_in_pair::operator()): take
index a44af92f4734b5344c09df4efeab237f1bf22a10..f21874e8ddb5225512bdcac0649bd40001ee866e 100644 (file)
@@ -106,6 +106,26 @@ Menuset
     End
 
     Menu "edit_table"
+       Item "Multicolumn|M" "tabular-feature multicolumn"
+       Separator
+       Item "Line Top|T" "tabular-feature toggle-line-top"
+       Item "Line Bottom|B" "tabular-feature toggle-line-bottom"
+       Item "Line Left|L" "tabular-feature toggle-line-left"
+       Item "Line Right|R" "tabular-feature toggle-line-right"
+       Separator
+       Item "Align Left|e" "tabular-feature align-left"
+       Item "Align Center|C" "tabular-feature align-center"
+       Item "Align Right|i" "tabular-feature align-right"
+       Separator
+       Item "V.Align Top|o" "tabular-feature valign-top"
+       Item "V.Align Center|n" "tabular-feature valign-center"
+       Item "V.Align Bottom|v" "tabular-feature valign-bottom"
+       Separator
+       Item "Append Row|A" "tabular-feature append-row"
+       Item "Append Column|u" "tabular-feature append-column"
+       Separator
+       Item "Delete Row|w" "tabular-feature delete-row"
+       Item "Delete Column|D" "tabular-feature delete-column"
     End
 
     Menu "edit_paste"
@@ -128,6 +148,7 @@ Menuset
        Item "Paper...|a" "layout-paper"
        Item "Document...|D" "layout-document"
        Item "Table...|T" "layout-table"
+       OptItem "Tabular...|a" "layout-tabular"
        Item "Quotes...|Q" "layout-quotes"
        Separator
        Item "Emphasize Style|E" "font-emph"
index aaa0e0979b0de8dbe83bade5174ab87f7945f4bc..b27dcbe828607bddec9d9a742809123065a3b588 100644 (file)
@@ -280,7 +280,10 @@ void LyXAction::init()
                { LFUN_LAYOUT_QUOTES, "layout-quotes", "", ReadOnly },
                { LFUN_LAYOUT_SAVE_DEFAULT, "layout-save-default", "",
                  ReadOnly },
-               { LFUN_LAYOUT_TABLE, "layout-table", "", Noop },
+               { LFUN_LAYOUT_TABLE, "layout-table",
+                 N_("Open the table layout"), Noop },
+               { LFUN_LAYOUT_TABULAR, "layout-tabular",
+                 N_("Open the tabular layout"), Noop },
                { LFUN_HOME, "line-begin",
                  N_("Go to beginning of line"), ReadOnly },
                { LFUN_HOMESEL, "line-begin-select",
index 90e18482d2b38454e66467bd011514cf09b02548..61cfebcf0081a8c044f225481a459f3070cac540 100644 (file)
@@ -272,6 +272,7 @@ enum kb_action {
        LFUN_SWITCHBUFFER,  // and where is this comming from?
        LFUN_INSERT_URL,                // Angus 20000726
        LFUN_TABULAR_FEATURE,           // Jug 20000728
+       LFUN_LAYOUT_TABULAR,            // Jug 20000731
        LFUN_LASTACTION  /* this marks the end of the table */
 };
 
index 0edb0bda5c0b9b4ddc4f52330b9f4741d06e9d6a..ed0aa6d3f21b6d5e0cc4ebae17d0f796affc65bb 100644 (file)
@@ -11,10 +11,6 @@ LYXDATADIRS = forms
 ETAGS_ARGS = --lang=c++
 libxforms_la_SOURCES = \
        Dialogs.C \
-       FormCitation.C \
-       FormCitation.h \
-       form_citation.C \
-       form_citation.h \
        FormCopyright.C \
        FormCopyright.h \
        form_copyright.C \
@@ -31,6 +27,14 @@ libxforms_la_SOURCES = \
        FormPrint.h \
        form_print.C \
        form_print.h \
+       FormGraphics.C \
+       FormGraphics.h \
+       form_graphics.C \
+       form_graphics.h \
+       FormCitation.C \
+       FormCitation.h \
+       form_citation.C \
+       form_citation.h \
        FormTabular.C \
        FormTabular.h \
        form_tabular.C \
index 1289c75cdd512aeb5317971ab0a5627427196453..c90b43e98a855520d859805aee1bf7dbe1cb0cb2 100644 (file)
 #include <algorithm>
 #include <iterator>
 using std::find_if;
+using std::bind2nd;
 using std::endl;
 
 void RadioButtonGroup::registerRadioButton(FL_OBJECT *button, int value)
 {
-#if 0
-    bvec.push_back(button);
-    vvec.push_back(value);
-#endif
     map.push_back( ButtonValuePair(button, value) );
 }
 
 
 void RadioButtonGroup::reset()
 {
-#if 0
-    bvec.clear();
-    vvec.clear();
-#endif
     map.clear(); 
 }
 
@@ -54,7 +47,7 @@ void RadioButtonGroup::reset()
     template <typename T>
     struct equal_to_second_in_pair {
         typedef bool                    result_type;
-        typedef T              first_argument_type;
+        typedef T      first_argument_type;
         typedef typename T::second_type second_argument_type;
 
         bool operator() (
@@ -67,37 +60,11 @@ void RadioButtonGroup::reset()
 
 void RadioButtonGroup::setButton(int value)
 {
-#if 0
-    ValueVector::iterator vit =
-        find_if(vvec.begin(), vvec.end(),
-            bind2nd(equal_to<int>(), value));
-    
-    if (vit == vvec.end()) {
-        lyxerr << "BUG: Requested value in RadioButtonGroup doesn't exists"
-            << endl;
-        return;
-    }
-
-    unsigned n = std::distance(vvec.begin(), vit);
-
-    fl_set_button(bvec[n], 1);
-#endif
-
-
     ButtonValueMap::const_iterator it = 
-#if 0
         find_if(map.begin(), map.end(),
                 bind2nd(equal_to_second_in_pair<ButtonValuePair>(),
                     value));
-#else
-        std::find_if(map.begin(), map.end(),
-                std::compose1(
-                    std::bind2nd(std::equal_to<int>(), value)
-                    ,
-                    std::select2nd<ButtonValuePair>()
-                )
-        );
-#endif
+
     // If we found nothing, report it and return
     if (it == map.end()) {
         lyxerr << "BUG: Requested value in RadioButtonGroup doesn't exists"
@@ -118,21 +85,6 @@ struct is_set_button {
 
 int  RadioButtonGroup::getButton()
 {
-#if 0
-    ButtonVector::const_iterator bit = bvec.begin();
-    ValueVector::const_iterator vit = vvec.begin();
-
-    while (bit != bvec.end()) {
-        if (fl_get_button(*bit))
-            return *vit;
-
-        bit++;
-        vit++;
-    }
-
-    return 0;
-#endif
-
     // Find the first button that is active
     ButtonValueMap::iterator it =
         find_if(map.begin(), map.end(),
index 49af9f3cc576506fb60c54d7c73f8e4e8d065754..d7e6fec5d718ff947cdde7e2ba1f174b1a2e7a2d 100644 (file)
@@ -1589,3 +1589,213 @@ LyXText * InsetTabular::getLyXText(BufferView * bv) const
        return the_locking_inset->getLyXText(bv);
     return Inset::getLyXText(bv);
 }
+
+
+void InsetTabular::OpenLayoutDialog(BufferView * bv) const
+{
+    if (the_locking_inset) {
+       InsetTabular * i = static_cast<InsetTabular *>
+           (the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE));
+       if (i) {
+           i->OpenLayoutDialog(bv);
+           return;
+       }
+    }
+    dialogs_ = bv->owner()->getDialogs();
+    dialogs_->showTabular(const_cast<InsetTabular *>(this));
+}
+
+//
+// functions returns:
+// 0 ... disabled
+// 1 ... enabled
+// 2 ... toggled on
+// 3 ... toggled off
+//
+int InsetTabular::getStatus(string what) const
+{
+    int action = LyXTabular::LAST_ACTION;
+    string argument;
+    int i;
+    
+    for(i=0; tabularFeatures[i].action != LyXTabular::LAST_ACTION; ++i) {
+       if (!strncmp(tabularFeatures[i].feature.c_str(), what.c_str(),
+                    tabularFeatures[i].feature.length())) {
+           action = tabularFeatures[i].action;
+           break;
+       }
+    }
+    if (action == LyXTabular::LAST_ACTION)
+       return 0;
+
+    argument = frontStrip(what.substr(tabularFeatures[i].feature.length()));
+
+    int sel_row_start, sel_row_end;
+    int dummy;
+    bool flag = true;
+
+    if (hasSelection()) {
+       int tmp;
+       sel_row_start = tabular->row_of_cell(sel_cell_start);
+       sel_row_end = tabular->row_of_cell(sel_cell_end);
+       if (sel_row_start > sel_row_end) {
+           tmp = sel_row_start;
+           sel_row_start = sel_row_end;
+           sel_row_end = tmp;
+       }
+    } else {
+       sel_row_start = sel_row_end = tabular->row_of_cell(actcell);
+    }
+
+    switch (action) {
+    case LyXTabular::SET_PWIDTH:
+    case LyXTabular::SET_MPWIDTH:
+    case LyXTabular::SET_SPECIAL_COLUMN:
+    case LyXTabular::SET_SPECIAL_MULTI:
+       return 0;
+
+    case LyXTabular::APPEND_ROW:
+    case LyXTabular::APPEND_COLUMN:
+    case LyXTabular::DELETE_ROW:
+    case LyXTabular::DELETE_COLUMN:
+    case LyXTabular::SET_ALL_LINES:
+    case LyXTabular::UNSET_ALL_LINES:
+       return 1;
+
+    case LyXTabular::MULTICOLUMN:
+       if (tabular->IsMultiColumn(actcell))
+           return 2;
+       return 3;
+
+    case LyXTabular::M_TOGGLE_LINE_TOP:
+       flag = false;
+    case LyXTabular::TOGGLE_LINE_TOP:
+       if (tabular->TopLine(actcell, flag))
+           return 2;
+       return 3;
+    
+    case LyXTabular::M_TOGGLE_LINE_BOTTOM:
+       flag = false;
+    case LyXTabular::TOGGLE_LINE_BOTTOM:
+       if (tabular->BottomLine(actcell, flag))
+           return 2;
+       return 3;
+               
+    case LyXTabular::M_TOGGLE_LINE_LEFT:
+       flag = false;
+    case LyXTabular::TOGGLE_LINE_LEFT:
+       if (tabular->LeftLine(actcell, flag))
+           return 2;
+       return 3;
+
+    case LyXTabular::M_TOGGLE_LINE_RIGHT:
+       flag = false;
+    case LyXTabular::TOGGLE_LINE_RIGHT:
+       if (tabular->RightLine(actcell, flag))
+           return 2;
+       return 3;
+
+    case LyXTabular::M_ALIGN_LEFT:
+       flag = false;
+    case LyXTabular::ALIGN_LEFT:
+       if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_LEFT)
+           return 2;
+       return 3;
+
+    case LyXTabular::M_ALIGN_RIGHT:
+       flag = false;
+    case LyXTabular::ALIGN_RIGHT:
+       if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_RIGHT)
+           return 2;
+       return 3;
+
+    case LyXTabular::M_ALIGN_CENTER:
+       flag = false;
+    case LyXTabular::ALIGN_CENTER:
+       if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_CENTER)
+           return 2;
+       return 3;
+
+    case LyXTabular::M_VALIGN_TOP:
+       flag = false;
+    case LyXTabular::VALIGN_TOP:
+       if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_TOP)
+           return 2;
+       return 3;
+
+    case LyXTabular::M_VALIGN_BOTTOM:
+       flag = false;
+    case LyXTabular::VALIGN_BOTTOM:
+       if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_BOTTOM)
+           return 2;
+       return 3;
+
+    case LyXTabular::M_VALIGN_CENTER:
+       flag = false;
+    case LyXTabular::VALIGN_CENTER:
+       if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_CENTER)
+           return 2;
+       return 3;
+
+    case LyXTabular::SET_LONGTABULAR:
+       if (tabular->IsLongTabular())
+           return 2;
+       return 3;
+
+    case LyXTabular::UNSET_LONGTABULAR:
+       if (!tabular->IsLongTabular())
+           return 2;
+       return 3;
+
+    case LyXTabular::SET_ROTATE_TABULAR:
+       if (tabular->GetRotateTabular())
+           return 2;
+       return 3;
+
+    case LyXTabular::UNSET_ROTATE_TABULAR:
+       if (!tabular->GetRotateTabular())
+           return 2;
+       return 3;
+
+    case LyXTabular::SET_ROTATE_CELL:
+       if (tabular->GetRotateCell(actcell))
+           return 2;
+       return 3;
+
+    case LyXTabular::UNSET_ROTATE_CELL:
+       if (!tabular->GetRotateCell(actcell))
+           return 2;
+       return 3;
+
+    case LyXTabular::SET_USEBOX:
+       if (strToInt(argument) == tabular->GetUsebox(actcell))
+           return 2;
+       return 3;
+
+    case LyXTabular::SET_LTFIRSTHEAD:
+       if (tabular->GetRowOfLTHead(actcell, dummy))
+           return 2;
+       return 3;
+
+    case LyXTabular::SET_LTHEAD:
+       if (tabular->GetRowOfLTHead(actcell, dummy))
+           return 2;
+       return 3;
+
+    case LyXTabular::SET_LTFOOT:
+       if (tabular->GetRowOfLTFoot(actcell, dummy))
+           return 2;
+       return 3;
+
+    case LyXTabular::SET_LTLASTFOOT:
+       if (tabular->GetRowOfLTFoot(actcell, dummy))
+           return 2;
+       return 3;
+
+    case LyXTabular::SET_LTNEWPAGE:
+       if (tabular->GetLTNewPage(actcell))
+           return 2;
+       return 3;
+    }
+    return 0;
+}
index 95351626110007fd7b13ad0adcec9c79563248fc..0e0988c4b792a26bc4db5248da0593ae60d7d005 100644 (file)
@@ -162,6 +162,8 @@ public:
     ///
     LyXText * getLyXText(BufferView *) const;
     void resizeLyXText(BufferView *) const;
+    void OpenLayoutDialog(BufferView *) const;
+    int getStatus(string argument) const;
 
     ///
     /// Public structures and variables
index c17982140e26ee48316c4bd8af4196cffb84aa7e..7e1f654d68a3fd3ad0f20157e4e18ca58983b16a 100644 (file)
@@ -1282,9 +1282,8 @@ int InsetText::cx(BufferView * bv) const
 
 int InsetText::cy(BufferView * bv) const
 {
-    long int y_dummy = 0;
-    Row * tmprow = TEXT(bv)->GetRowNearY(y_dummy);
-    return TEXT(bv)->cursor.y() - tmprow->baseline();
+    LyXFont font;
+    return TEXT(bv)->cursor.y() - ascent(bv, font);
 }
 
 
index dfe45358d57664ad10de14a4176fe327dcc049e5..a35294065bba3271e257293f8bc5f7926a26ff8e 100644 (file)
@@ -427,6 +427,46 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
                disable = ! owner->view()->text->cursor.par()->table;
                break;
 #endif
+       case LFUN_LAYOUT_TABULAR:
+               disable = true;
+               if (owner->view()->the_locking_inset) {
+                       disable = (owner->view()->the_locking_inset->LyxCode() != Inset::TABULAR_CODE) &&
+                               !owner->view()->the_locking_inset->GetFirstLockingInsetOfType(Inset::TABULAR_CODE);
+               }
+               break;
+
+       case LFUN_TABULAR_FEATURE:
+               disable = true;
+               if (owner->view()->the_locking_inset) {
+                       int ret = 0;
+                       if (owner->view()->the_locking_inset->LyxCode() == Inset::TABULAR_CODE) {
+                               ret = static_cast<InsetTabular *>
+                                       (owner->view()->the_locking_inset)->
+                                       getStatus(argument);
+                       } else if (owner->view()->the_locking_inset->GetFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
+                               ret = static_cast<InsetTabular *>
+                                       (owner->view()->the_locking_inset->
+                                       GetFirstLockingInsetOfType(Inset::TABULAR_CODE))->
+                                       getStatus(argument);
+                       }
+                       switch(ret) {
+                       case 0:
+                               break;
+                       case 1:
+                               disable = false;
+                               break;
+                       case 2:
+                               disable = false;
+                               flag |= LyXFunc::ToggleOn;
+                               break;
+                       case 3:
+                               disable = false;
+                               flag |= LyXFunc::ToggleOff;
+                               break;
+                       }
+               }
+               break;
+
        case LFUN_VC_REGISTER:
                disable = buf->lyxvc.inUse();
                break;
@@ -517,7 +557,7 @@ string LyXFunc::Dispatch(int ac,
                owner->view()->hideCursor();
 
        // We cannot use this function here
-       if (getStatus(action) & Disabled)
+       if (getStatus(ac) & Disabled)
                goto exit_with_message;
 
        commandshortcut.erase();
@@ -1288,6 +1328,21 @@ string LyXFunc::Dispatch(int ac,
        }
        break;
                
+       case LFUN_LAYOUT_TABULAR:
+           if (owner->view()->the_locking_inset) {
+               if (owner->view()->the_locking_inset->LyxCode()==Inset::TABULAR_CODE) {
+                   InsetTabular * inset = static_cast<InsetTabular *>
+                       (owner->view()->the_locking_inset);
+                   inset->OpenLayoutDialog(owner->view());
+               } else if (owner->view()->the_locking_inset->
+                          GetFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
+                   InsetTabular * inset = static_cast<InsetTabular *>(
+                       owner->view()->the_locking_inset->GetFirstLockingInsetOfType(Inset::TABULAR_CODE));
+                   inset->OpenLayoutDialog(owner->view());
+               }
+           }
+           break;
+
        case LFUN_LAYOUT_PAPER:
                MenuLayoutPaper();
                break;
index 3008be0676e5b98c3e98202032f15ff9664761a9..15d2a814a579b45e01dfc9e6efac07d7e0dc03eb 100644 (file)
@@ -516,8 +516,10 @@ void LyXText::draw(BufferView * bview, Row const * row,
 //                     tmpinset->update(bview, font, false);
                        tmpinset->draw(bview, font, offset+row->baseline(), x,
                                       cleared);
-                       if (status == CHANGED_IN_DRAW)
+                       if (status == CHANGED_IN_DRAW) {
                                UpdateInset(bview, tmpinset);
+                               status = CHANGED_IN_DRAW;
+                       }
                }
                ++vpos;
 
@@ -3952,7 +3954,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
                                w = inset_owner->width(bview, font);
                        else
                                w = ww;
-                       pain.fillRectangle(x_offset,h, w, row_ptr->height()-h);
+                       pain.fillRectangle(x_offset,y_offset+h, w, row_ptr->height()-h);
                }
                if (!inset_owner && !inset->display() && !inset->needFullRow())
                {
index deda64412f4746743187715bdac66e58cfecc9c4..bbd6061d3732657d817e0875b1617a28d1854da9 100644 (file)
@@ -1528,6 +1528,8 @@ void LyXText::SetParagraph(BufferView * bview,
        SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
        SetSelection();
        SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
+       if (inset_owner)
+           bview->updateInset(inset_owner, true);
 }