• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

kjsembed

  • sources
  • kde-4.12
  • kdelibs
  • kjsembed
  • kjsembed
qlayout_binding.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2005, 2006 Ian Reinhart Geiser <geiseri@kde.org>
3  Copyright (C) 2005, 2006 Matt Broadstone <mbroadst@gmail.com>
4  Copyright (C) 2005, 2006 Richard J. Moore <rich@kde.org>
5  Copyright (C) 2005, 2006 Erik L. Bunce <kde@bunce.us>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 #include "qlayout_binding.h"
23 #include "static_binding.h"
24 #include "kjseglobal.h"
25 
26 #include <kjs/object.h>
27 #include <QtCore/QDebug>
28 
29 #include <QtGui/QWidget>
30 #include <QtGui/QAction>
31 #include <QtGui/QLayout>
32 #include <QtUiTools/QUiLoader>
33 
34 namespace KJSEmbed
35 {
36  QUiLoader *uiLoader();
37 }
38 
39 
40 using namespace KJSEmbed;
41 
42 namespace LayoutNS
43 {
44 START_QOBJECT_METHOD( addWidget, QLayout )
45  QWidget *w = KJSEmbed::extractObject<QWidget>(exec, args, 0, 0);
46  object->addWidget(w);
47 END_QOBJECT_METHOD
48 START_QOBJECT_METHOD( removeWidget, QLayout )
49  QWidget *w = KJSEmbed::extractObject<QWidget>(exec, args, 0, 0);
50  object->removeWidget(w);
51 END_QOBJECT_METHOD
52 START_QOBJECT_METHOD( parentWidget, QLayout )
53  QWidget *w = object->parentWidget();
54  result = KJSEmbed::createQObject(exec,w);
55 END_QOBJECT_METHOD
56 
57 }
58 
59 START_METHOD_LUT( Layout )
60  {"addWidget", 1, KJS::DontDelete|KJS::ReadOnly, &LayoutNS::addWidget},
61  {"removeWidget", 1, KJS::DontDelete|KJS::ReadOnly, &LayoutNS::removeWidget},
62  {"parentWidget", 0, KJS::DontDelete|KJS::ReadOnly, &LayoutNS::parentWidget}
63 END_METHOD_LUT
64 
65 NO_ENUMS( Layout )
66 NO_STATICS( Layout )
67 
68 KJSO_SIMPLE_BINDING_CTOR( Layout, QLayout, QObjectBinding )
69 KJSO_QOBJECT_BIND( Layout, QLayout )
70 
71 KJSO_START_CTOR( Layout, QLayout, 0 )
72 // qDebug("Layout::CTOR(): args.size()=%d", args.size());
73 
74  if( args.size() > 0 )
75  {
76  QString layoutName = toQString(args[0]->toString(exec));
77  QObject *parentObject = 0;
78  KJSEmbed::QObjectBinding *parentImp = KJSEmbed::extractBindingImp<KJSEmbed::QObjectBinding>(exec, args[1] );
79  if( parentImp )
80  {
81  parentObject = parentImp->object<QObject>();
82  }
83 
84  QLayout *layout = uiLoader()->createLayout(layoutName, parentObject, "QLayout");
85  if( layout )
86  {
87  KJS::JSObject *layoutObject = new Layout(exec, layout);//KJSEmbed::createQObject(exec, layout);
88  return layoutObject;
89  }
90  return KJS::throwError(exec, KJS::GeneralError, i18n("'%1' is not a valid QLayout.",
91  layoutName));
92  // return KJSEmbed::throwError(exec, i18n("'%1' is not a valid QLayout.").arg(layoutName));
93  }
94 
95  // should Trow error incorrect args
96  return KJS::throwError(exec, KJS::GeneralError, i18n("Must supply a layout name."));
97  // return KJSEmbed::throwError(exec, i18n("Must supply a layout name."));
98 KJSO_END_CTOR
99 
100 //kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle;
KJSEmbed::QObjectBinding
Definition: qobject_binding.h:79
LayoutNS::w
QWidget * w
Definition: qlayout_binding.cpp:45
KJSO_QOBJECT_BIND
#define KJSO_QOBJECT_BIND(NAME, TYPE)
Definition: binding_support.h:205
qlayout_binding.h
QWidget
KJSO_START_CTOR
KJSO_START_CTOR(UiLoaderBinding, QUiLoader, 1)
Definition: quiloader_binding.cpp:40
QObject
DomDocumentNS::if
if(!success)
Definition: dom.cpp:363
START_METHOD_LUT
START_METHOD_LUT(Layout)
Definition: qlayout_binding.cpp:59
KJSEmbed::ObjectBinding::object
T * object() const
Definition: object_binding.h:119
KJSEmbed::createQObject
KJSEMBED_EXPORT KJS::JSObject * createQObject(KJS::ExecState *exec, QObject *value, KJSEmbed::ObjectBinding::Ownership owner=KJSEmbed::ObjectBinding::JSOwned)
Returns a binding object for the specified QObject.
Definition: qobject_binding.cpp:735
START_QOBJECT_METHOD
#define START_QOBJECT_METHOD(METHODNAME, TYPE)
A simple pointer syle method.
Definition: qobject_binding.h:45
END_QOBJECT_METHOD
#define END_QOBJECT_METHOD
End a variant method started by START_QOBJECT_METHOD.
Definition: qobject_binding.h:60
NO_ENUMS
#define NO_ENUMS(TYPE)
Definition: binding_support.h:147
KJSO_SIMPLE_BINDING_CTOR
#define KJSO_SIMPLE_BINDING_CTOR(NAME, TYPE, BASENAME)
Definition: binding_support.h:113
LayoutNS::removeWidget
object removeWidget(w)
LayoutNS::result
result
Definition: qlayout_binding.cpp:54
END_METHOD_LUT
#define END_METHOD_LUT
Definition: binding_support.h:135
kjseglobal.h
LayoutNS::addWidget
object addWidget(w)
KJSEmbed::uiLoader
QUiLoader * uiLoader()
Definition: qwidget_binding.cpp:41
KJSEmbed::extractObject
T * extractObject(KJS::ExecState *exec, KJS::JSValue *arg, T *defaultValue)
Extracts a pointer based type from an ObjectBinding object.
Definition: object_binding.h:158
static_binding.h
KJSO_END_CTOR
#define KJSO_END_CTOR
Definition: binding_support.h:178
KJS::throwError
JSObject * throwError(ExecState *e, ErrorType t, const QString &m)
Definition: binding_support.h:241
NO_STATICS
#define NO_STATICS(TYPE)
Definition: binding_support.h:153
KJSEmbed::toQString
QString toQString(const KJS::UString &u)
Definition: kjseglobal.h:58
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:47:53 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kjsembed

Skip menu "kjsembed"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal