From f4c86428a35989edc21141c875b426b30477d596 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Mon, 11 Feb 2002 10:42:11 +0000 Subject: [PATCH] FormExternal patch from Rob, graphics9 patch from Herbert. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3517 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/xforms/ChangeLog | 19 ++ src/frontends/xforms/FormGraphics.C | 84 ++++--- src/frontends/xforms/form_external.C | 6 +- src/frontends/xforms/form_graphics.C | 95 ++++---- src/frontends/xforms/form_graphics.h | 12 +- src/frontends/xforms/forms/form_external.fd | 12 +- src/frontends/xforms/forms/form_graphics.fd | 230 +++++++++++--------- src/insets/ChangeLog | 8 + src/insets/insetgraphics.C | 212 +++++++++--------- src/insets/insetgraphics.h | 5 - src/insets/insetgraphicsParams.C | 59 +++-- src/insets/insetgraphicsParams.h | 28 +-- 12 files changed, 430 insertions(+), 340 deletions(-) diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 6084222652..44720acf7d 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,22 @@ +2002-02-10 Rob Lahaye + * forms/form_external.fd: + * form_external.C: change color2 of a few buttons into the + proper grey color. + +2002-02-08 Herbert Voss + + * forms/form_graphics.fd: + * FormGraphics.C: + * form_graphics.[Ch]: Adding buttons for unzip-Option, + getValues from LyX/LaTeXfolder + +2002-02-08 Rob Lahaye + + * forms/form_graphics.fd: + * FormGraphics.C: + * form_graphics.[Ch]: simplify the bounding box folder + of the Graphic GUI + 2002-02-08 Jean-Marc Lasgouttes * Menubar_pimpl.C (create_submenu): work around an xforms bug (?) diff --git a/src/frontends/xforms/FormGraphics.C b/src/frontends/xforms/FormGraphics.C index 5eb5c39a52..ad18b19ce2 100644 --- a/src/frontends/xforms/FormGraphics.C +++ b/src/frontends/xforms/FormGraphics.C @@ -42,6 +42,7 @@ int const WIDTH_MAXDIGITS = 10; int const HEIGHT_MAXDIGITS = 10; int const ROTATE_MAXCHARS = 4; int const FILENAME_MAXCHARS = 1024; +string defaultUnit = "cm"; } // namespace anon @@ -97,6 +98,7 @@ void FormGraphics::build() bc().addReadOnly(file_->check_rotate); bc().addReadOnly(file_->button_clip); bc().addReadOnly(file_->button_draft); + bc().addReadOnly(file_->button_nounzip); // the lyxview section lyxview_.reset(build_lyxview()); @@ -143,10 +145,7 @@ void FormGraphics::build() fl_set_input_return (bbox_->input_bb_y1, FL_RETURN_CHANGED); string const bb_units = "pt|cm|in"; - fl_addto_choice(bbox_->choice_bb_x0, bb_units.c_str()); - fl_addto_choice(bbox_->choice_bb_y0, bb_units.c_str()); - fl_addto_choice(bbox_->choice_bb_x1, bb_units.c_str()); - fl_addto_choice(bbox_->choice_bb_y1, bb_units.c_str()); + fl_addto_choice(bbox_->choice_bb_units, bb_units.c_str()); bc().addReadOnly(bbox_->button_getBB); // the rotate section @@ -188,6 +187,7 @@ void FormGraphics::apply() igp.rotateOrigin = string(); igp.draft = fl_get_button(file_->button_draft); igp.clip = fl_get_button(file_->button_clip); + igp.noUnzip = fl_get_button(file_->button_nounzip); // the lyxview section if (fl_get_button(lyxview_->radio_pref)) @@ -236,22 +236,22 @@ void FormGraphics::apply() bb = "0 "; else bb = getLengthFromWidgets(bbox_->input_bb_x0, - bbox_->choice_bb_x0)+" "; + bbox_->choice_bb_units)+" "; if (getStringFromInput(bbox_->input_bb_y0).empty()) bb += "0 "; else bb += (getLengthFromWidgets(bbox_->input_bb_y0, - bbox_->choice_bb_y0)+" "); + bbox_->choice_bb_units)+" "); if (getStringFromInput(bbox_->input_bb_x1).empty()) bb += "0 "; else bb += (getLengthFromWidgets(bbox_->input_bb_x1, - bbox_->choice_bb_x1)+" "); + bbox_->choice_bb_units)+" "); if (getStringFromInput(bbox_->input_bb_y1).empty()) bb += "0 "; else bb += (getLengthFromWidgets(bbox_->input_bb_y1, - bbox_->choice_bb_y1)+" "); + bbox_->choice_bb_units)+" "); igp.bb = bb; } @@ -261,10 +261,8 @@ void FormGraphics::apply() void FormGraphics::update() { - string unit = "cm"; if (lyxrc.default_papersize < 3) - unit = "in"; - string const defaultUnit = string(unit); + defaultUnit = string("in"); // Update dialog with details from inset InsetGraphicsParams & igp = controller().params(); @@ -287,6 +285,7 @@ void FormGraphics::update() { fl_get_button(file_->check_rotate)); fl_set_button(file_->button_draft, igp.draft); fl_set_button(file_->button_clip, igp.clip); + fl_set_button(file_->button_nounzip, igp.noUnzip); // the lyxview section switch (igp.display) { @@ -404,16 +403,16 @@ void FormGraphics::update() { LyXLength anyLength; anyLength = LyXLength(token(igp.bb,' ',0)); updateWidgetsFromLength(bbox_->input_bb_x0, - bbox_->choice_bb_x0,anyLength,"pt"); + bbox_->choice_bb_units,anyLength,"pt"); anyLength = LyXLength(token(igp.bb,' ',1)); updateWidgetsFromLength(bbox_->input_bb_y0, - bbox_->choice_bb_y0,anyLength,"pt"); + bbox_->choice_bb_units,anyLength,"pt"); anyLength = LyXLength(token(igp.bb,' ',2)); updateWidgetsFromLength(bbox_->input_bb_x1, - bbox_->choice_bb_x1,anyLength,"pt"); + bbox_->choice_bb_units,anyLength,"pt"); anyLength = LyXLength(token(igp.bb,' ',3)); updateWidgetsFromLength(bbox_->input_bb_y1, - bbox_->choice_bb_y1,anyLength,"pt"); + bbox_->choice_bb_units,anyLength,"pt"); } // the special section @@ -471,13 +470,23 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long) setEnabled(lyxview_->input_lyxheight, 0); setEnabled(lyxview_->choice_width_lyxheight, 0); setEnabled(lyxview_->input_lyxscale, 1); + } else if (ob == lyxview_->button_latex_values) { + LyXLength dummy = LyXLength(getLengthFromWidgets(size_->input_width, + size_->choice_width_units)); + updateWidgetsFromLength(lyxview_->input_lyxwidth, + lyxview_->choice_width_lyxwidth, dummy, defaultUnit); + dummy = LyXLength(getLengthFromWidgets(size_->input_height, + size_->choice_width_units)); + updateWidgetsFromLength(lyxview_->input_lyxheight, + lyxview_->choice_width_lyxheight, dummy, defaultUnit); + string const scale = fl_get_input(size_->input_scale); + fl_set_input(lyxview_->input_lyxscale, scale.c_str()); // the bb section } else if (!controller().bbChanged && - (ob == bbox_->input_bb_x0 || ob == bbox_->input_bb_y0 || - ob == bbox_->input_bb_x1 || ob == bbox_->input_bb_y1 || - ob == bbox_->choice_bb_x0 || ob == bbox_->choice_bb_y0 || - ob == bbox_->choice_bb_x1 || ob == bbox_->choice_bb_y1)) { + (ob == bbox_->choice_bb_units || + ob == bbox_->input_bb_x0 || ob == bbox_->input_bb_y0 || + ob == bbox_->input_bb_x1 || ob == bbox_->input_bb_y1)) { controller().bbChanged = true; } else if (ob == bbox_->button_getBB) { string const filename = getStringFromInput(file_->input_filename); @@ -485,19 +494,19 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long) string const fileWithAbsPath = MakeAbsPath(filename, OnlyPath(filename)); string bb = controller().readBB(fileWithAbsPath); lyxerr << "getBB::BoundingBox = " << bb << "\n"; - if (!bb.empty()) { - updateWidgetsFromLengthString(bbox_->input_bb_x0, - bbox_->choice_bb_x0, - token(bb,' ',0), "pt"); - updateWidgetsFromLengthString(bbox_->input_bb_y0, - bbox_->choice_bb_y0, - token(bb,' ',1), "pt"); - updateWidgetsFromLengthString(bbox_->input_bb_x1, - bbox_->choice_bb_x1, - token(bb,' ',2), "pt"); - updateWidgetsFromLengthString(bbox_->input_bb_y1, - bbox_->choice_bb_y1, - token(bb,' ',3), "pt"); + if (!bb.empty()) { + updateWidgetsFromLengthString(bbox_->input_bb_x0, + bbox_->choice_bb_units, + token(bb,' ',0), "pt"); + updateWidgetsFromLengthString(bbox_->input_bb_y0, + bbox_->choice_bb_units, + token(bb,' ',1), "pt"); + updateWidgetsFromLengthString(bbox_->input_bb_x1, + bbox_->choice_bb_units, + token(bb,' ',2), "pt"); + updateWidgetsFromLengthString(bbox_->input_bb_y1, + bbox_->choice_bb_units, + token(bb,' ',3), "pt"); } controller().bbChanged = false; } @@ -524,6 +533,17 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long) setEnabled(size_->choice_height_units, 0); setEnabled(size_->check_aspectratio, 0); setEnabled(size_->input_scale, 1); + } else if (ob == size_->button_lyx_values) { + LyXLength dummy = LyXLength(getLengthFromWidgets( + lyxview_->input_lyxwidth, lyxview_->choice_width_lyxwidth)); + updateWidgetsFromLength(size_->input_width, + size_->choice_width_units, dummy, defaultUnit); + dummy = LyXLength(getLengthFromWidgets(lyxview_->input_lyxheight, + lyxview_->choice_width_lyxheight)); + updateWidgetsFromLength(size_->input_height, + size_->choice_height_units, dummy, defaultUnit); + string const scale = fl_get_input(lyxview_->input_lyxscale); + fl_set_input(size_->input_scale, scale.c_str()); } // check if the input is valid diff --git a/src/frontends/xforms/form_external.C b/src/frontends/xforms/form_external.C index 3c50ba861d..6d36f8f528 100644 --- a/src/frontends/xforms/form_external.C +++ b/src/frontends/xforms/form_external.C @@ -31,6 +31,7 @@ FD_form_external * FormExternal::build_external() fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_boxtype(obj, FL_FRAME_BOX); + fl_set_object_color(obj, FL_COL1, FL_RIGHT_BCOL); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast); fl_set_object_callback(obj, C_FormBaseInputCB, 0); @@ -66,7 +67,6 @@ FD_form_external * FormExternal::build_external() fdui->button_edit = obj = fl_add_button(FL_NORMAL_BUTTON, 435, 50, 110, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } - fl_set_object_color(obj, FL_COL1, FL_BLACK); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast); fl_set_object_callback(obj, C_FormBaseInputCB, 0); @@ -75,7 +75,6 @@ FD_form_external * FormExternal::build_external() fdui->button_view = obj = fl_add_button(FL_NORMAL_BUTTON, 435, 90, 110, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } - fl_set_object_color(obj, FL_COL1, FL_BLACK); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast); fl_set_object_callback(obj, C_FormBaseInputCB, 0); @@ -84,12 +83,10 @@ FD_form_external * FormExternal::build_external() fdui->button_update = obj = fl_add_button(FL_NORMAL_BUTTON, 435, 130, 110, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } - fl_set_object_color(obj, FL_COL1, FL_BLACK); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast); fl_set_object_callback(obj, C_FormBaseInputCB, 0); fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 255, 270, 90, 30, _("OK")); - fl_set_object_color(obj, FL_COL1, FL_BLACK); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); fl_set_object_callback(obj, C_FormBaseOKCB, 0); @@ -98,7 +95,6 @@ FD_form_external * FormExternal::build_external() fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 355, 270, 90, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } - fl_set_object_color(obj, FL_COL1, FL_BLACK); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); fl_set_object_callback(obj, C_FormBaseApplyCB, 0); diff --git a/src/frontends/xforms/form_graphics.C b/src/frontends/xforms/form_graphics.C index 9ebb3ee488..c3c0248ce7 100644 --- a/src/frontends/xforms/form_graphics.C +++ b/src/frontends/xforms/form_graphics.C @@ -106,7 +106,7 @@ FD_form_file * FormGraphics::build_file() fl_set_object_lalign(obj, FL_ALIGN_RIGHT); fl_set_object_callback(obj, C_FormBaseInputCB, 0); { - char const * const dummy = N_("Title:|#T"); + char const * const dummy = N_("Title|#T"); fdui->input_subcaption = obj = fl_add_input(FL_NORMAL_INPUT, 190, 65, 280, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } @@ -116,7 +116,7 @@ FD_form_file * FormGraphics::build_file() fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lstyle(obj, FL_BOLD_STYLE); { - char const * const dummy = N_("Angle:|#n"); + char const * const dummy = N_("Angle|#n"); fdui->input_rotate_angle = obj = fl_add_input(FL_INT_INPUT, 190, 125, 55, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } @@ -126,7 +126,7 @@ FD_form_file * FormGraphics::build_file() fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE); { - char const * const dummy = N_("Origin:|#O"); + char const * const dummy = N_("Origin|#O"); fdui->choice_origin = obj = fl_add_choice(FL_NORMAL_CHOICE, 350, 125, 118, 28, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } @@ -138,7 +138,7 @@ FD_form_file * FormGraphics::build_file() fl_set_object_lstyle(obj, FL_BOLD_STYLE); { char const * const dummy = N_("clip to bounding box|#b"); - fdui->button_clip = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 145, 190, 30, 30, idex(_(dummy))); + fdui->button_clip = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 140, 190, 30, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_lsize(obj, FL_NORMAL_SIZE); @@ -160,6 +160,14 @@ FD_form_file * FormGraphics::build_file() fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lalign(obj, FL_ALIGN_RIGHT); fl_set_object_callback(obj, C_FormBaseInputCB, 0); + { + char const * const dummy = N_("don't unzip, when \nexporting to LaTeX|#u"); + fdui->button_nounzip = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 315, 190, 30, 30, idex(_(dummy))); + fl_set_button_shortcut(obj, scex(_(dummy)), 1); + } + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_lalign(obj, FL_ALIGN_RIGHT); + fl_set_object_callback(obj, C_FormBaseInputCB, 0); fl_end_form(); fdui->form->fdui = fdui; @@ -219,7 +227,7 @@ FD_form_size * FormGraphics::build_size() fl_end_group(); { - char const * const dummy = N_("Value:|#V"); + char const * const dummy = N_("Value|#V"); fdui->input_scale = obj = fl_add_input(FL_NORMAL_INPUT, 325, 75, 85, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } @@ -230,7 +238,7 @@ FD_form_size * FormGraphics::build_size() fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE); { - char const * const dummy = N_("Width:|#W"); + char const * const dummy = N_("Width|#W"); fdui->input_width = obj = fl_add_input(FL_NORMAL_INPUT, 325, 140, 85, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } @@ -241,7 +249,7 @@ FD_form_size * FormGraphics::build_size() fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormBaseInputCB, 0); { - char const * const dummy = N_("Height:|#g"); + char const * const dummy = N_("Height|#g"); fdui->input_height = obj = fl_add_input(FL_NORMAL_INPUT, 325, 175, 85, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } @@ -260,6 +268,14 @@ FD_form_size * FormGraphics::build_size() fl_set_object_lalign(obj, FL_ALIGN_RIGHT); fl_set_object_callback(obj, C_FormBaseInputCB, 0); obj = fl_add_frame(FL_ENGRAVED_FRAME, 15, 60, 470, 65, ""); + { + char const * const dummy = N_("Get LyX size|#x"); + fdui->button_lyx_values = obj = fl_add_button(FL_NORMAL_BUTTON, 360, 20, 115, 30, idex(_(dummy))); + fl_set_button_shortcut(obj, scex(_(dummy)), 1); + } + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_callback(obj, C_FormBaseInputCB, 0); + obj = fl_add_frame(FL_ENGRAVED_FRAME, 340, 10, 5, 50, ""); fl_end_form(); fdui->form->fdui = fdui; @@ -284,63 +300,50 @@ FD_form_bbox * FormGraphics::build_bbox() fdui->form->u_vdata = this; obj = fl_add_box(FL_FLAT_BOX, 0, 0, 505, 235, ""); fl_set_object_lsize(obj, FL_NORMAL_SIZE); - obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 20, 25, 455, 195, ""); + obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 15, 10, 475, 205, _("Corner coordinates (X, Y)")); + fl_set_object_boxtype(obj, FL_UP_BOX); fl_set_object_lsize(obj, FL_NORMAL_SIZE); - obj = fl_add_text(FL_NORMAL_TEXT, 135, 35, 35, 25, _("X")); + obj = fl_add_text(FL_NORMAL_TEXT, 195, 110, 30, 25, _(", ")); fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE); + fl_set_object_lalign(obj, FL_ALIGN_CENTER|FL_ALIGN_INSIDE); fl_set_object_lstyle(obj, FL_BOLD_STYLE); - obj = fl_add_text(FL_NORMAL_TEXT, 360, 35, 30, 25, _("Y")); + obj = fl_add_text(FL_NORMAL_TEXT, 195, 55, 30, 25, _(", ")); fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE); + fl_set_object_lalign(obj, FL_ALIGN_CENTER|FL_ALIGN_INSIDE); fl_set_object_lstyle(obj, FL_BOLD_STYLE); { - char const * const dummy = N_("Left Bottom:|#L"); - fdui->input_bb_x0 = obj = fl_add_input(FL_NORMAL_INPUT, 135, 60, 50, 30, idex(_(dummy))); - fl_set_button_shortcut(obj, scex(_(dummy)), 1); - } - fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_callback(obj, C_FormBaseInputCB, 0); - fdui->choice_bb_x0 = obj = fl_add_choice(FL_NORMAL_CHOICE, 190, 60, 50, 30, ""); - fl_set_object_boxtype(obj, FL_FRAME_BOX); - fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_callback(obj, C_FormBaseInputCB, 0); - { - char const * const dummy = N_("Right Top:|#R"); - fdui->input_bb_x1 = obj = fl_add_input(FL_NORMAL_INPUT, 135, 100, 50, 30, idex(_(dummy))); + char const * const dummy = N_("Top right ( |#T"); + fdui->input_bb_x1 = obj = fl_add_input(FL_NORMAL_INPUT, 150, 45, 50, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormBaseInputCB, 0); - fdui->choice_bb_x1 = obj = fl_add_choice(FL_NORMAL_CHOICE, 190, 100, 50, 30, ""); - fl_set_object_boxtype(obj, FL_FRAME_BOX); + fdui->input_bb_y1 = obj = fl_add_input(FL_NORMAL_INPUT, 220, 45, 50, 30, _(" )")); fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_lalign(obj, FL_ALIGN_RIGHT); fl_set_object_callback(obj, C_FormBaseInputCB, 0); { - char const * const dummy = N_("Left Bottom:|#f"); - fdui->input_bb_y0 = obj = fl_add_input(FL_NORMAL_INPUT, 360, 60, 50, 30, idex(_(dummy))); + char const * const dummy = N_("Bottom left ( |#B"); + fdui->input_bb_x0 = obj = fl_add_input(FL_NORMAL_INPUT, 150, 95, 50, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormBaseInputCB, 0); - fdui->choice_bb_y0 = obj = fl_add_choice(FL_NORMAL_CHOICE, 415, 60, 45, 30, ""); - fl_set_object_boxtype(obj, FL_FRAME_BOX); + fdui->input_bb_y0 = obj = fl_add_input(FL_NORMAL_INPUT, 220, 95, 50, 30, _(" )")); fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_lalign(obj, FL_ALIGN_RIGHT); fl_set_object_callback(obj, C_FormBaseInputCB, 0); { - char const * const dummy = N_("Right Top:|#T"); - fdui->input_bb_y1 = obj = fl_add_input(FL_NORMAL_INPUT, 360, 100, 50, 30, idex(_(dummy))); + char const * const dummy = N_("Units|#U"); + fdui->choice_bb_units = obj = fl_add_choice(FL_NORMAL_CHOICE, 370, 70, 45, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } - fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_callback(obj, C_FormBaseInputCB, 0); - fdui->choice_bb_y1 = obj = fl_add_choice(FL_NORMAL_CHOICE, 415, 100, 45, 30, ""); fl_set_object_boxtype(obj, FL_FRAME_BOX); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormBaseInputCB, 0); { - char const * const dummy = N_("Get bounding box from file|#G"); - fdui->button_getBB = obj = fl_add_button(FL_NORMAL_BUTTON, 135, 160, 220, 30, idex(_(dummy))); + char const * const dummy = N_("Get values from file|#G"); + fdui->button_getBB = obj = fl_add_button(FL_NORMAL_BUTTON, 110, 160, 165, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_lsize(obj, FL_NORMAL_SIZE); @@ -372,7 +375,7 @@ FD_form_special * FormGraphics::build_special() obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 15, 15, 455, 70, _("Special Options")); fl_set_object_lsize(obj, FL_NORMAL_SIZE); { - char const * const dummy = N_("LaTeX Options:|#L"); + char const * const dummy = N_("LaTeX Options|#L"); fdui->input_special = obj = fl_add_input(FL_NORMAL_INPUT, 190, 40, 265, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } @@ -405,7 +408,7 @@ FD_form_lyxview * FormGraphics::build_lyxview() fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lstyle(obj, FL_BOLD_STYLE); { - char const * const dummy = N_("Value:|#V"); + char const * const dummy = N_("Value|#V"); fdui->input_lyxscale = obj = fl_add_input(FL_NORMAL_INPUT, 350, 75, 70, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } @@ -493,7 +496,7 @@ FD_form_lyxview * FormGraphics::build_lyxview() obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 150, 10, 340, 50, _("Screen Size")); fl_set_object_lstyle(obj, FL_BOLD_STYLE); { - char const * const dummy = N_("Width:|#w"); + char const * const dummy = N_("Width|#w"); fdui->input_lyxwidth = obj = fl_add_input(FL_NORMAL_INPUT, 350, 130, 70, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } @@ -504,7 +507,7 @@ FD_form_lyxview * FormGraphics::build_lyxview() fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormBaseInputCB, 0); { - char const * const dummy = N_("Height:|#h"); + char const * const dummy = N_("Height|#h"); fdui->input_lyxheight = obj = fl_add_input(FL_NORMAL_INPUT, 350, 170, 70, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } @@ -518,6 +521,14 @@ FD_form_lyxview * FormGraphics::build_lyxview() obj = fl_add_text(FL_NORMAL_TEXT, 30, 45, 115, 25, _("(from Preferences)")); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE); + { + char const * const dummy = N_("Get LaTeX size|#x"); + fdui->button_latex_values = obj = fl_add_button(FL_NORMAL_BUTTON, 350, 20, 115, 30, idex(_(dummy))); + fl_set_button_shortcut(obj, scex(_(dummy)), 1); + } + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_callback(obj, C_FormBaseInputCB, 0); + obj = fl_add_frame(FL_ENGRAVED_FRAME, 320, 10, 5, 50, ""); fl_end_form(); fdui->form->fdui = fdui; diff --git a/src/frontends/xforms/form_graphics.h b/src/frontends/xforms/form_graphics.h index c91e6aa7da..cca00507e8 100644 --- a/src/frontends/xforms/form_graphics.h +++ b/src/frontends/xforms/form_graphics.h @@ -46,6 +46,7 @@ struct FD_form_file { FL_OBJECT *button_clip; FL_OBJECT *button_draft; FL_OBJECT *check_rotate; + FL_OBJECT *button_nounzip; }; struct FD_form_size { ~FD_form_size(); @@ -61,19 +62,17 @@ struct FD_form_size { FL_OBJECT *input_height; FL_OBJECT *choice_height_units; FL_OBJECT *check_aspectratio; + FL_OBJECT *button_lyx_values; }; struct FD_form_bbox { ~FD_form_bbox(); FL_FORM *form; - FL_OBJECT *input_bb_x0; - FL_OBJECT *choice_bb_x0; FL_OBJECT *input_bb_x1; - FL_OBJECT *choice_bb_x1; - FL_OBJECT *input_bb_y0; - FL_OBJECT *choice_bb_y0; FL_OBJECT *input_bb_y1; - FL_OBJECT *choice_bb_y1; + FL_OBJECT *input_bb_x0; + FL_OBJECT *input_bb_y0; + FL_OBJECT *choice_bb_units; FL_OBJECT *button_getBB; }; struct FD_form_special { @@ -100,6 +99,7 @@ struct FD_form_lyxview { FL_OBJECT *choice_width_lyxwidth; FL_OBJECT *input_lyxheight; FL_OBJECT *choice_width_lyxheight; + FL_OBJECT *button_latex_values; }; #endif /* FD_form_graphics_h_ */ diff --git a/src/frontends/xforms/forms/form_external.fd b/src/frontends/xforms/forms/form_external.fd index 252ff602fa..e32a094b38 100644 --- a/src/frontends/xforms/forms/form_external.fd +++ b/src/frontends/xforms/forms/form_external.fd @@ -35,7 +35,7 @@ class: FL_CHOICE type: NORMAL_CHOICE box: 130 10 300 30 boxtype: FL_FRAME_BOX -colors: FL_COL1 FL_BLACK +colors: FL_COL1 FL_RIGHT_BCOL alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE @@ -125,7 +125,7 @@ class: FL_BUTTON type: NORMAL_BUTTON box: 435 50 110 30 boxtype: FL_UP_BOX -colors: FL_COL1 FL_BLACK +colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE @@ -143,7 +143,7 @@ class: FL_BUTTON type: NORMAL_BUTTON box: 435 90 110 30 boxtype: FL_UP_BOX -colors: FL_COL1 FL_BLACK +colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE @@ -161,7 +161,7 @@ class: FL_BUTTON type: NORMAL_BUTTON box: 435 130 110 30 boxtype: FL_UP_BOX -colors: FL_COL1 FL_BLACK +colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE @@ -179,7 +179,7 @@ class: FL_BUTTON type: RETURN_BUTTON box: 255 270 90 30 boxtype: FL_UP_BOX -colors: FL_COL1 FL_BLACK +colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE @@ -197,7 +197,7 @@ class: FL_BUTTON type: NORMAL_BUTTON box: 355 270 90 30 boxtype: FL_UP_BOX -colors: FL_COL1 FL_BLACK +colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE diff --git a/src/frontends/xforms/forms/form_graphics.fd b/src/frontends/xforms/forms/form_graphics.fd index f78081941a..a678e741a2 100644 --- a/src/frontends/xforms/forms/form_graphics.fd +++ b/src/frontends/xforms/forms/form_graphics.fd @@ -143,7 +143,7 @@ argument: Name: form_file Width: 505 Height: 235 -Number of Objects: 14 +Number of Objects: 15 -------------------- class: FL_BOX @@ -245,7 +245,7 @@ alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Title:|#T +label: Title|#T shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity @@ -281,7 +281,7 @@ alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Angle:|#n +label: Angle|#n shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity @@ -317,7 +317,7 @@ alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Origin:|#O +label: Origin|#O shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity @@ -346,7 +346,7 @@ argument: -------------------- class: FL_CHECKBUTTON type: PUSH_BUTTON -box: 145 190 30 30 +box: 140 190 30 30 boxtype: FL_NO_BOX colors: FL_COL1 FL_YELLOW alignment: FL_ALIGN_RIGHT @@ -397,11 +397,29 @@ name: check_rotate callback: C_FormBaseInputCB argument: 0 +-------------------- +class: FL_CHECKBUTTON +type: PUSH_BUTTON +box: 315 190 30 30 +boxtype: FL_NO_BOX +colors: FL_COL1 FL_YELLOW +alignment: FL_ALIGN_RIGHT +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: don't unzip, when \nexporting to LaTeX|#u +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: button_nounzip +callback: C_FormBaseInputCB +argument: 0 + =============== FORM =============== Name: form_size Width: 505 Height: 235 -Number of Objects: 15 +Number of Objects: 17 -------------------- class: FL_BOX @@ -539,7 +557,7 @@ alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Value:|#V +label: Value|#V shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity @@ -575,7 +593,7 @@ alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Width:|#W +label: Width|#W shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity @@ -611,7 +629,7 @@ alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Height:|#g +label: Height|#g shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity @@ -673,11 +691,47 @@ name: callback: argument: +-------------------- +class: FL_BUTTON +type: NORMAL_BUTTON +box: 360 20 115 30 +boxtype: FL_UP_BOX +colors: FL_COL1 FL_COL1 +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Get LyX size|#x +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: button_lyx_values +callback: C_FormBaseInputCB +argument: 0 + +-------------------- +class: FL_FRAME +type: ENGRAVED_FRAME +box: 340 10 5 50 +boxtype: FL_NO_BOX +colors: FL_BLACK FL_COL1 +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_DEFAULT_SIZE +lcol: FL_BLACK +label: +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: +callback: +argument: + =============== FORM =============== Name: form_bbox Width: 505 Height: 235 -Number of Objects: 13 +Number of Objects: 10 -------------------- class: FL_BOX @@ -700,14 +754,14 @@ argument: -------------------- class: FL_LABELFRAME type: ENGRAVED_FRAME -box: 20 25 455 195 -boxtype: FL_NO_BOX +box: 15 10 475 205 +boxtype: FL_UP_BOX colors: FL_BLACK FL_COL1 alignment: FL_ALIGN_TOP_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: +label: Corner coordinates (X, Y) shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity @@ -718,14 +772,14 @@ argument: -------------------- class: FL_TEXT type: NORMAL_TEXT -box: 135 35 35 25 +box: 195 110 30 25 boxtype: FL_FLAT_BOX colors: FL_COL1 FL_MCOL -alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE +alignment: FL_ALIGN_CENTER|FL_ALIGN_INSIDE style: FL_BOLD_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: X +label: , shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity @@ -736,14 +790,14 @@ argument: -------------------- class: FL_TEXT type: NORMAL_TEXT -box: 360 35 30 25 +box: 195 55 30 25 boxtype: FL_FLAT_BOX colors: FL_COL1 FL_MCOL -alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE +alignment: FL_ALIGN_CENTER|FL_ALIGN_INSIDE style: FL_BOLD_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Y +label: , shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity @@ -754,158 +808,104 @@ argument: -------------------- class: FL_INPUT type: NORMAL_INPUT -box: 135 60 50 30 +box: 150 45 50 30 boxtype: FL_DOWN_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Left Bottom:|#L +label: Top right ( |#T shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity -name: input_bb_x0 -callback: C_FormBaseInputCB -argument: 0 - --------------------- -class: FL_CHOICE -type: NORMAL_CHOICE -box: 190 60 50 30 -boxtype: FL_FRAME_BOX -colors: FL_COL1 FL_BLACK -alignment: FL_ALIGN_LEFT -style: FL_NORMAL_STYLE -size: FL_NORMAL_SIZE -lcol: FL_BLACK -label: -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: choice_bb_x0 +name: input_bb_x1 callback: C_FormBaseInputCB argument: 0 -------------------- class: FL_INPUT type: NORMAL_INPUT -box: 135 100 50 30 +box: 220 45 50 30 boxtype: FL_DOWN_BOX colors: FL_COL1 FL_MCOL -alignment: FL_ALIGN_LEFT -style: FL_NORMAL_STYLE -size: FL_NORMAL_SIZE -lcol: FL_BLACK -label: Right Top:|#R -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: input_bb_x1 -callback: C_FormBaseInputCB -argument: 0 - --------------------- -class: FL_CHOICE -type: NORMAL_CHOICE -box: 190 100 50 30 -boxtype: FL_FRAME_BOX -colors: FL_COL1 FL_BLACK -alignment: FL_ALIGN_LEFT +alignment: FL_ALIGN_RIGHT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: +label: ) shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity -name: choice_bb_x1 +name: input_bb_y1 callback: C_FormBaseInputCB argument: 0 -------------------- class: FL_INPUT type: NORMAL_INPUT -box: 360 60 50 30 +box: 150 95 50 30 boxtype: FL_DOWN_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Left Bottom:|#f +label: Bottom left ( |#B shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity -name: input_bb_y0 -callback: C_FormBaseInputCB -argument: 0 - --------------------- -class: FL_CHOICE -type: NORMAL_CHOICE -box: 415 60 45 30 -boxtype: FL_FRAME_BOX -colors: FL_COL1 FL_BLACK -alignment: FL_ALIGN_LEFT -style: FL_NORMAL_STYLE -size: FL_NORMAL_SIZE -lcol: FL_BLACK -label: -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: choice_bb_y0 +name: input_bb_x0 callback: C_FormBaseInputCB argument: 0 -------------------- class: FL_INPUT type: NORMAL_INPUT -box: 360 100 50 30 +box: 220 95 50 30 boxtype: FL_DOWN_BOX colors: FL_COL1 FL_MCOL -alignment: FL_ALIGN_LEFT +alignment: FL_ALIGN_RIGHT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Right Top:|#T +label: ) shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity -name: input_bb_y1 +name: input_bb_y0 callback: C_FormBaseInputCB argument: 0 -------------------- class: FL_CHOICE type: NORMAL_CHOICE -box: 415 100 45 30 +box: 370 70 45 30 boxtype: FL_FRAME_BOX colors: FL_COL1 FL_BLACK alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: +label: Units|#U shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity -name: choice_bb_y1 +name: choice_bb_units callback: C_FormBaseInputCB argument: 0 -------------------- class: FL_BUTTON type: NORMAL_BUTTON -box: 135 160 220 30 +box: 110 160 165 30 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Get bounding box from file|#G +label: Get values from file|#G shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity @@ -965,7 +965,7 @@ alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: LaTeX Options:|#L +label: LaTeX Options|#L shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity @@ -977,7 +977,7 @@ argument: 0 Name: form_lyxview Width: 505 Height: 235 -Number of Objects: 24 +Number of Objects: 26 -------------------- class: FL_BOX @@ -1025,7 +1025,7 @@ alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Value:|#V +label: Value|#V shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity @@ -1313,7 +1313,7 @@ alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Width:|#w +label: Width|#w shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity @@ -1349,7 +1349,7 @@ alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Height:|#h +label: Height|#h shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity @@ -1411,5 +1411,41 @@ name: callback: argument: +-------------------- +class: FL_BUTTON +type: NORMAL_BUTTON +box: 350 20 115 30 +boxtype: FL_UP_BOX +colors: FL_COL1 FL_COL1 +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Get LaTeX size|#x +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: button_latex_values +callback: C_FormBaseInputCB +argument: 0 + +-------------------- +class: FL_FRAME +type: ENGRAVED_FRAME +box: 320 10 5 50 +boxtype: FL_NO_BOX +colors: FL_BLACK FL_COL1 +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_DEFAULT_SIZE +lcol: FL_BLACK +label: +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: +callback: +argument: + ============================== -------------------- diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 317718ff59..9f003f2889 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,11 @@ +2002-02-08 Herbert Voss + + * insetgraphic.C: + * insetgraphicsParams.[Ch]: adding new Option noUnzip to + prevent LyX from unzipping when this should be handled + by latex vis the graphic.cfg. + clean up the code + 2002-02-08 Herbert Voss * insetgraphic.C: prepareFile(): fix bug when file doesn't diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 0abcdb398a..8d4ed1d42c 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -93,6 +93,7 @@ TODO Before initial production release: #include "insets/insetgraphicsParams.h" #include "graphics/GraphicsCache.h" #include "graphics/GraphicsCacheItem.h" +#include "graphics/GraphicsImage.h" #include "frontends/Dialogs.h" #include "frontends/Alert.h" @@ -100,7 +101,6 @@ TODO Before initial production release: #include "buffer.h" #include "BufferView.h" #include "converter.h" -#include "frontends/support/LyXImage.h" #include "Painter.h" #include "lyx_gui_misc.h" #include "support/FileInfo.h" @@ -135,16 +135,11 @@ string const RemoveExtension(string const & filename) } -// Initialize only those variables that do not have a constructor. InsetGraphics::InsetGraphics() - : cacheHandle(0), imageLoaded(false) {} InsetGraphics::InsetGraphics(InsetGraphics const & ig, bool same_id) - : Inset(), SigC::Object() - , cacheHandle(ig.cacheHandle) - , imageLoaded(ig.imageLoaded) { setParams(ig.getParams()); if (same_id) @@ -154,6 +149,9 @@ InsetGraphics::InsetGraphics(InsetGraphics const & ig, bool same_id) InsetGraphics::~InsetGraphics() { + grfx::GCache & gc = grfx::GCache::get(); + gc.remove(*this); + // Emits the hide signal to the dialog connected (if any) hideDialog(); } @@ -162,37 +160,50 @@ InsetGraphics::~InsetGraphics() string const InsetGraphics::statusMessage() const { string msg; - if (cacheHandle.get()) { - switch (cacheHandle->getImageStatus()) { - case GraphicsCacheItem::UnknownError: - msg = _("Unknown Error"); - break; - case GraphicsCacheItem::Loading: - msg = _("Loading..."); - break; - case GraphicsCacheItem::ErrorReading: - msg = _("Error reading"); - break; - case GraphicsCacheItem::Converting: - msg = _("Converting Image"); - break; - case GraphicsCacheItem::ErrorConverting: - msg = _("Error converting"); - break; - case GraphicsCacheItem::Loaded: - // No message to write. - break; - } + grfx::GCache const & gc = grfx::GCache::get(); + grfx::ImageStatus const status = gc.status(*this); + + switch (status) { + case grfx::WaitingToLoad: + msg = _("Waiting for draw request to start loading..."); + break; + case grfx::Loading: + msg = _("Loading..."); + break; + case grfx::Converting: + msg = _("Converting to loadable format..."); + break; + case grfx::ScalingEtc: + msg = _("Loaded. Scaling etc..."); + break; + case grfx::ErrorLoading: + msg = _("Error loading"); + break; + case grfx::ErrorConverting: + msg = _("Error converting to loadable format"); + break; + case grfx::ErrorScalingEtc: + msg = _("Error scaling etc"); + break; + case grfx::ErrorUnknown: + msg = _("No image associated with this inset is in the cache!"); + break; + case grfx::Loaded: + msg = _("Loaded"); + break; } + return msg; } int InsetGraphics::ascent(BufferView *, LyXFont const &) const { - LyXImage * pixmap = 0; - if (cacheHandle.get() && (pixmap = cacheHandle->getImage())) - return pixmap->getHeight(); + grfx::GCache const & gc = grfx::GCache::get(); + grfx::ImagePtr const image_ptr = gc.image(*this); + + if (image_ptr.get() && image_ptr->getPixmap()) + return image_ptr->getHeight(); else return 50; } @@ -207,10 +218,11 @@ int InsetGraphics::descent(BufferView *, LyXFont const &) const int InsetGraphics::width(BufferView *, LyXFont const & font) const { - LyXImage * pixmap = 0; - - if (cacheHandle.get() && (pixmap = cacheHandle->getImage())) - return pixmap->getWidth(); + grfx::GCache const & gc = grfx::GCache::get(); + grfx::ImagePtr const image_ptr = gc.image(*this); + + if (image_ptr.get() && image_ptr->getPixmap()) + return image_ptr->getWidth(); else { int font_width = 0; @@ -239,38 +251,49 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font, int baseline, float & x, bool) const { Painter & paint = bv->painter(); + grfx::GCache & gc = grfx::GCache::get(); + grfx::ImageStatus const status = gc.status(*this); + + // Better to be paranoid and safe! + grfx::ImagePtr i_ptr = gc.image(*this); + Pixmap const pixmap = (status == grfx::Loaded && i_ptr.get()) ? + i_ptr->getPixmap() : 0; int ldescent = descent(bv, font); - int lascent = ascent(bv, font); - int lwidth = width(bv, font); + int lascent = ascent(bv, font); + int lwidth = width(bv, font); + + Pixmap const check_pixmap = (status == grfx::Loaded && i_ptr.get()) ? + i_ptr->getPixmap() : 0; + + if (pixmap != check_pixmap) { + // Tell BufferView we need to be updated! + bv->text->status(bv, LyXText::CHANGED_IN_DRAW); + } // Make sure x is updated upon exit from this routine int old_x = int(x); x += lwidth; + // Initiate the loading of the graphics file + if (status == grfx::WaitingToLoad) { + gc.startLoading(*this); + } + // This will draw the graphics. If the graphics has not been loaded yet, // we draw just a rectangle. - if (imageLoaded) { + + if (pixmap != 0) { paint.image(old_x + 2, baseline - lascent, - lwidth - 4, lascent + ldescent, - cacheHandle->getImage()); + lwidth - 4, lascent + ldescent, i_ptr); + } else { - // Get the image status, default to unknown error. - GraphicsCacheItem::ImageStatus status = GraphicsCacheItem::UnknownError; - if (lyxrc.use_gui && params.display != InsetGraphicsParams::NONE && - cacheHandle.get()) - status = cacheHandle->getImageStatus(); - // Check if the image is now ready. - if (status == GraphicsCacheItem::Loaded) { - imageLoaded = true; - // Tell BufferView we need to be updated! - bv->text->status(bv, LyXText::CHANGED_IN_DRAW); - return; - } + paint.rectangle(old_x + 2, baseline - lascent, lwidth - 4, lascent + ldescent); + // Print the file name. LyXFont msgFont(font); msgFont.setFamily(LyXFont::SANS_FAMILY); @@ -281,6 +304,7 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font, baseline - lyxfont::maxAscent(msgFont) - 4, justname, msgFont); } + // Print the message. string const msg = statusMessage(); if (!msg.empty()) { @@ -291,6 +315,16 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font, } +// Update the inset after parameters changed (read from file or changed in +// dialog. The grfx::GCache makes the decisions about whether or not to draw +// (interogates lyxrc, ascertains whether file exists etc) +void InsetGraphics::updateInset() const +{ + grfx::GCache & gc = grfx::GCache::get(); + gc.update(*this); +} + + void InsetGraphics::edit(BufferView *bv, int, int, unsigned int) { bv->owner()->getDialogs()->showGraphics(this); @@ -536,47 +570,37 @@ string const InsetGraphics::prepareFile(Buffer const *buf) const // // first check if file is viewed in LyX. First local // than global - if ((params.display == InsetGraphicsParams::NONE) || - ((params.display == InsetGraphicsParams::DEFAULT) && - (lyxrc.display_graphics == "no"))) { - lyxerr << "InsetGraphics::no converting of: " << params.filename << "\n"; - return params.filename; - } // if it's a zipped one, than let LaTeX do the rest!!! - if (zippedFile(params.filename)) { - lyxerr << "InsetGraphics::prepareFilter(zippedFile): return " + if ((zippedFile(params.filename) && params.noUnzip) || buf->niceFile) { + lyxerr << "don't unzip file or export latex" << params.filename << endl; return params.filename; } + string filename_ = params.filename; + if (zippedFile(filename_)) + filename_ = unzipFile(filename_); // now we have unzipped files // Get the extension (format) of the original file. // we handle it like a virtual one, so we can have // different extensions with the same type. - string const extension = getExtFromContents(params.filename); - // Are we creating a PDF or a PS file? - // (Should actually mean, are we usind latex or pdflatex). + string const extension = getExtFromContents(filename_); + // are we usind latex ((e)ps) or pdflatex (pdf,jpg,png) string const image_target = decideOutputImageFormat(extension); - if (extension == image_target) - return params.filename; - if (!IsFileReadable(params.filename)) { + if (extension == image_target) // :-) + return filename_; + if (!IsFileReadable(filename_)) { // :-( Alert::alert(_("File") + params.filename, _("isn't readable or doesn't exists!")); - return params.filename; + return filename_; } string outfile; - if (!buf->niceFile) { - string const temp = AddName(buf->tmppath, params.filename); - lyxerr << "temp = " << temp << "\n"; - outfile = RemoveExtension(temp); - } else { - string const path = buf->filePath(); - string const relname = MakeRelPath(params.filename, path); - outfile = RemoveExtension(relname); - } + string const temp = AddName(buf->tmppath, filename_); + outfile = RemoveExtension(temp); + lyxerr << "tempname = " << temp << "\n"; lyxerr << "buf::tmppath = " << buf->tmppath << "\n"; - lyxerr << "filename = " << params.filename << "\n"; + lyxerr << "filename_ = " << filename_ << "\n"; lyxerr << "outfile = " << outfile << endl; - converters.convert(buf, params.filename, outfile, extension, image_target); + converters.convert(buf, filename_, outfile, extension, image_target); return outfile; } @@ -592,6 +616,7 @@ int InsetGraphics::latex(Buffer const *buf, ostream & os, return 1; // One end of line marker added to the stream. } // Keep count of newlines that we issued. +#warning the newlines=0 were in the original code. where is the sense? (Herbert) int newlines = 0; // This variables collect all the latex code that should be before and // after the actual includegraphics command. @@ -672,39 +697,6 @@ void InsetGraphics::validate(LaTeXFeatures & features) const } -// Update the inset after parameters changed (read from file or changed in -// dialog. -void InsetGraphics::updateInset() const -{ - GraphicsCache & gc = GraphicsCache::getInstance(); - boost::shared_ptr temp(0); - - // We do it this way so that in the face of some error, we will still - // be in a valid state. - InsetGraphicsParams::DisplayType local_display = params.display; - if (local_display == InsetGraphicsParams::DEFAULT) { - if (lyxrc.display_graphics == "mono") - local_display = InsetGraphicsParams::MONOCHROME; - else if (lyxrc.display_graphics == "gray") - local_display = InsetGraphicsParams::GRAYSCALE; - else if (lyxrc.display_graphics == "color") - local_display = InsetGraphicsParams::COLOR; - else - local_display = InsetGraphicsParams::NONE; - } - - if (!params.filename.empty() && lyxrc.use_gui && - local_display != InsetGraphicsParams::NONE) { - temp = gc.addFile(params.filename); - } - - // Mark the image as unloaded so that it gets updated. - imageLoaded = false; - - cacheHandle = temp; -} - - bool InsetGraphics::setParams(InsetGraphicsParams const & p) { // If nothing is changed, just return and say so. diff --git a/src/insets/insetgraphics.h b/src/insets/insetgraphics.h index 6e00518c45..16498ef72e 100644 --- a/src/insets/insetgraphics.h +++ b/src/insets/insetgraphics.h @@ -30,7 +30,6 @@ #include "sigc++/signal_system.h" class Dialogs; -class LyXImage; /// class InsetGraphics : public Inset, public SigC::Object { @@ -113,10 +112,6 @@ private: string const createLatexOptions() const; /// Convert the file if needed, and return the location of the file. string const prepareFile(Buffer const * buf) const; - /// The graphics cache handle. - mutable boost::shared_ptr cacheHandle; - /// is the pixmap initialized? - mutable bool imageLoaded; /// InsetGraphicsParams params; }; diff --git a/src/insets/insetgraphicsParams.C b/src/insets/insetgraphicsParams.C index 4d09828351..94aa851d5b 100644 --- a/src/insets/insetgraphicsParams.C +++ b/src/insets/insetgraphicsParams.C @@ -97,17 +97,18 @@ void InsetGraphicsParams::init() bb = string(); // bounding box draft = false; // draft mode clip = false; // clip image - display = DEFAULT; + display = DEFAULT; // see pref subcaption = false; // subfigure + noUnzip = false; // unzip files width = LyXLength(); // set to 0pt height = LyXLength(); lyxwidth = LyXLength(); // for the view in lyx - lyxheight = LyXLength(); - scale = 0; - lyxscale = 0; + lyxheight = LyXLength(); // also set to 0pt + scale = 0; // unit is % + lyxscale = 0; // same for lyxview size_type = DEFAULT_SIZE; // do nothing lyxsize_type = DEFAULT_SIZE; // do nothing - keepAspectRatio = false; // + keepAspectRatio = false; // only for latex rotate = false; // Rotating rotateOrigin = "center"; // Origin rotateAngle = 0.0; // in degrees @@ -123,6 +124,7 @@ void InsetGraphicsParams::copy(InsetGraphicsParams const & igp) display = igp.display; subcaption = igp.subcaption; subcaptionText = igp.subcaptionText; + noUnzip = igp.noUnzip; keepAspectRatio = igp.keepAspectRatio; width = igp.width; height = igp.height; @@ -147,6 +149,7 @@ bool operator==(InsetGraphicsParams const & left, left.clip == right.clip && left.display == right.display && left.subcaption == right.subcaption && + left.noUnzip == right.noUnzip && left.subcaptionText == right.subcaptionText && left.keepAspectRatio == right.keepAspectRatio && left.width == right.width && @@ -188,13 +191,15 @@ void InsetGraphicsParams::Write(Buffer const * buf, ostream & os) const os << "\tclip\n"; if (draft) // draft mode os << "\tdraft\n"; - // Save the display type + // Save the display type for the view inside lyx os << "\tdisplay " << displayTranslator.find(display) << '\n'; // Save the subcaption status if (subcaption) os << "\tsubcaption\n"; if (!subcaptionText.empty()) os << "\tsubcaptionText \"" << subcaptionText << '\"' << '\n'; + if (noUnzip) + os << "\tnoUnzip\n"; // we always need the size type // 0: no special // 1: width/height combination @@ -216,6 +221,7 @@ void InsetGraphicsParams::Write(Buffer const * buf, ostream & os) const os << "\trotateOrigin " << rotateOrigin << '\n'; if (!special.empty()) os << "\tspecial " << special << '\n'; + // the values for the view in lyx os << "\tlyxsize_type " << lyxsize_type << '\n'; if (!lyxwidth.zero()) // the lyx-viewsize os << "\tlyxwidth " << lyxwidth.asString() << '\n'; @@ -254,19 +260,8 @@ bool InsetGraphicsParams::Read(Buffer const * buf, LyXLex & lex, } else if (token == "subcaptionText") { lex.next(); subcaptionText = lex.getString(); - } else if (token == "widthResize") { - if (lex.next()) { - string const token = lex.getString(); - if (token == "scale") { - lex.next(); - scale = lex.getInteger(); - size_type = SCALE; - } - else { - width = convertResizeValue(token, lex); - size_type = WH; - } - } + } else if (token == "noUnzip") { + noUnzip = true; } else if (token == "size_type") { lex.next(); switch (lex.getInteger()) { @@ -280,9 +275,6 @@ bool InsetGraphicsParams::Read(Buffer const * buf, LyXLex & lex, lex.next(); width = LyXLength(lex.getString()); size_type = WH; - } else if (token == "heightResize") { - if (lex.next()) - height = convertResizeValue(lex.getString(), lex); } else if (token == "height") { lex.next(); height = LyXLength(lex.getString()); @@ -318,8 +310,27 @@ bool InsetGraphicsParams::Read(Buffer const * buf, LyXLex & lex, } else if (token == "lyxscale") { lex.next(); lyxscale = lex.getInteger(); - } else { - // If it's none of the above, its not ours. + // now the compytibility stuff for "old" 1.2.0 files which uses + // the first try of the new graphic inset. Can be deleted, when + // 1.3 comes out + } else if (token == "widthResize") { + if (lex.next()) { + string const token = lex.getString(); + if (token == "scale") { + lex.next(); + scale = lex.getInteger(); + size_type = SCALE; + } + else { + width = convertResizeValue(token, lex); + size_type = WH; + } + } + } else if (token == "heightResize") { + if (lex.next()) + height = convertResizeValue(lex.getString(), lex); + // end compytibility stuff + } else { // If it's none of the above, its not ours. return false; } return true; diff --git a/src/insets/insetgraphicsParams.h b/src/insets/insetgraphicsParams.h index 5f83835853..c218d0ecb4 100644 --- a/src/insets/insetgraphicsParams.h +++ b/src/insets/insetgraphicsParams.h @@ -36,7 +36,7 @@ struct InsetGraphicsParams NONE // only keep a frame in place. }; /// - enum sizeType { + enum sizeType { // for latex and/or lyx DEFAULT_SIZE, // like none WH, // width/height values SCALE // percentage value @@ -47,40 +47,42 @@ struct InsetGraphicsParams bool subcaption; /// The text of the subcaption. string subcaptionText; - /// The bounding box with "xLB yLB yRT yRT ", divided by a space! /// Do we rotate? bool rotate; /// Origin point of rotation string rotateOrigin; /// Rotation angle. float rotateAngle; - string bb; /// clip image bool clip; /// draft mode bool draft; - /// How to display the image - DisplayType display; - /// any userdefined special command - string special; - /// three possible values for rescaling + /// what to do with zipped files + bool noUnzip; + /// The bounding box with "xLB yLB yRT yRT ", divided by a space! + string bb; + /// Type of rescaling + sizeType size_type; + /// three possible values for rescaling (latex) LyXLength width; /// LyXLength height; /// int scale; - /// Type of rescaling - sizeType size_type; /// Keep the ratio between height and width when resizing. bool keepAspectRatio; + /// any userdefined special command + string special; + /// How to display the image inside lyx + DisplayType display; /// the size for the view inside lyx + /// Typ of the LyXView, same as for latex + sizeType lyxsize_type; LyXLength lyxwidth; /// LyXLength lyxheight; - /// Typ of rescaling the Screen + /// Typ of rescaling the Screen inside lyx int lyxscale; - /// Typ of the LyXView, same as for latex - sizeType lyxsize_type; /// InsetGraphicsParams(); /// -- 2.39.5