mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +00:00
Clean fix for Michael's reported bug with the character dialog. Occurred
because build() is called from the controller meaning that minw_ etc were not reset. Fix to citation dialog; the style should now remain centred within the frame. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2607 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
6844068ec2
commit
ccb3cb54e5
@ -1,3 +1,21 @@
|
||||
2001-08-26 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* FormCitation.C:
|
||||
* forms/form_citation.fd: a littl;e tweaking to ensure that the
|
||||
style choice remains centred within the frame if its contents change.
|
||||
|
||||
* FormBase.h: added an allow_resize_ member variable. If false
|
||||
resizing the dialog is prohibitted.
|
||||
|
||||
* FormBase.[Ch]:
|
||||
* FormBrowser.[Ch]: modify c-tors to pass this new variable to FormBase.
|
||||
|
||||
* FormAboutlyx.C:
|
||||
* FormCharacter.C:
|
||||
* FormThesaurus.C:
|
||||
make use of this functionality to ensure that the dialog cannot be
|
||||
resized.
|
||||
|
||||
2001-08-24 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* FormCitation.h:
|
||||
|
@ -25,7 +25,7 @@ using std::getline;
|
||||
typedef FormCB<ControlAboutlyx, FormDB<FD_form_aboutlyx> > base_class;
|
||||
|
||||
FormAboutlyx::FormAboutlyx(ControlAboutlyx & c)
|
||||
: base_class(c, _("About LyX"))
|
||||
: base_class(c, _("About LyX"), false)
|
||||
{}
|
||||
|
||||
FL_FORM * FormAboutlyx::form() const
|
||||
@ -70,9 +70,6 @@ void FormAboutlyx::build()
|
||||
fl_addto_tabfolder(dialog_->tabbed_folder,_("Credits"),
|
||||
credits_->form);
|
||||
|
||||
fl_set_form_maxsize( dialog_->form,
|
||||
dialog_->form->w, dialog_->form->h);
|
||||
|
||||
// Manage the cancel/close button
|
||||
bc().setCancel(dialog_->close);
|
||||
}
|
||||
|
@ -24,8 +24,9 @@
|
||||
extern "C" int C_FormBaseWMHideCB(FL_FORM * form, void *);
|
||||
|
||||
|
||||
FormBase::FormBase(ControlButtons & c, string const & t)
|
||||
: ViewBC<xformsBC>(c), minw_(0), minh_(0), title_(t)
|
||||
FormBase::FormBase(ControlButtons & c, string const & t, bool allowResize)
|
||||
: ViewBC<xformsBC>(c), minw_(0), minh_(0), allow_resize_(allowResize),
|
||||
title_(t)
|
||||
{}
|
||||
|
||||
|
||||
@ -40,7 +41,11 @@ void FormBase::show()
|
||||
{
|
||||
if (!form()) {
|
||||
build();
|
||||
|
||||
}
|
||||
|
||||
// use minw_ to flag whether the dialog has ever been shown
|
||||
// (Needed now that build() is/should be called from the controller)
|
||||
if (minw_ == 0) {
|
||||
bc().refresh();
|
||||
|
||||
// work around dumb xforms sizing bug
|
||||
@ -49,7 +54,7 @@ void FormBase::show()
|
||||
|
||||
fl_set_form_atclose(form(), C_FormBaseWMHideCB, 0);
|
||||
}
|
||||
|
||||
|
||||
fl_freeze_form(form());
|
||||
update(); // make sure its up-to-date
|
||||
fl_unfreeze_form(form());
|
||||
@ -69,6 +74,9 @@ void FormBase::show()
|
||||
// calls to fl_set_form_minsize/maxsize apply only to the next
|
||||
// fl_show_form(), so this comes first.
|
||||
fl_set_form_minsize(form(), minw_, minh_);
|
||||
if (!allow_resize_)
|
||||
fl_set_form_maxsize(form(), minw_, minh_);
|
||||
|
||||
fl_show_form(form(),
|
||||
FL_PLACE_MOUSE | FL_FREE_SIZE, 0,
|
||||
title_.c_str());
|
||||
|
@ -33,7 +33,7 @@ class FormBase : public ViewBC<xformsBC>
|
||||
{
|
||||
public:
|
||||
///
|
||||
FormBase(ControlButtons &, string const &);
|
||||
FormBase(ControlButtons &, string const &, bool allowResize);
|
||||
///
|
||||
virtual ~FormBase() {}
|
||||
|
||||
@ -59,13 +59,13 @@ private:
|
||||
that the xform colors have been re-mapped). */
|
||||
virtual void redraw();
|
||||
|
||||
protected:
|
||||
/// Overcome a dumb xforms sizing bug
|
||||
mutable int minw_;
|
||||
///
|
||||
mutable int minh_;
|
||||
/// Can the dialog be resized after it has been created?
|
||||
bool allow_resize_;
|
||||
|
||||
private:
|
||||
/// dialog title, displayed by WM.
|
||||
string title_;
|
||||
};
|
||||
@ -76,7 +76,7 @@ class FormDB: public FormBase
|
||||
{
|
||||
protected:
|
||||
///
|
||||
FormDB(ControlButtons &, string const &);
|
||||
FormDB(ControlButtons &, string const &, bool allowResize=true);
|
||||
/// Pointer to the actual instantiation of xform's form
|
||||
virtual FL_FORM * form() const;
|
||||
/// Real GUI implementation.
|
||||
@ -85,8 +85,8 @@ protected:
|
||||
|
||||
|
||||
template <class Dialog>
|
||||
FormDB<Dialog>::FormDB(ControlButtons & c, string const & t)
|
||||
: FormBase(c, t)
|
||||
FormDB<Dialog>::FormDB(ControlButtons & c, string const & t, bool allowResize)
|
||||
: FormBase(c, t, allowResize)
|
||||
{}
|
||||
|
||||
|
||||
@ -103,15 +103,16 @@ class FormCB: public Base
|
||||
{
|
||||
protected:
|
||||
///
|
||||
FormCB(ControlButtons &, string const &);
|
||||
FormCB(ControlButtons &, string const &, bool allowResize=true);
|
||||
/// The parent controller
|
||||
Controller & controller() const;
|
||||
};
|
||||
|
||||
|
||||
template <class Controller, class Base>
|
||||
FormCB<Controller, Base>::FormCB(ControlButtons & c, string const & t)
|
||||
: Base(c, t)
|
||||
FormCB<Controller, Base>::FormCB(ControlButtons & c, string const & t,
|
||||
bool allowResize)
|
||||
: Base(c, t, allowResize)
|
||||
{}
|
||||
|
||||
|
||||
|
@ -12,8 +12,8 @@
|
||||
#include "form_browser.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
FormBrowser::FormBrowser(ControlButtons & c, string const & t)
|
||||
: FormDB<FD_form_browser>(c, t)
|
||||
FormBrowser::FormBrowser(ControlButtons & c, string const & t, bool allowResize)
|
||||
: FormDB<FD_form_browser>(c, t, allowResize)
|
||||
{}
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ struct FD_form_browser;
|
||||
class FormBrowser : public FormDB<FD_form_browser> {
|
||||
public:
|
||||
///
|
||||
FormBrowser(ControlButtons &, string const &);
|
||||
FormBrowser(ControlButtons &, string const &, bool allowResize=true);
|
||||
|
||||
private:
|
||||
/// Build the dialog.
|
||||
|
@ -31,7 +31,7 @@ using namespace character;
|
||||
typedef FormCB<ControlCharacter, FormDB<FD_form_character> > base_class;
|
||||
|
||||
FormCharacter::FormCharacter(ControlCharacter & c)
|
||||
: base_class(c, _("Character Layout"))
|
||||
: base_class(c, _("Character Layout"), false)
|
||||
{}
|
||||
|
||||
|
||||
@ -45,8 +45,6 @@ void FormCharacter::build()
|
||||
{
|
||||
dialog_.reset(build_character());
|
||||
|
||||
fl_set_form_maxsize(dialog_->form, minw_, minh_);
|
||||
|
||||
vector<FamilyPair> const family = getFamilyData();
|
||||
vector<SeriesPair> const series = getSeriesData();
|
||||
vector<ShapePair> const shape = getShapeData();
|
||||
|
@ -46,12 +46,15 @@ int string_width(string const & str)
|
||||
}
|
||||
|
||||
|
||||
void fillChoice(FL_OBJECT * choice, vector<string> const & vec)
|
||||
void fillChoice(FD_form_citation * dialog, vector<string> vec)
|
||||
{
|
||||
string const str = " " + getStringFromVector(vec, " | ") + " ";
|
||||
|
||||
fl_clear_choice(choice);
|
||||
fl_addto_choice(choice, str.c_str());
|
||||
fl_clear_choice(dialog->choice_style);
|
||||
fl_addto_choice(dialog->choice_style, str.c_str());
|
||||
|
||||
// The width of the choice varies with the contents.
|
||||
// Ensure that it is centred in the frame.
|
||||
|
||||
int width = 0;
|
||||
for (vector<string>::const_iterator it = vec.begin();
|
||||
@ -59,16 +62,18 @@ void fillChoice(FL_OBJECT * choice, vector<string> const & vec)
|
||||
width = max(width, string_width(*it));
|
||||
}
|
||||
|
||||
// Paranoia checks
|
||||
int const x = max(5, int(choice->x + 0.5 * (choice->w - width)));
|
||||
if (x + width > choice->form->w)
|
||||
width = choice->form->w - 10;
|
||||
|
||||
fl_set_object_geometry(choice, x, choice->y, width + 5, choice->h);
|
||||
int const dx =
|
||||
max(5, int(0.5 * (dialog->frame_style->w - width)));
|
||||
|
||||
fl_set_object_geometry(dialog->choice_style,
|
||||
dialog->frame_style->x + dx,
|
||||
dialog->choice_style->y,
|
||||
width,
|
||||
dialog->choice_style->h);
|
||||
}
|
||||
|
||||
void updateStyle(FL_OBJECT * choice, FL_OBJECT * full, FL_OBJECT * force,
|
||||
string command)
|
||||
|
||||
void updateStyle(FD_form_citation * dialog, string command)
|
||||
{
|
||||
// Find the style of the citekeys
|
||||
vector<biblio::CiteStyle> const & styles =
|
||||
@ -80,14 +85,14 @@ void updateStyle(FL_OBJECT * choice, FL_OBJECT * full, FL_OBJECT * force,
|
||||
|
||||
// Use this to initialise the GUI
|
||||
if (cit == styles.end()) {
|
||||
fl_set_choice(choice, 1);
|
||||
fl_set_button(full, 0);
|
||||
fl_set_button(force, 0);
|
||||
fl_set_choice(dialog->choice_style, 1);
|
||||
fl_set_button(dialog->button_full_author_list, 0);
|
||||
fl_set_button(dialog->button_force_uppercase, 0);
|
||||
} else {
|
||||
int const i = int(cit - styles.begin());
|
||||
fl_set_choice(choice, i+1);
|
||||
fl_set_button(full, cs.full);
|
||||
fl_set_button(force, cs.forceUCase);
|
||||
fl_set_choice(dialog->choice_style, i+1);
|
||||
fl_set_button(dialog->button_full_author_list, cs.full);
|
||||
fl_set_button(dialog->button_force_uppercase, cs.forceUCase);
|
||||
}
|
||||
}
|
||||
|
||||
@ -357,7 +362,7 @@ ButtonPolicy::SMInput FormCitation::input(FL_OBJECT * ob, long)
|
||||
|
||||
if (topCitekey != currentCitekey) {
|
||||
int choice = fl_get_choice(dialog_->choice_style);
|
||||
fillChoice(dialog_->choice_style,
|
||||
fillChoice(dialog_.get(),
|
||||
controller().getCiteStrings(currentCitekey));
|
||||
fl_set_choice(dialog_->choice_style, choice);
|
||||
}
|
||||
@ -380,13 +385,10 @@ void FormCitation::update()
|
||||
string key;
|
||||
if (!citekeys.empty()) key = citekeys[0];
|
||||
|
||||
fillChoice(dialog_->choice_style, controller().getCiteStrings(key));
|
||||
fillChoice(dialog_.get(), controller().getCiteStrings(key));
|
||||
|
||||
// Use the citation command to update the GUI
|
||||
updateStyle(dialog_->choice_style,
|
||||
dialog_->button_full_author_list,
|
||||
dialog_->button_force_uppercase,
|
||||
controller().params().getCmdName());
|
||||
updateStyle(dialog_.get(), controller().params().getCmdName());
|
||||
|
||||
bool const natbib = controller().usingNatbib();
|
||||
setEnabled(dialog_->button_full_author_list, natbib);
|
||||
|
@ -56,7 +56,7 @@ private:
|
||||
FD_form_citation * build_citation();
|
||||
|
||||
/// search for a citation
|
||||
void FormCitation::findBiblio(biblio::Direction const dir);
|
||||
void findBiblio(biblio::Direction const dir);
|
||||
|
||||
///
|
||||
void updateBrowser(FL_OBJECT *, std::vector<string> const &) const;
|
||||
|
@ -24,7 +24,7 @@
|
||||
typedef FormCB<ControlThesaurus, FormDB<FD_form_tabbed_thesaurus> > base_class;
|
||||
|
||||
FormThesaurus::FormThesaurus(ControlThesaurus & c)
|
||||
: base_class(c, _("LyX: Thesaurus")),
|
||||
: base_class(c, _("LyX: Thesaurus"), false),
|
||||
clickline_(-1)
|
||||
{
|
||||
}
|
||||
@ -39,8 +39,6 @@ void FormThesaurus::build()
|
||||
adverb_.reset(build_adverb());
|
||||
other_.reset(build_other());
|
||||
|
||||
fl_set_form_maxsize(dialog_->form, minw_, minh_);
|
||||
|
||||
// Manage the ok, apply and cancel/close buttons
|
||||
bc().setCancel(dialog_->button_close);
|
||||
bc().addReadOnly(dialog_->input_replace);
|
||||
|
@ -93,7 +93,7 @@ FD_form_citation * FormCitation::build_citation()
|
||||
}
|
||||
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
|
||||
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
|
||||
obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 410, 280, 370, 80, _("Citation style"));
|
||||
fdui->frame_style = obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 410, 280, 370, 80, _("Citation style"));
|
||||
fl_set_object_shortcut(obj, _("frame_style"), 1);
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
fl_set_object_lstyle(obj, FL_BOLD_STYLE);
|
||||
|
@ -31,6 +31,7 @@ struct FD_form_citation {
|
||||
FL_OBJECT *button_search_case;
|
||||
FL_OBJECT *button_previous;
|
||||
FL_OBJECT *button_next;
|
||||
FL_OBJECT *frame_style;
|
||||
FL_OBJECT *choice_style;
|
||||
FL_OBJECT *button_full_author_list;
|
||||
FL_OBJECT *button_force_uppercase;
|
||||
|
@ -157,6 +157,7 @@ callback:
|
||||
argument:
|
||||
|
||||
--------------------
|
||||
|
||||
class: FL_LABELFRAME
|
||||
type: ENGRAVED_FRAME
|
||||
box: 410 140 370 120
|
||||
@ -278,7 +279,7 @@ label: Citation style
|
||||
shortcut: frame_style
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name:
|
||||
name: frame_style
|
||||
callback:
|
||||
argument:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user