ソースを参照

Expose QSplitter::setCollapsible to host environment

Neal Wilson 6年前
コミット
0daa9891d6
1個のファイルの変更27行の追加0行の削除
  1. 27
    0
      src/typica.w

+ 27
- 0
src/typica.w ファイルの表示

774
     return qscriptvalue_cast<QByteArray>(context->argument(arg));
774
     return qscriptvalue_cast<QByteArray>(context->argument(arg));
775
 }
775
 }
776
 
776
 
777
+template<> bool argument(int arg, QScriptContext *context)
778
+{
779
+    return context->argument(arg).toBool();
780
+}
781
+
777
 @ The scripting engine is informed of a number of classes defined elsewhere in
782
 @ The scripting engine is informed of a number of classes defined elsewhere in
778
 the program. Code related to scripting these classes is grouped with the code
783
 the program. Code related to scripting these classes is grouped with the code
779
 implementing the classes. Additionally, there are several classes from Qt which
784
 implementing the classes. Additionally, there are several classes from Qt which
1627
                                     QScriptEngine *engine);
1632
                                     QScriptEngine *engine);
1628
 QScriptValue QSplitter_count(QScriptContext *context,
1633
 QScriptValue QSplitter_count(QScriptContext *context,
1629
                              QScriptEngine *engine);
1634
                              QScriptEngine *engine);
1635
+QScriptValue QSplitter_setCollapsible(QScriptContext *context,
1636
+                                      QScriptEngine *engine);
1630
 void setQSplitterProperties(QScriptValue value, QScriptEngine *engine);
1637
 void setQSplitterProperties(QScriptValue value, QScriptEngine *engine);
1631
 
1638
 
1632
 @ Of these, the scripting engine must be informed of the constructor.
1639
 @ Of these, the scripting engine must be informed of the constructor.
1654
     value.setProperty("restoreState",
1661
     value.setProperty("restoreState",
1655
                       engine->newFunction(QSplitter_restoreState));
1662
                       engine->newFunction(QSplitter_restoreState));
1656
     value.setProperty("count", engine->newFunction(QSplitter_count));
1663
     value.setProperty("count", engine->newFunction(QSplitter_count));
1664
+    value.setProperty("setCollapsible", engine->newFunction(QSplitter_setCollapsible));
1657
 }
1665
 }
1658
 
1666
 
1659
 @ The |"addWidget"| property is a simple wrapper around
1667
 @ The |"addWidget"| property is a simple wrapper around
1746
     return QScriptValue();
1754
     return QScriptValue();
1747
 }
1755
 }
1748
 
1756
 
1757
+@ Sometimes a |QSplitter| is used to make it easy to hide optional elements. In
1758
+this use case it can be useful to indicate that required elements cannot be
1759
+collapsed.
1760
+
1761
+@<Functions for scripting@>=
1762
+QScriptValue QSplitter_setCollapsible(QScriptContext *context, QScriptEngine *)
1763
+{
1764
+    if(context->argumentCount() == 2)
1765
+    {
1766
+        QSplitter *self = getself<QSplitter *>(context);
1767
+        self->setCollapsible(argument<int>(0, context), argument<bool>(1, context));
1768
+    }
1769
+    else
1770
+    {
1771
+        context->throwError("Incorrect number of arguments");
1772
+    }
1773
+    return QScriptValue();
1774
+}
1775
+
1749
 @* Scripting Layout classes.
1776
 @* Scripting Layout classes.
1750
 
1777
 
1751
 \noindent Layout classes simplify managing the size and position of widgets in a
1778
 \noindent Layout classes simplify managing the size and position of widgets in a

読み込み中…
キャンセル
保存