khtml Library API Documentation

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.4 2003/01/18 01:09:31 mueller 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 
00278 class RenderFileButton : public RenderFormElement
00279 {
00280     Q_OBJECT
00281 public:
00282     RenderFileButton(DOM::HTMLInputElementImpl *element);
00283 
00284     virtual const char *renderName() const { return "RenderFileButton"; }
00285     virtual void calcMinMaxWidth();
00286     virtual void updateFromElement();
00287     void select();
00288 
00289     DOM::HTMLInputElementImpl *element() const
00290     { return static_cast<DOM::HTMLInputElementImpl*>(RenderObject::element()); }
00291 
00292     KLineEdit* lineEdit() const { return m_edit; }
00293 
00294 public slots:
00295     virtual void slotClicked();
00296     virtual void slotReturnPressed();
00297     virtual void slotTextChanged(const QString &string);
00298 
00299 protected:
00300     virtual void handleFocusOut();
00301 
00302     virtual bool isEditable() const { return true; }
00303 
00304     bool m_clicked;
00305     bool m_haveFocus;
00306     KLineEdit   *m_edit;
00307     QPushButton *m_button;
00308 };
00309 
00310 
00311 // -------------------------------------------------------------------------
00312 
00313 class RenderLabel : public RenderFormElement
00314 {
00315 public:
00316     RenderLabel(DOM::HTMLGenericFormElementImpl *element);
00317 
00318     virtual const char *renderName() const { return "RenderLabel"; }
00319 };
00320 
00321 
00322 // -------------------------------------------------------------------------
00323 
00324 class RenderLegend : public RenderFlow
00325 {
00326 public:
00327     RenderLegend(DOM::HTMLGenericFormElementImpl *element);
00328 
00329     virtual const char *renderName() const { return "RenderLegend"; }
00330 };
00331 
00332 // -------------------------------------------------------------------------
00333 
00334 class ComboBoxWidget : public KComboBox
00335 {
00336 public:
00337     ComboBoxWidget(QWidget *parent);
00338 
00339 protected:
00340     virtual bool event(QEvent *);
00341     virtual bool eventFilter(QObject *dest, QEvent *e);
00342 };
00343 
00344 // -------------------------------------------------------------------------
00345 
00346 class RenderSelect : public RenderFormElement
00347 {
00348     Q_OBJECT
00349 public:
00350     RenderSelect(DOM::HTMLSelectElementImpl *element);
00351 
00352     virtual const char *renderName() const { return "RenderSelect"; }
00353 
00354     virtual void calcMinMaxWidth();
00355     virtual void layout();
00356 
00357     void setOptionsChanged(bool _optionsChanged);
00358 
00359     bool selectionChanged() { return m_selectionChanged; }
00360     void setSelectionChanged(bool _selectionChanged) { m_selectionChanged = _selectionChanged; }
00361     virtual void updateFromElement();
00362 
00363     void updateSelection();
00364 
00365     DOM::HTMLSelectElementImpl *element() const
00366     { return static_cast<DOM::HTMLSelectElementImpl*>(RenderObject::element()); }
00367 
00368 protected:
00369     KListBox *createListBox();
00370     ComboBoxWidget *createComboBox();
00371 
00372     unsigned  m_size;
00373     bool m_multiple;
00374     bool m_useListBox;
00375     bool m_selectionChanged;
00376     bool m_ignoreSelectEvents;
00377     bool m_optionsChanged;
00378 
00379 protected slots:
00380     void slotSelected(int index);
00381     void slotSelectionChanged();
00382 };
00383 
00384 // -------------------------------------------------------------------------
00385 
00386 class TextAreaWidget : public KTextEdit
00387 {
00388 public:
00389     TextAreaWidget(int wrap, QWidget* parent);
00390 
00391 protected:
00392     virtual bool event (QEvent *e );
00393 };
00394 
00395 
00396 // -------------------------------------------------------------------------
00397 
00398 class RenderTextArea : public RenderFormElement
00399 {
00400     Q_OBJECT
00401 public:
00402     RenderTextArea(DOM::HTMLTextAreaElementImpl *element);
00403     ~RenderTextArea();
00404 
00405     virtual const char *renderName() const { return "RenderTextArea"; }
00406     virtual void calcMinMaxWidth();
00407     virtual void close ( );
00408     virtual void updateFromElement();
00409 
00410     // don't even think about making this method virtual!
00411     DOM::HTMLTextAreaElementImpl* element() const
00412     { return static_cast<DOM::HTMLTextAreaElementImpl*>(RenderObject::element()); }
00413 
00414     QString text();
00415 
00416     void select();
00417 
00418 protected slots:
00419     void slotTextChanged();
00420 
00421 protected:
00422     virtual void handleFocusOut();
00423 
00424     virtual bool isEditable() const { return true; }
00425 };
00426 
00427 // -------------------------------------------------------------------------
00428 
00429 }; //namespace
00430 
00431 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:22:42 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001