/branches/Version13x/Scribus/scribus/guidemanager.cpp |
---|
67,7 → 67,8 |
GuideManager::GuideManager(QWidget* parent) : |
GuideManagerBase(parent, "GuideManager"), |
m_Doc(0)//, |
m_Doc(0), |
currentPage(0) |
//ScrPaletteBase(parent, "GuideManager", false, 0) |
{ |
setIcon(loadIcon("AppIcon.png")); |
91,16 → 92,51 |
if (!m_Doc) |
return; |
setEnabled(true); |
// store old values for current page |
storePreviousValues(); |
currentPage = m_Doc->currentPage(); |
unitChange(); |
resetMarginsForPage(); |
// restore values from new page |
clearRestoreHorizontalList(); |
clearRestoreVerticalList(); |
// TODO: implement some auto into GUI restore algorithm |
horizontalAutoCountSpin_valueChanged(1); |
verticalAutoCountSpin_valueChanged(1); |
// restore: brand "auto guides into GUI restore algorithm" |
currentPage->guides.clearHorizontals(GuideManagerCore::Auto); |
bool enable = currentPage->guides.horizontalAutoGap() > 0.0 ? true : false; |
horizontalAutoGapCheck->setChecked(enable); |
horizontalAutoGapSpin->setEnabled(enable); |
horizontalAutoGapSpin->setValue(currentPage->guides.horizontalAutoGap()); |
horizontalAutoCountSpin->setValue(currentPage->guides.horizontalAutoCount()); |
// verticals |
currentPage->guides.clearVerticals(GuideManagerCore::Auto); |
enable = currentPage->guides.verticalAutoGap() > 0.0 ? true : false; |
verticalAutoGapCheck->setChecked(enable); |
verticalAutoGapSpin->setEnabled(enable); |
verticalAutoGapSpin->setValue(currentPage->guides.verticalAutoGap()); |
verticalAutoCountSpin->setValue(currentPage->guides.verticalAutoCount()); |
bGroup->setButton(currentPage->guides.autoRefer()); |
} |
void GuideManager::storePreviousValues() |
{ |
if (!currentPage || !m_Doc) |
return; |
double gapValue = 0.0; |
if (horizontalAutoGapCheck->isChecked()) |
gapValue = value2pts(horizontalAutoGapSpin->value(), m_Doc->unitIndex()); |
currentPage->guides.setHorizontalAutoGap(gapValue); |
currentPage->guides.setHorizontalAutoCount(horizontalAutoCountSpin->value()); |
gapValue = 0.0; |
if (verticalAutoGapCheck->isChecked()) |
gapValue = value2pts(verticalAutoGapSpin->value(), m_Doc->unitIndex()); |
currentPage->guides.setVerticalAutoGap(gapValue); |
currentPage->guides.setVerticalAutoCount(verticalAutoCountSpin->value()); |
currentPage->guides.setAutoRefer(bGroup->selectedId()); |
} |
void GuideManager::unitChange() |
{ |
if (!m_Doc) |
393,7 → 429,7 |
newPageHeight = gh; |
} |
QValueList<double> values; |
double gapValue; |
double gapValue = 0.0; |
double rowSize; |
if (horizontalAutoGapCheck->isChecked()) |
{ |
404,6 → 440,7 |
rowSize = newPageHeight / value; |
currentPage->guides.clearHorizontals(GuideManagerCore::Auto); |
for (int i = 1, gapCount = 0; i < value; ++i) |
{ |
if (horizontalAutoGapCheck->isChecked()) |
439,11 → 476,11 |
} |
QValueList<double> values; |
double gapValue; |
double gapValue = 0.0; |
double columnSize; |
if (verticalAutoGapCheck->isChecked()) |
{ |
gapValue = value2pts(horizontalAutoGapSpin->value(), m_Doc->unitIndex()); |
gapValue = value2pts(verticalAutoGapSpin->value(), m_Doc->unitIndex()); |
columnSize = (newPageWidth - (value - 1) * gapValue) / value; |
} |
else |
450,6 → 487,7 |
columnSize = newPageWidth / value; |
currentPage->guides.clearVerticals(GuideManagerCore::Auto); |
for (int i = 1, gapCount = 0; i < value; ++i) |
{ |
if (verticalAutoGapCheck->isChecked()) |
/branches/Version13x/Scribus/scribus/guidemanagercore.cpp |
---|
20,6 → 20,11 |
GuideManagerCore::GuideManagerCore(): |
undoManager(UndoManager::instance()) |
{ |
m_horizontalAutoGap = 0.0; |
m_verticalAutoGap = 0.0; |
m_autoRefer = 0; |
m_horizontalAutoCount = 0; |
m_verticalAutoCount = 0; |
} |
GuideManagerCore::GuideManagerCore(Page *parentPage): |
26,6 → 31,11 |
undoManager(UndoManager::instance()) |
{ |
m_page = parentPage; |
m_horizontalAutoGap = 0.0; |
m_verticalAutoGap = 0.0; |
m_autoRefer = 0; |
m_horizontalAutoCount = 0; |
m_verticalAutoCount = 0; |
} |
GuideManagerCore::~GuideManagerCore() |
/branches/Version13x/Scribus/scribus/guidemanagercore.h |
---|
85,7 → 85,6 |
the old reading method is used. All guides are saved in new format then. */ |
static void readHorizontalGuides(const QString guideString, Page *page, GuideType type, bool useOldGuides=false); |
/*! \brief Read the guides from XML attribute (file opening). |
It's statis method sou you can call it without instance initialized: |
GuideManagerCore::readVerticalGuides(foo blah); |
99,6 → 98,28 |
static QString writeHorizontalGuides(Page *page, GuideType type); |
static QString writeVerticalGuides(Page *page, GuideType type); |
//! \brief Properties for Auto guides remembrance. See GuideManager. |
int horizontalAutoCount() { return m_horizontalAutoCount; }; |
//! \brief Properties for Auto guides remembrance. See GuideManager. |
void setHorizontalAutoCount(int val) { m_horizontalAutoCount = val; }; |
//! \brief Properties for Auto guides remembrance. See GuideManager. |
int verticalAutoCount() { return m_verticalAutoCount; }; |
//! \brief Properties for Auto guides remembrance. See GuideManager. |
void setVerticalAutoCount(int val) { m_verticalAutoCount = val; }; |
//! \brief Properties for Auto guides remembrance. See GuideManager. |
double horizontalAutoGap(){ return m_horizontalAutoGap; }; |
//! \brief Properties for Auto guides remembrance. See GuideManager. |
double verticalAutoGap(){return m_verticalAutoGap; }; |
//! \brief Properties for Auto guides remembrance. See GuideManager. |
void setHorizontalAutoGap(double gap){ m_horizontalAutoGap = gap; }; |
//! \brief Properties for Auto guides remembrance. See GuideManager. |
void setVerticalAutoGap(double gap){ m_verticalAutoGap = gap; }; |
//! \brief Properties for Auto guides remembrance. See GuideManager. |
int autoRefer() { return m_autoRefer; }; |
//! \brief Properties for Auto guides remembrance. See GuideManager. |
void setAutoRefer(int val) { m_autoRefer = val; }; |
private: |
UndoManager * const undoManager; |
Page* m_page; |
106,6 → 127,12 |
Guides verticalStdG; |
Guides horizontalAutoG; |
Guides verticalAutoG; |
double m_horizontalAutoGap; |
double m_verticalAutoGap; |
int m_horizontalAutoCount; |
int m_verticalAutoCount; |
int m_autoRefer; |
double closestHorAbove(double y) const; |
double closestHorBelow(double y) const; |
/branches/Version13x/Scribus/scribus/guidemanager.h |
---|
162,8 → 162,14 |
All gudes are deleted before copying. |
\param t a type to clear and copy.*/ |
void copyGuidesToAllPages(GuideManagerCore::GuideType t); |
/*! \brief Draw guides into painter */ |
void drawGuides(); |
/*! \brief Save needed (Auto) values into GuideManagerCore. |
To be restored on the page return. */ |
void storePreviousValues(); |
protected slots: |
void addHorButton_clicked(); |
void delHorButton_clicked(); |