2008-04-24 14:49:12 +02:00
|
|
|
/***************************************************************************
|
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
CFont.cpp
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2018-02-12 02:53:46 +01:00
|
|
|
(c) 2000-2017 Benoît Minisini <g4mba5@gmail.com>
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
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 2, or (at your option)
|
|
|
|
any later version.
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
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.
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
MA 02110-1301, USA.
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#define __CFONT_CPP
|
|
|
|
|
|
|
|
#include "gambas.h"
|
|
|
|
#include "main.h"
|
|
|
|
|
|
|
|
#include <math.h>
|
[DEVELOPMENT ENVIRONMENT]
* NEW: New code snippet to define a startup Main procedure.
* NEW: In the open project dialog, selecting a project directory now
displays the project contents inside a treeview, like the IDE does.
[GB.QT4]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
* BUG: When showing a form, the initial focus should be correctly set in
all cases now.
[GB.GTK]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
git-svn-id: svn://localhost/gambas/trunk@3024 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2010-06-28 00:04:25 +02:00
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QFontMetrics>
|
|
|
|
#include <QFontDatabase>
|
|
|
|
#include <QTextDocument>
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
#include "CWidget.h"
|
|
|
|
#include "CDraw.h"
|
|
|
|
#include "CFont.h"
|
|
|
|
|
|
|
|
#include "gb.form.font.h"
|
|
|
|
|
|
|
|
#ifdef USE_DPI
|
|
|
|
int CFONT_dpi = 96;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static GB_CLASS CLASS_Font;
|
|
|
|
|
|
|
|
static QStringList _families;
|
|
|
|
static QFontDatabase *_info = 0;
|
|
|
|
|
|
|
|
static void init_font_database()
|
|
|
|
{
|
2012-11-17 17:46:33 +01:00
|
|
|
if (_info)
|
|
|
|
return;
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
_info = new QFontDatabase();
|
|
|
|
_families = _info->families();
|
2008-04-24 14:49:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void exit_font_database()
|
|
|
|
{
|
2012-11-17 17:46:33 +01:00
|
|
|
if (_info)
|
|
|
|
delete _info;
|
2008-04-24 14:49:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CFONT *CFONT_create(const QFont &font, FONT_FUNC func, void *object)
|
|
|
|
{
|
2012-11-17 17:46:33 +01:00
|
|
|
CFONT *_object = (CFONT *)GB.New(CLASS_Font, NULL, NULL);
|
2011-05-16 04:16:22 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
*(THIS->font) = font;
|
|
|
|
THIS->func = func;
|
|
|
|
THIS->object = object;
|
|
|
|
if (object)
|
|
|
|
GB.Ref(object);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
return THIS;
|
2008-04-24 14:49:12 +02:00
|
|
|
}
|
|
|
|
|
2012-08-11 01:57:38 +02:00
|
|
|
void CFONT_set(FONT_FUNC func, void *font, void *object)
|
2008-04-24 14:49:12 +02:00
|
|
|
{
|
2012-08-11 01:57:38 +02:00
|
|
|
if (!font)
|
|
|
|
{
|
|
|
|
QFont f;
|
|
|
|
(*func)(f, object);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
(*func)(*(((CFONT *)font)->font), object);
|
|
|
|
}
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
double CFONT_size_real_to_virtual(double size)
|
|
|
|
{
|
2012-11-17 17:46:33 +01:00
|
|
|
#ifdef USE_DPI
|
|
|
|
return size * (double)QPaintDevice::x11AppDpiY() / CFONT_dpi;
|
|
|
|
#else
|
|
|
|
return size;
|
|
|
|
#endif
|
2008-04-24 14:49:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
double CFONT_size_virtual_to_real(double size)
|
|
|
|
{
|
2012-11-17 17:46:33 +01:00
|
|
|
#ifdef USE_DPI
|
|
|
|
return size * CFONT_dpi / (double)QPaintDevice::x11AppDpiY();
|
|
|
|
#else
|
|
|
|
return size;
|
|
|
|
#endif
|
2008-04-24 14:49:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void set_font_from_string(CFONT *_object, QString &str)
|
|
|
|
{
|
2012-11-17 17:46:33 +01:00
|
|
|
QStringList list;
|
|
|
|
QString name, elt, flag;
|
|
|
|
double size = 0;
|
|
|
|
bool number;
|
|
|
|
QFont f;
|
|
|
|
|
|
|
|
// (!) Remove this test later, it is for backward compatibility
|
|
|
|
|
|
|
|
if (str.length())
|
|
|
|
{
|
|
|
|
list = str.split(",");
|
|
|
|
|
|
|
|
for (QStringList::Iterator it = list.begin(); it != list.end(); ++it )
|
|
|
|
{
|
|
|
|
elt = (*it);
|
2014-03-29 19:21:56 +01:00
|
|
|
elt = elt.trimmed();
|
2012-11-17 17:46:33 +01:00
|
|
|
flag = elt.toUpper();
|
|
|
|
size = elt.toDouble(&number);
|
|
|
|
|
|
|
|
if (flag == "BOLD")
|
2018-03-08 02:35:09 +01:00
|
|
|
{
|
2012-11-17 17:46:33 +01:00
|
|
|
f.setBold(true);
|
2018-05-12 19:38:38 +02:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
|
2018-03-08 02:35:09 +01:00
|
|
|
f.setStyleName("Bold");
|
2018-05-12 19:38:38 +02:00
|
|
|
#endif
|
2018-03-08 02:35:09 +01:00
|
|
|
}
|
2012-11-17 17:46:33 +01:00
|
|
|
else if (flag == "ITALIC")
|
|
|
|
f.setItalic(true);
|
|
|
|
else if (flag == "UNDERLINE")
|
|
|
|
f.setUnderline(true);
|
|
|
|
else if (flag == "STRIKEOUT")
|
|
|
|
f.setStrikeOut(true);
|
|
|
|
else if (flag[0] == '+' || flag[0] == '-' || flag[0] == '0')
|
|
|
|
{
|
|
|
|
//f.setPointSizeFloat((int)(powf(qApp->font().pointSizeFloat(), 1.0 + ((int)size / 10.0)) + 0.5));
|
|
|
|
f.setPointSizeF(GRADE_TO_SIZE(size, qApp->font().pointSizeF()));
|
|
|
|
}
|
|
|
|
else if (number && size > 0.0)
|
|
|
|
f.setPointSizeF(SIZE_VIRTUAL_TO_REAL(size));
|
|
|
|
else if (elt.length())
|
|
|
|
{
|
2009-07-03 22:15:26 +02:00
|
|
|
f.setBold(false);
|
|
|
|
f.setItalic(false);
|
|
|
|
f.setUnderline(false);
|
|
|
|
f.setStrikeOut(false);
|
|
|
|
f.setFamily(elt);
|
2018-05-12 19:38:38 +02:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
|
|
|
|
f.setStyleName("");
|
|
|
|
#endif
|
2012-11-17 17:46:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
*(THIS->font) = f;
|
2008-04-24 14:49:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
BEGIN_METHOD_VOID(Font_init)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
CLASS_Font = GB.FindClass("Font");
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
BEGIN_METHOD_VOID(Font_exit)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
exit_font_database();
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
BEGIN_METHOD(Font_new, GB_STRING font)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
QString s;
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
THIS->font = new QFont;
|
|
|
|
THIS->func = 0;
|
|
|
|
THIS->object = 0;
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
if (!MISSING(font))
|
|
|
|
QString s = QSTRING_ARG(font);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
set_font_from_string(THIS, s);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
BEGIN_METHOD_VOID(Font_free)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
if (THIS->object)
|
|
|
|
GB.Unref(POINTER(&THIS->object));
|
|
|
|
delete THIS->font;
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
|
|
|
static void CFONT_manage(int prop, CFONT *_object, void *_param)
|
|
|
|
{
|
2012-11-17 17:46:33 +01:00
|
|
|
bool noResize = false;
|
|
|
|
QFont *f = THIS->font;
|
2012-11-18 17:59:46 +01:00
|
|
|
double size;
|
2012-11-17 17:46:33 +01:00
|
|
|
|
|
|
|
noResize = true; //((long)THIS->control == CFONT_DRAW && !DRAW_must_resize_font());
|
|
|
|
|
|
|
|
if (READ_PROPERTY)
|
|
|
|
{
|
|
|
|
switch(prop)
|
|
|
|
{
|
|
|
|
case CFONT::Name: GB.ReturnNewZeroString(f->family().toUtf8()); break;
|
|
|
|
case CFONT::Size:
|
|
|
|
if (noResize)
|
|
|
|
GB.ReturnFloat(f->pointSizeF());
|
|
|
|
else
|
|
|
|
GB.ReturnFloat(SIZE_REAL_TO_VIRTUAL(f->pointSizeF()));
|
|
|
|
break;
|
|
|
|
case CFONT::Grade:
|
|
|
|
GB.ReturnInteger(SIZE_TO_GRADE(f->pointSizeF(), qApp->font().pointSizeF()));
|
|
|
|
break;
|
|
|
|
case CFONT::Bold: GB.ReturnBoolean(f->bold()); break;
|
|
|
|
case CFONT::Italic: GB.ReturnBoolean(f->italic()); break;
|
|
|
|
case CFONT::Underline: GB.ReturnBoolean(f->underline()); break;
|
|
|
|
case CFONT::Strikeout: GB.ReturnBoolean(f->strikeOut()); break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (prop)
|
|
|
|
{
|
|
|
|
case CFONT::Name: f->setFamily(GB.ToZeroString(PROP(GB_STRING))); break;
|
|
|
|
case CFONT::Size:
|
|
|
|
if (noResize)
|
2012-11-18 17:59:46 +01:00
|
|
|
size = VPROP(GB_FLOAT);
|
2012-11-17 17:46:33 +01:00
|
|
|
else
|
2012-11-18 17:59:46 +01:00
|
|
|
size = SIZE_VIRTUAL_TO_REAL(VPROP(GB_FLOAT));
|
|
|
|
|
|
|
|
if (size <= 0)
|
|
|
|
{
|
|
|
|
GB.Error("Bad font size");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
f->setPointSizeF(size);
|
2012-11-17 17:46:33 +01:00
|
|
|
break;
|
|
|
|
case CFONT::Grade:
|
|
|
|
{
|
|
|
|
int g = VPROP(GB_INTEGER);
|
2017-09-29 21:03:35 +02:00
|
|
|
if (g < FONT_GRADE_MIN)
|
|
|
|
g = FONT_GRADE_MIN;
|
|
|
|
else if (g > FONT_GRADE_MAX)
|
|
|
|
g = FONT_GRADE_MAX;
|
2012-11-17 17:46:33 +01:00
|
|
|
f->setPointSizeF(GRADE_TO_SIZE(g, qApp->font().pointSizeF()));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CFONT::Bold: f->setBold(VPROP(GB_BOOLEAN)); break;
|
|
|
|
case CFONT::Italic: f->setItalic(VPROP(GB_BOOLEAN)); break;
|
|
|
|
case CFONT::Underline: f->setUnderline(VPROP(GB_BOOLEAN)); break;
|
|
|
|
case CFONT::Strikeout: f->setStrikeOut(VPROP(GB_BOOLEAN)); break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (THIS->func)
|
|
|
|
(*(THIS->func))(*f, THIS->object);
|
|
|
|
else if (THIS->object)
|
|
|
|
{
|
2014-04-05 02:28:41 +02:00
|
|
|
GB_VALUE value;
|
|
|
|
value.type = GB_T_OBJECT;
|
|
|
|
value._object.value = THIS;
|
|
|
|
GB.SetProperty(THIS->object, "Font", &value);
|
2012-11-17 17:46:33 +01:00
|
|
|
}
|
[DEVELOPMENT ENVIRONMENT]
* NEW: Use the new TextEditor instead of the old Editor control.
Consequently, the 'gb.qt4.ext' component is not needed by the IDE
anymore.
* NEW: Option dialog: Put the fonts options in their own panel.
* NEW: Farm client: Add new categories.
[GB.FORM]
* NEW: Fix some breeze icons.
[GB.FORM.EDITOR]
* NEW: TextEditor: Development continues...
[GB.GTK]
* NEW: Font.Modified is a new property that returns if the font has been
modified, i.e. if one of its properties has been set. This property can
be freely reset. That way, it allows to implement the concept of "default
font".
* BUG: Remove a GTK+ bug workaround in the Control.Refresh() method. Maybe
it is useless now.
[GB.GTK3]
* NEW: Font.Modified is a new property that returns if the font has been
modified, i.e. if one of its properties has been set. This property can
be freely reset. That way, it allows to implement the concept of "default
font".
* BUG: Remove a GTK+ bug workaround in the Control.Refresh() method. Maybe
it is useless now.
[GB.GUI.BASE]
* BUG: GridView: Use the new Font.Modified property so that the initial
font of a cell is always the font of the GridView, even if it changed
after the cell has been filled.
[GB.QT4]
* NEW: Font.Modified is a new property that returns if the font has been
modified, i.e. if one of its properties has been set. This property can
be freely reset. That way, it allows to implement the concept of "default
font".
[GB.QT5]
* NEW: Font.Modified is a new property that returns if the font has been
modified, i.e. if one of its properties has been set. This property can
be freely reset. That way, it allows to implement the concept of "default
font".
git-svn-id: svn://localhost/gambas/trunk@7089 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2015-05-20 00:21:22 +02:00
|
|
|
|
|
|
|
THIS->modified = TRUE;
|
2012-11-17 17:46:33 +01:00
|
|
|
}
|
2008-04-24 14:49:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
BEGIN_PROPERTY(Font_Name)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
CFONT_manage(CFONT::Name, OBJECT(CFONT), _param);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
BEGIN_PROPERTY(Font_Size)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
CFONT_manage(CFONT::Size, OBJECT(CFONT), _param);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
BEGIN_PROPERTY(Font_Grade)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
CFONT_manage(CFONT::Grade, OBJECT(CFONT), _param);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
BEGIN_PROPERTY(Font_Bold)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
CFONT_manage(CFONT::Bold, OBJECT(CFONT), _param);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
BEGIN_PROPERTY(Font_Italic)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
CFONT_manage(CFONT::Italic, OBJECT(CFONT), _param);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
BEGIN_PROPERTY(Font_Underline)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
CFONT_manage(CFONT::Underline, OBJECT(CFONT), _param);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
BEGIN_PROPERTY(Font_Strikeout)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
CFONT_manage(CFONT::Strikeout, OBJECT(CFONT), _param);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
|
|
|
static void add(QString &str, const QString& data)
|
|
|
|
{
|
2012-11-17 17:46:33 +01:00
|
|
|
if (str.length())
|
|
|
|
str += ',';
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
str += data;
|
2008-04-24 14:49:12 +02:00
|
|
|
}
|
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
BEGIN_METHOD_VOID(Font_ToString)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
QFont *f = THIS->font;
|
|
|
|
QString str;
|
|
|
|
double size;
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
//str = qfont.family().left(1).upper() + qfont.family().mid(1).lower() + " " + QString::number(qfont.pointSize());
|
|
|
|
add(str, f->family());
|
|
|
|
size = SIZE_REAL_TO_VIRTUAL(f->pointSizeF());
|
|
|
|
size = (double)((int)(size * 10 + 0.5)) / 10;
|
|
|
|
add(str, QString::number(size));
|
|
|
|
if (f->bold())
|
|
|
|
add(str, "Bold");
|
|
|
|
if (f->italic())
|
|
|
|
add(str, "Italic");
|
|
|
|
if (f->underline())
|
|
|
|
add(str, "Underline");
|
|
|
|
if (f->strikeOut())
|
|
|
|
add(str, "StrikeOut");
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2015-05-08 08:33:25 +02:00
|
|
|
RETURN_NEW_STRING(str);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
BEGIN_METHOD(Font_get, GB_STRING str)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
CFONT *font;
|
|
|
|
QString s = QSTRING_ARG(str);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
//qDebug(">> Font_get: %s", s.latin1());
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
font = (CFONT *)GB.New(CLASS_Font, NULL, NULL);
|
|
|
|
set_font_from_string(font, s);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
GB.ReturnObject(font);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
//qDebug("<< Font_get");
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-02-25 02:35:55 +01:00
|
|
|
BEGIN_METHOD_VOID(Font_Copy)
|
|
|
|
|
|
|
|
GB.ReturnObject(CFONT_create(*THIS->font));
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2008-04-24 14:49:12 +02:00
|
|
|
|
[DEVELOPMENT ENVIRONMENT]
* NEW: New code snippet to define a startup Main procedure.
* NEW: In the open project dialog, selecting a project directory now
displays the project contents inside a treeview, like the IDE does.
[GB.QT4]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
* BUG: When showing a form, the initial focus should be correctly set in
all cases now.
[GB.GTK]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
git-svn-id: svn://localhost/gambas/trunk@3024 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2010-06-28 00:04:25 +02:00
|
|
|
BEGIN_PROPERTY(Font_Ascent)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
QFontMetrics fm(*(THIS->font));
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
GB.ReturnInteger(fm.ascent());
|
2008-04-24 14:49:12 +02:00
|
|
|
|
[DEVELOPMENT ENVIRONMENT]
* NEW: New code snippet to define a startup Main procedure.
* NEW: In the open project dialog, selecting a project directory now
displays the project contents inside a treeview, like the IDE does.
[GB.QT4]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
* BUG: When showing a form, the initial focus should be correctly set in
all cases now.
[GB.GTK]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
git-svn-id: svn://localhost/gambas/trunk@3024 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2010-06-28 00:04:25 +02:00
|
|
|
END_PROPERTY
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
|
[DEVELOPMENT ENVIRONMENT]
* NEW: New code snippet to define a startup Main procedure.
* NEW: In the open project dialog, selecting a project directory now
displays the project contents inside a treeview, like the IDE does.
[GB.QT4]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
* BUG: When showing a form, the initial focus should be correctly set in
all cases now.
[GB.GTK]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
git-svn-id: svn://localhost/gambas/trunk@3024 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2010-06-28 00:04:25 +02:00
|
|
|
BEGIN_PROPERTY(Font_Descent)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
QFontMetrics fm(*(THIS->font));
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
GB.ReturnInteger(fm.descent());
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
[DEVELOPMENT ENVIRONMENT]
* NEW: New code snippet to define a startup Main procedure.
* NEW: In the open project dialog, selecting a project directory now
displays the project contents inside a treeview, like the IDE does.
[GB.QT4]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
* BUG: When showing a form, the initial focus should be correctly set in
all cases now.
[GB.GTK]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
git-svn-id: svn://localhost/gambas/trunk@3024 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2010-06-28 00:04:25 +02:00
|
|
|
BEGIN_PROPERTY(Font_Height)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
QFontMetrics fm(*(THIS->font));
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
GB.ReturnInteger(fm.height() + fm.leading());
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
[DEVELOPMENT ENVIRONMENT]
* NEW: New code snippet to define a startup Main procedure.
* NEW: In the open project dialog, selecting a project directory now
displays the project contents inside a treeview, like the IDE does.
[GB.QT4]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
* BUG: When showing a form, the initial focus should be correctly set in
all cases now.
[GB.GTK]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
git-svn-id: svn://localhost/gambas/trunk@3024 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2010-06-28 00:04:25 +02:00
|
|
|
BEGIN_METHOD(Font_TextHeight, GB_STRING text)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
QFontMetrics fm(*(THIS->font));
|
|
|
|
QString s;
|
|
|
|
int nl;
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
if (!MISSING(text))
|
|
|
|
s = QSTRING_ARG(text);
|
|
|
|
nl = s.count('\n');
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
GB.ReturnInteger(fm.height() * (1 + nl) + fm.leading() * nl);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
[DEVELOPMENT ENVIRONMENT]
* NEW: New code snippet to define a startup Main procedure.
* NEW: In the open project dialog, selecting a project directory now
displays the project contents inside a treeview, like the IDE does.
[GB.QT4]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
* BUG: When showing a form, the initial focus should be correctly set in
all cases now.
[GB.GTK]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
git-svn-id: svn://localhost/gambas/trunk@3024 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2010-06-28 00:04:25 +02:00
|
|
|
BEGIN_METHOD(Font_TextWidth, GB_STRING text)
|
|
|
|
|
2017-08-26 17:45:04 +02:00
|
|
|
QFontMetricsF fm(*(THIS->font));
|
2012-11-17 17:46:33 +01:00
|
|
|
QStringList sl;
|
2017-08-26 17:45:04 +02:00
|
|
|
qreal w, width = 0;
|
2012-11-17 17:46:33 +01:00
|
|
|
int i;
|
[DEVELOPMENT ENVIRONMENT]
* NEW: New code snippet to define a startup Main procedure.
* NEW: In the open project dialog, selecting a project directory now
displays the project contents inside a treeview, like the IDE does.
[GB.QT4]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
* BUG: When showing a form, the initial focus should be correctly set in
all cases now.
[GB.GTK]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
git-svn-id: svn://localhost/gambas/trunk@3024 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2010-06-28 00:04:25 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
QString str = QSTRING_ARG(text);
|
[DEVELOPMENT ENVIRONMENT]
* NEW: New code snippet to define a startup Main procedure.
* NEW: In the open project dialog, selecting a project directory now
displays the project contents inside a treeview, like the IDE does.
[GB.QT4]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
* BUG: When showing a form, the initial focus should be correctly set in
all cases now.
[GB.GTK]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
git-svn-id: svn://localhost/gambas/trunk@3024 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2010-06-28 00:04:25 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
sl = str.split('\n');
|
[DEVELOPMENT ENVIRONMENT]
* NEW: New code snippet to define a startup Main procedure.
* NEW: In the open project dialog, selecting a project directory now
displays the project contents inside a treeview, like the IDE does.
[GB.QT4]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
* BUG: When showing a form, the initial focus should be correctly set in
all cases now.
[GB.GTK]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
git-svn-id: svn://localhost/gambas/trunk@3024 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2010-06-28 00:04:25 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
for (i = 0; i < (int)sl.count(); i++)
|
|
|
|
{
|
|
|
|
w = fm.width(sl[i]);
|
|
|
|
if (w > width) width = w;
|
|
|
|
}
|
[DEVELOPMENT ENVIRONMENT]
* NEW: New code snippet to define a startup Main procedure.
* NEW: In the open project dialog, selecting a project directory now
displays the project contents inside a treeview, like the IDE does.
[GB.QT4]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
* BUG: When showing a form, the initial focus should be correctly set in
all cases now.
[GB.GTK]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
git-svn-id: svn://localhost/gambas/trunk@3024 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2010-06-28 00:04:25 +02:00
|
|
|
|
2017-08-26 17:45:04 +02:00
|
|
|
GB.ReturnInteger((int)(width + 0.5));
|
[DEVELOPMENT ENVIRONMENT]
* NEW: New code snippet to define a startup Main procedure.
* NEW: In the open project dialog, selecting a project directory now
displays the project contents inside a treeview, like the IDE does.
[GB.QT4]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
* BUG: When showing a form, the initial focus should be correctly set in
all cases now.
[GB.GTK]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
git-svn-id: svn://localhost/gambas/trunk@3024 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2010-06-28 00:04:25 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
|
|
|
static void rich_text_size(CFONT *_object, char *text, int len, int sw, int *w, int *h)
|
|
|
|
{
|
|
|
|
QTextDocument rt;
|
|
|
|
|
2019-07-10 04:19:02 +02:00
|
|
|
DRAW_init_rich_text(&rt, *(THIS->font));
|
|
|
|
|
[DEVELOPMENT ENVIRONMENT]
* NEW: New code snippet to define a startup Main procedure.
* NEW: In the open project dialog, selecting a project directory now
displays the project contents inside a treeview, like the IDE does.
[GB.QT4]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
* BUG: When showing a form, the initial focus should be correctly set in
all cases now.
[GB.GTK]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
git-svn-id: svn://localhost/gambas/trunk@3024 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2010-06-28 00:04:25 +02:00
|
|
|
rt.setHtml(QString::fromUtf8((const char *)text, len));
|
2013-05-04 16:17:15 +02:00
|
|
|
|
[DEVELOPMENT ENVIRONMENT]
* NEW: New code snippet to define a startup Main procedure.
* NEW: In the open project dialog, selecting a project directory now
displays the project contents inside a treeview, like the IDE does.
[GB.QT4]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
* BUG: When showing a form, the initial focus should be correctly set in
all cases now.
[GB.GTK]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
git-svn-id: svn://localhost/gambas/trunk@3024 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2010-06-28 00:04:25 +02:00
|
|
|
if (sw > 0)
|
|
|
|
rt.setTextWidth(sw);
|
|
|
|
|
|
|
|
if (w) *w = rt.idealWidth();
|
|
|
|
if (h) *h = rt.size().height();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_METHOD(Font_RichTextWidth, GB_STRING text)
|
|
|
|
|
|
|
|
int w;
|
|
|
|
|
|
|
|
rich_text_size(THIS, STRING(text), LENGTH(text), -1, &w, NULL);
|
|
|
|
GB.ReturnInteger(w);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_METHOD(Font_RichTextHeight, GB_STRING text; GB_INTEGER width)
|
|
|
|
|
|
|
|
int h;
|
|
|
|
|
|
|
|
rich_text_size(THIS, STRING(text), LENGTH(text), VARGOPT(width, -1), NULL, &h);
|
|
|
|
GB.ReturnInteger(h);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2008-04-24 14:49:12 +02:00
|
|
|
#ifdef USE_DPI
|
2012-11-17 17:46:33 +01:00
|
|
|
BEGIN_PROPERTY(Font_Resolution)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
if (READ_PROPERTY)
|
|
|
|
GB.ReturnInteger(CFONT_dpi);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CFONT_dpi = VPROP(GB_INTEGER);
|
|
|
|
if (CFONT_dpi < 1)
|
|
|
|
CFONT_dpi = 96;
|
|
|
|
}
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
#endif
|
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
BEGIN_METHOD_VOID(Fonts_next)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
QString s;
|
|
|
|
int *index = (int *)GB.GetEnum();
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
if (*index == 0)
|
|
|
|
init_font_database();
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
if (*index >= _families.count())
|
|
|
|
GB.StopEnum();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s = _families[*index];
|
2015-05-08 08:33:25 +02:00
|
|
|
RETURN_NEW_STRING(s);
|
2012-11-17 17:46:33 +01:00
|
|
|
(*index)++;
|
|
|
|
}
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2012-09-17 13:13:32 +02:00
|
|
|
BEGIN_METHOD(Fonts_Exist, GB_STRING family)
|
|
|
|
|
|
|
|
int i;
|
|
|
|
char *family = GB.ToZeroString(ARG(family));
|
|
|
|
|
|
|
|
init_font_database();
|
|
|
|
|
|
|
|
for (i = 0; i < _families.count(); i++)
|
|
|
|
{
|
|
|
|
if (_families[i] == family)
|
|
|
|
{
|
|
|
|
GB.ReturnBoolean(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GB.ReturnBoolean(false);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
BEGIN_PROPERTY(Fonts_Count)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
init_font_database();
|
|
|
|
GB.ReturnInteger(_families.count());
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
BEGIN_PROPERTY(Font_Fixed)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
init_font_database();
|
|
|
|
GB.ReturnBoolean(_info->isFixedPitch(THIS->font->family()));
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
BEGIN_PROPERTY(Font_Scalable)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
init_font_database();
|
|
|
|
GB.ReturnBoolean(_info->isSmoothlyScalable(THIS->font->family()));
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
BEGIN_PROPERTY(Font_Styles)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
QStringList styles;
|
|
|
|
GB_ARRAY array;
|
|
|
|
int i;
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
init_font_database();
|
|
|
|
styles = _info->styles(THIS->font->family());
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
GB.Array.New(&array, GB_T_STRING, styles.count());
|
|
|
|
for (i = 0; i < styles.count(); i++)
|
2015-05-08 08:33:25 +02:00
|
|
|
*(char **)GB.Array.Get(array, i) = NEW_STRING(styles[i]);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
GB.ReturnObject(array);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
[DEVELOPMENT ENVIRONMENT]
* NEW: Use the new TextEditor instead of the old Editor control.
Consequently, the 'gb.qt4.ext' component is not needed by the IDE
anymore.
* NEW: Option dialog: Put the fonts options in their own panel.
* NEW: Farm client: Add new categories.
[GB.FORM]
* NEW: Fix some breeze icons.
[GB.FORM.EDITOR]
* NEW: TextEditor: Development continues...
[GB.GTK]
* NEW: Font.Modified is a new property that returns if the font has been
modified, i.e. if one of its properties has been set. This property can
be freely reset. That way, it allows to implement the concept of "default
font".
* BUG: Remove a GTK+ bug workaround in the Control.Refresh() method. Maybe
it is useless now.
[GB.GTK3]
* NEW: Font.Modified is a new property that returns if the font has been
modified, i.e. if one of its properties has been set. This property can
be freely reset. That way, it allows to implement the concept of "default
font".
* BUG: Remove a GTK+ bug workaround in the Control.Refresh() method. Maybe
it is useless now.
[GB.GUI.BASE]
* BUG: GridView: Use the new Font.Modified property so that the initial
font of a cell is always the font of the GridView, even if it changed
after the cell has been filled.
[GB.QT4]
* NEW: Font.Modified is a new property that returns if the font has been
modified, i.e. if one of its properties has been set. This property can
be freely reset. That way, it allows to implement the concept of "default
font".
[GB.QT5]
* NEW: Font.Modified is a new property that returns if the font has been
modified, i.e. if one of its properties has been set. This property can
be freely reset. That way, it allows to implement the concept of "default
font".
git-svn-id: svn://localhost/gambas/trunk@7089 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2015-05-20 00:21:22 +02:00
|
|
|
BEGIN_PROPERTY(Font_Modified)
|
|
|
|
|
|
|
|
if (READ_PROPERTY)
|
|
|
|
GB.ReturnBoolean(THIS->modified);
|
|
|
|
else
|
|
|
|
THIS->modified = VPROP(GB_BOOLEAN);
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2008-04-24 14:49:12 +02:00
|
|
|
GB_DESC CFontsDesc[] =
|
|
|
|
{
|
[DEVELOPMENT ENVIRONMENT]
* NEW: Use the new TextEditor instead of the old Editor control.
Consequently, the 'gb.qt4.ext' component is not needed by the IDE
anymore.
* NEW: Option dialog: Put the fonts options in their own panel.
* NEW: Farm client: Add new categories.
[GB.FORM]
* NEW: Fix some breeze icons.
[GB.FORM.EDITOR]
* NEW: TextEditor: Development continues...
[GB.GTK]
* NEW: Font.Modified is a new property that returns if the font has been
modified, i.e. if one of its properties has been set. This property can
be freely reset. That way, it allows to implement the concept of "default
font".
* BUG: Remove a GTK+ bug workaround in the Control.Refresh() method. Maybe
it is useless now.
[GB.GTK3]
* NEW: Font.Modified is a new property that returns if the font has been
modified, i.e. if one of its properties has been set. This property can
be freely reset. That way, it allows to implement the concept of "default
font".
* BUG: Remove a GTK+ bug workaround in the Control.Refresh() method. Maybe
it is useless now.
[GB.GUI.BASE]
* BUG: GridView: Use the new Font.Modified property so that the initial
font of a cell is always the font of the GridView, even if it changed
after the cell has been filled.
[GB.QT4]
* NEW: Font.Modified is a new property that returns if the font has been
modified, i.e. if one of its properties has been set. This property can
be freely reset. That way, it allows to implement the concept of "default
font".
[GB.QT5]
* NEW: Font.Modified is a new property that returns if the font has been
modified, i.e. if one of its properties has been set. This property can
be freely reset. That way, it allows to implement the concept of "default
font".
git-svn-id: svn://localhost/gambas/trunk@7089 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2015-05-20 00:21:22 +02:00
|
|
|
GB_DECLARE_STATIC("Fonts"),
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
GB_STATIC_METHOD("Exist", "b", Fonts_Exist, "(Family)s"),
|
|
|
|
GB_STATIC_METHOD("_next", "s", Fonts_next, NULL),
|
|
|
|
GB_STATIC_PROPERTY_READ("Count", "i", Fonts_Count),
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
GB_END_DECLARE
|
2008-04-24 14:49:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
GB_DESC CFontDesc[] =
|
|
|
|
{
|
2012-11-17 17:46:33 +01:00
|
|
|
GB_DECLARE("Font", sizeof(CFONT)),
|
|
|
|
//GB_NOT_CREATABLE(),
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
GB_STATIC_METHOD("_init", NULL, Font_init, NULL),
|
|
|
|
GB_STATIC_METHOD("_exit", NULL, Font_exit, NULL),
|
|
|
|
GB_METHOD("_new", NULL, Font_new, "[(Font)s]"),
|
|
|
|
GB_METHOD("_free", NULL, Font_free, NULL),
|
|
|
|
GB_METHOD("Copy", "Font", Font_Copy, NULL),
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
GB_PROPERTY("Name", "s", Font_Name),
|
|
|
|
GB_PROPERTY("Size", "f", Font_Size),
|
|
|
|
GB_PROPERTY("Grade", "i", Font_Grade),
|
|
|
|
GB_PROPERTY("Bold", "b", Font_Bold),
|
|
|
|
GB_PROPERTY("Italic", "b", Font_Italic),
|
|
|
|
GB_PROPERTY("Underline", "b", Font_Underline),
|
|
|
|
GB_PROPERTY("Strikeout", "b", Font_Strikeout),
|
[DEVELOPMENT ENVIRONMENT]
* NEW: Use the new TextEditor instead of the old Editor control.
Consequently, the 'gb.qt4.ext' component is not needed by the IDE
anymore.
* NEW: Option dialog: Put the fonts options in their own panel.
* NEW: Farm client: Add new categories.
[GB.FORM]
* NEW: Fix some breeze icons.
[GB.FORM.EDITOR]
* NEW: TextEditor: Development continues...
[GB.GTK]
* NEW: Font.Modified is a new property that returns if the font has been
modified, i.e. if one of its properties has been set. This property can
be freely reset. That way, it allows to implement the concept of "default
font".
* BUG: Remove a GTK+ bug workaround in the Control.Refresh() method. Maybe
it is useless now.
[GB.GTK3]
* NEW: Font.Modified is a new property that returns if the font has been
modified, i.e. if one of its properties has been set. This property can
be freely reset. That way, it allows to implement the concept of "default
font".
* BUG: Remove a GTK+ bug workaround in the Control.Refresh() method. Maybe
it is useless now.
[GB.GUI.BASE]
* BUG: GridView: Use the new Font.Modified property so that the initial
font of a cell is always the font of the GridView, even if it changed
after the cell has been filled.
[GB.QT4]
* NEW: Font.Modified is a new property that returns if the font has been
modified, i.e. if one of its properties has been set. This property can
be freely reset. That way, it allows to implement the concept of "default
font".
[GB.QT5]
* NEW: Font.Modified is a new property that returns if the font has been
modified, i.e. if one of its properties has been set. This property can
be freely reset. That way, it allows to implement the concept of "default
font".
git-svn-id: svn://localhost/gambas/trunk@7089 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2015-05-20 00:21:22 +02:00
|
|
|
GB_PROPERTY("Modified", "b", Font_Modified),
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
GB_METHOD("ToString", "s", Font_ToString, NULL),
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
GB_METHOD("TextWidth", "i", Font_TextWidth, "(Text)s"),
|
|
|
|
GB_METHOD("TextHeight", "i", Font_TextHeight, "(Text)s"),
|
[DEVELOPMENT ENVIRONMENT]
* NEW: New code snippet to define a startup Main procedure.
* NEW: In the open project dialog, selecting a project directory now
displays the project contents inside a treeview, like the IDE does.
[GB.QT4]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
* BUG: When showing a form, the initial focus should be correctly set in
all cases now.
[GB.GTK]
* NEW: Some changes in the Font class: Font.Height is now a property that
returns the font height, and Font.Width has been removed. Now, to compute
the size of a text fragment, you must use Font.TextWidth() and
Font.TextHeight(). Moreover, two new methods, Font.RichTextWidth() and
Font.RichTextHeight() allow to compute the size of a rich text fragment.
git-svn-id: svn://localhost/gambas/trunk@3024 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2010-06-28 00:04:25 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
GB_METHOD("RichTextWidth", "i", Font_RichTextWidth, "(Text)s"),
|
|
|
|
GB_METHOD("RichTextHeight", "i", Font_RichTextHeight, "(Text)s[(Width)i]"),
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
GB_STATIC_METHOD("_get", "Font", Font_get, "(Font)s"),
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
#ifdef USE_DPI
|
|
|
|
GB_STATIC_PROPERTY("Resolution", "i", Font_Resolution),
|
|
|
|
#endif
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
GB_PROPERTY_READ("Ascent", "i", Font_Ascent),
|
|
|
|
GB_PROPERTY_READ("Descent", "i", Font_Descent),
|
|
|
|
GB_PROPERTY_READ("Height", "i", Font_Height),
|
2015-07-31 05:00:41 +02:00
|
|
|
GB_PROPERTY_READ("H", "i", Font_Height),
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
GB_PROPERTY_READ("Fixed", "b", Font_Fixed),
|
|
|
|
GB_PROPERTY_READ("Scalable", "b", Font_Scalable),
|
|
|
|
GB_PROPERTY_READ("Styles", "String[]", Font_Styles),
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2012-11-17 17:46:33 +01:00
|
|
|
GB_END_DECLARE
|
2008-04-24 14:49:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|