From b7b224bd68f7c5a172bb3ee0d5b47c6756eae952 Mon Sep 17 00:00:00 2001 From: kichik Date: Thu, 19 Jul 2007 04:55:53 +0000 Subject: [PATCH] added rtl support git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5214 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/nsDialogs/rtl.c | 79 +++++++++++++++++++++++++++++++++++++++++ Contrib/nsDialogs/rtl.h | 9 +++++ 2 files changed, 88 insertions(+) create mode 100644 Contrib/nsDialogs/rtl.c create mode 100644 Contrib/nsDialogs/rtl.h diff --git a/Contrib/nsDialogs/rtl.c b/Contrib/nsDialogs/rtl.c new file mode 100644 index 00000000..9ca28933 --- /dev/null +++ b/Contrib/nsDialogs/rtl.c @@ -0,0 +1,79 @@ +#include +#include + +#include "defs.h" +#include "nsis.h" + +extern struct nsDialog g_dialog; + +void __declspec(dllexport) SetRTL(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra) +{ + g_dialog.rtl = (BOOL) popint(); +} + +void NSDFUNC ConvertStyleToRTL(enum nsControlType type, LPDWORD style, LPDWORD exStyle) +{ + if (!g_dialog.rtl) + return; + + switch (type) + { + case NSCTL_BUTTON: + *style ^= BS_LEFTTEXT | BS_RIGHT | BS_LEFT; + + if ((*style & (BS_LEFT|BS_RIGHT)) == (BS_LEFT|BS_RIGHT)) + { + *style ^= BS_LEFT | BS_RIGHT; + if (*style & (BS_RADIOBUTTON | BS_CHECKBOX | BS_USERBUTTON)) + { + *style |= BS_RIGHT; + } + } + break; + + case NSCTL_EDIT: + if ((*style & ES_CENTER) == 0) + { + *style ^= ES_RIGHT; + } + break; + + case NSCTL_STATIC: + if ((*style & SS_TYPEMASK) == SS_LEFT || (*style & SS_TYPEMASK) == SS_LEFTNOWORDWRAP) + { + *style &= ~SS_TYPEMASK; + *style |= SS_RIGHT; + } + else if ((*style & SS_TYPEMASK) == SS_ICON) { + *style |= SS_CENTERIMAGE; + } + break; + + case NSCTL_RICHEDIT: + case NSCTL_RICHEDIT2: + if ((*style & ES_CENTER) == 0) + { + *style ^= ES_RIGHT; + } + break; + + case NSCTL_TREE: + *style |= TVS_RTLREADING; + *exStyle |= WS_EX_RIGHT; + break; + + default: + *exStyle |= WS_EX_RIGHT; + break; + } + + *exStyle |= WS_EX_RTLREADING | WS_EX_LEFTSCROLLBAR; +} + +void NSDFUNC ConvertPosToRTL(int *x, int width, int dialogWidth) +{ + if (!g_dialog.rtl) + return; + + *x = dialogWidth - width - *x; +} diff --git a/Contrib/nsDialogs/rtl.h b/Contrib/nsDialogs/rtl.h new file mode 100644 index 00000000..b6e920ca --- /dev/null +++ b/Contrib/nsDialogs/rtl.h @@ -0,0 +1,9 @@ +#ifndef __NS_DIALOGS__RTL_H__ +#define __NS_DIALOGS__RTL_H__ + +#include "defs.h" + +void NSDFUNC ConvertStyleToRTL(enum nsControlType type, LPDWORD style, LPDWORD exStyle); +void NSDFUNC ConvertPosToRTL(int *x, int width, int dialogWidth); + +#endif//__NS_DIALOGS__RTL_H__