render_form.h Source File (khtml Library)

| # khtml Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# render_form.h

    00001 /*
    00002  * This file is part of the DOM implementation for KDE.
    00003  *
    00004  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
    00005  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
    00006  *           (C) 2000 Dirk Mueller (mueller@kde.org)
    00007  *
    00008  * This library is free software; you can redistribute it and/or
    00009  * modify it under the terms of the GNU Library General Public
    00010  * License as published by the Free Software Foundation; either
    00011  * version 2 of the License, or (at your option) any later version.
    00012  *
    00013  * This library is distributed in the hope that it will be useful,
    00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00016  * Library General Public License for more details.
    00017  *
    00018  * You should have received a copy of the GNU Library General Public License
    00019  * along with this library; see the file COPYING.LIB.  If not, write to
    00020  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00021  * Boston, MA 02111-1307, USA.
    00022  *
    00023  * $Id: render_form.h,v 1.74.2.6 2003/10/25 13:36:01 ggarand Exp $
    00024  */
    00025 #ifndef RENDER_FORM_H
    00026 #define RENDER_FORM_H
    00027
    00028 #include "rendering/render_replaced.h"
    00029 #include "rendering/render_image.h"
    00030 #include "rendering/render_flow.h"
    00031 #include "rendering/render_style.h"
    00032 #include "html/html_formimpl.h"
    00033
    00034 class QWidget;
    00035 class QLineEdit;
    00036 class QListboxItem;
    00037
    00038 #include <ktextedit.h>
    00039 #include <klineedit.h>
    00040 #include <qcheckbox.h>
    00041 #include <qradiobutton.h>
    00042 #include <qpushbutton.h>
    00043 #include <qhbox.h>
    00044 #include <klistbox.h>
    00045 #include <kcombobox.h>
    00046 #include "dom/dom_misc.h"
    00047
    00048 class KHTMLPartBrowserExtension;
    00049
    00050 namespace DOM {
    00051     class HTMLFormElementImpl;
    00052     class HTMLInputElementImpl;
    00053     class HTMLSelectElementImpl;
    00054     class HTMLGenericFormElementImpl;
    00055     class HTMLTextAreaElementImpl;
    00056 }
    00057
    00058 namespace khtml {
    00059
    00060 class DocLoader;
    00061
    00062 // -------------------------------------------------------------------------
    00063
    00064 class RenderFormElement : public khtml::RenderWidget
    00065 {
    00066     Q_OBJECT
    00067 public:
    00068     RenderFormElement(DOM::HTMLGenericFormElementImpl* node);
    00069     virtual ~RenderFormElement();
    00070
    00071     virtual const char *renderName() const { return "RenderForm"; }
    00072
    00073     virtual bool isRendered() const  { return true; }
    00074     virtual bool isFormElement() const { return true; }
    00075
    00076     virtual void updateFromElement();
    00077
    00078     virtual void layout();
    00079     virtual short baselinePosition( bool ) const;
    00080
    00081     DOM::HTMLGenericFormElementImpl *element() const
    00082     { return static_cast<DOM::HTMLGenericFormElementImpl*>(RenderObject::element()); }
    00083
    00084 public slots:
    00085     virtual void slotClicked();
    00086     void slotPressed();
    00087     void slotReleased();
    00088
    00089 protected:
    00090     virtual bool isRenderButton() const { return false; }
    00091     virtual bool isEditable() const { return false; }
    00092
    00093     QPoint m_mousePos;
    00094     int m_state;
    00095     bool m_isDoubleClick;
    00096 };
    00097
    00098 // -------------------------------------------------------------------------
    00099
    00100 // generic class for all buttons
    00101 class RenderButton : public RenderFormElement
    00102 {
    00103     Q_OBJECT
    00104 public:
    00105     RenderButton(DOM::HTMLGenericFormElementImpl* node);
    00106
    00107     virtual const char *renderName() const { return "RenderButton"; }
    00108     virtual short baselinePosition( bool ) const;
    00109
    00110     // don't even think about making this method virtual!
    00111     DOM::HTMLInputElementImpl* element() const
    00112     { return static_cast<DOM::HTMLInputElementImpl*>(RenderObject::element()); }
    00113
    00114 protected:
    00115     virtual bool isRenderButton() const { return true; }
    00116 };
    00117
    00118 // -------------------------------------------------------------------------
    00119
    00120 class RenderCheckBox : public RenderButton
    00121 {
    00122     Q_OBJECT
    00123 public:
    00124     RenderCheckBox(DOM::HTMLInputElementImpl* node);
    00125
    00126     virtual const char *renderName() const { return "RenderCheckBox"; }
    00127     virtual void updateFromElement();
    00128     virtual void calcMinMaxWidth();
    00129
    00130     QCheckBox *widget() const { return static_cast<QCheckBox*>(m_widget); }
    00131
    00132 public slots:
    00133     virtual void slotStateChanged(int state);
    00134 };
    00135
    00136 // -------------------------------------------------------------------------
    00137
    00138 class RenderRadioButton : public RenderButton
    00139 {
    00140     Q_OBJECT
    00141 public:
    00142     RenderRadioButton(DOM::HTMLInputElementImpl* node);
    00143
    00144     virtual const char *renderName() const { return "RenderRadioButton"; }
    00145
    00146     virtual void calcMinMaxWidth();
    00147     virtual void updateFromElement();
    00148
    00149     QRadioButton *widget() const { return static_cast<QRadioButton*>(m_widget); }
    00150
    00151 public slots:
    00152     void slotClicked();
    00153 };
    00154
    00155 // -------------------------------------------------------------------------
    00156
    00157 class RenderSubmitButton : public RenderButton
    00158 {
    00159 public:
    00160     RenderSubmitButton(DOM::HTMLInputElementImpl *element);
    00161
    00162     virtual const char *renderName() const { return "RenderSubmitButton"; }
    00163
    00164     virtual QString defaultLabel();
    00165
    00166     virtual void calcMinMaxWidth();
    00167     virtual void updateFromElement();
    00168     virtual short baselinePosition( bool ) const;
    00169 private:
    00170     QString rawText();
    00171 };
    00172
    00173 // -------------------------------------------------------------------------
    00174
    00175 class RenderImageButton : public RenderImage
    00176 {
    00177 public:
    00178     RenderImageButton(DOM::HTMLInputElementImpl *element);
    00179
    00180     virtual const char *renderName() const { return "RenderImageButton"; }
    00181 };
    00182
    00183
    00184 // -------------------------------------------------------------------------
    00185
    00186 class RenderResetButton : public RenderSubmitButton
    00187 {
    00188 public:
    00189     RenderResetButton(DOM::HTMLInputElementImpl *element);
    00190
    00191     virtual const char *renderName() const { return "RenderResetButton"; }
    00192
    00193     virtual QString defaultLabel();
    00194 };
    00195
    00196 // -------------------------------------------------------------------------
    00197
    00198 class RenderPushButton : public RenderSubmitButton
    00199 {
    00200 public:
    00201     RenderPushButton(DOM::HTMLInputElementImpl *element);
    00202
    00203     virtual QString defaultLabel();
    00204 };
    00205
    00206 // -------------------------------------------------------------------------
    00207
    00208 class RenderLineEdit : public RenderFormElement
    00209 {
    00210     Q_OBJECT
    00211 public:
    00212     RenderLineEdit(DOM::HTMLInputElementImpl *element);
    00213
    00214     virtual void calcMinMaxWidth();
    00215
    00216     virtual const char *renderName() const { return "RenderLineEdit"; }
    00217     virtual void updateFromElement();
    00218
    00219     void select();
    00220
    00221     KLineEdit *widget() const { return static_cast<KLineEdit*>(m_widget); }
    00222     DOM::HTMLInputElementImpl* element() const
    00223     { return static_cast<DOM::HTMLInputElementImpl*>(RenderObject::element()); }
    00224
    00225 public slots:
    00226     void slotReturnPressed();
    00227     void slotTextChanged(const QString &string);
    00228     void slotClearCompletionHistory();
    00229 protected:
    00230     virtual void handleFocusOut();
    00231
    00232 private:
    00233     virtual bool isEditable() const { return true; }
    00234 };
    00235
    00236 // -------------------------------------------------------------------------
    00237
    00238 class LineEditWidget : public KLineEdit
    00239 {
    00240     Q_OBJECT
    00241 public:
    00242     LineEditWidget(QWidget *parent);
    00243
    00244 protected:
    00245     virtual bool event( QEvent *e );
    00246     void clearMenuHistory();
    00247     virtual QPopupMenu *createPopupMenu();
    00248 signals:
    00249     void pressed();
    00250     void released();
    00251     void clearCompletionHistory();
    00252 private slots:
    00253     void extendedMenuActivated( int id);
    00254 private:
    00255     enum LineEditMenuID {
    00256         ClearHistory
    00257     };
    00258 };
    00259
    00260 // -------------------------------------------------------------------------
    00261
    00262 class RenderFieldset : public RenderFlow
    00263 {
    00264 public:
    00265     RenderFieldset(DOM::HTMLGenericFormElementImpl *element);
    00266
    00267     virtual const char *renderName() const { return "RenderFieldSet"; }
    00268 protected:
    00269     virtual void paintBoxDecorations(QPainter *p,int, int _y,
    00270                                        int, int _h, int _tx, int _ty);
    00271     void paintBorderMinusLegend(QPainter *p, int _tx, int _ty, int w,
    00272                                   int h, const RenderStyle *style, int lx, int lw);
    00273     bool findLegend( int &lx, int &ly, int &lw, int &lh);
    00274 };
    00275 // -------------------------------------------------------------------------
    00276
    00277 class RenderCustomButton : public RenderReplacedFlow
    00278 {
    00279 public:
    00280     RenderCustomButton(DOM::HTMLGenericFormElementImpl *element);
    00281
    00282     virtual const char *renderName() const { return "RenderCustomButton"; }
    00283 };
    00284
    00285 // -------------------------------------------------------------------------
    00286
    00287 class RenderFileButton : public RenderFormElement
    00288 {
    00289     Q_OBJECT
    00290 public:
    00291     RenderFileButton(DOM::HTMLInputElementImpl *element);
    00292
    00293     virtual const char *renderName() const { return "RenderFileButton"; }
    00294     virtual void calcMinMaxWidth();
    00295     virtual void updateFromElement();
    00296     void select();
    00297
    00298     DOM::HTMLInputElementImpl *element() const
    00299     { return static_cast<DOM::HTMLInputElementImpl*>(RenderObject::element()); }
    00300
    00301     KLineEdit* lineEdit() const { return m_edit; }
    00302
    00303 public slots:
    00304     virtual void slotClicked();
    00305     virtual void slotReturnPressed();
    00306     virtual void slotTextChanged(const QString &string);
    00307
    00308 protected:
    00309     virtual void handleFocusOut();
    00310
    00311     virtual bool isEditable() const { return true; }
    00312
    00313     bool m_clicked;
    00314     bool m_haveFocus;
    00315     KLineEdit   *m_edit;
    00316     QPushButton *m_button;
    00317 };
    00318
    00319
    00320 // -------------------------------------------------------------------------
    00321
    00322 class RenderLabel : public RenderFormElement
    00323 {
    00324 public:
    00325     RenderLabel(DOM::HTMLGenericFormElementImpl *element);
    00326
    00327     virtual const char *renderName() const { return "RenderLabel"; }
    00328 };
    00329
    00330
    00331 // -------------------------------------------------------------------------
    00332
    00333 class RenderLegend : public RenderFlow
    00334 {
    00335 public:
    00336     RenderLegend(DOM::HTMLGenericFormElementImpl *element);
    00337
    00338     virtual const char *renderName() const { return "RenderLegend"; }
    00339 };
    00340
    00341 // -------------------------------------------------------------------------
    00342
    00343 class ComboBoxWidget : public KComboBox
    00344 {
    00345 public:
    00346     ComboBoxWidget(QWidget *parent);
    00347
    00348 protected:
    00349     virtual bool event(QEvent *);
    00350     virtual bool eventFilter(QObject *dest, QEvent *e);
    00351 };
    00352
    00353 // -------------------------------------------------------------------------
    00354
    00355 class RenderSelect : public RenderFormElement
    00356 {
    00357     Q_OBJECT
    00358 public:
    00359     RenderSelect(DOM::HTMLSelectElementImpl *element);
    00360
    00361     virtual const char *renderName() const { return "RenderSelect"; }
    00362
    00363     virtual void calcMinMaxWidth();
    00364     virtual void layout();
    00365
    00366     void setOptionsChanged(bool _optionsChanged);
    00367
    00368     bool selectionChanged() { return m_selectionChanged; }
    00369     void setSelectionChanged(bool _selectionChanged) { m_selectionChanged = _selectionChanged; }
    00370     virtual void updateFromElement();
    00371
    00372     void updateSelection();
    00373
    00374     DOM::HTMLSelectElementImpl *element() const
    00375     { return static_cast<DOM::HTMLSelectElementImpl*>(RenderObject::element()); }
    00376
    00377 protected:
    00378     KListBox *createListBox();
    00379     ComboBoxWidget *createComboBox();
    00380
    00381     unsigned  m_size;
    00382     bool m_multiple;
    00383     bool m_useListBox;
    00384     bool m_selectionChanged;
    00385     bool m_ignoreSelectEvents;
    00386     bool m_optionsChanged;
    00387
    00388 protected slots:
    00389     void slotSelected(int index);
    00390     void slotSelectionChanged();
    00391 };
    00392
    00393 // -------------------------------------------------------------------------
    00394
    00395 class TextAreaWidget : public KTextEdit
    00396 {
    00397 public:
    00398     TextAreaWidget(int wrap, QWidget* parent);
    00399
    00400 protected:
    00401     virtual bool event (QEvent *e );
    00402 };
    00403
    00404
    00405 // -------------------------------------------------------------------------
    00406
    00407 class RenderTextArea : public RenderFormElement
    00408 {
    00409     Q_OBJECT
    00410 public:
    00411     RenderTextArea(DOM::HTMLTextAreaElementImpl *element);
    00412     ~RenderTextArea();
    00413
    00414     virtual const char *renderName() const { return "RenderTextArea"; }
    00415     virtual void calcMinMaxWidth();
    00416     virtual void close ( );
    00417     virtual void updateFromElement();
    00418
    00419     // don't even think about making this method virtual!
    00420     DOM::HTMLTextAreaElementImpl* element() const
    00421     { return static_cast<DOM::HTMLTextAreaElementImpl*>(RenderObject::element()); }
    00422
    00423     QString text();
    00424
    00425     void select();
    00426
    00427 protected slots:
    00428     void slotTextChanged();
    00429
    00430 protected:
    00431     virtual void handleFocusOut();
    00432
    00433     virtual bool isEditable() const { return true; }
    00434 };
    00435
    00436 // -------------------------------------------------------------------------
    00437
    00438 } //namespace
    00439
    00440 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:34:35 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001