You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdegraphics/kcoloredit/kcoloreditdoc.h

157 lines
6.0 KiB

/***************************************************************************
kcoloreditdoc.h - description
-------------------
begin : Sat Jul 8 09:57:28 CEST 2000
copyright : (C) 2000 by Artur Rataj
email : art@zeus.polsl.gliwice.pl
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef KCOLOREDITDOC_H
#define KCOLOREDITDOC_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// include files for QT
#include <tqobject.h>
#include <tqstring.h>
#include <tqptrlist.h>
// application specific includes
#include "palette.h"
#include "palettehistory.h"
// forward declaration of the KColorEdit classes
class KColorEditView;
/** KColorEditDoc provides a document object for a document-view model.
*
* The KColorEditDoc class provides a document object that can be used in conjunction with the classes KColorEditApp and KColorEditView
* to create a document-view model for standard KDE applications based on KApplication and KMainWindow. Thereby, the document object
* is created by the KColorEditApp instance and contains the document structure with the according methods for manipulation of the document
* data by KColorEditView objects. Also, KColorEditDoc contains the methods for serialization of the document data from and to files.
*
* @author Source Framework Automatically Generated by KDevelop, (c) The KDevelop Team.
* @version KDevelop version 0.4 code generation
*/
class KColorEditDoc : public QObject
{
Q_OBJECT
public:
/** Constructor for the fileclass of the application */
KColorEditDoc(TQWidget *parent, const char *name=0);
/** Destructor for the fileclass of the application */
~KColorEditDoc();
/** adds a view to the document which represents the document contents. Usually this is your main view. */
void addView(KColorEditView *view);
/** removes a view from the list of currently connected views */
void removeView(KColorEditView *view);
/** sets the modified flag for the document after a modifying action on the view connected to the document.*/
void setModified(bool modified);
/** returns if the document is modified or not. Use this to determine if your document needs saving by the user on closing.*/
bool isModified() const { return m_modified; };
/** "save modified" - asks the user for saving if the document is modified */
bool saveModified();
/** deletes the document's contents */
void deleteContents();
/** initializes the document generally */
bool newDocument();
/** closes the actual document */
void closeDocument();
/** loads the document */
bool openDocument(const TQString& filename);
/** saves the document */
bool saveDocument(const TQString& filename);
/** sets the path to the file connected with the document */
void setAbsFilePath(const TQString &filename);
/** returns the pathname of the current document file*/
const TQString& absFilePath() const;
/** sets the filename of the document */
void setTitle(const TQString &_t);
/** returns the title of the document */
const TQString& title() const;
/** @return a description of a possible unsuccessfull IO operation */
const TQString& errorString() const;
/** returns a pointer to paletteHistory */
PaletteHistory* paletteHistory();
/** sets a palette cursor position */
void setPaletteCursorPos(const int pos);
/** @return a palette cursor position */
int paletteCursorPos();
/** Sets palette selection and enables or disables cut/paste
* depending on whether any colors are selected
*/
void setPaletteSelection(const int begin, const int end);
/** Gets lesser selection position or equal selection position
* if no colors are selected
*/
int paletteSelectionBegin() const;
/** Gets greater selection position or equal selection position
* if no colors are selected
*/
int paletteSelectionEnd() const;
/** Copies a selection into a clipboard */
void copy();
/** Cuts a selection into a clipboard */
void cut();
/** Pastes a selection from a clipboard */
void paste();
/** Inserts a color at index */
void insert(int index, const Color& color);
/** Replaces a color at index */
void replace(int index, const Color& color);
protected:
/** Sets an error string if an IO operation was unsuccesfull */
void setErrorString(const TQString& string);
/** Copies a palette to clipboard */
void copyToClipboard(Palette& palette);
public slots:
/** Calls redraw() on all views connected to the document object,
* except for sender if sender is not null
*/
void slotRedrawAllViews(KColorEditView* sender, bool newDocument = false);
/** Sets a view mode */
void slotChangeViewMode(bool viewColorNames);
signals:
void selectionChanged( int, int );
void clipboardChanged();
void modified( bool );
void paletteAvailable( bool );
public:
/** the list of the views currently connected to the document */
TQPtrList<KColorEditView> *m_pViewList;
private:
/** the modified flag of the current document */
bool m_modified;
TQString m_title;
TQString m_absFilePath;
TQString m_errorString;
protected:
Palette m_palette;
PaletteHistory m_paletteHistory;
int m_paletteCursorPos;
int m_paletteSelectionBegin;
int m_paletteSelectionEnd;
};
#endif // KCOLOREDITDOC_H