summaryrefslogtreecommitdiff
path: root/app/wlib/mswlib/mswmisc.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/wlib/mswlib/mswmisc.c')
-rw-r--r--app/wlib/mswlib/mswmisc.c766
1 files changed, 353 insertions, 413 deletions
diff --git a/app/wlib/mswlib/mswmisc.c b/app/wlib/mswlib/mswmisc.c
index 5b45e2b..4bf9481 100644
--- a/app/wlib/mswlib/mswmisc.c
+++ b/app/wlib/mswlib/mswmisc.c
@@ -17,14 +17,14 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <shellapi.h>
#include <string.h>
-#include <malloc.h>
+#include <malloc.h> // required for heapinfo in function wMemStats
#include <stdlib.h>
#include <commdlg.h>
#include <math.h>
@@ -61,8 +61,8 @@ const char * GetCurCommandName(void);
#define LABELFONTRESET
#else
#define LABELFONTDECL HFONT hFont;
-#define LABELFONTRESET if (!mswThickFont) {SelectObject( hDc, hFont );}
-#define LABELFONTSELECT if (!mswThickFont) {hFont = SelectObject( hDc, mswLabelFont );}
+#define LABELFONTRESET SelectObject( hDc, hFont );
+#define LABELFONTSELECT hFont = SelectObject( hDc, mswLabelFont );
#endif
/*
@@ -78,13 +78,8 @@ int mswEditHeight;
int mswAllowBalloonHelp = TRUE;
HFONT mswOldTextFont;
HFONT mswLabelFont;
-/** @prefs [msw tweak] ThickFont=1 */
-long mswThickFont = 1;
double mswScale = 1.0;
-/** @prefs [Preference] LargeIcons=1.5 Set toolbar icon scaling. Limited 1.0 to 2.0 */
-double scaleIcon = 1.0; /** Scaling factor for toolbar icons */
-
callBacks_t *mswCallBacks[CALLBACK_CNT];
void closeBalloonHelp(int inx);
@@ -101,12 +96,12 @@ extern FILE * logFile;
*/
struct wWin_t {
- WOBJ_COMMON
- int validGeometry;
- int min_width;
- int max_width;
- int min_height;
- int max_height;
+ WOBJ_COMMON
+ int validGeometry;
+ int min_width;
+ int max_width;
+ int min_height;
+ int max_height;
wWinPix_t lastX, lastY;
wWinPix_t padX, padY;
wControl_p first, last;
@@ -177,8 +172,6 @@ char *mswProfileFile;
static wBalloonHelp_t * balloonHelpStrings;
-static wCursor_t curCursor = wCursorNormal;
-
#ifdef HELPSTR
static FILE * helpStrF;
#endif
@@ -193,18 +186,20 @@ extern char *userLocale;
// list of supported fileformats for image files
static char * filterImageFiles[] = { N_("All image files"),
- "*.gif;*.jpg;*.jpeg;*.png;*.tif;*.tiff",
- N_("GIF files (*.gif)"),
- "*.gif",
- N_("JPEG files (*.jpeg,*.jpg)"),
- "*.jpg;*.jpeg",
- N_("PNG files (*.png)"),
- "*.png",
- N_("TIFF files (*.tiff, *.tif)"),
- "*.tif;*.tiff",
- N_("All files (*)"),
- "*",
- };
+ "*.gif;*.jpg;*.jpeg;*.png;*.tif;*.tiff",
+ N_("GIF files (*.gif)"),
+ "*.gif",
+ N_("JPEG files (*.jpeg,*.jpg)"),
+ "*.jpg;*.jpeg",
+ N_("PNG files (*.png)"),
+ "*.png",
+ N_("TIFF files (*.tiff, *.tif)"),
+ "*.tif;*.tiff",
+ N_("All files (*)"),
+ "*",
+ };
+
+static HICON hWindowIcon;
/*
*****************************************************************************
@@ -308,7 +303,8 @@ void mswRepaintLabel(HWND hWnd, wControl_p b)
LABELFONTSELECT
newBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
oldBrush = SelectObject(hDc, newBrush);
- dw = GetTextExtent(hDc, CAST_AWAY_CONST b->labelStr, (int)(strlen(b->labelStr)));
+ dw = GetTextExtent(hDc, CAST_AWAY_CONST b->labelStr,
+ (int)(strlen(b->labelStr)));
rect.left = b->labelX;
rect.top = b->labelY;
rect.right = b->labelX + LOWORD(dw);
@@ -318,7 +314,8 @@ void mswRepaintLabel(HWND hWnd, wControl_p b)
/*SetBkMode( hDc, OPAQUE );*/
SetBkColor(hDc, GetSysColor(COLOR_BTNFACE));
- if (!TextOut(hDc, b->labelX, b->labelY, b->labelStr, (int)(strlen(b->labelStr)))) {
+ if (!TextOut(hDc, b->labelX, b->labelY, b->labelStr,
+ (int)(strlen(b->labelStr)))) {
mswFail("Repainting text label");
}
@@ -381,8 +378,8 @@ void * mswAlloc(
w->data = data;
w->focusChainNext = NULL;
w->shown = TRUE;
- w->hilite = FALSE;
- w->errStr = NULL;
+ w->hilite = FALSE;
+ w->errStr = NULL;
return w;
}
@@ -587,29 +584,27 @@ static void getSavedSizeAndPos(
if ((option&F_RECALLPOS) && nameStr) {
int x, y, w, h;
- int xadj, yadj;
+ int xadj, yadj;
const char *cp;
int state;
- w = h = 0;
- xadj = 1;
- yadj = mTitleH + 1;
- if (option & F_RESIZE) {
- xadj += mResizeBorderW * 2;
- yadj += mResizeBorderH * 2;
- }
- else
- {
- xadj += mFixBorderW * 2;
- yadj += mFixBorderH * 2;
- }
- //if (option & F_MENUBAR) {
- // yadj += mMenuH;
- //}
+ w = h = 0;
+ xadj = 1;
+ yadj = mTitleH + 1;
+ if (option & F_RESIZE) {
+ xadj += mResizeBorderW * 2;
+ yadj += mResizeBorderH * 2;
+ } else {
+ xadj += mFixBorderW * 2;
+ yadj += mFixBorderH * 2;
+ }
+ //if (option & F_MENUBAR) {
+ // yadj += mMenuH;
+ //}
if ((option & F_RESIZE) &&
(cp = wPrefGetStringBasic("msw window size", nameStr)) &&
- (state = (int)strtol(cp, &cq, 10), cp != cq) && // state is not used
+ (state = (int)strtol(cp, &cq, 10), cp != cq) && // state is not used
(cp = cq, w = (wWinPix_t)(strtod(cp, &cq)), cp != cq) &&
(cp = cq, h = (wWinPix_t)(strtod(cp, &cq)), cp != cq)
) {
@@ -645,6 +640,11 @@ static void getSavedSizeAndPos(
x = 0;
}
+ // Make sure we can see the dialog
+ xadj += 100;
+ yadj += 100;
+
+
if (y + h > screenHeight - yadj) {
y = screenHeight - yadj - h;
}
@@ -660,7 +660,7 @@ static void getSavedSizeAndPos(
}
/**
- * Set min and max dimensions for a window.
+ * Set min and max dimensions for a window.
*
* \param min_width IN minimum width of window
* \param max_width IN maximum width of window
@@ -671,21 +671,21 @@ static void getSavedSizeAndPos(
* \param aspect_ration IN unused on Windows
*/
void wSetGeometry(wWin_p win,
- wWinPix_t min_width,
- wWinPix_t max_width,
- wWinPix_t min_height,
- wWinPix_t max_height,
- wWinPix_t base_width,
- wWinPix_t base_height,
- double aspect_ratio)
+ wWinPix_t min_width,
+ wWinPix_t max_width,
+ wWinPix_t min_height,
+ wWinPix_t max_height,
+ wWinPix_t base_width,
+ wWinPix_t base_height,
+ double aspect_ratio)
{
- win->validGeometry = TRUE; //remember that geometry was set
- win->min_width = min_width;
- win->max_width = max_width;
- win->min_height = min_height;
- win->max_height = max_height;
+ win->validGeometry = TRUE; //remember that geometry was set
+ win->min_width = min_width;
+ win->max_width = max_width;
+ win->min_height = min_height;
+ win->max_height = max_height;
- return;
+ return;
}
/**
@@ -695,13 +695,13 @@ void wSetGeometry(wWin_p win,
* \param typ IN type of window (W_MAIN or W_POPUP)
* \param option IN options for window creation
* \param classname IN pre-registered window class
- * \param style IN
+ * \param style IN
* \param labelStr IN window title
* \param winProc IN callback procedure
* \param w IN default window width
* \param h IN default window height
* \param data IN ??
- * \param nameStr IN name of window
+ * \param nameStr IN name of window
* \param pShowCmd IN/OUT window show option (maximize or show normal)
* \return window data structure
*/
@@ -740,7 +740,7 @@ static wWin_p winCommonCreate(
if (typ == W_MAIN) {
*pShowCmd = ((option & F_MAXIMIZE) ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL);
} else {
- *pShowCmd = SW_HIDE; //Make sure to hide first
+ *pShowCmd = SW_HIDE; //Make sure to hide first
}
if (xx != CW_USEDEFAULT) {
@@ -800,6 +800,10 @@ static wWin_p winCommonCreate(
win->nameStr = mswStrdup(nameStr);
+ //HICON hIcon1 = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(101), IMAGE_ICON, 32, 32, LR_DEFAULTSIZE);
+ SendMessage(win->hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hWindowIcon);
+ SendMessage(win->hWnd, WM_SETICON, ICON_BIG, (LPARAM)hWindowIcon);
+
if (typ == W_MAIN) {
mswInitColorPalette();
}
@@ -850,7 +854,7 @@ wWin_p wWinMainCreate(
TEXTMETRIC tm;
char *pos;
char * configName;
- long maximize;
+ long maximize;
/* check for configuration name */
if (pos = strchr(name, ';')) {
@@ -887,14 +891,9 @@ wWin_p wWinMainCreate(
/* length of path + \ + length of filename + . + length of extension + \0 */
helpFile = (char*)malloc(strlen(libDir) + 1 + strlen(appName) + 1 + 3 + 1);
wsprintf(helpFile, "%s\\%s.chm", libDir, appName);
- wPrefGetInteger("msw tweak", "ThickFont", &mswThickFont, 0);
-
- wPrefGetInteger("draw", "maximized", &maximize, 0L);
- option |= (maximize ? F_MAXIMIZE : 0);
- wPrefGetFloat(PREFSECTION, LARGEICON, &scaleIcon, 1.0);
- if (scaleIcon < 1.0) scaleIcon = 1.0;
- if (scaleIcon > 2.0) scaleIcon = 2.0;
+ wPrefGetInteger("draw", "maximized", &maximize, 0L);
+ option |= (maximize ? F_MAXIMIZE : 0);
showCmd = SW_SHOW;
w = winCommonCreate(NULL, W_MAIN, option|F_RESIZE, "MswMainWindow",
@@ -902,18 +901,11 @@ wWin_p wWinMainCreate(
nameStr, &showCmd);
mswHWnd = w->hWnd;
- //HICON hIcon = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(0), IMAGE_ICON, 32, 32, LR_DEFAULTSIZE);
- //HICON hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(0));
- //SendMessage(mswHWnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
- //SendMessage(mswHWnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
-
- if (!mswThickFont) {
- SendMessage(mswHWnd, WM_SETFONT, (WPARAM)mswLabelFont, (LPARAM)0);
- hDc = GetDC(mswHWnd);
- GetTextMetrics(hDc, &tm);
- mswEditHeight = tm.tmHeight+2;
- ReleaseDC(mswHWnd, hDc);
- }
+ SendMessage(mswHWnd, WM_SETFONT, (WPARAM)mswLabelFont, (LPARAM)0);
+ hDc = GetDC(mswHWnd);
+ GetTextMetrics(hDc, &tm);
+ mswEditHeight = tm.tmHeight+2;
+ ReleaseDC(mswHWnd, hDc);
ShowWindow(mswHWnd, showCmd);
UpdateWindow(mswHWnd);
@@ -1257,19 +1249,19 @@ static void savePos(wWin_p win)
if (win->nameStr &&
IsWindowVisible(win->hWnd) /*&& !IsIconic( win->hWnd )*/) {
- GetWindowRect(win->hWnd, &rect);
+ GetWindowRect(win->hWnd, &rect);
- if (win->option&F_RECALLPOS) {
+ if (win->option&F_RECALLPOS) {
char posStr[20];
- wsprintf(posStr, "%d %d",
- rect.left,
- rect.top);
- wPrefSetString("msw window pos", win->nameStr, posStr);
+ wsprintf(posStr, "%d %d",
+ rect.left,
+ rect.top);
+ wPrefSetString("msw window pos", win->nameStr, posStr);
if (win->option&F_RESIZE) {
- GetClientRect(win->hWnd, &rect);
- w = rect.right - rect.left;
- h = rect.bottom - rect.top;
+ GetClientRect(win->hWnd, &rect);
+ w = rect.right - rect.left;
+ h = rect.bottom - rect.top;
wsprintf(posStr, "%d %d %d",
0, // unused
w, h);
@@ -1311,9 +1303,10 @@ void wWinShow(
win->centerWin = FALSE;
win->shown = TRUE;
- // Clear hilites
- for (wControl_p controlP = win->first; controlP; controlP = controlP->next)
- controlP->hilite = FALSE;
+ // Clear hilites
+ for (wControl_p controlP = win->first; controlP; controlP = controlP->next) {
+ controlP->hilite = FALSE;
+ }
if (mswHWnd == (HWND)0 || !IsIconic(mswHWnd)) {
ShowWindow(win->hWnd, SW_SHOW);
@@ -1459,73 +1452,6 @@ void wWinClear(
{
}
-extern long dontHideCursor;
-
-void wSetCursor(wDraw_p win,
- wCursor_t cursor)
-{
- switch (cursor) {
- case wCursorNormal:
- default:
- SetCursor(LoadCursor(NULL, IDC_ARROW));
- break;
-
- case wCursorWait:
- SetCursor(LoadCursor(NULL, IDC_WAIT));
- break;
-
- case wCursorCross:
- SetCursor(LoadCursor(NULL, IDC_CROSS));
- break;
-
- case wCursorIBeam:
- SetCursor(LoadCursor(NULL, IDC_IBEAM));
- break;
-
- case wCursorQuestion:
- SetCursor(LoadCursor(NULL, IDC_HELP));
- break;
-
- case wCursorHand:
- SetCursor(LoadCursor(NULL, IDC_HAND));
- break;
-
- case wCursorNo:
- SetCursor(LoadCursor(NULL, IDC_NO));
- break;
-
- case wCursorSizeAll:
- SetCursor(LoadCursor(NULL, IDC_SIZEALL));
- break;
-
- case wCursorSizeNESW:
- SetCursor(LoadCursor(NULL, IDC_SIZENESW));
- break;
-
- case wCursorSizeNWSE:
- SetCursor(LoadCursor(NULL, IDC_SIZENWSE));
- break;
-
- case wCursorSizeNS:
- SetCursor(LoadCursor(NULL, IDC_SIZENS));
- break;
-
- case wCursorSizeWE:
- SetCursor(LoadCursor(NULL, IDC_SIZEWE));
- break;
-
- case wCursorAppStart:
- SetCursor(LoadCursor(NULL, IDC_APPSTARTING));
- break;
-
- case wCursorNone:
- if (!dontHideCursor)
- SetCursor(NULL);
- break;
- }
-
- curCursor = cursor;
-}
void wWinDoCancel(wWin_p win)
{
@@ -1821,34 +1747,36 @@ void wControlHilite(
HDC hDc;
HPEN oldPen, newPen;
int oldMode;
- LOGBRUSH logBrush = { BS_SOLID, CONTROLHILITECOLOR, (ULONG_PTR)NULL };
+ LOGBRUSH logBrush = { BS_SOLID, CONTROLHILITECOLOR, (ULONG_PTR)NULL };
if (b == NULL) {
return;
}
- if ((b->parent==NULL) || (!IsWindowVisible(b->parent->hWnd)) || (!IsWindowVisible(b->hWnd))) {
- b->hilite = FALSE;
+ if ((b->parent==NULL) || (!IsWindowVisible(b->parent->hWnd))
+ || (!IsWindowVisible(b->hWnd))) {
+ b->hilite = FALSE;
return;
}
- if (b->hilite == hilite)
- return;
- b->hilite = hilite;
+ if (b->hilite == hilite) {
+ return;
+ }
+ b->hilite = hilite;
hDc = GetDC(b->parent->hWnd);
- newPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_ROUND | PS_JOIN_BEVEL,
- CONTROLHILITEWIDTH,
- &logBrush,
- 0,
- NULL);
+ newPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_ROUND | PS_JOIN_BEVEL,
+ CONTROLHILITEWIDTH,
+ &logBrush,
+ 0,
+ NULL);
oldPen = SelectObject(hDc, newPen);
oldMode = SetROP2(hDc, R2_NOTXORPEN);
- Rectangle(hDc,
- b->x - CONTROLHILITEWIDTH - 1,
- b->y - CONTROLHILITEWIDTH - 1,
- b->x + b->w + CONTROLHILITEWIDTH + 1,
- b->y + b->h + CONTROLHILITEWIDTH + 1);
+ Rectangle(hDc,
+ b->x - CONTROLHILITEWIDTH - 1,
+ b->y - CONTROLHILITEWIDTH - 1,
+ b->x + b->w + CONTROLHILITEWIDTH + 1,
+ b->y + b->h + CONTROLHILITEWIDTH + 1);
SetROP2(hDc, oldMode);
SelectObject(hDc, oldPen);
DeleteObject(newPen);
@@ -1893,23 +1821,23 @@ void wMessage(
/**
* Open a document using an external application
- *
+ *
* \param file
* \return TRUE on success, FALSE on error
- *
+ *
*/
unsigned wOpenFileExternal(char *file)
{
- HINSTANCE res;
+ HINSTANCE res;
- res = ShellExecute(mswHWnd, "open", file, NULL, NULL, SW_SHOW);
+ res = ShellExecute(mswHWnd, "open", file, NULL, NULL, SW_SHOW);
- if ((UINT_PTR)res <= 32) {
- wNoticeEx(NT_ERROR, "Error when opening file!", "Cancel", NULL);
- return(FALSE);
- }
+ if ((UINT_PTR)res <= 32) {
+ wNoticeEx(NT_ERROR, "Error when opening file!", "Cancel", NULL);
+ return(FALSE);
+ }
- return(TRUE);
+ return(TRUE);
}
void wExit(int rc)
@@ -1933,9 +1861,9 @@ void wExit(int rc)
}
}
- wPrefFlush("");
+ wPrefFlush("");
- for (inx=controlMap_da.cnt-1; inx>=0; inx--) {
+ for (inx=controlMap_da.cnt-1; inx>=0; inx--) {
b = controlMap(inx).b;
if (b != NULL) {
@@ -1948,7 +1876,7 @@ void wExit(int rc)
controlMap(inx).b = NULL;
}
- deleteBitmaps();
+ deleteBitmaps();
if (mswOldTextFont != (HFONT)0) {
DeleteObject(mswOldTextFont);
@@ -2187,7 +2115,7 @@ int wNotice3(
}
/**
- * Show help text for the given topic.
+ * Show help text for the given topic.
*
* \param topic The topic. if NULL the index page is shown.
*/
@@ -2197,11 +2125,11 @@ void wHelp(
{
char *pszHelpTopic;
HWND hwndHelp;
- const char *theTopic = "index";
+ const char *theTopic = "index";
- if (topic) {
- theTopic = topic;
- }
+ if (topic) {
+ theTopic = topic;
+ }
if (!helpInitted) {
HtmlHelp(NULL, NULL, HH_INITIALIZE, (DWORD_PTR)&dwCookie) ;
@@ -2235,7 +2163,7 @@ void doHelpMenu(void * context)
helpInitted = TRUE;
}
- const char * topic;
+ const char * topic;
switch ((int)(INT_PTR)context) {
case 1: /* Contents */
HtmlHelp(mswHWnd, helpFile, HH_DISPLAY_TOC, (DWORD_PTR)NULL);
@@ -2253,9 +2181,9 @@ void doHelpMenu(void * context)
case 3: /*Context*/
- topic = GetCurCommandName();
- wHelp(topic);
- break;
+ topic = GetCurCommandName();
+ wHelp(topic);
+ break;
default:
return;
@@ -2264,8 +2192,9 @@ void doHelpMenu(void * context)
helpInitted = TRUE;
}
-void wDoAccelHelp(wAccelKey_e key, void * context) {
- doHelpMenu(context);
+void wDoAccelHelp(wAccelKey_e key, void * context)
+{
+ doHelpMenu(context);
}
void wMenuAddHelp(
@@ -2301,126 +2230,133 @@ void wControlSetBalloonText(wControl_p b, const char * text)
void openBalloonHelp(wControl_p b, int dx, int dy)
{
- HDC hDc;
- DWORD extent;
- RECT rect;
- POINT pt;
- HFONT hFont;
- const char * msg;
- if (b->errStr) {
- msg = b->errStr;
- }
- else {
- msg = b->tipStr;
- if (!balloonHelpEnable) {
+ HDC hDc;
+ DWORD extent;
+ RECT rect;
+ POINT pt;
+ HFONT hFont;
+ const char * msg;
+ if (b->errStr) {
+ msg = b->errStr;
+ } else {
+ msg = b->tipStr;
+ if (!balloonHelpEnable) {
#ifdef BALLOON_TRACE
- fprintf(logFile, "openBalloon !Enable state %d\n", balloonHelpState); fflush(logFile);
+ fprintf(logFile, "openBalloon !Enable state %d\n", balloonHelpState);
+ fflush(logFile);
#endif
- return;
- }
- }
+ return;
+ }
+ }
#ifdef BALLOON_TRACE
- fprintf(logFile, "openBalloon %s state %d\n", msg, balloonHelpState); fflush(logFile);
+ fprintf(logFile, "openBalloon %s state %d\n", msg, balloonHelpState);
+ fflush(logFile);
#endif
- if (!balloonHelpHWnd)
- return;
- int w, h;
- hDc = GetDC(balloonHelpHWnd);
- hFont = SelectObject(hDc, mswLabelFont);
- extent = GetTextExtent(hDc, CAST_AWAY_CONST msg, (int)(strlen(msg)));
- w = LOWORD(extent);
- h = HIWORD(extent);
-
- if (b->type == B_RADIO ||
- b->type == B_TOGGLE) {
- pt.y = b->h;
- }
- else {
- GetClientRect(b->hWnd, &rect);
- pt.y = rect.bottom;
- }
-
- pt.x = dx;
- pt.y -= dy;
- ClientToScreen(b->hWnd, &pt);
-
- if (pt.x + w + 2 > screenWidth) {
- pt.x = screenWidth - (w + 2);
- }
-
- if (pt.x < 0) {
- pt.x = 0;
- }
-
- SetWindowPos(balloonHelpHWnd, HWND_TOPMOST, pt.x, pt.y, w + 6, h + 4,
- SWP_SHOWWINDOW | SWP_NOACTIVATE);
- if (!b->errStr) {
- SetBkColor(hDc, GetSysColor(COLOR_INFOBK));
- SetTextColor(hDc, GetSysColor(COLOR_INFOTEXT));
- } else {
- SetBkColor(hDc, GetSysColor(COLOR_HIGHLIGHT));
- SetTextColor(hDc, GetSysColor(COLOR_HIGHLIGHTTEXT));
- }
- TextOut(hDc, 2, 1, msg, (int)(strlen(msg)));
- SelectObject(hDc, hFont);
- ReleaseDC(balloonHelpHWnd, hDc);
- balloonHelpState = balloonHelpShow;
- balloonControlButton = b;
+ if (!balloonHelpHWnd) {
+ return;
+ }
+ int w, h;
+ hDc = GetDC(balloonHelpHWnd);
+ hFont = SelectObject(hDc, mswLabelFont);
+ extent = GetTextExtent(hDc, CAST_AWAY_CONST msg, (int)(strlen(msg)));
+ w = LOWORD(extent);
+ h = HIWORD(extent);
+
+ if (b->type == B_RADIO ||
+ b->type == B_TOGGLE) {
+ pt.y = b->h;
+ } else {
+ GetClientRect(b->hWnd, &rect);
+ pt.y = rect.bottom;
+ }
+
+ pt.x = dx;
+ pt.y -= dy;
+ ClientToScreen(b->hWnd, &pt);
+
+ if (pt.x + w + 2 > screenWidth) {
+ pt.x = screenWidth - (w + 2);
+ }
+
+ if (pt.x < 0) {
+ pt.x = 0;
+ }
+
+ SetWindowPos(balloonHelpHWnd, HWND_TOPMOST, pt.x, pt.y, w + 6, h + 4,
+ SWP_SHOWWINDOW | SWP_NOACTIVATE);
+ if (!b->errStr) {
+ SetBkColor(hDc, GetSysColor(COLOR_INFOBK));
+ SetTextColor(hDc, GetSysColor(COLOR_INFOTEXT));
+ } else {
+ SetBkColor(hDc, GetSysColor(COLOR_HIGHLIGHT));
+ SetTextColor(hDc, GetSysColor(COLOR_HIGHLIGHTTEXT));
+ }
+ TextOut(hDc, 2, 1, msg, (int)(strlen(msg)));
+ SelectObject(hDc, hFont);
+ ReleaseDC(balloonHelpHWnd, hDc);
+ balloonHelpState = balloonHelpShow;
+ balloonControlButton = b;
}
void startBalloonHelp(void)
{
- wBalloonHelp_t * bh;
-
- if (!balloonHelpButton->tipStr) {
- if (!balloonHelpStrings)
- return;
- for (bh = balloonHelpStrings; bh->name && strcmp(bh->name, balloonHelpButton->helpStr) != 0; bh++);
- if (!bh->name || !bh->value)
- balloonHelpButton->tipStr = _(balloonHelpButton->helpStr);
- else
- balloonHelpButton->tipStr = _(bh->value);
- }
+ wBalloonHelp_t * bh;
- openBalloonHelp(balloonHelpButton, 0, 0);
+ if (!balloonHelpButton->tipStr) {
+ if (!balloonHelpStrings) {
+ return;
+ }
+ for (bh = balloonHelpStrings; bh->name
+ && strcmp(bh->name, balloonHelpButton->helpStr) != 0; bh++);
+ if (!bh->name || !bh->value) {
+ balloonHelpButton->tipStr = _(balloonHelpButton->helpStr);
+ } else {
+ balloonHelpButton->tipStr = _(bh->value);
+ }
+ }
+
+ openBalloonHelp(balloonHelpButton, 0, 0);
}
void closeBalloonHelp(int inx)
{
#ifdef BALLOON_TRACE
- fprintf(logFile, "closeBallonHelp %d state=%d\n", inx, balloonHelpState); fflush(logFile);
+ fprintf(logFile, "closeBallonHelp %d state=%d\n", inx, balloonHelpState);
+ fflush(logFile);
#endif
- if (balloonHelpTimer) {
- KillTimer(mswHWnd, balloonHelpTimer);
- balloonHelpTimer = (UINT_PTR)0;
- }
+ if (balloonHelpTimer) {
+ KillTimer(mswHWnd, balloonHelpTimer);
+ balloonHelpTimer = (UINT_PTR)0;
+ }
- if (balloonHelpState == balloonHelpShow)
- if (balloonHelpHWnd) {
- ShowWindow(balloonHelpHWnd, SW_HIDE);
- }
+ if (balloonHelpState == balloonHelpShow)
+ if (balloonHelpHWnd) {
+ ShowWindow(balloonHelpHWnd, SW_HIDE);
+ }
- balloonHelpState = balloonHelpIdle;
+ balloonHelpState = balloonHelpIdle;
}
-void wControlSetBalloon(wControl_p b, wWinPix_t dx, wWinPix_t dy, const char * msg)
+void wControlSetBalloon(wControl_p b, wWinPix_t dx, wWinPix_t dy,
+ const char * msg)
{
- if (msg) {
- if (b->errStr)
- free(b->errStr);
- b->errStr = mswStrdup(msg);
- openBalloonHelp(b, dx, dy);
- }
- else {
- if (b->errStr)
- free(b->errStr);
- b->errStr = NULL;
- closeBalloonHelp(2);
- }
+ if (msg) {
+ if (b->errStr) {
+ free(b->errStr);
+ }
+ b->errStr = mswStrdup(msg);
+ openBalloonHelp(b, dx, dy);
+ } else {
+ if (b->errStr) {
+ free(b->errStr);
+ }
+ b->errStr = NULL;
+ closeBalloonHelp(2);
+ }
}
@@ -2482,19 +2418,20 @@ struct wFilSel_t {
char *
GetImageFileFormats(void)
{
- char *filter = malloc(2048);
- char *current = filter;
- char *message;
+ char *filter = malloc(2048);
+ char *current = filter;
+ char *message;
- for (int i = 0; i < sizeof(filterImageFiles) / sizeof(filterImageFiles[0]); i += 2) {
- message = gettext(filterImageFiles[i]);
- strcpy(current, message);
- current += strlen(message) + 1;
- strcpy(current, filterImageFiles[i + 1]);
- current += strlen(current) + 1;
- }
- *current = '\0';
- return(filter);
+ for (int i = 0; i < sizeof(filterImageFiles) / sizeof(filterImageFiles[0]);
+ i += 2) {
+ message = gettext(filterImageFiles[i]);
+ strcpy(current, message);
+ current += strlen(message) + 1;
+ strcpy(current, filterImageFiles[i + 1]);
+ current += strlen(current) + 1;
+ }
+ *current = '\0';
+ return(filter);
}
/**
@@ -2530,12 +2467,11 @@ int wFilSelect(
memset(&ofn, 0, sizeof ofn);
ofn.lStructSize = sizeof ofn;
ofn.hwndOwner = mswHWnd;
- if (fs->option == FS_PICTURES) {
- ofn.lpstrFilter = GetImageFileFormats();
- }
- else {
- ofn.lpstrFilter = fs->extList;
- }
+ if (fs->option == FS_PICTURES) {
+ ofn.lpstrFilter = GetImageFileFormats();
+ } else {
+ ofn.lpstrFilter = fs->extList;
+ }
ofn.nFilterIndex = 0;
selFileName = malloc(SELECTEDFILENAME_BUFFERSIZE);
@@ -2773,24 +2709,24 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
HDC hDc;
wAccelKey_e extChar;
- LPMINMAXINFO pMMI;
+ LPMINMAXINFO pMMI;
switch (message) {
- case WM_GETMINMAXINFO:
- pMMI = (LPMINMAXINFO)lParam;
- inx = GetWindowWord(hWnd, 0);
-
- if (inx >= CONTROL_BASE && inx <= controlMap_da.cnt) {
- w = (wWin_p)controlMap(inx - CONTROL_BASE).b;
- if (w != NULL) {
- if (w->validGeometry) {
- pMMI->ptMaxTrackSize.x = w->max_width;
- pMMI->ptMaxTrackSize.y = w->max_height;
- pMMI->ptMinTrackSize.x = w->min_width;
- pMMI->ptMinTrackSize.y = w->min_height;
- }
- }
- }
- return (LRESULT)0;
+ case WM_GETMINMAXINFO:
+ pMMI = (LPMINMAXINFO)lParam;
+ inx = GetWindowWord(hWnd, 0);
+
+ if (inx >= CONTROL_BASE && inx <= controlMap_da.cnt) {
+ w = (wWin_p)controlMap(inx - CONTROL_BASE).b;
+ if (w != NULL) {
+ if (w->validGeometry) {
+ pMMI->ptMaxTrackSize.x = w->max_width;
+ pMMI->ptMaxTrackSize.y = w->max_height;
+ pMMI->ptMinTrackSize.x = w->min_width;
+ pMMI->ptMinTrackSize.y = w->min_height;
+ }
+ }
+ }
+ return (LRESULT)0;
case WM_MOUSEWHEEL:
inx = GetWindowWord(hWnd, 0);
@@ -2800,13 +2736,13 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (mswCallBacks[b->type] != NULL &&
mswCallBacks[b->type]->messageProc)
return mswCallBacks[b->type]->messageProc((wControl_p)b, hWnd,
- message, wParam, lParam);
+ message, wParam, lParam);
return (LRESULT)0;
- case WM_COMMAND:
+ case WM_COMMAND:
closeBalloonHelp(3);
- case WM_DRAWITEM:
+ case WM_DRAWITEM:
case WM_MEASUREITEM:
if (WCMD_PARAM_ID < CONTROL_BASE || WCMD_PARAM_ID > (WPARAM)controlMap_da.cnt) {
@@ -2891,8 +2827,8 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case SIZE_MAXIMIZED:
case SIZE_MINIMIZED:
case SIZE_RESTORED:
- newW = LOWORD(lParam);
- newH = HIWORD(lParam);
+ newW = LOWORD(lParam);
+ newH = HIWORD(lParam);
if (newW <= 0 || newH <= 0) {
break;
@@ -2910,8 +2846,8 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (w->winProc) {
w->winProc(w, wResize_e, NULL, w->data);
- w->winProc(w, wState_e, NULL, w->data);
- }
+ w->winProc(w, wState_e, NULL, w->data);
+ }
break;
@@ -2939,7 +2875,7 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (mswCallBacks[w->type] != NULL &&
mswCallBacks[w->type]->messageProc)
return mswCallBacks[w->type]->messageProc((wControl_p)w, hWnd,
- message, wParam, lParam);
+ message, wParam, lParam);
break;
}
@@ -2961,14 +2897,15 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (b && b->type == B_DRAW) {
// Change Num keypad to a special code to emulate cursor keys
- if (wParam == VK_UP ||
- wParam == VK_DOWN ||
- wParam == VK_RIGHT ||
- wParam == VK_LEFT ||
- wParam == VK_INSERT ||
- wParam == VK_DELETE)
- {
- if ((lParam & 0x1000000) == 0) lParam |= 0x1000000;
+ if (wParam == VK_UP ||
+ wParam == VK_DOWN ||
+ wParam == VK_RIGHT ||
+ wParam == VK_LEFT ||
+ wParam == VK_INSERT ||
+ wParam == VK_DELETE) {
+ if ((lParam & 0x1000000) == 0) {
+ lParam |= 0x1000000;
+ }
}
return SendMessage(b->hWnd, WM_CHAR, wParam, lParam);
}
@@ -2984,7 +2921,7 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (mswCallBacks[B_BUTTON] != NULL &&
mswCallBacks[B_BUTTON]->messageProc) {
ret = mswCallBacks[B_BUTTON]->messageProc(b, b->hWnd,
- WM_COMMAND, wParam, lParam);
+ WM_COMMAND, wParam, lParam);
}
inMainWndProc = FALSE;
@@ -3004,7 +2941,7 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (mswCallBacks[B_BUTTON] != NULL &&
mswCallBacks[B_BUTTON]->messageProc) {
ret = mswCallBacks[B_BUTTON]->messageProc(b, b->hWnd,
- WM_COMMAND, wParam, lParam);
+ WM_COMMAND, wParam, lParam);
}
inMainWndProc = FALSE;
@@ -3027,7 +2964,7 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (mswCallBacks[b->type] != NULL &&
mswCallBacks[b->type]->messageProc) {
ret = mswCallBacks[b->type]->messageProc(b, b->hWnd,
- WM_COMMAND, MAKELPARAM(LOWORD(wParam), BN_CLICKED), (LPARAM)(b->hWnd));
+ WM_COMMAND, MAKELPARAM(LOWORD(wParam), BN_CLICKED), (LPARAM)(b->hWnd));
}
inMainWndProc = FALSE;
@@ -3098,64 +3035,66 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
return (LRESULT)0;
case WM_SETCURSOR:
- if (hWnd == mswHWnd)
- wSetCursor(NULL, curCursor);
+ // Set normal Arrow cursor, DefWindowProc can override it
+ SetCursor(LoadCursor(NULL, IDC_ARROW));
+
+ if (!mswAllowBalloonHelp) {
+ break;
+ }
- if (!mswAllowBalloonHelp) {
- break;
- }
+ if (IsIconic(mswHWnd)) {
+ break;
+ }
- if (IsIconic(mswHWnd)) {
- break;
- }
+ b = getControlFromCursor(hWnd, NULL);
- b = getControlFromCursor(hWnd, NULL);
-
#ifdef BALLOON_TRACE
- fprintf(logFile, "SETCURSOR %s\n", b ? b->helpStr : "NULL"); fflush(logFile);
+ fprintf(logFile, "SETCURSOR %s\n", b ? b->helpStr : "NULL");
+ fflush(logFile);
#endif
- if (b == balloonControlButton) {
- //closeBalloonHelp(61);
- break;
- }
-
- if (GetActiveWindow() != hWnd) {
- closeBalloonHelp(62);
- break;
- }
- if (!b) {
- closeBalloonHelp(63);
- break;
- }
- if (b->type == B_DRAW) {
- closeBalloonHelp(64);
- break;
- }
- if (b->helpStr == NULL) {
- closeBalloonHelp(65);
- break;
- }
-
- if (b != balloonHelpButton) {
- closeBalloonHelp(7);
- }
+ if (b == balloonControlButton) {
+ //closeBalloonHelp(61);
+ break;
+ }
+
+ if (GetActiveWindow() != hWnd) {
+ closeBalloonHelp(62);
+ break;
+ }
+ if (!b) {
+ closeBalloonHelp(63);
+ break;
+ }
+ if (b->type == B_DRAW) {
+ closeBalloonHelp(64);
+ break;
+ }
+ if (b->helpStr == NULL) {
+ closeBalloonHelp(65);
+ break;
+ }
+
+ if (b != balloonHelpButton) {
+ closeBalloonHelp(7);
+ }
#ifdef BALLOON_TRACE
- fprintf(logFile, "SETCURSOR state %d\n", balloonHelpState); fflush(logFile);
+ fprintf(logFile, "SETCURSOR state %d\n", balloonHelpState);
+ fflush(logFile);
#endif
- if (balloonHelpState != balloonHelpIdle) {
- break;
- }
+ if (balloonHelpState != balloonHelpIdle) {
+ break;
+ }
- balloonHelpTimer = SetTimer(mswHWnd, BALLOONHELP_TIMER,
- balloonHelpTimeOut, NULL);
+ balloonHelpTimer = SetTimer(mswHWnd, BALLOONHELP_TIMER,
+ balloonHelpTimeOut, NULL);
- if (balloonHelpTimer == (UINT_PTR)0) {
- break;
- }
+ if (balloonHelpTimer == (UINT_PTR)0) {
+ break;
+ }
- balloonHelpState = balloonHelpWait;
- balloonHelpButton = b;
- break;
+ balloonHelpState = balloonHelpWait;
+ balloonHelpButton = b;
+ break;
case WM_SYSCOMMAND:
@@ -3263,7 +3202,7 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case 51:
count51++;
- /*return NULL;*/
+ /*return NULL;*/
case WM_PALETTECHANGED:
@@ -3421,7 +3360,7 @@ static BOOL InitApplication(HINSTANCE hinstCurrent)
wc.cbWndExtra = 4;
if (!RegisterClass(&wc)) {
- mswFail("RegisterClass(drawClass)");
+ mswFail("RegisterClass(drawClass)");
return FALSE;
}
@@ -3443,11 +3382,11 @@ int PASCAL WinMain(HINSTANCE hinstCurrent, HINSTANCE hinstPrevious,
char **argv;
int argc;
- if (!hinstPrevious) {
- if (!InitApplication(hinstCurrent)) {
- return FALSE;
- }
- }
+ if (!hinstPrevious) {
+ if (!InitApplication(hinstCurrent)) {
+ return FALSE;
+ }
+ }
mswHInst = hinstCurrent;
mTitleH = GetSystemMetrics(SM_CYCAPTION) - 1;
@@ -3456,11 +3395,12 @@ int PASCAL WinMain(HINSTANCE hinstCurrent, HINSTANCE hinstPrevious,
mResizeBorderW = GetSystemMetrics(SM_CXFRAME);
mResizeBorderH = GetSystemMetrics(SM_CYFRAME);
mMenuH = GetSystemMetrics(SM_CYMENU) + 1;
- screenWidth = GetSystemMetrics(SM_CXFULLSCREEN);
- screenHeight = GetSystemMetrics(SM_CYFULLSCREEN);
- mswLabelFont = GetStockObject(DEFAULT_GUI_FONT);
+ screenWidth = GetSystemMetrics(SM_CXSCREEN);
+ screenHeight = GetSystemMetrics(SM_CYSCREEN);
+ mswLabelFont = GetStockObject(DEFAULT_GUI_FONT);
hDc = GetDC(0);
mswScale = GetDeviceCaps(hDc, LOGPIXELSX) / 96.0;
+ hWindowIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(101));
if (mswScale < 1.0) {
mswScale = 1.0;