Source: /app/hbasic/hbasic/src/propertyeditor.h
|
|
|
|
/* **************************************************************************
File: propertyeditor.h
Desc: Widget to edit properties of GUI components.
----------------------------------------------------------------------------
copyright : (C) 2001 HBasic project (Marcus Engels)
***************************************************************************/
/* **************************************************************************
* *
* 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. *
* *
***************************************************************************/
/* ----------------------------------------------------------------------- */
/* Changelog: Description of important changes within this file. */
/* Please report with date, maintainer and change description. */
/* ----------------------------------------------------------------------- */
#ifndef PROPERTYEDITOR_H
#define PROPERTYEDITOR_H
class QVariant;
class HBSheetCell;
class HBSheetEditor;
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "structs.h"
#include "../gui_db_access/report_editor.h"
#include "window_list.h"
#define DMODE_GUI_WIDGET 1
#define DMODE_REPORT_PART 2
#define DMODE_REPORT_ELEMENT 3
#define DMODE_SHEET_CELL 4
class PropertyList;
class CPropertyEditor;
class QPainter;
class QColorGroup;
class QComboBox;
class QLineEdit;
class QPushButton;
class QHBox;
class QSpinBox;
class QLabel;
class FormDesigner;
class QCloseEvent;
class QResizeEvent;
class HBReportElmt;
class CSheetTableWidget;
#define POINTER_TOOL 32000
#define CONNECT_TOOL 32001
#define ORDER_TOOL 32002
int size_type_to_int( QSizePolicy::SizeType t );
QString size_type_to_string( QSizePolicy::SizeType t );
QSizePolicy::SizeType int_to_size_type( int i );
/**
* @short Parent class for all other item types of the property list.
*
* The PropertyItem class is the parent class for all other item types of
* the property list. It handles common tasks that may be used by the
* other item classes.
*/
class PropertyItem : public QListViewItem
{
public:
PropertyItem( PropertyList *l, PropertyItem *after, PropertyItem *prop, const QString &propName );
~PropertyItem();
void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align );
void paintBranches( QPainter * p, const QColorGroup & cg,
int w, int y, int h );
void paintFocus( QPainter *p, const QColorGroup &cg, const QRect &r );
virtual bool hasSubItems() const;
virtual void createChildren();
virtual void initChildren();
void setup( void );
bool isOpen() const;
void setOpen( bool b );
virtual void showEditor();
virtual void hideEditor();
virtual void setValue( const QVariant &v );
QVariant value() const;
QString name() const;
virtual void notifyValueChange();
virtual void setChanged( bool b, bool updateDb = TRUE );
bool isChanged() const;
virtual void placeEditor( QWidget *w );
virtual PropertyItem *propertyParent() const;
virtual void childValueChanged( PropertyItem *child );
void addChild( PropertyItem *i );
int childCount() const;
PropertyItem *child( int i ) const;
virtual bool hasCustomContents() const;
virtual void drawCustomContents( QPainter *p, const QRect &r );
void updateBackColor();
virtual QString currentItem() const;
virtual int currentIntItem() const;
virtual void setCurrentItem( const QString &s );
virtual void setCurrentItem( int i );
virtual int currentIntItemFromObject() const;
virtual QString currentItemFromObject() const;
void setFocus( QWidget *w );
virtual void toggle();
void setText( int col, const QString &txt );
int hbasic_property; // TRUE if component property FALSE if QT prop.
protected: /* properties */
PropertyList *listview;
QVariant val;
private: /* methods */
QColor backgroundColor();
private:
bool open, changed;
PropertyItem *property;
QString propertyName;
QList children;
QColor backColor;
};
/* ################################################################## */
/**
* @short Handle property list items of type string.
*
* The PropertyTextItem class handles items in the property list of type
* String.
*/
class PropertyTextItem : public QObject,
public PropertyItem
{
Q_OBJECT
public:
PropertyTextItem( PropertyList *l, PropertyItem *after,
PropertyItem *prop, const QString &propName, bool comment,
bool multiLine, bool ascii = FALSE, bool a = FALSE );
~PropertyTextItem();
virtual void createChildren();
virtual void initChildren();
/**
* Show or place the text item editor.
*/
virtual void showEditor();
virtual void hideEditor();
virtual void setValue( const QVariant &v );
virtual bool hasSubItems() const;
virtual void childValueChanged( PropertyItem *child );
virtual void setChanged( bool b, bool updateDb = TRUE );
private slots:
void setValue();
void getText();
private:
QLineEdit *lined();
QGuardedPtr lin;
QGuardedPtr box;
QPushButton *button;
bool withComment, hasMultiLines, asciiOnly, accel;
};
/* ################################################################## */
/**
* @short Handle property list items of type boolean.
*
* The PropertyBoolItem class handles items in the property list of type
* Boolean.
*/
class PropertyBoolItem : public QObject,
public PropertyItem
{
Q_OBJECT
public:
PropertyBoolItem( PropertyList *l, PropertyItem *after, PropertyItem *prop, const QString &propName );
~PropertyBoolItem();
virtual void showEditor();
virtual void hideEditor();
virtual void setValue( const QVariant &v );
virtual void toggle();
private slots:
void setValue();
private:
QComboBox *combo();
QGuardedPtr comb;
};
/* ################################################################## */
/**
* @short Handle property list items of type integer.
*
* The PropertyIntItem class handles items in the property list of type
* Integer.
*/
class PropertyIntItem : public QObject,
public PropertyItem
{
Q_OBJECT
public:
PropertyIntItem( PropertyList *l, PropertyItem *after, PropertyItem *prop,
const QString &propName, bool s );
~PropertyIntItem();
virtual void showEditor();
virtual void hideEditor();
virtual void setValue( const QVariant &v );
private slots:
void setValue();
private:
QSpinBox *spinBox();
QGuardedPtr spinBx;
bool signedValue;
};
/**
* @short Handle property list items of type double.
*
* The PropertyIntItem class handles items in the property list of type
* Double.
*/
class PropertyDoubleItem : public QObject,
public PropertyItem
{
Q_OBJECT
public:
PropertyDoubleItem( PropertyList *l, PropertyItem *after, PropertyItem *prop,
const QString &propName );
~PropertyDoubleItem();
virtual void showEditor();
virtual void hideEditor();
virtual void setValue( const QVariant &v );
private slots:
void setValue();
private:
QLineEdit *lined();
QGuardedPtr lin;
};
/* ################################################################## */
/**
* @short Handle property list items of type string list.
*
* The PropertyListItem class handles items in the property list of type
* String list.
*/
class PropertyListItem : public QObject,
public PropertyItem
{
Q_OBJECT
public:
PropertyListItem( PropertyList *l, PropertyItem *after, PropertyItem *prop,
const QString &propName, bool editable );
~PropertyListItem();
virtual void showEditor();
virtual void hideEditor();
virtual void setValue( const QVariant &v );
QString currentItem() const;
int currentIntItem() const;
void setCurrentItem( const QString &s );
void setCurrentItem( int i );
int currentIntItemFromObject() const;
QString currentItemFromObject() const;
private slots:
void setValue();
private:
QComboBox *combo();
QGuardedPtr comb;
int oldInt;
bool editable;
QString oldString;
};
/* ################################################################## */
/**
* @short Handle property list items of type font.
*
* The PropertyFontItem class handles items in the property list of type
* QFont.
*/
class PropertyFontItem : public QObject,
public PropertyItem
{
Q_OBJECT
public:
PropertyFontItem( PropertyList *l, PropertyItem *after, PropertyItem *prop, const QString &propName );
~PropertyFontItem();
virtual void createChildren();
virtual void initChildren();
virtual void showEditor();
virtual void hideEditor();
virtual void setValue( const QVariant &v );
virtual bool hasSubItems() const;
virtual void childValueChanged( PropertyItem *child );
private slots:
void getFont();
private:
QGuardedPtr lined;
QGuardedPtr button;
QGuardedPtr box;
};
/* ################################################################## */
/**
* @short Handle property list items of type point.
*
* The PropertyCoordItem class handles items in the property list of type
* point.
*/
class PropertyCoordItem : public QObject,
public PropertyItem
{
Q_OBJECT
public:
enum Type { Rect, Size, Point };
PropertyCoordItem( PropertyList *l, PropertyItem *after, PropertyItem *prop,
const QString &propName, Type t );
~PropertyCoordItem();
virtual void createChildren();
virtual void initChildren();
virtual void showEditor();
virtual void hideEditor();
virtual void setValue( const QVariant &v );
virtual bool hasSubItems() const;
virtual void childValueChanged( PropertyItem *child );
private:
QLineEdit *lined();
QGuardedPtr lin;
Type typ;
};
/* ################################################################## */
/**
* @short Handle property list items of type color.
*
* The PropertyColorItem class handles items in the property list of type
* QColor.
*/
class PropertyColorItem : public QObject,
public PropertyItem
{
Q_OBJECT
public:
PropertyColorItem( PropertyList *l, PropertyItem *after, PropertyItem *prop,
const QString &propName, bool children );
~PropertyColorItem();
virtual void createChildren();
virtual void initChildren();
virtual void showEditor();
virtual void hideEditor();
virtual void setValue( const QVariant &v );
virtual bool hasSubItems() const;
virtual void childValueChanged( PropertyItem *child );
virtual bool hasCustomContents() const;
virtual void drawCustomContents( QPainter *p, const QRect &r );
private slots:
void getColor();
private:
QGuardedPtr box;
QGuardedPtr colorPrev;
QGuardedPtr button;
bool withChildren;
};
/* ################################################################## */
/**
* @short Handle property list items of type pixmap.
*
* The PropertyPixmapItem class handles items in the property list of type
* QPixmap.
*/
class PropertyPixmapItem : public QObject,
public PropertyItem
{
Q_OBJECT
public:
PropertyPixmapItem( PropertyList *l, PropertyItem *after, PropertyItem *prop,
const QString &propName );
~PropertyPixmapItem();
virtual void showEditor();
virtual void hideEditor();
virtual void setValue( const QVariant &v );
virtual bool hasCustomContents() const;
virtual void drawCustomContents( QPainter *p, const QRect &r );
private slots:
void getPixmap();
private:
QGuardedPtr box;
QGuardedPtr pixPrev;
QPushButton *button;
};
/* ################################################################## */
/**
* @short Handle property list items of type size.
*
* The PropertySizePolicyItem class handles items in the property list of type
* Size.
*/
class PropertySizePolicyItem : public QObject,
public PropertyItem
{
Q_OBJECT
public:
PropertySizePolicyItem( PropertyList *l, PropertyItem *after, PropertyItem *prop,
const QString &propName );
~PropertySizePolicyItem();
virtual void createChildren();
virtual void initChildren();
virtual void showEditor();
virtual void hideEditor();
virtual void setValue( const QVariant &v );
virtual bool hasSubItems() const;
virtual void childValueChanged( PropertyItem *child );
private:
QLineEdit *lined();
QGuardedPtr lin;
};
/* ################################################################## */
/**
* @short Handle property list items of type palette.
*
* The PropertyPaletteItem class handles items in the property list of type
* palette.
*/
class PropertyPaletteItem : public QObject,
public PropertyItem
{
Q_OBJECT
public:
PropertyPaletteItem( PropertyList *l, PropertyItem *after, PropertyItem *prop,
const QString &propName );
~PropertyPaletteItem();
virtual void showEditor();
virtual void hideEditor();
virtual void setValue( const QVariant &v );
virtual bool hasCustomContents() const;
virtual void drawCustomContents( QPainter *p, const QRect &r );
private slots:
void getPalette();
private:
QGuardedPtr box;
QGuardedPtr palettePrev;
QGuardedPtr button;
};
/* ################################################################## */
/**
* @short Handle property list items of type cursor.
*
* The PropertyCursorItem class handles items in the property list of type
* QCursor.
*/
class PropertyCursorItem : public QObject,
public PropertyItem
{
Q_OBJECT
public:
PropertyCursorItem( PropertyList *l, PropertyItem *after, PropertyItem *prop,
const QString &propName );
~PropertyCursorItem();
virtual void showEditor();
virtual void hideEditor();
virtual void setValue( const QVariant &v );
private slots:
void setValue();
private:
QComboBox *combo();
QGuardedPtr comb;
};
/* ################################################################## */
/**
* @short Handle list of property entries in property editor widget.
*
* The PropertyList class handles the list of all property editor items
* within the property editor window.
*/
class PropertyList : public QListView
{
Q_OBJECT
public:
short display_mode;
public:
PropertyList( CPropertyEditor *e );
void setupProperties();
void setupReportProperties( short type );
void setupSheetProperties( void );
QVariant *getElementProperty( char *name );
void storeReportProperty( QString *name, QVariant *value );
void storeCompProperty( PropertyItem *i );
void setupGuiProperties( void );
void storeSheetProperty( QString *name, QVariant *value );
void setCurrentItem( QListViewItem *i );
void valueChanged( PropertyItem *i );
void refetchData();
void setLPropertyValue( PropertyItem *i );
void setCurrentProperty( const QString &n );
void setReportEditor( CReportEditorWidget *ptr );
void setupCompProperties( void );
CPropertyEditor *propertyEditor() const;
CReportPart *report_part;
CReportEditorWidget *report_editor;
HBReportElmt *report_element;
/* Pointer to current sheet cell and sheet editor. If the property list */
/* of the sheet contents changes we send change events to the sheet editor */
/* so that it may update the current display of the sheet. */
HBSheetCell *cell_ptr;
CSheetTableWidget *sheet_edit_ptr;
GUI_HEADER *hbasic_widget; /* Hbasic description for property widget. */
public slots:
void updateEditorSize();
private slots:
void itemPressed( QListViewItem *i, const QPoint &p, int c );
void toggleOpen( QListViewItem *i );
bool eventFilter( QObject *o, QEvent *e );
protected:
void resizeEvent( QResizeEvent *e );
void paintEmptyArea( QPainter *p, const QRect &r );
bool addPropertyItem( PropertyItem *&item, const QCString &name, QVariant::Type t );
private:
CPropertyEditor *editor;
};
/* ################################################################## */
/**
* @short Main property editor widget.
*
* The CPropertyEditor class is the main editor widget to display and
* iedit the property items in the HBasic program.
*/
class CPropertyEditor : public CWindowListChild
{
Q_OBJECT
Q_PROPERTY( bool visible READ getVisible WRITE setVisible );
public:
CPropertyEditor( QWidget *parent );
QWidget *widget() const;
void clear();
void setup();
short visible;
bool getVisible() const;
void setVisible( bool );
void emitWidgetChanged();
void refetchData();
void closed( void ); // FormWindow *w );
PropertyList *propertyList() const;
FormDesigner *formDesigner( void );
QString currentProperty() const;
QString classOfCurrentProperty() const;
void setDialogFont( QFont *new_font );
QMetaObject* metaObjectOfCurrentProperty() const;
void setProperty( const QVariant &v, const QString ¤tItemText, bool select = TRUE );
void redrawContents( void );
void resetFocus();
signals:
void hidden();
public slots:
void setCurrentWidget( QWidget *w , GUI_HEADER *hbasic_comp, FormDesigner *fw );
void setReportField( CReportEditorWidget *report_editor, CReportPart *part_ptr, HBReportElmt *rep_field_ptr );
void setReportPart( CReportEditorWidget *report_editor, CReportPart *part_desc_ptr );
void setSheetCell( CSheetTableWidget *edit_ptr, HBSheetCell *sheet_cell );
protected:
void closeEvent( QCloseEvent *e );
void resizeEvent( QResizeEvent *e );
private:
QWidget *wid;
PropertyList *listview;
FormDesigner *formwindow;
};
#endif
Generated by: root on linux on Sun Jul 13 18:06:35 2003, using kdoc 2.0a54. |