compile
[kdegraphics.git] / okular / ui / formwidgets.h
blob6d88ab7bc3ed6dbe840d65b1b4c4aa6d0387e973
1 /***************************************************************************
2 * Copyright (C) 2007 by Pino Toscano <pino@kde.org> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 ***************************************************************************/
10 #ifndef _OKULAR_FORMWIDGETS_H_
11 #define _OKULAR_FORMWIDGETS_H_
13 #include "core/area.h"
15 #include <qcheckbox.h>
16 #include <qcombobox.h>
17 #include <qlineedit.h>
18 #include <qlistwidget.h>
19 #include <qpushbutton.h>
20 #include <qradiobutton.h>
21 #include <ktextedit.h>
22 #include <kurlrequester.h>
24 class QButtonGroup;
25 class FormWidgetIface;
26 class PageViewItem;
27 class RadioButtonEdit;
29 namespace Okular {
30 class Action;
31 class FormField;
32 class FormFieldButton;
33 class FormFieldChoice;
34 class FormFieldText;
37 struct RadioData
39 RadioData() {}
41 QList< int > ids;
42 QButtonGroup *group;
45 class FormWidgetsController : public QObject
47 Q_OBJECT
49 public:
50 FormWidgetsController( QObject *parent = 0 );
51 virtual ~FormWidgetsController();
53 void signalChanged( FormWidgetIface *w );
54 void signalAction( Okular::Action *action );
56 QButtonGroup* registerRadioButton( FormWidgetIface* widget, const QList< int >& siblings );
57 void dropRadioButtons();
59 signals:
60 void changed( FormWidgetIface *w );
61 void action( Okular::Action *action );
63 private slots:
64 void slotButtonClicked( QAbstractButton *button );
66 private:
67 QList< RadioData > m_radios;
71 class FormWidgetFactory
73 public:
74 static FormWidgetIface * createWidget( Okular::FormField * ff, QWidget * parent = 0 );
78 class FormWidgetIface
80 public:
81 FormWidgetIface( QWidget * w, Okular::FormField * ff );
82 virtual ~FormWidgetIface();
84 Okular::NormalizedRect rect() const;
85 void setWidthHeight( int w, int h );
86 void moveTo( int x, int y );
87 bool setVisibility( bool visible );
88 void setCanBeFilled( bool fill );
90 void setPageItem( PageViewItem *pageItem );
91 Okular::FormField* formField() const;
92 PageViewItem* pageItem() const;
94 virtual void setFormWidgetsController( FormWidgetsController *controller );
95 virtual QAbstractButton* button();
97 protected:
98 FormWidgetsController * m_controller;
100 private:
101 QWidget * m_widget;
102 Okular::FormField * m_ff;
103 PageViewItem * m_pageItem;
107 class PushButtonEdit : public QPushButton, public FormWidgetIface
109 Q_OBJECT
111 public:
112 PushButtonEdit( Okular::FormFieldButton * button, QWidget * parent = 0 );
114 private slots:
115 void slotClicked();
117 private:
118 Okular::FormFieldButton * m_form;
121 class CheckBoxEdit : public QCheckBox, public FormWidgetIface
123 Q_OBJECT
125 public:
126 CheckBoxEdit( Okular::FormFieldButton * button, QWidget * parent = 0 );
128 // reimplemented from FormWidgetIface
129 void setFormWidgetsController( FormWidgetsController *controller );
130 QAbstractButton* button();
132 private slots:
133 void slotStateChanged( int state );
135 private:
136 Okular::FormFieldButton * m_form;
139 class RadioButtonEdit : public QRadioButton, public FormWidgetIface
141 Q_OBJECT
143 public:
144 RadioButtonEdit( Okular::FormFieldButton * button, QWidget * parent = 0 );
146 // reimplemented from FormWidgetIface
147 void setFormWidgetsController( FormWidgetsController *controller );
148 QAbstractButton* button();
150 private slots:
151 void slotToggled( bool checked );
153 private:
154 Okular::FormFieldButton * m_form;
157 class FormLineEdit : public QLineEdit, public FormWidgetIface
159 Q_OBJECT
161 public:
162 explicit FormLineEdit( Okular::FormFieldText * text, QWidget * parent = 0 );
164 private slots:
165 void textEdited( const QString& );
167 private:
168 Okular::FormFieldText * m_form;
171 class TextAreaEdit : public KTextEdit, public FormWidgetIface
173 Q_OBJECT
175 public:
176 explicit TextAreaEdit( Okular::FormFieldText * text, QWidget * parent = 0 );
178 private slots:
179 void slotChanged();
181 private:
182 Okular::FormFieldText * m_form;
186 class FileEdit : public KUrlRequester, public FormWidgetIface
188 Q_OBJECT
190 public:
191 explicit FileEdit( Okular::FormFieldText * text, QWidget * parent = 0 );
193 private slots:
194 void slotChanged( const QString& );
196 private:
197 Okular::FormFieldText * m_form;
201 class ListEdit : public QListWidget, public FormWidgetIface
203 Q_OBJECT
205 public:
206 explicit ListEdit( Okular::FormFieldChoice * choice, QWidget * parent = 0 );
208 private slots:
209 void slotSelectionChanged();
211 private:
212 Okular::FormFieldChoice * m_form;
216 class ComboEdit : public QComboBox, public FormWidgetIface
218 Q_OBJECT
220 public:
221 explicit ComboEdit( Okular::FormFieldChoice * choice, QWidget * parent = 0 );
223 private slots:
224 void indexChanged( int );
226 private:
227 Okular::FormFieldChoice * m_form;
230 #endif