KoPageLayoutWidget::KoPageLayoutWidget(QWidget *parent, const KoPageLayout &layout) : QWidget(parent) , d(new Private) { d->widget.setupUi(this); d->pageLayout = layout; d->marginsEnabled = true; d->allowSignals = true; d->orientationGroup = new QButtonGroup(this); d->orientationGroup->addButton(d->widget.portrait, KoPageFormat::Portrait); d->orientationGroup->addButton(d->widget.landscape, KoPageFormat::Landscape); QButtonGroup *group2 = new QButtonGroup(this); group2->addButton(d->widget.singleSided); group2->addButton(d->widget.facingPages); // the two sets of labels we use might have different lengths; make sure this does not create a 'jumping' ui d->widget.facingPages->setChecked(true); facingPagesChanged(); int width = qMax(d->widget.leftLabel->width(), d->widget.rightLabel->width()); d->widget.singleSided->setChecked(true); facingPagesChanged(); width = qMax(width, qMax(d->widget.leftLabel->width(), d->widget.rightLabel->width())); d->widget.leftLabel->setMinimumSize(QSize(width, 5)); d->widget.units->addItems(KoUnit::listOfUnitNameForUi(KoUnit::HidePixel)); d->widget.sizes->addItems(KoPageFormat::localizedPageFormatNames()); setPageSpread(false); connect(d->widget.sizes, SIGNAL(currentIndexChanged(int)), this, SLOT(sizeChanged(int))); connect(d->widget.units, SIGNAL(currentIndexChanged(int)), this, SLOT(unitChanged(int))); connect(group2, SIGNAL(buttonClicked (int)), this, SLOT(facingPagesChanged())); connect(d->orientationGroup, SIGNAL(buttonClicked (int)), this, SLOT(orientationChanged())); connect(d->widget.width, SIGNAL(valueChangedPt(qreal)), this, SLOT(optionsChanged())); connect(d->widget.height, SIGNAL(valueChangedPt(qreal)), this, SLOT(optionsChanged())); connect(d->widget.topMargin, SIGNAL(valueChangedPt(qreal)), this, SLOT(marginsChanged())); connect(d->widget.bottomMargin, SIGNAL(valueChangedPt(qreal)), this, SLOT(marginsChanged())); connect(d->widget.bindingEdgeMargin, SIGNAL(valueChangedPt(qreal)), this, SLOT(marginsChanged())); connect(d->widget.pageEdgeMargin, SIGNAL(valueChangedPt(qreal)), this, SLOT(marginsChanged())); connect(d->widget.width, SIGNAL(valueChangedPt(qreal)), this, SLOT(optionsChanged())); connect(d->widget.height, SIGNAL(valueChangedPt(qreal)), this, SLOT(optionsChanged())); setUnit(KoUnit(KoUnit::Millimeter)); setPageLayout(layout); if (layout.format == 0) // make sure we always call this during startup, even if the A3 (index=0) was chosen sizeChanged(layout.format); showTextDirection(false); /* disable advanced page layout features by default */ d->widget.facingPageLabel->setVisible(false); d->widget.facingPages->setVisible(false); d->widget.singleSided->setVisible(false); d->widget.stylesLabel->setVisible(false); d->widget.pageStyle->setVisible(false); }
void KoPAMasterPage::loadOdfPageTag( const KoXmlElement &element, KoPALoadingContext &loadingContext ) { KoPAPageBase::loadOdfPageTag( element, loadingContext ); if ( element.hasAttributeNS( KoXmlNS::style, "display-name" ) ) { setName( element.attributeNS( KoXmlNS::style, "display-name" ) ); } else { setName( element.attributeNS( KoXmlNS::style, "name" ) ); } QString pageLayoutName = element.attributeNS( KoXmlNS::style, "page-layout-name" ); const KoOdfStylesReader& styles = loadingContext.odfLoadingContext().stylesReader(); const KoXmlElement* masterPageStyle = styles.findStyle( pageLayoutName ); KoPageLayout pageLayout; if ( masterPageStyle ) { pageLayout.loadOdf( *masterPageStyle ); } setPageLayout( pageLayout ); }
KarbonPart::KarbonPart(QWidget* parentWidget, const char* widgetName, QObject* parent, const char* name, bool singleViewMode) : KoDocument(parentWidget, parent, singleViewMode), d(new Private()) { Q_UNUSED(widgetName); d->document.setResourceManager(resourceManager()); setObjectName(name); setComponentData(KarbonFactory::componentData(), false); setTemplateType("karbon_template"); resourceManager()->setUndoStack(undoStack()); initConfig(); // set as default paper KoPageLayout pl = pageLayout(); pl.format = KoPageFormat::defaultFormat(); pl.orientation = KoPageFormat::Portrait; pl.width = MM_TO_POINT(KoPageFormat::width(pl.format, pl.orientation)); pl.height = MM_TO_POINT(KoPageFormat::height(pl.format, pl.orientation)); setPageLayout(pl); }
KWStartupWidget::KWStartupWidget(QWidget *parent, KWDocument *doc, const KoColumns &columns) : QWidget(parent), m_unit(doc->unit()) { widget.setupUi(this); m_columns = columns; m_layout.leftMargin = MM_TO_POINT(30); m_layout.rightMargin = MM_TO_POINT(30); m_layout.topMargin = MM_TO_POINT(25); m_layout.bottomMargin = MM_TO_POINT(25); m_doc = doc; setFocusProxy(widget.createButton); QVBoxLayout *lay = new QVBoxLayout(widget.sizeTab); m_sizeWidget = new KoPageLayoutWidget(widget.sizeTab, m_layout); m_sizeWidget->showPageSpread(true); m_sizeWidget->setUnit(m_unit); lay->addWidget(m_sizeWidget); lay = new QVBoxLayout(widget.columnsTab); m_columnsWidget = new KWDocumentColumns(widget.columnsTab, m_columns); m_columnsWidget->setUnit(m_unit); m_columnsWidget->setShowPreview(false); lay->addWidget(m_columnsWidget); lay = new QVBoxLayout(widget.previewPane); widget.previewPane->setLayout(lay); KoPagePreviewWidget *prev = new KoPagePreviewWidget(widget.previewPane); lay->addWidget(prev); prev->setColumns(columns); prev->setPageLayout(m_layout); connect(m_sizeWidget, SIGNAL(layoutChanged(KoPageLayout)), this, SLOT(sizeUpdated(KoPageLayout))); connect(widget.createButton, SIGNAL(clicked()), this, SLOT(buttonClicked())); connect(m_sizeWidget, SIGNAL(unitChanged(KoUnit)), this, SLOT(unitChanged(KoUnit))); connect(m_columnsWidget, SIGNAL(columnsChanged(KoColumns)), prev, SLOT(setColumns(KoColumns))); connect(m_columnsWidget, SIGNAL(columnsChanged(KoColumns)), this, SLOT(columnsUpdated(KoColumns))); connect(m_sizeWidget, SIGNAL(layoutChanged(KoPageLayout)), prev, SLOT(setPageLayout(KoPageLayout))); }
//This function adds a new tab to the browser notebook each time its called void addNewTab( GtkWidget* browserForm, gpointer data){ GtkWidget *tableInitialing , *cancelButton, *addButton, *hboxHeader, *hboxLabel; gint currentPageNum; gint nextPageNum; //Number of tabs increase by one each time a tab is added NUMBER_OF_TABS++; hboxHeader = gtk_hbox_new( TRUE, 0); gtk_widget_set_size_request( hboxHeader, 200, 20); hboxLabel = gtk_label_new("New tab"); gtk_widget_set_size_request(hboxLabel, 95, 20); gtk_box_pack_start_defaults( GTK_BOX(hboxHeader), hboxLabel); cancelButton = gtk_button_new_with_mnemonic("_x"); gtk_button_set_relief( GTK_BUTTON( cancelButton), GTK_RELIEF_NONE); //Connects signal related to close button g_signal_connect_swapped( G_OBJECT(cancelButton), "clicked", G_CALLBACK(delete_tab), (gpointer) browserForm); gtk_box_pack_start_defaults( GTK_BOX(hboxHeader), cancelButton); addButton = gtk_button_new_with_mnemonic("_+"); gtk_button_set_relief( GTK_BUTTON( addButton), GTK_RELIEF_NONE); gtk_widget_set_size_request( addButton, 20, 20); //Connects the addButton to its callback function when clicked g_signal_connect_swapped( G_OBJECT(addButton), "clicked", G_CALLBACK(addNewTab), (gpointer) browserForm); gtk_box_pack_start_defaults( GTK_BOX(hboxHeader), addButton); gtk_widget_show_all(hboxHeader); //Creates a table of 30 rows and 17 columns tableInitialing = setPageLayout(browserForm->parent, browserForm); currentPageNum = gtk_notebook_get_current_page( GTK_NOTEBOOK(browserForm)); nextPageNum = currentPageNum + 1; gtk_notebook_insert_page( GTK_NOTEBOOK(browserForm), tableInitialing, hboxHeader, nextPageNum + 1); gtk_notebook_next_page( GTK_NOTEBOOK(browserForm)); gtk_widget_show_all(browserForm); }
int main(int argc, char* argv[]){ //Declaration of variables GtkWidget * window, *tableInitialing, *hboxHeader, *hboxLabel; GtkWidget * browserForm, *cancelButton, *addButton, *addButtonTest; //This function parses the command line arguments, removing the wants it recognizes gtk_init( &argc, &argv); //includes the resource file to modify GtkWidgets gtk_rc_parse("resourceFile.gtkrc"); //initialises the form notebook browserForm = gtk_notebook_new(); //This line of code sets the properties of the main window window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size( GTK_WINDOW(window), 1000, 700); gtk_widget_set_size_request( window, 900, 600); gtk_container_set_border_width( GTK_CONTAINER(window), 10); gtk_window_set_title(GTK_WINDOW(window), "One click browser Made to ease browsing"); gtk_window_set_resizable( GTK_WINDOW(window), TRUE); gtk_window_set_icon_from_file( GTK_WINDOW(window), "images/OneClickLogo.png", NULL); //Connects signals relating to the window g_signal_connect( G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL); g_signal_connect( G_OBJECT(window), "delete_event", G_CALLBACK(delete_event), NULL); //Initialising the addButton and linking it with its callback function when clicked addButton = gtk_button_new_with_mnemonic("_+"); gtk_button_set_relief( GTK_BUTTON(addButton), GTK_RELIEF_NONE); g_signal_connect_swapped( G_OBJECT(addButton), "clicked", G_CALLBACK(addNewTab), (gpointer) browserForm); //Initialises the hbox-It contains the addButton, cancelButton and the hboxLabel hboxHeader = gtk_hbox_new( TRUE, 0); gtk_widget_set_size_request( hboxHeader, 200, 20); hboxLabel = gtk_label_new("New tab"); gtk_widget_set_size_request( hboxLabel, 95, 20); //Initialising the cancelButton and linking it with its callback function when clicked cancelButton = gtk_button_new_with_mnemonic("_x"); gtk_button_set_relief( GTK_BUTTON(cancelButton), GTK_RELIEF_NONE); g_signal_connect_swapped( G_OBJECT(cancelButton), "clicked", G_CALLBACK(delete_tab), (gpointer) browserForm); //Adding widgets to the hbox gtk_box_pack_start_defaults( GTK_BOX(hboxHeader), hboxLabel); gtk_box_pack_start_defaults( GTK_BOX(hboxHeader), cancelButton); gtk_box_pack_start_defaults( GTK_BOX(hboxHeader), addButton); gtk_widget_show_all(hboxHeader); //setPageLayout initialises the table and then table is then added to the browser notebook tableInitialing = setPageLayout(window, browserForm); gtk_notebook_append_page( GTK_NOTEBOOK(browserForm), tableInitialing, hboxHeader); gtk_notebook_set_scrollable( GTK_NOTEBOOK(browserForm), TRUE); gtk_container_add(GTK_CONTAINER(window), browserForm); gtk_widget_show_all(window); gtk_main(); return 0; } //End of main function
bool KarbonPart::loadOdf(KoOdfReadStore & odfStore) { kDebug(38000) << "Start loading OASIS document..." /*<< doc.toString()*/; KoXmlElement contents = odfStore.contentDoc().documentElement(); kDebug(38000) << "Start loading OASIS document..." << contents.text(); kDebug(38000) << "Start loading OASIS contents..." << contents.lastChild().localName(); kDebug(38000) << "Start loading OASIS contents..." << contents.lastChild().namespaceURI(); kDebug(38000) << "Start loading OASIS contents..." << contents.lastChild().isElement(); KoXmlElement body(KoXml::namedItemNS(contents, KoXmlNS::office, "body")); if (body.isNull()) { kDebug(38000) << "No office:body found!"; setErrorMessage(i18n("Invalid OASIS document. No office:body tag found.")); return false; } body = KoXml::namedItemNS(body, KoXmlNS::office, "drawing"); if (body.isNull()) { kDebug(38000) << "No office:drawing found!"; setErrorMessage(i18n("Invalid OASIS document. No office:drawing tag found.")); return false; } KoXmlElement page(KoXml::namedItemNS(body, KoXmlNS::draw, "page")); if (page.isNull()) { kDebug(38000) << "No office:drawing found!"; setErrorMessage(i18n("Invalid OASIS document. No draw:page tag found.")); return false; } KoXmlElement * master = 0; if (odfStore.styles().masterPages().contains("Standard")) master = odfStore.styles().masterPages().value("Standard"); else if (odfStore.styles().masterPages().contains("Default")) master = odfStore.styles().masterPages().value("Default"); else if (! odfStore.styles().masterPages().empty()) master = odfStore.styles().masterPages().begin().value(); if (master) { const QString pageStyleName = master->attributeNS(KoXmlNS::style, "page-layout-name", QString()); const KoXmlElement *style = odfStore.styles().findStyle(pageStyleName); if (style) { KoPageLayout layout; layout.loadOdf(*style); setPageLayout(layout); } } else { kWarning() << "No master page found!"; return false; } KoOdfLoadingContext context(odfStore.styles(), odfStore.store()); KoShapeLoadingContext shapeContext(context, resourceManager()); d->document.loadOasis(page, shapeContext); if (d->document.pageSize().isEmpty()) { QSizeF pageSize = d->document.contentRect().united(QRectF(0, 0, 1, 1)).size(); setPageSize(pageSize); } loadOasisSettings(odfStore.settingsDoc()); return true; }