diff options
Diffstat (limited to 'src/modules/fonts')
-rw-r--r-- | src/modules/fonts/FontOptions.cpp | 163 |
1 files changed, 76 insertions, 87 deletions
diff --git a/src/modules/fonts/FontOptions.cpp b/src/modules/fonts/FontOptions.cpp index 9651e22a43..3b1c218107 100644 --- a/src/modules/fonts/FontOptions.cpp +++ b/src/modules/fonts/FontOptions.cpp @@ -59,30 +59,29 @@ OBJLIST<ColourInternal> colour_id_list(10, sttCompareColour), colour_id_list_w2( static int sttCompareEffect(const EffectInternal* p1, const EffectInternal* p2)
{
- int result = _tcscmp(p1->group, p2->group);
- if (result != 0)
- return result;
+ int result = _tcscmp(p1->group, p2->group);
+ if (result != 0)
+ return result;
- result = p1->order - p2->order;
- if (result != 0)
- return result;
+ result = p1->order - p2->order;
+ if (result != 0)
+ return result;
- return _tcscmp( p1->getName(), p2->getName());
+ return _tcscmp( p1->getName(), p2->getName());
}
OBJLIST<EffectInternal> effect_id_list(10, sttCompareEffect), effect_id_list_w2(10, sttCompareEffect), effect_id_list_w3(10, sttCompareEffect);
-typedef struct DrawTextWithEffectParam_tag
+struct DrawTextWithEffectParam
{
- int cbSize;
- HDC hdc; // handle to DC
- LPCTSTR lpchText; // text to draw
- int cchText; // length of text to draw
- LPRECT lprc; // rectangle coordinates
- UINT dwDTFormat; // formatting options
- FONTEFFECT * pEffect; // effect to be drawn on
-
-} DrawTextWithEffectParam;
+ int cbSize;
+ HDC hdc; // handle to DC
+ LPCTSTR lpchText; // text to draw
+ int cchText; // length of text to draw
+ LPRECT lprc; // rectangle coordinates
+ UINT dwDTFormat; // formatting options
+ FONTEFFECT * pEffect; // effect to be drawn on
+};
#define MS_DRAW_TEXT_WITH_EFFECTA "Modern/SkinEngine/DrawTextWithEffectA"
#define MS_DRAW_TEXT_WITH_EFFECTW "Modern/SkinEngine/DrawTextWithEffectW"
@@ -92,27 +91,26 @@ typedef struct DrawTextWithEffectParam_tag // Helper
int __inline DrawTextWithEffect(HDC hdc, LPCTSTR lpchText, int cchText, RECT * lprc, UINT dwDTFormat, FONTEFFECT * pEffect)
{
- DrawTextWithEffectParam params;
- static BYTE bIfServiceExists = ServiceExists(MS_DRAW_TEXT_WITH_EFFECT) ? 1 : 0;
-
- if (pEffect == NULL || pEffect->effectIndex == 0)
- return DrawText (hdc, lpchText, cchText, lprc, dwDTFormat); // If no effect specified draw by GDI it just more careful with ClearType
-
- if (bIfServiceExists == 0)
- return DrawText (hdc, lpchText, cchText, lprc, dwDTFormat);
-
- // else
- params.cbSize = sizeof(DrawTextWithEffectParam);
- params.hdc = hdc;
- params.lpchText = lpchText;
- params.cchText = cchText;
- params.lprc = lprc;
- params.dwDTFormat = dwDTFormat;
- params.pEffect = pEffect;
- return CallService(MS_DRAW_TEXT_WITH_EFFECT, (WPARAM)¶ms, 0);
+ DrawTextWithEffectParam params;
+ static BYTE bIfServiceExists = ServiceExists(MS_DRAW_TEXT_WITH_EFFECT) ? 1 : 0;
+
+ if (pEffect == NULL || pEffect->effectIndex == 0)
+ return DrawText (hdc, lpchText, cchText, lprc, dwDTFormat); // If no effect specified draw by GDI it just more careful with ClearType
+
+ if (bIfServiceExists == 0)
+ return DrawText (hdc, lpchText, cchText, lprc, dwDTFormat);
+
+ // else
+ params.cbSize = sizeof(DrawTextWithEffectParam);
+ params.hdc = hdc;
+ params.lpchText = lpchText;
+ params.cchText = cchText;
+ params.lprc = lprc;
+ params.dwDTFormat = dwDTFormat;
+ params.pEffect = pEffect;
+ return CallService(MS_DRAW_TEXT_WITH_EFFECT, (WPARAM)¶ms, 0);
}
-
#define UM_SETFONTGROUP (WM_USER + 101)
#define TIMER_ID 11015
@@ -222,23 +220,22 @@ BOOL ExportSettings(HWND hwndDlg, TCHAR *filename, OBJLIST<FontInternal>& flist, WriteLine(fhand, buff);
}
- header[0] = 0;
- for (i=0; i < elist.getCount(); i++) {
- EffectInternal& E = elist[i];
-
- mir_snprintf(buff, SIZEOF(buff), "\r\n[%s]", E.dbSettingsGroup);
- if (strcmp(buff, header) != 0) {
- strcpy(header, buff);
- WriteLine(fhand, buff);
- }
- mir_snprintf(buff, SIZEOF(buff), "%sEffect = b%d", E.setting, E.value.effectIndex);
- WriteLine(fhand, buff);
- mir_snprintf(buff, SIZEOF(buff), "%sEffectCol1 = d%d", E.setting, E.value.baseColour);
- WriteLine(fhand, buff);
- mir_snprintf(buff, SIZEOF(buff), "%sEffectCol2 = d%d", E.setting, E.value.secondaryColour);
- WriteLine(fhand, buff);
- }
+ header[0] = 0;
+ for (i=0; i < elist.getCount(); i++) {
+ EffectInternal& E = elist[i];
+ mir_snprintf(buff, SIZEOF(buff), "\r\n[%s]", E.dbSettingsGroup);
+ if (strcmp(buff, header) != 0) {
+ strcpy(header, buff);
+ WriteLine(fhand, buff);
+ }
+ mir_snprintf(buff, SIZEOF(buff), "%sEffect = b%d", E.setting, E.value.effectIndex);
+ WriteLine(fhand, buff);
+ mir_snprintf(buff, SIZEOF(buff), "%sEffectCol1 = d%d", E.setting, E.value.baseColour);
+ WriteLine(fhand, buff);
+ mir_snprintf(buff, SIZEOF(buff), "%sEffectCol2 = d%d", E.setting, E.value.secondaryColour);
+ WriteLine(fhand, buff);
+ }
CloseHandle(fhand);
return TRUE;
@@ -276,10 +273,9 @@ struct FSUIListItemData {
int font_id;
int colour_id;
- int effect_id;
+ int effect_id;
};
-
static BOOL sttFsuiBindColourIdToFonts(HWND hwndList, const TCHAR *name, const TCHAR *backgroundGroup, const TCHAR *backgroundName, int colourId)
{
int i;
@@ -303,24 +299,21 @@ static BOOL sttFsuiBindColourIdToFonts(HWND hwndList, const TCHAR *name, const T return res;
}
-static BOOL sttFsuiBindEffectIdToFonts(HWND hwndList, const TCHAR *name, int effectId)
+static bool sttFsuiBindEffectIdToFonts(HWND hwndList, const TCHAR *name, int effectId)
{
- int i;
- BOOL res = FALSE;
- for (i = SendMessage(hwndList, LB_GETCOUNT, 0, 0); i--;)
- {
- FSUIListItemData *itemData = (FSUIListItemData *)SendMessage(hwndList, LB_GETITEMDATA, i, 0);
- if (itemData && itemData->font_id >= 0) {
- FontInternal& F = font_id_list_w2[itemData->font_id];
-
- if (name && !_tcscmp(F.name, name)) {
- itemData->effect_id = effectId;
- res = TRUE;
- }
-
- } }
-
- return res;
+ for (int i = SendMessage(hwndList, LB_GETCOUNT, 0, 0); i--;) {
+ FSUIListItemData *itemData = (FSUIListItemData *)SendMessage(hwndList, LB_GETITEMDATA, i, 0);
+ if (itemData && itemData->font_id >= 0) {
+ FontInternal& F = font_id_list_w2[itemData->font_id];
+
+ if (name && !_tcscmp(F.name, name)) {
+ itemData->effect_id = effectId;
+ return true;
+ }
+ }
+ }
+
+ return false;
}
static HTREEITEM sttFindNamedTreeItemAt(HWND hwndTree, HTREEITEM hItem, const TCHAR *name)
@@ -444,28 +437,24 @@ static void sttSaveCollapseState(HWND hwndTree) static void sttFreeListItems(HWND hList)
{
- int idx = 0;
- LRESULT res;
- FSUIListItemData *itemData;
int count = SendMessage(hList, LB_GETCOUNT, 0, 0);
if (count > 0) {
- while (idx < count) {
- res = SendMessage(hList, LB_GETITEMDATA, idx++, 0);
- itemData = (FSUIListItemData *)res;
+ for (int idx = 0; idx < count; idx++) {
+ LRESULT res = SendMessage(hList, LB_GETITEMDATA, idx, 0);
+ FSUIListItemData *itemData = (FSUIListItemData *)res;
if (itemData && res != LB_ERR)
mir_free(itemData);
}
}
}
-static BOOL ShowEffectButton(HWND hwndDlg, BOOL bShow)
+static void ShowEffectButton(HWND hwndDlg, BOOL bShow)
{
- ShowWindow( GetDlgItem(hwndDlg, IDC_BKGCOLOUR), bShow ? SW_HIDE : SW_SHOW);
- ShowWindow( GetDlgItem(hwndDlg, IDC_BKGCOLOUR_STATIC), bShow ? SW_HIDE : SW_SHOW);
+ ShowWindow( GetDlgItem(hwndDlg, IDC_BKGCOLOUR), bShow ? SW_HIDE : SW_SHOW);
+ ShowWindow( GetDlgItem(hwndDlg, IDC_BKGCOLOUR_STATIC), bShow ? SW_HIDE : SW_SHOW);
- ShowWindow( GetDlgItem(hwndDlg, IDC_EFFECT), bShow ? SW_SHOW : SW_HIDE);
- ShowWindow( GetDlgItem(hwndDlg, IDC_EFFECT_STATIC), bShow ? SW_SHOW : SW_HIDE);
- return TRUE;
+ ShowWindow( GetDlgItem(hwndDlg, IDC_EFFECT), bShow ? SW_SHOW : SW_HIDE);
+ ShowWindow( GetDlgItem(hwndDlg, IDC_EFFECT_STATIC), bShow ? SW_SHOW : SW_HIDE);
}
TCHAR* ModernEffectNames[] = { _T("<none>"), _T("Shadow at left"), _T("Shadow at right"), _T("Outline"), _T("Outline smooth"), _T("Smooth bump"), _T("Contour thin"), _T("Contour heavy") };
@@ -645,8 +634,8 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam, int first_font_index = -1;
int colourId = 0;
int first_colour_index = -1;
- int effectId = 0;
- int first_effect_index = -1;
+ int effectId = 0;
+ int first_effect_index = -1;
SendDlgItemMessage(hwndDlg, IDC_FONTLIST, WM_SETREDRAW, FALSE, 0);
@@ -655,7 +644,7 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam, if (_tcsncmp(F.group, group_buff, 64) == 0) {
FSUIListItemData *itemData = (FSUIListItemData*)mir_alloc(sizeof(FSUIListItemData));
itemData->colour_id = -1;
- itemData->effect_id = -1;
+ itemData->effect_id = -1;
itemData->font_id = fontId;
if (first_font_index == -1)
@@ -683,7 +672,7 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam, itemData = (FSUIListItemData*)mir_alloc(sizeof(FSUIListItemData));
itemData->colour_id = colourId;
itemData->font_id = -1;
- itemData->effect_id = -1;
+ itemData->effect_id = -1;
itemId = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_ADDSTRING, (WPARAM)-1, (LPARAM)itemData);
}
|