// -*- c++ -*-

/*
 *  Copyright (C) 2001-2004, Richard J. Moore <rich@kde.org>
 *
 *  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., 59 Temple Place - Suite 330,
 *  Boston, MA 02111-1307, USA.
 */

#ifndef KJSEMBEDCUSTOMOBJECTIMP_H
#define KJSEMBEDCUSTOMOBJECTIMP_H

#include <kjs/object.h>
#include <kjsembed/jsbinding.h>
#include <kjsembed/slotutils.h>

#include <kjsembed/jsobjectproxy_imp.h>

class QObject;

namespace KJSEmbed {
namespace Bindings {

/**
 * Implements the JS methods of custom object bindings.
 *
 * @author Richard Moore, rich@kde.org
 * @version $Id: customobject_imp.h,v 1.20 2004/04/11 00:40:14 rich Exp $
 */
class CustomObjectImp : public JSProxyImp
{
public:
    /** Identifiers for the methods provided by this class. */
    enum MethodId {
	WidgetGrabWidget,
	WidgetDrawLine,
	WidgetDrawText,

	ListBoxInsertItem,

	ListViewAddColumn,
	ListViewInsertItem,

	MainWindowSetCentralWidget,
	MainWindowCreateGUI,

	TabWidgetAddTab,

	ScrollViewViewport,
	ScrollViewAddChild,

	ApplicationExec,

	TimerIsActive,
	TimerStart,
	TimerStop,

	BoxLayoutAddWidget,
	BoxLayoutAddSpacing,
	BoxLayoutAddStretch,
	BoxLayoutAddLayout,

	URLRequesterSetMode,
	URLRequesterSetFilter,
	URLRequesterUrl,
	URLRequesterSetLocalProtocol,
	URLRequesterLocalProtocol,

	KXMLGUIClientActionCollection,

	KReadOnlyPartOpenStream,
	KReadOnlyPartWriteStream,
	KReadOnlyPartCloseStream,

	HBoxSpacing
    };

    static void addBindings( KJS::ExecState *exec, KJS::Object &object );

    CustomObjectImp( KJS::ExecState *exec, int id, JSObjectProxy *parent );
    virtual ~CustomObjectImp() {}

    KJS::Value widgetGrabWidget(KJS::ExecState *exec, KJS::Object &, const KJS::List &args );
    void widgetDrawLine( KJS::ExecState *exec, KJS::Object &, const KJS::List &args );
    void widgetDrawText( KJS::ExecState *exec, KJS::Object &, const KJS::List &args );

    void listBoxInsertItem( KJS::ExecState *exec, KJS::Object &, const KJS::List &args );

    void listViewAddColumn( KJS::ExecState *exec, KJS::Object &, const KJS::List &args );
    void listViewInsertItem( KJS::ExecState *exec, KJS::Object &, const KJS::List &args );

    void mainWinSetCentralWidget( KJS::ExecState *exec, KJS::Object &, const KJS::List &args );
    void mainWinCreateGUI( KJS::ExecState *exec, KJS::Object &, const KJS::List &args );

    void tabWidgetAddTab( KJS::ExecState *exec, KJS::Object&, const KJS::List &args );

    KJS::Value scrollViewViewport( KJS::ExecState *exec, KJS::Object&, const KJS::List &args );
    void scrollViewAddChild( KJS::ExecState *exec, KJS::Object&, const KJS::List &args );

    KJS::Value applicationExec( KJS::ExecState *exec, KJS::Object &, const KJS::List &args );

    KJS::Value timerIsActive( KJS::ExecState *exec, KJS::Object &, const KJS::List &args );
    KJS::Value timerStart( KJS::ExecState *exec, KJS::Object &, const KJS::List &args );
    KJS::Value timerStop( KJS::ExecState *exec, KJS::Object &, const KJS::List &args );

    void boxLayoutAddWidget( KJS::ExecState *exec, KJS::Object &, const KJS::List &args );
    void boxLayoutAddSpacing( KJS::ExecState *exec, KJS::Object &, const KJS::List &args );
    void boxLayoutAddStretch( KJS::ExecState *exec, KJS::Object &, const KJS::List &args );
    void boxLayoutAddLayout( KJS::ExecState *exec, KJS::Object &, const KJS::List &args );

    KJS::Value xmlguiClientActionCollection( KJS::ExecState *exec, KJS::Object &, const KJS::List &args );

    KJS::Value kroPartOpenStream( KJS::ExecState *exec, KJS::Object &, const KJS::List &args );
    KJS::Value kroPartWriteStream( KJS::ExecState *exec, KJS::Object &, const KJS::List &args );
    KJS::Value kroPartCloseStream( KJS::ExecState *exec, KJS::Object &, const KJS::List &args );

    void hboxSpacing( KJS::ExecState *exec, KJS::Object &, const KJS::List &args );

    virtual bool implementsCall() const { return true; }
    virtual KJS::Value call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );

private:
    int id;
    JSObjectProxy *proxy;
    class CustomObjectImpPrivate *d;
};

} // namespace KJSEmbed::Bindings
} // namespace KJSEmbed

#endif // KJSEMBEDCUSTOMOBJECTIMP_H

// Local Variables:
// c-basic-offset: 4
// End:
