Files
lmms/include/gui_templates.h
Tobias Doerffel 3cd8b97623 further UI finetuning
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1592 0778d3d1-df1d-0410-868b-ea421aaaa00d
2008-09-08 22:48:43 +00:00

69 lines
1.8 KiB
C++

/*
* gui_templates.h - GUI-specific templates
*
* Copyright (c) 2005-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.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 2 of the License, 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 (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef _GUI_TEMPLATES_H
#define _GUI_TEMPLATES_H
#include "lmmsconfig.h"
#include <QtGui/QApplication>
#include <QtGui/QFont>
#include <QtGui/QDesktopWidget>
// return DPI-independent font-size - font with returned font-size has always
// the same size in pixels
template<int SIZE>
inline QFont pointSize( QFont _f )
{
static const float DPI = 96;
#ifdef LMMS_BUILD_WIN32
_f.setPointSizeF( ((float) SIZE+0.5f) * DPI /
QApplication::desktop()->logicalDpiY() );
#else
_f.setPointSizeF( (float) SIZE * DPI /
QApplication::desktop()->logicalDpiY() );
#endif
return( _f );
}
inline QFont pointSizeF( QFont _f, float SIZE )
{
static const float DPI = 96;
#ifdef LMMS_BUILD_WIN32
_f.setPointSizeF( (SIZE+0.5f) * DPI /
QApplication::desktop()->logicalDpiY() );
#else
_f.setPointSizeF( SIZE * DPI /
QApplication::desktop()->logicalDpiY() );
#endif
return( _f );
}
#endif