mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-29 05:01:49 +00:00
InsetText draw-update fixes, implemented edit-table-menu, patch from Baruch.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@942 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7110b8eda4
commit
aee6858d52
29
ChangeLog
29
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
|
||||
|
@ -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"
|
||||
|
@ -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",
|
||||
|
@ -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 */
|
||||
};
|
||||
|
||||
|
@ -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 \
|
||||
|
@ -23,24 +23,17 @@
|
||||
#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();
|
||||
}
|
||||
|
||||
@ -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(),
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user