Support for QFormLayouts with qt:add-field
This commit is contained in:
parent
e0fca00772
commit
5d32d36bc7
16
main.cpp
16
main.cpp
|
@ -4,6 +4,7 @@
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QtUiTools>
|
#include <QtUiTools>
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
|
#include <QFormLayout>
|
||||||
#include <QOpenGLWidget>
|
#include <QOpenGLWidget>
|
||||||
#include <QtMultimedia/QSoundEffect>
|
#include <QtMultimedia/QSoundEffect>
|
||||||
#include <chicken.h>
|
#include <chicken.h>
|
||||||
|
@ -72,6 +73,7 @@ protected:
|
||||||
#define qttextedit QTextEdit *
|
#define qttextedit QTextEdit *
|
||||||
#define qtaction QAction *
|
#define qtaction QAction *
|
||||||
#define qtlayout QLayout *
|
#define qtlayout QLayout *
|
||||||
|
#define qtformlayout QFormLayout *
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
|
@ -498,6 +500,20 @@ char *qt_listwidgetitem(qtwidget w, int i) {
|
||||||
|
|
||||||
void qt_addlayoutwidget(qtlayout l, qtwidget w) { l->addWidget(w); }
|
void qt_addlayoutwidget(qtlayout l, qtwidget w) { l->addWidget(w); }
|
||||||
|
|
||||||
|
void qt_addformlayoutwidget(qtformlayout l, const char* label, qtwidget w, int row) {
|
||||||
|
if (row < 0)
|
||||||
|
l->addRow(label, w);
|
||||||
|
else
|
||||||
|
l->insertRow(row, label, w);
|
||||||
|
}
|
||||||
|
|
||||||
|
void qt_addformlayoutlayout(qtformlayout l, const char* label, qtlayout add_l, int row) {
|
||||||
|
if (row < 0)
|
||||||
|
l->addRow(label, add_l);
|
||||||
|
else
|
||||||
|
l->insertRow(row, label, add_l);
|
||||||
|
}
|
||||||
|
|
||||||
qtsound qt_sound(char *filename) {
|
qtsound qt_sound(char *filename) {
|
||||||
QSoundEffect* sound = new QSoundEffect();
|
QSoundEffect* sound = new QSoundEffect();
|
||||||
sound->setSource(QUrl::fromLocalFile(filename));
|
sound->setSource(QUrl::fromLocalFile(filename));
|
||||||
|
|
|
@ -57,6 +57,8 @@ void qt_addlistwidgetitem(qtwidget w, char *s);
|
||||||
void qt_addtreewidgetitem(qtwidget w, char *s);
|
void qt_addtreewidgetitem(qtwidget w, char *s);
|
||||||
char *qt_listwidgetitem(qtwidget w, int i);
|
char *qt_listwidgetitem(qtwidget w, int i);
|
||||||
void qt_addlayoutwidget(qtlayout l, qtwidget w);
|
void qt_addlayoutwidget(qtlayout l, qtwidget w);
|
||||||
|
void qt_addformlayoutwidget(qtformlayout l, const char* label, qtwidget w, int row);
|
||||||
|
void qt_addformlayoutlayout(qtformlayout l, const char* label, qtlayout add_l, int row);
|
||||||
char *qt_getexistingdirectory(qtwidget p, char *cap, char *dir, int opts);
|
char *qt_getexistingdirectory(qtwidget p, char *cap, char *dir, int opts);
|
||||||
char *qt_getopenfilename(qtwidget p, char *cap, char *dir, char *filter, int opts);
|
char *qt_getopenfilename(qtwidget p, char *cap, char *dir, char *filter, int opts);
|
||||||
char *qt_getsavefilename(qtwidget p, char *cap, char *dir, char *filter, int opts);
|
char *qt_getsavefilename(qtwidget p, char *cap, char *dir, char *filter, int opts);
|
||||||
|
|
21
qt-light.scm
21
qt-light.scm
|
@ -5,10 +5,11 @@
|
||||||
qt:widget qt:show qt:hide qt:run
|
qt:widget qt:show qt:hide qt:run
|
||||||
qt:delete qt:message qt:connect qt:find
|
qt:delete qt:message qt:connect qt:find
|
||||||
qt:widget qt:receiver qt:pixmap qt:icon qt:theme-icon qt:timer
|
qt:widget qt:receiver qt:pixmap qt:icon qt:theme-icon qt:timer
|
||||||
qt:icon->pixmap qt:pixmap->icon
|
qt:icon->pixmap qt:pixmap->icon
|
||||||
qt:property qt:gl qt:update qt:start qt:stop
|
qt:property qt:gl qt:update qt:start qt:stop
|
||||||
qt:clear qt:add qt:item <qt> qt:classname qt:inherits
|
qt:clear qt:add qt:item qt:add-field
|
||||||
<qt-object> <qt-widget> <qt-pixmap> <qt-icon> <qt-application>
|
qt:classname qt:inherits
|
||||||
|
<qt> <qt-object> <qt-widget> <qt-pixmap> <qt-icon> <qt-application>
|
||||||
<qt-receiver> <qt-timer> <qt-sound> <qt-text-edit>
|
<qt-receiver> <qt-timer> <qt-sound> <qt-text-edit>
|
||||||
<qt-action>
|
<qt-action>
|
||||||
qt:get-open-filename qt:get-save-filename qt:get-directory
|
qt:get-open-filename qt:get-save-filename qt:get-directory
|
||||||
|
@ -50,10 +51,12 @@
|
||||||
(define <qt-text-edit> (% <qt-widget> (class 'qt-text-edit)))
|
(define <qt-text-edit> (% <qt-widget> (class 'qt-text-edit)))
|
||||||
(define <qt-action> (% <qt-object> (class 'qt-action)))
|
(define <qt-action> (% <qt-object> (class 'qt-action)))
|
||||||
(define <qt-layout> (% <qt-object> (class 'qt-layout)))
|
(define <qt-layout> (% <qt-object> (class 'qt-layout)))
|
||||||
|
(define <qt-form-layout> (% <qt-object> (class 'qt-form-layout)))
|
||||||
|
|
||||||
(define (qt:->pointer i) (and i (? i pointer)))
|
(define (qt:->pointer i) (and i (? i pointer)))
|
||||||
(define (qt:pointer->widget p) (and p (% <qt-widget> (pointer p))))
|
(define (qt:pointer->widget p) (and p (% <qt-widget> (pointer p))))
|
||||||
(define (qt:pointer->layout p) (and p (% <qt-layout> (pointer p))))
|
(define (qt:pointer->layout p) (and p (% <qt-layout> (pointer p))))
|
||||||
|
(define (qt:pointer->form-layout p) (and p (% <qt-form-layout> (pointer p))))
|
||||||
(define (qt:pointer->object p) (and p (% <qt-object> (pointer p))))
|
(define (qt:pointer->object p) (and p (% <qt-object> (pointer p))))
|
||||||
(define (qt:pointer->timer p) (and p (% <qt-timer> (pointer p))))
|
(define (qt:pointer->timer p) (and p (% <qt-timer> (pointer p))))
|
||||||
(define (qt:pointer->application p) (and p (% <qt-application> (pointer p))))
|
(define (qt:pointer->application p) (and p (% <qt-application> (pointer p))))
|
||||||
|
@ -71,6 +74,7 @@
|
||||||
(bind-type qtpixmap c-pointer qt:->pointer qt:pointer->pixmap)
|
(bind-type qtpixmap c-pointer qt:->pointer qt:pointer->pixmap)
|
||||||
(bind-type qticon c-pointer qt:->pointer qt:pointer->icon)
|
(bind-type qticon c-pointer qt:->pointer qt:pointer->icon)
|
||||||
(bind-type qtlayout c-pointer qt:->pointer qt:pointer->layout)
|
(bind-type qtlayout c-pointer qt:->pointer qt:pointer->layout)
|
||||||
|
(bind-type qtformlayout c-pointer qt:->pointer qt:pointer->form-layout)
|
||||||
(bind-type qtobject c-pointer qt:->pointer qt:pointer->object)
|
(bind-type qtobject c-pointer qt:->pointer qt:pointer->object)
|
||||||
(bind-type qttimer c-pointer qt:->pointer qt:pointer->timer)
|
(bind-type qttimer c-pointer qt:->pointer qt:pointer->timer)
|
||||||
(bind-type qtreceiver c-pointer qt:->pointer qt:pointer->receiver)
|
(bind-type qtreceiver c-pointer qt:->pointer qt:pointer->receiver)
|
||||||
|
@ -116,11 +120,13 @@ extern "C" {
|
||||||
(let ((result (qt:find o name)))
|
(let ((result (qt:find o name)))
|
||||||
(if result
|
(if result
|
||||||
(cond ((qt:inherits result "QTextEdit")
|
(cond ((qt:inherits result "QTextEdit")
|
||||||
(qt:pointer->textedit (qt:->pointer result)))
|
(qt:pointer->text-edit (qt:->pointer result)))
|
||||||
((qt:inherits result "QWidget")
|
((qt:inherits result "QWidget")
|
||||||
(qt:pointer->widget (qt:->pointer result)))
|
(qt:pointer->widget (qt:->pointer result)))
|
||||||
((qt:inherits result "QAction")
|
((qt:inherits result "QAction")
|
||||||
(qt:pointer->action (qt:->pointer result)))
|
(qt:pointer->action (qt:->pointer result)))
|
||||||
|
((qt:inherits result "QFormLayout")
|
||||||
|
(qt:pointer->form-layout (qt:->pointer result)))
|
||||||
((qt:inherits result "QLayout")
|
((qt:inherits result "QLayout")
|
||||||
(qt:pointer->layout (qt:->pointer result)))
|
(qt:pointer->layout (qt:->pointer result)))
|
||||||
(#t
|
(#t
|
||||||
|
@ -223,6 +229,13 @@ extern "C" {
|
||||||
((qt:inherits w "QLayout") (qt:addlayoutwidget w x))
|
((qt:inherits w "QLayout") (qt:addlayoutwidget w x))
|
||||||
(else (error 'qt:add "invalid widget" w x)) ) )
|
(else (error 'qt:add "invalid widget" w x)) ) )
|
||||||
|
|
||||||
|
(define (qt:add-field layout label item #!optional (row #f))
|
||||||
|
(cond ((qt:inherits item "QLayout")
|
||||||
|
(qt:addformlayoutlayout layout label item (or row -1)))
|
||||||
|
((qt:inherits item "QWidget")
|
||||||
|
(qt:addformlayoutwidget layout label item (or row -1)))
|
||||||
|
(else (error 'qt:add-field "invalid widget/layout" layout item))))
|
||||||
|
|
||||||
(define (qt:item w i) (and (positive? i) (qt:listwidgetitem w i)))
|
(define (qt:item w i) (and (positive? i) (qt:listwidgetitem w i)))
|
||||||
(define qt:clear qt:clearlistwidget)
|
(define qt:clear qt:clearlistwidget)
|
||||||
|
|
||||||
|
|
Ŝarĝante…
Reference in New Issue