Browse Source

Expose QSplitter::setCollapsible to host environment

Neal Wilson 6 years ago
parent
commit
0daa9891d6
1 changed files with 27 additions and 0 deletions
  1. 27
    0
      src/typica.w

+ 27
- 0
src/typica.w View File

@@ -774,6 +774,11 @@ template<> QByteArray argument(int arg, QScriptContext *context)
774 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 782
 @ The scripting engine is informed of a number of classes defined elsewhere in
778 783
 the program. Code related to scripting these classes is grouped with the code
779 784
 implementing the classes. Additionally, there are several classes from Qt which
@@ -1627,6 +1632,8 @@ QScriptValue QSplitter_restoreState(QScriptContext *context,
1627 1632
                                     QScriptEngine *engine);
1628 1633
 QScriptValue QSplitter_count(QScriptContext *context,
1629 1634
                              QScriptEngine *engine);
1635
+QScriptValue QSplitter_setCollapsible(QScriptContext *context,
1636
+                                      QScriptEngine *engine);
1630 1637
 void setQSplitterProperties(QScriptValue value, QScriptEngine *engine);
1631 1638
 
1632 1639
 @ Of these, the scripting engine must be informed of the constructor.
@@ -1654,6 +1661,7 @@ void setQSplitterProperties(QScriptValue value, QScriptEngine *engine)
1654 1661
     value.setProperty("restoreState",
1655 1662
                       engine->newFunction(QSplitter_restoreState));
1656 1663
     value.setProperty("count", engine->newFunction(QSplitter_count));
1664
+    value.setProperty("setCollapsible", engine->newFunction(QSplitter_setCollapsible));
1657 1665
 }
1658 1666
 
1659 1667
 @ The |"addWidget"| property is a simple wrapper around
@@ -1746,6 +1754,25 @@ QScriptValue QSplitter_restoreState(QScriptContext *context, QScriptEngine *)
1746 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 1776
 @* Scripting Layout classes.
1750 1777
 
1751 1778
 \noindent Layout classes simplify managing the size and position of widgets in a

Loading…
Cancel
Save