diff -r bb3a0e5ebe53 -r 30c11cff511d src/gui.h --- a/src/gui.h Thu Jul 04 20:12:03 2013 +0300 +++ b/src/gui.h Thu Jul 04 21:01:52 2013 +0300 @@ -22,6 +22,7 @@ #include #include #include +#include #include "config.h" #include "ldtypes.h" @@ -175,6 +176,10 @@ }; // ----------------------------------------------------------------------------- +// Pointer to the instance of ForgeWindow. +extern ForgeWindow* g_win; + +// ----------------------------------------------------------------------------- // Other GUI-related stuff not directly part of ForgeWindow: QPixmap getIcon (str iconName); vector parseQuickColorMeta (); @@ -188,9 +193,36 @@ CheckBoxGroup* makeAxesBox (); QImage imageFromScreencap (uchar* data, ushort w, ushort h); +// ============================================================================= // ----------------------------------------------------------------------------- -// Pointer to the instance of ForgeWindow. -extern ForgeWindow* g_win; +// Takes in pairs of radio buttons and respective values and returns the value of +// the first found radio button that was checked. +// ============================================================================= +template T radioSwitch( const T& defval, vector> haystack ) +{ + for( pair i : haystack ) + if( i.first->isChecked() ) + return i.second; + + return defval; +} + +// ============================================================================= +// ----------------------------------------------------------------------------- +// Takes in pairs of radio buttons and respective values and checks the first +// found radio button to have the given value. +// ============================================================================= +template void radioDefault( const T& expr, vector> haystack ) +{ + for( pair i : haystack ) + { + if( i.second == expr ) + { + i.first->setChecked( true ); + return; + } + } +} // ============================================================================= // ActionAdder