📄 cpicturebox.cpp
字号:
/*************************************************************************** CPictureBox.cpp The PictureBox class (c) 2000-2003 Beno顃 Minisini <gambas@users.sourceforge.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.***************************************************************************/#define __CPICTUREBOX_CPP#include <qapplication.h>#include <qlabel.h>#include <qpixmap.h>#include <qframe.h>#include "gambas.h"#include "CPicture.h"#include "CPictureBox.h"/*#define DEBUG_CBUTTON*/MyLabel::MyLabel(QWidget *parent): QLabel(parent){}MyLabel::~MyLabel(){}void MyLabel::resizeEvent( QResizeEvent* e ){ QFrame::resizeEvent(e);}BEGIN_METHOD(CPICTUREBOX_new, GB_OBJECT parent) MyLabel *wid = new MyLabel(CONTAINER(VARG(parent))); THIS->picture = NULL; CWIDGET_new(wid, (void *)_object, "Image"); wid->setAlignment(Qt::AlignLeft | Qt::AlignTop); wid->show();END_METHODBEGIN_METHOD_VOID(CPICTUREBOX_free) CLEAR_PICTURE(&(THIS->picture)); CALL_METHOD_VOID(CWIDGET_delete);END_METHODBEGIN_PROPERTY(CPICTUREBOX_picture) if (READ_PROPERTY) GB.ReturnObject(THIS->picture); else { SET_PICTURE(WIDGET->setPixmap, WIDGET->setPicture, &(THIS->picture), PROP(GB_OBJECT)); /* if (wid->pixmap() != 0) if (!wid->hasScaledContents()) wid->resize(wid->pixmap()->width(), wid->pixmap()->height()); */ }END_PROPERTYBEGIN_PROPERTY(CPICTUREBOX_stretch) if (READ_PROPERTY) GB.ReturnBoolean(WIDGET->hasScaledContents()); else WIDGET->setScaledContents(VPROP(GB_BOOLEAN));END_PROPERTY/*BEGIN_PROPERTY(CPICTUREBOX_border) if (READ_PROPERTY) GB.ReturnBoolean(QLABEL(_object)->frameStyle() != QFrame::NoFrame); else { if (PROPERTY(char) != 0) QLABEL(_object)->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); else QLABEL(_object)->setFrameStyle(QFrame::NoFrame); }END_PROPERTY*/BEGIN_PROPERTY(CPICTUREBOX_alignment) if (READ_PROPERTY) GB.ReturnInteger(WIDGET->alignment() & ALIGN_MASK); else WIDGET->setAlignment((VPROP(GB_INTEGER) & ALIGN_MASK) | Qt::WordBreak);END_PROPERTY/*BEGIN_PROPERTY(CPICTUREBOX_transparent) bool trans; if (READ_PROPERTY) GB.ReturnBoolean(THIS->transparent); else { trans = PROPERTY(GB_BOOLEAN); if (THIS->transparent == trans) return; THIS->transparent = trans; }END_PROPERTY*/GB_DESC CPictureBoxDesc[] ={ GB_DECLARE("PictureBox", sizeof(CPICTUREBOX)), GB_INHERITS("Control"), GB_METHOD("_new", NULL, CPICTUREBOX_new, "(Parent)Container;"), GB_METHOD("_free", NULL, CPICTUREBOX_free, NULL), GB_PROPERTY("Picture", "Picture", CPICTUREBOX_picture), GB_PROPERTY("Stretch", "b", CPICTUREBOX_stretch), //GB_PROPERTY("Transparent", "b", CPICTUREBOX_transparent), GB_PROPERTY("Border", "i<Border>", CWIDGET_border_full), GB_PROPERTY("Alignment", "i<Align>", CPICTUREBOX_alignment), GB_CONSTANT("_Properties", "s", CPICTUREBOX_PROPERTIES), GB_END_DECLARE};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -