//
//     Copyright 2006 Jim Bublitz <jbublitz@nwinternet.com>
//     Earlier copyrights 1998 - 2005 Jim Bublitz and/or Phil Thompson
//     may also apply


//                 Generated by preSip
//            module khtml  version KDE 3.5.3


// This software 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.
//
// This software 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this library; see the file COPYING.
// If not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.


class KHTMLSettings
{
%TypeHeaderCode
#include <khtml_settings.h>
%End


public:

    enum KJavaScriptAdvice
    {
        KJavaScriptDunno, 
        KJavaScriptAccept, 
        KJavaScriptReject
    };


    enum KAnimationAdvice
    {
        KAnimationDisabled, 
        KAnimationLoopOnce, 
        KAnimationEnabled
    };


%If ( KDE_3_2_0 -  )

    enum KJSWindowOpenPolicy
    {
        KJSWindowOpenAllow, 
        KJSWindowOpenAsk, 
        KJSWindowOpenDeny, 
        KJSWindowOpenSmart
    };


    enum KJSWindowStatusPolicy
    {
        KJSWindowStatusAllow, 
        KJSWindowStatusIgnore
    };


    enum KJSWindowMovePolicy
    {
        KJSWindowMoveAllow, 
        KJSWindowMoveIgnore
    };


    enum KJSWindowResizePolicy
    {
        KJSWindowResizeAllow, 
        KJSWindowResizeIgnore
    };


    enum KJSWindowFocusPolicy
    {
        KJSWindowFocusAllow, 
        KJSWindowFocusIgnore
    };

%End

                         KHTMLSettings ();
                         KHTMLSettings (const KHTMLSettings&);
    void                 init ();
    void                 init (KConfig*, bool = 1);
    bool                 changeCursor ();
    bool                 underlineLink ();
    bool                 hoverLink ();

%If ( KDE_3_4_0 -  )
    bool                 allowTabulation () const;
    bool                 autoSpellCheck () const;
%End

    KHTMLSettings::KAnimationAdvice showAnimations () const;
    QString              stdFontName () const;
    QString              fixedFontName () const;
    QString              serifFontName () const;
    QString              sansSerifFontName () const;
    QString              cursiveFontName () const;
    QString              fantasyFontName () const;
    void                 setStdFontName (const QString&);
    void                 setFixedFontName (const QString&);
    int                  minFontSize () const;
    int                  mediumFontSize () const;

%If ( KDE_3_2_0 -  )
    bool                 jsErrorsEnabled () const;
    void                 setJSErrorsEnabled (bool);
%End

    const QString&       encoding () const;

%If ( KDE_3_4_0 -  )
    bool                 followSystemColors () const;
%End

    const QColor&        textColor ();

%If ( KDE_3_4_0 -  )
    const QColor&        baseColor () const;
%End

    const QColor&        linkColor ();
    const QColor&        vLinkColor ();
    bool                 autoLoadImages ();

%If ( KDE_3_4_0 -  )
    bool                 unfinishedImageFrame () const;
%End


%If ( KDE_3_3_0 -  )
    bool                 isOpenMiddleClickEnabled ();
%End


%If ( KDE_3_1_0 -  )
    bool                 isBackRightClickEnabled ();
%End

    bool                 isJavaEnabled (const QString& = QString ::null );
    bool                 isJavaScriptEnabled (const QString& = QString ::null );
    bool                 isJavaScriptDebugEnabled (const QString& = QString ::null );

%If ( KDE_3_2_0 -  )
    bool                 isJavaScriptErrorReportingEnabled (const QString& = QString ::null ) const;
%End

    bool                 isPluginsEnabled (const QString& = QString ::null );

%If ( KDE_3_5_0 -  )
    bool                 isAdFiltered (const QString&) const;
    bool                 isAdFilterEnabled () const;
    bool                 isHideAdsEnabled () const;
    void                 addAdFilter (const QString&);
    bool                 accessKeysEnabled () const;
%End


%If ( KDE_3_2_0 -  )
    KHTMLSettings::KJSWindowOpenPolicy windowOpenPolicy (const QString& = QString ::null ) const;
    KHTMLSettings::KJSWindowMovePolicy windowMovePolicy (const QString& = QString ::null ) const;
    KHTMLSettings::KJSWindowResizePolicy windowResizePolicy (const QString& = QString ::null ) const;
    KHTMLSettings::KJSWindowStatusPolicy windowStatusPolicy (const QString& = QString ::null ) const;
    KHTMLSettings::KJSWindowFocusPolicy windowFocusPolicy (const QString& = QString ::null ) const;
%End

    static KJavaScriptAdvice strToAdvice (const QString&);
//ig     static void          splitDomainAdvice (const QString&, QString&, KHTMLSettings::KJavaScriptAdvice&, KHTMLSettings::KJavaScriptAdvice&);
    static const char*   adviceToStr (KHTMLSettings::KJavaScriptAdvice);

%If ( KDE_3_2_0 -  )
//ig     void                 readDomainSettings (KConfig*, bool, bool, KPerDomainSettings&);
%End

    QString              settingsToCSS () const;
    static const QString& availableFamilies ();
    QString              userStyleSheet () const;
    bool                 isFormCompletionEnabled () const;
    int                  maxFormCompletionItems () const;

%If ( KDE_3_1_1 -  )
    bool                 isAutoDelayedActionsEnabled () const;

%If ( KDE_3_5_0 -  )
    QValueList<QPair<QString,QChar>> fallbackAccessKeysAssignments () const;
    void                 setJSPopupBlockerPassivePopup (bool);
    bool                 jsPopupBlockerPassivePopup () const;
%End

%End


};  // class KHTMLSettings



%If (KDE_3_5_0 - )
%MappedType QValueList<QPair<QString,QChar>>
//converts a Python list of tuples (QString,QChar)
{
%TypeHeaderCode
#include <qvaluelist.h>
#include <qstring.h>
#include <khtml_settings.h>
typedef QPair<QString,QChar> AssignPair;
%End

%ConvertFromTypeCode
    if (!sipCpp)
        return PyList_New(0);

    // Create the list
    PyObject *pylist;
    if ((pylist = PyList_New(0)) == NULL)
        return NULL;

    QValueList<AssignPair> *cpplist = (QValueList<AssignPair> *)sipCpp;

    // Get it.
    QValueList<AssignPair>::Iterator it;
    for( it = cpplist->begin(); it != cpplist->end(); ++it )
    {
        PyObject *inst = NULL;
        QString s = (*it).first;
        QChar c  = (*it).second;
        PyObject *pys = sipConvertFromNewType(new QString(s), sipType_QString, sipTransferObj);
        PyObject *pyc = sipConvertFromNewType(new QChar(c), sipType_QChar, sipTransferObj);
        if ((pys == NULL) || ((inst = Py_BuildValue ("NN", pys, pyc)) == NULL)
            || PyList_Append (pylist, inst) < 0)
        {
            Py_XDECREF (inst);
            Py_XDECREF (pys);
            Py_XDECREF (pyc);
            Py_DECREF (pylist);
            return NULL;
        }
    }

    return pylist;
%End


%ConvertToTypeCode
    if (sipIsErr == NULL)
        return PyList_Check(sipPy);

    QValueList<AssignPair> *cpplist = new QValueList<AssignPair>;

    QString *p1;
    QChar *p2;
    int iserr = 0;

    for (int i = 0; i < PyList_Size (sipPy); i++)
    {
        int p1_state, p2_state;

        PyObject *elem = PyList_GET_ITEM (sipPy, i);
        PyObject *pyp1 = PyTuple_GET_ITEM (elem, 0);
        PyObject *pyp2 = PyTuple_GET_ITEM (elem, 1);
        p1 = (QString *)sipForceConvertToType(pyp1, sipType_QString, sipTransferObj, SIP_NOT_NONE, &p1_state, &iserr);
        p2 = (QChar *)sipForceConvertToType(pyp2, sipType_QChar, sipTransferObj, SIP_NOT_NONE, &p2_state, &iserr);

        if (iserr)
        {
            if (p1)
                sipReleaseType(p1, sipType_QString, p1_state);

            *sipIsErr = 1;
            delete cpplist;
            return 0;
        }

        cpplist->append (AssignPair (*p1, *p2));

        sipReleaseType(p1, sipType_QString, p1_state);
        sipReleaseType(p2, sipType_QChar, p2_state);
    }

    *sipCppPtr = cpplist;

    return 1;
%End
};
%End


