Add QIcon object and QIcon<->QPixmap conversion
This commit is contained in:
parent
a8f324ca68
commit
e7e46e31f3
46
main.cpp
46
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<QObject *>(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);
|
||||
|
|
|
@ -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);
|
||||
|
|
21
qt-light.scm
21
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> qt:classname
|
||||
<qt-object> <qt-widget> <qt-pixmap> <qt-application>
|
||||
<qt-object> <qt-widget> <qt-pixmap> <qt-icon> <qt-application>
|
||||
<qt-receiver> <qt-timer> <qt-sound> <qt-text-edit>
|
||||
<qt-action>
|
||||
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 <qt-widget> (% <qt-object> (class 'qt-widget)))
|
||||
(define <qt-application> (% <qt-object> (class 'qt-application)))
|
||||
(define <qt-pixmap> (% <qt> (class 'qt-pixmap)))
|
||||
(define <qt-icon> (% <qt> (class 'qt-icon)))
|
||||
(define <qt-receiver> (% <qt-object> (class 'qt-receiver)))
|
||||
(define <qt-timer> (% <qt-object> (class 'qt-timer)))
|
||||
(define <qt-text-edit> (% <qt-widget> (class 'qt-text-edit)))
|
||||
|
@ -54,6 +56,7 @@
|
|||
(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->pixmap p) (and p (% <qt-pixmap> (pointer p))))
|
||||
(define (qt:pointer->icon p) (and p (% <qt-icon> (pointer p))))
|
||||
(define (qt:pointer->receiver p) (and p (% <qt-receiver> (pointer p))))
|
||||
(define (qt:pointer->sound p) (and p (% <qt-sound> (pointer p))))
|
||||
(define (qt:pointer->text-edit p) (and p (% <qt-text-edit> (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" {
|
|||
(! <qt-pixmap> 'delete
|
||||
(lambda (self) (qt:deletepixmap self)))
|
||||
|
||||
(! <qt-icon> '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)
|
||||
|
|
Ŝarĝante…
Reference in New Issue