diff --git a/main.cpp b/main.cpp index 5a7dc4b..3c90ebf 100644 --- a/main.cpp +++ b/main.cpp @@ -65,6 +65,7 @@ protected: #define qtreceiver SimpleReceiver * #define qtwidget QWidget * #define qtpixmap QPixmap * +#define qticon QIcon * #define qttimer QTimer * #define qtsound QSoundEffect * #define qttextedit QTextEdit * @@ -113,6 +114,7 @@ void qt_show(QWidget *w) { w->show(); } void qt_hide(QWidget *w) { w->show(); } void qt_deleteobject(QObject *o) { delete o; } void qt_deletepixmap(QPixmap *o) { delete o; } +void qt_deletepixmap(QIcon *o) { delete o; } ___bool qt_connect(QWidget *w1, char *sig, QObject *w2, char *slot) { return bool(QObject::connect(w1, sig, w2, slot)); } QObject *qt_find(QObject *parent, char *name) { return parent->findChild(QString(name)); } QObject *qt_receiver(char *name, C_word proc) { return new SimpleReceiver(name, proc); } @@ -167,6 +169,50 @@ qtpixmap qt_pixmap(char *filename) } +qticon qt_icon(char *filename) +{ + QIcon *icon = new QIcon(filename); + if(icon->isNull()) { + delete icon; + return 0; + } + return icon; +} + + +qticon qt_themeicon(char *theme_icon_name) +{ + QIcon *icon = new QIcon(QIcon::fromTheme(theme_icon_name)); + if(icon->isNull()) { + delete icon; + return 0; + } + return icon; +} + + +qtpixmap qt_icontopixmap(QIcon *icon, int w, int h) +{ + QPixmap *px = new QPixmap(icon->pixmap(w, h)); + if(px->isNull()) { + delete px; + return 0; + } + return px; +} + + +qticon qt_pixmaptoicon(QPixmap* px) +{ + QIcon* icon = new QIcon(*px); + if(icon->isNull()) { + delete icon; + return 0; + } + return icon; +} + + int qt_message(char *caption, char *text, QWidget *parent, char *b0, char *b1, char *b2) { return QMessageBox::information(parent, caption, text, b0, b1, b2); diff --git a/prototypes.h b/prototypes.h index 898cde0..d239851 100644 --- a/prototypes.h +++ b/prototypes.h @@ -8,7 +8,12 @@ void qt_hide(qtwidget widget); ___safe ___bool qt_run(___bool once); void qt_deleteobject(qtobject widget); void qt_deletepixmap(qtpixmap widget); +void qt_deleteicon(qticon icon); qtpixmap qt_pixmap(char *filename); +qticon qt_themeicon(char *theme_icon_name); +qticon qt_icon(char *filename); +qtpixmap qt_icontopixmap(qticon icon, int w, int h); +qticon qt_pixmaptoicon(qtpixmap px); ___bool qt_connect(qtwidget w1, char *sig, qtobject w2, char *slot); qtobject qt_find(qtobject parent, char *name); qtobject qt_receiver(char *name, C_word proc); diff --git a/qt-light.scm b/qt-light.scm index 23a7f82..e0caf25 100644 --- a/qt-light.scm +++ b/qt-light.scm @@ -3,15 +3,16 @@ (module qt-light (qt:init qt:widget qt:show qt:hide qt:run - qt:delete qt:message qt:connect qt:find - qt:widget qt:receiver qt:pixmap qt:timer + qt:delete qt:message qt:connect qt:find + qt:widget qt:receiver qt:pixmap qt:icon qt:theme-icon qt:timer + qt:icon->pixmap qt:pixmap->icon qt:property qt:gl qt:update qt:start qt:stop qt:clear qt:add qt:item qt:classname - + qt:get-open-filename qt:get-save-filename qt:get-directory - qt:sound qt:play qt:set-headers + qt:sound qt:play qt:set-headers qt:selection qt:insert qt:shortcut qt:add-action qt:remove-action @@ -43,6 +44,7 @@ (define (% (class 'qt-widget))) (define (% (class 'qt-application))) (define (% (class 'qt-pixmap))) +(define (% (class 'qt-icon))) (define (% (class 'qt-receiver))) (define (% (class 'qt-timer))) (define (% (class 'qt-text-edit))) @@ -54,6 +56,7 @@ (define (qt:pointer->timer p) (and p (% (pointer p)))) (define (qt:pointer->application p) (and p (% (pointer p)))) (define (qt:pointer->pixmap p) (and p (% (pointer p)))) +(define (qt:pointer->icon p) (and p (% (pointer p)))) (define (qt:pointer->receiver p) (and p (% (pointer p)))) (define (qt:pointer->sound p) (and p (% (pointer p)))) (define (qt:pointer->text-edit p) (and p (% (pointer p)))) @@ -64,6 +67,7 @@ (bind-type qtwidget c-pointer qt:->pointer qt:pointer->widget) (bind-type qtapplication c-pointer qt:->pointer qt:pointer->application) (bind-type qtpixmap c-pointer qt:->pointer qt:pointer->pixmap) +(bind-type qticon c-pointer qt:->pointer qt:pointer->icon) (bind-type qtobject c-pointer qt:->pointer qt:pointer->object) (bind-type qttimer c-pointer qt:->pointer qt:pointer->timer) (bind-type qtreceiver c-pointer qt:->pointer qt:pointer->receiver) @@ -114,8 +118,17 @@ extern "C" { (! 'delete (lambda (self) (qt:deletepixmap self))) +(! 'delete + (lambda (self) (qt:deleteicon self))) + (define (qt:delete o) (@ delete o)) +(define qt:theme-icon qt:themeicon) + +(define qt:icon->pixmap qt:icontopixmap) + +(define qt:pixmap->icon qt:pixmaptoicon) + (define qt:message (let ((qt:message qt:message)) (lambda (text #!key (caption "") parent (button1 "OK") (button2 "Cancel") button3)