mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +00:00
Some helper functions for the augmented dialogs.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8195 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
b3ac06d3a2
commit
8c374dcefb
@ -1,3 +1,11 @@
|
||||
2003-12-04 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* ControlExternal.[Ch] (bbChanged): new accessor functions to a
|
||||
boolean flag.
|
||||
(readBB): attempt to read the BoundingBox from the graphics file.
|
||||
If that fails, try the Graphics Cache.
|
||||
(all_origins, origin_gui_str): helpers for the frontends.
|
||||
|
||||
2003-12-01 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||
|
||||
* ControlVSpace.C: enable the buttons for new insets.
|
||||
|
@ -13,24 +13,35 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "ControlExternal.h"
|
||||
|
||||
#include "funcrequest.h"
|
||||
#include "gettext.h"
|
||||
#include "helper_funcs.h"
|
||||
#include "lyxrc.h"
|
||||
|
||||
#include "graphics/GraphicsCache.h"
|
||||
#include "graphics/GraphicsCacheItem.h"
|
||||
#include "graphics/GraphicsImage.h"
|
||||
|
||||
#include "insets/insetexternal.h"
|
||||
#include "insets/ExternalSupport.h"
|
||||
#include "insets/ExternalTemplate.h"
|
||||
|
||||
#include "support/filetools.h"
|
||||
#include "support/tostr.h"
|
||||
|
||||
namespace external = lyx::external;
|
||||
|
||||
using lyx::support::MakeAbsPath;
|
||||
using lyx::support::readBB_from_PSFile;
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
|
||||
|
||||
ControlExternal::ControlExternal(Dialog & parent)
|
||||
: Dialog::Controller(parent)
|
||||
: Dialog::Controller(parent),
|
||||
bb_changed_(false)
|
||||
{}
|
||||
|
||||
|
||||
@ -52,6 +63,7 @@ void ControlExternal::dispatchParams()
|
||||
{
|
||||
string const lfun = InsetExternalMailer::params2string(params(),
|
||||
kernel().buffer());
|
||||
|
||||
kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
|
||||
}
|
||||
|
||||
@ -136,11 +148,87 @@ string const ControlExternal::Browse(string const & input) const
|
||||
if (et_ptr)
|
||||
pattern = et_ptr->fileRegExp;
|
||||
|
||||
// FIXME: a temporary hack until the FileDialog interface is updated
|
||||
pattern += '|';
|
||||
|
||||
std::pair<string, string> dir1(N_("Documents|#o#O"),
|
||||
string(lyxrc.document_path));
|
||||
|
||||
return browseRelFile(input, bufpath, title, pattern, false, dir1);
|
||||
}
|
||||
|
||||
|
||||
string const ControlExternal::readBB(string const & file)
|
||||
{
|
||||
string const abs_file =
|
||||
MakeAbsPath(file, kernel().bufferFilepath());
|
||||
|
||||
// try to get it from the file, if possible. Zipped files are
|
||||
// unzipped in the readBB_from_PSFile-Function
|
||||
string const bb = readBB_from_PSFile(abs_file);
|
||||
if (!bb.empty())
|
||||
return bb;
|
||||
|
||||
// we don't, so ask the Graphics Cache if it has loaded the file
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
|
||||
lyx::graphics::Cache & gc = lyx::graphics::Cache::get();
|
||||
if (gc.inCache(abs_file)) {
|
||||
lyx::graphics::Image const * image = gc.item(abs_file)->image();
|
||||
|
||||
if (image) {
|
||||
width = image->getWidth();
|
||||
height = image->getHeight();
|
||||
}
|
||||
}
|
||||
|
||||
return ("0 0 " + tostr(width) + ' ' + tostr(height));
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
external::RotationDataType origins_array[] = {
|
||||
external::RotationData::DEFAULT,
|
||||
external::RotationData::TOPLEFT,
|
||||
external::RotationData::BOTTOMLEFT,
|
||||
external::RotationData::BASELINELEFT,
|
||||
external::RotationData::CENTER,
|
||||
external::RotationData::TOPCENTER,
|
||||
external::RotationData::BOTTOMCENTER,
|
||||
external::RotationData::BASELINECENTER,
|
||||
external::RotationData::TOPRIGHT,
|
||||
external::RotationData::BOTTOMRIGHT,
|
||||
external::RotationData::BASELINERIGHT
|
||||
};
|
||||
|
||||
lyx::size_type const origins_array_size =
|
||||
sizeof(origins_array) / sizeof(origins_array[0]);
|
||||
|
||||
vector<external::RotationDataType> const
|
||||
origins(origins_array, origins_array + origins_array_size);
|
||||
|
||||
// These are the strings, corresponding to the above, that the GUI should
|
||||
// use. Note that they can/should be translated.
|
||||
char const * const origin_gui_strs[] = {
|
||||
N_("Default"),
|
||||
N_("Top left"), N_("Bottom left"), N_("Baseline left"),
|
||||
N_("Center"), N_("Top center"), N_("Bottom center"), N_("Baseline center"),
|
||||
N_("Top right"), N_("Bottom right"), N_("Baseline right")
|
||||
};
|
||||
|
||||
} // namespace anon
|
||||
|
||||
namespace lyx {
|
||||
namespace external {
|
||||
|
||||
vector<RotationDataType> const & all_origins()
|
||||
{
|
||||
return origins;
|
||||
}
|
||||
|
||||
string const origin_gui_str(size_type i)
|
||||
{
|
||||
return origin_gui_strs[i];
|
||||
}
|
||||
|
||||
} // namespace external
|
||||
} // namespace lyx
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
#include "Dialog.h"
|
||||
|
||||
#include "support/types.h"
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
#include <string>
|
||||
@ -28,6 +30,7 @@ namespace lyx {
|
||||
namespace external {
|
||||
|
||||
class Template;
|
||||
class RotationDataType;
|
||||
|
||||
} // namespace external
|
||||
} // namespace lyx
|
||||
@ -61,9 +64,26 @@ public:
|
||||
lyx::external::Template getTemplate(int) const;
|
||||
///
|
||||
std::string const Browse(std::string const &) const;
|
||||
|
||||
/// Read the Bounding Box from a eps or ps-file
|
||||
std::string const readBB(std::string const & file);
|
||||
///
|
||||
void bbChanged(bool val) { bb_changed_ = val; }
|
||||
bool bbChanged() const { return bb_changed_; }
|
||||
private:
|
||||
///
|
||||
boost::scoped_ptr<InsetExternalParams> params_;
|
||||
bool bb_changed_;
|
||||
};
|
||||
|
||||
|
||||
namespace lyx {
|
||||
namespace external {
|
||||
|
||||
std::vector<RotationDataType> const & all_origins();
|
||||
std::string const origin_gui_str(lyx::size_type i);
|
||||
|
||||
} // namespace external
|
||||
} // namespace lyx
|
||||
|
||||
#endif // CONTROLEXTERNAL_H
|
||||
|
Loading…
Reference in New Issue
Block a user