summaryrefslogtreecommitdiffstats
path: root/styles/phase2/scaling.h
diff options
context:
space:
mode:
Diffstat (limited to 'styles/phase2/scaling.h')
-rw-r--r--styles/phase2/scaling.h139
1 files changed, 139 insertions, 0 deletions
diff --git a/styles/phase2/scaling.h b/styles/phase2/scaling.h
new file mode 100644
index 00000000..bb478c0f
--- /dev/null
+++ b/styles/phase2/scaling.h
@@ -0,0 +1,139 @@
+#ifndef __SCALING_H__
+#define __SCALING_H__
+
+#include <stdlib.h>
+#include <math.h>
+
+static int QT3SCALE_MAX = 3 ;
+static int QT3SCALE = 1 ;
+
+#define QT3SCALE_TAG_BUFFSIZE 3
+static char QT3SCALE_TAG[QT3SCALE_TAG_BUFFSIZE] = { '1', 0, 0 } ;
+
+//--- Information about current application font
+
+const static TQFont CurrentFont = TQApplication::font() ;
+const static TQFontInfo CurrentFontInfo(CurrentFont) ;
+const static TQFontMetrics CurrentFontMetrics(CurrentFont) ;
+
+
+static int FONT_Size = 16 ; // Sans 12 pixel size
+static double FONT_Scale = 1.00 ; // 96 DPI
+
+//------------------------------------------------------------------------------
+// Functions called during style initialization
+//------------------------------------------------------------------------------
+
+static void
+Generate_Scaling_Metrics(const QWidget * w = 0)
+{
+ //--- FONT_Size is an important metric for scaling widget elements
+
+ FONT_Size = CurrentFontMetrics.ascent() + CurrentFontMetrics.descent() ;
+ /* Alternative methods for initial computing FONT_Size
+ with exmplary values displayed for Sans 10/12 fonts:
+ CurrentFontMetrics.strikeOutPos() * 3 ; // 12/15
+ CurrentFontInfo.pixelSize() ; // 13/16
+ CurrentFontMetrics.overlinePos() ; // 13/16
+ CurrentFontMetrics.ascent() + CurrentFontMetrics.descent() ; // 14/18
+ CurrentFontMetrics.height() ; // 15/19
+ */
+ if (FONT_Size % 2 != 0) FONT_Size++ ;
+
+ //--- FONT_scale is also an important metric for scaling widget elements
+
+ double Pixels_96dpi = 4 * CurrentFontInfo.pointSize() / 3 ;
+ // Calculate font size relative to 96dpi
+ FONT_Scale = (double)(int)((double)( FONT_Size / Pixels_96dpi )*4)/4 ;
+ // Calculate font scaling relative to 96dpi in increments of 0.25
+
+//fprintf(stderr,
+// "At the current %.2f scaling, a %d-point font is %d (%d) pixels high\n",
+// FONT_scale, FONT_points, FONT_size, FONT_height
+//) ;
+}
+
+//------------------------------------------------------------------------------
+
+void Set_QT3SCALE()
+{
+ QT3SCALE = 1 ;
+ const char *QT3SCALE_env = getenv("QT3SCALE");
+ if ( QT3SCALE_env != NULL ) {
+ int QT3SCALE_int = atoi(QT3SCALE_env) ;
+ if ( QT3SCALE_int > 1 && QT3SCALE_int <= QT3SCALE_MAX )
+ QT3SCALE = QT3SCALE_int ;
+ }
+ snprintf(QT3SCALE_TAG, QT3SCALE_TAG_BUFFSIZE, "%d", QT3SCALE) ;
+}
+
+//------------------------------------------------------------------------------
+
+/*
+ QStyle::PE_ButtonCommand - button used to initiate an action, for example, a QPushButton.
+ QStyle::PE_ButtonDefault - this button is the default button, e.g. in a dialog.
+ QStyle::PE_ButtonBevel - generic button bevel.
+ QStyle::PE_ButtonTool - tool button, for example, a QToolButton.
+ QStyle::PE_ButtonDropDown - drop down button, for example, a tool button that displays a popup menu, for example, QPopupMenu.
+
+ QStyle::PE_FocusRect - generic focus indicator.
+
+ QStyle::PE_ArrowUp - up arrow.
+ QStyle::PE_ArrowDown - down arrow.
+ QStyle::PE_ArrowRight - right arrow.
+ QStyle::PE_ArrowLeft - left arrow.
+
+ QStyle::PE_SpinWidgetUp - up symbol for a spin widget, for example a QSpinBox.
+ QStyle::PE_SpinWidgetDown - down symbol for a spin widget.
+ QStyle::PE_SpinWidgetPlus - increase symbol for a spin widget.
+ QStyle::PE_SpinWidgetMinus - decrease symbol for a spin widget.
+
+ QStyle::PE_Indicator - on/off indicator, for example, a QCheckBox.
+ QStyle::PE_IndicatorMask - bitmap mask for an indicator.
+ QStyle::PE_ExclusiveIndicator - exclusive on/off indicator, for example, a QRadioButton.
+ QStyle::PE_ExclusiveIndicatorMask - bitmap mask for an exclusive indicator.
+
+ QStyle::PE_DockWindowHandle - tear off handle for dock windows and toolbars, for example QDockWindows and QToolBars.
+ QStyle::PE_DockWindowSeparator - item separator for dock window and toolbar contents.
+ QStyle::PE_DockWindowResizeHandle - resize handle for dock windows.
+ QStyle::PE_Splitter - splitter handle; see also QSplitter.
+
+ QStyle::PE_Panel - generic panel frame; see also QFrame.
+ QStyle::PE_PanelPopup - panel frame for popup windows/menus; see also QPopupMenu.
+ QStyle::PE_PanelMenuBar - panel frame for menu bars.
+ QStyle::PE_PanelDockWindow - panel frame for dock windows and toolbars.
+ QStyle::PE_PanelTabWidget - panel frame for tab widgets.
+ QStyle::PE_PanelLineEdit - panel frame for line edits.
+ QStyle::PE_PanelGroupBox - panel frame for group boxes.
+ QStyle::PE_TabBarBase - area below tabs in a tab widget, for example, QTab.
+
+ QStyle::PE_HeaderSection - section of a list or table header; see also QHeader.
+ QStyle::PE_HeaderArrow - arrow used to indicate sorting on a list or table header
+ QStyle::PE_StatusBarSection - section of a status bar; see also QStatusBar.
+
+ QStyle::PE_GroupBoxFrame - frame around a group box; see also QGroupBox.
+ QStyle::PE_WindowFrame - frame around a MDI window or a docking window
+
+ QStyle::PE_Separator - generic separator.
+
+ QStyle::PE_SizeGrip - window resize handle; see also QSizeGrip.
+
+ QStyle::PE_CheckMark - generic check mark; see also QCheckBox.
+
+ QStyle::PE_ScrollBarAddLine - scrollbar line increase indicator (i.e. scroll down); see also QScrollBar.
+ QStyle::PE_ScrollBarSubLine - scrollbar line decrease indicator (i.e. scroll up).
+ QStyle::PE_ScrollBarAddPage - scolllbar page increase indicator (i.e. page down).
+ QStyle::PE_ScrollBarSubPage - scrollbar page decrease indicator (i.e. page up).
+ QStyle::PE_ScrollBarSlider - scrollbar slider
+ QStyle::PE_ScrollBarFirst - scrollbar first line indicator (i.e. home).
+ QStyle::PE_ScrollBarLast - scrollbar last line indicator (i.e. end).
+
+ QStyle::PE_ProgressBarChunk - section of a progress bar indicator; see also QProgressBar.
+ QStyle::PE_CheckListController - controller part of a listview item
+ QStyle::PE_CheckListIndicator - checkbox part of a listview item
+ QStyle::PE_CheckListExclusiveIndicator - radiobutton part of a listview item
+ QStyle::PE_RubberBand - rubber band used in such things as iconview
+ QStyle::PE_CustomBase - base value for custom PrimitiveElements. All values above this are reserved for custom use. Custom values must be greater than this value.
+ */
+
+#endif