summaryrefslogtreecommitdiffstats
path: root/kexi/formeditor/tdevelop_plugin/kfd_kdev_part.h
blob: ad33bcde54d71816bdefc29ac59b0e004c599f8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* This file is part of the KDE project
   Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#ifndef KFORMDESIGNER_KDEVELOP_PART_H
#define KFORMDESIGNER_KDEVELOP_PART_H

#include <tqwidget.h>
#include <tqpixmap.h>

#include <kinterfacedesigner/designer.h>
#include <tdeparts/factory.h>

#include "form.h"

class TDEAboutData;
class TDEInstance;
class TQWorkspace;
class TQCloseEvent;

using KFormDesigner::Form;
using namespace KInterfaceDesigner;

class KFORMEDITOR_EXPORT KFDFactory : public KParts::Factory
{
	TQ_OBJECT
  

	public:
		KFDFactory();
		virtual ~KFDFactory();

		virtual KParts::Part* createPartObject(TQWidget *parentWidget=0, const char *widgetName=0, TQObject *parent=0, const char *name=0,
		  const char *classname="KParts::Part", const TQStringList &args=TQStringList());

		static TDEInstance *instance();
		static TDEAboutData *aboutData();

	private:
		static TDEInstance *m_instance;
};

class KFORMEDITOR_EXPORT KFormDesignerKDevPart : public Designer
{
	TQ_OBJECT
  

	public:
		KFormDesignerKDevPart(TQWidget *parent, const char *name, bool readOnly=true, const TQStringList &args=TQStringList());
		virtual ~KFormDesignerKDevPart();

		virtual DesignerType designerType() { return TQtDesigner; }
		virtual void openProject(const TQString &) {}

//		KFormDesigner::FormManager*   manager()  { return m_manager; }
		void      setUniqueFormMode(bool enable)  { m_uniqueFormMode = enable; }

		bool   closeForm(Form *form);
		bool   closeForms();

		virtual bool closeURL();

		static KFormDesigner::WidgetLibrary* formsLibrary();

	public slots:
		/*! Creates a new blank Form. The new Form is shown and become the active Form. */
		void createBlankForm();
		/*! Loads a Form from a UI file. A "Open File" dialog is shown to select the file. The loaded Form is shown and becomes
		   the active Form. */
		void open();
		void slotPreviewForm();
		void saveAs();
		void slotCreateFormSlot(KFormDesigner::Form *form, const TQString &widget, const TQString &signal);

	protected slots:
		void slotWidgetSelected(KFormDesigner::Form *form, bool multiple);
		void slotFormWidgetSelected(KFormDesigner::Form *form);
		void slotNoFormSelected();
		void slotFormModified(KFormDesigner::Form *form, bool isDirty);
		void setUndoEnabled(bool enabled, const TQString &text);
		void setRedoEnabled(bool enabled, const TQString &text);

	protected:
		virtual bool openFile();
		virtual bool saveFile();
		void disableWidgetActions();
		void enableFormActions();
		void setupActions();

	private:
		static KFormDesigner::WidgetLibrary* static_formsLibrary;
//		KFormDesigner::FormManager  *m_manager;
		TQWorkspace  *m_workspace;
		int  m_count;
		bool   m_uniqueFormMode;
		bool   m_openingFile;
		bool   m_inShell;
};

//! Helper: this widget is used to create form's surface
class KFORMEDITOR_EXPORT FormWidgetBase : public TQWidget, public KFormDesigner::FormWidget
{
	TQ_OBJECT
  

	public:
		FormWidgetBase(KFormDesignerKDevPart *part, TQWidget *parent = 0, const char *name = 0, int WFlags = WDestructiveClose)
		: TQWidget(parent, name, WFlags), m_part(part) {}
		~FormWidgetBase() {;}

		void drawRect(const TQRect& r, int type);
		void drawRects(const TQValueList<TQRect> &list, int type);
		void initRect();
		void clearRect();
		void highlightWidgets(TQWidget *from, TQWidget *to);//, const TQPoint &p);

	protected:
		void closeEvent(TQCloseEvent *ev);

	private:
		TQPixmap buffer; //!< stores grabbed entire form's area for redraw
		TQRect prev_rect; //!< previously selected rectangle
		KFormDesignerKDevPart  *m_part;
};

#endif