diff options
Diffstat (limited to 'iup/src/win/iupwin_text.c')
-rwxr-xr-x | iup/src/win/iupwin_text.c | 52 |
1 files changed, 36 insertions, 16 deletions
diff --git a/iup/src/win/iupwin_text.c b/iup/src/win/iupwin_text.c index dfe489a..2a61724 100755 --- a/iup/src/win/iupwin_text.c +++ b/iup/src/win/iupwin_text.c @@ -432,8 +432,8 @@ static int winTextSetLinColToPosition(Ihandle *ih, int lin, int col) col--; linmax = SendMessage(ih->handle, EM_GETLINECOUNT, 0, 0L); - if (lin > linmax) - lin = linmax; + if (lin > linmax-1) + lin = linmax-1; lineindex = SendMessage(ih->handle, EM_LINEINDEX, (WPARAM)lin, 0L); @@ -639,8 +639,12 @@ static int winTextSetPaddingAttrib(Ihandle* ih, const char* value) iupStrToIntInt(value, &(ih->data->horiz_padding), &(ih->data->vert_padding), 'x'); ih->data->vert_padding = 0; if (ih->handle) + { SendMessage(ih->handle, EM_SETMARGINS, EC_LEFTMARGIN|EC_RIGHTMARGIN, MAKELPARAM(ih->data->horiz_padding, ih->data->horiz_padding)); - return 0; + return 0; + } + else + return 1; /* store until not mapped, when mapped will be set again */ } static int winTextSetSelectedTextAttrib(Ihandle* ih, const char* value) @@ -713,8 +717,11 @@ static int winTextSetNCAttrib(Ihandle* ih, const char* value) SendMessage(ih->handle, EM_EXLIMITTEXT, 0, ih->data->nc); /* so it can be larger than 64k */ else SendMessage(ih->handle, EM_LIMITTEXT, ih->data->nc, 0L); + + return 0; } - return 0; + else + return 1; /* store until not mapped, when mapped will be set again */ } static int winTextSetSelectionAttrib(Ihandle* ih, const char* value) @@ -845,7 +852,7 @@ static char* winTextGetSelectionPosAttrib(Ihandle* ih) static int winTextSetInsertAttrib(Ihandle* ih, const char* value) { - if (!ih->handle) /* do not store the action before map */ + if (!ih->handle) /* do not do the action before map */ return 0; if (value) { @@ -867,9 +874,9 @@ static int winTextSetInsertAttrib(Ihandle* ih, const char* value) static int winTextSetAppendAttrib(Ihandle* ih, const char* value) { - int len; + int pos; char* str; - if (!ih->handle) /* do not store the action before map */ + if (!ih->handle) /* do not do the action before map */ return 0; if (!value) value = ""; str = (char*)value; @@ -881,9 +888,9 @@ static int winTextSetAppendAttrib(Ihandle* ih, const char* value) str = iupStrToDos(str); } - len = GetWindowTextLength(ih->handle)+1; - SendMessage(ih->handle, EM_SETSEL, (WPARAM)len, (LPARAM)len); - if (ih->data->is_multiline && ih->data->append_newline) + pos = GetWindowTextLength(ih->handle)+1; + SendMessage(ih->handle, EM_SETSEL, (WPARAM)pos, (LPARAM)pos); + if (ih->data->is_multiline && ih->data->append_newline && pos!=1) { if (ih->data->has_formatting) SendMessage(ih->handle, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)"\r"); @@ -920,7 +927,7 @@ static int winTextSetTabSizeAttrib(Ihandle* ih, const char* value) iupStrToInt(value, &tabsize); tabsize *= 4; SendMessage(ih->handle, EM_SETTABSTOPS, (WPARAM)1L, (LPARAM)&tabsize); - iupdrvDisplayRedraw(ih); + iupdrvRedrawNow(ih); return 1; } @@ -1120,6 +1127,7 @@ static int winTextSetBgColorAttrib(Ihandle *ih, const char *value) SendMessage(ih->handle, EM_SETBKGNDCOLOR, 0, (LPARAM)color); } } + iupdrvPostRedraw(ih); return 1; } @@ -1529,15 +1537,27 @@ static int winTextProc(Ihandle* ih, UINT msg, WPARAM wp, LPARAM lp, LRESULT *res ret = iupwinBaseProc(ih, msg, wp, lp, result); if (ret) { + iupAttribSetStr(ih, "_IUPWIN_IGNORE_CHAR", "1"); *result = 0; return 1; } + else + iupAttribSetStr(ih, "_IUPWIN_IGNORE_CHAR", NULL); } switch (msg) { case WM_CHAR: { + /* even aborting WM_KEYDOWN, a WM_CHAR will be sent, so ignore it also */ + /* if a dialog was shown, the loop will be processed, so ignore out of focus WM_CHAR messages */ + if (GetFocus() != ih->handle || iupAttribGet(ih, "_IUPWIN_IGNORE_CHAR")) + { + iupAttribSetStr(ih, "_IUPWIN_IGNORE_CHAR", NULL); + *result = 0; + return 1; + } + if ((char)wp == '\b') { if (!winTextCallActionCb(ih, NULL, 0, -1)) @@ -1736,7 +1756,7 @@ static int winTextProc(Ihandle* ih, UINT msg, WPARAM wp, LPARAM lp, LRESULT *res static void winTextCreateSpin(Ihandle* ih) { HWND hSpin; - DWORD dwStyle = WS_CHILD|UDS_ARROWKEYS|UDS_HOTTRACK|UDS_NOTHOUSANDS; + DWORD dwStyle = WS_CHILD|WS_CLIPSIBLINGS|UDS_ARROWKEYS|UDS_HOTTRACK|UDS_NOTHOUSANDS; int serial = iupDialogGetChildId(ih); if (iupStrEqualNoCase(iupAttribGetStr(ih, "SPINALIGN"), "LEFT")) @@ -1826,7 +1846,7 @@ static void winTextLayoutUpdateMethod(Ihandle* ih) static int winTextMapMethod(Ihandle* ih) { - DWORD dwStyle = WS_CHILD, + DWORD dwStyle = WS_CHILD|WS_CLIPSIBLINGS, dwExStyle = 0; char* winclass = "EDIT", *value; @@ -1873,7 +1893,7 @@ static int winTextMapMethod(Ihandle* ih) } else { - dwStyle |= ES_AUTOHSCROLL|ES_NOHIDESEL; + dwStyle |= ES_AUTOHSCROLL; if (iupAttribGetBoolean(ih, "PASSWORD")) dwStyle |= ES_PASSWORD; @@ -1950,8 +1970,8 @@ void iupdrvTextInitClass(Iclass* ic) iupClassRegisterAttribute(ic, "STANDARDFONT", NULL, winTextSetStandardFontAttrib, IUPAF_SAMEASSYSTEM, "DEFAULTFONT", IUPAF_NOT_MAPPED); /* Overwrite Visual */ - iupClassRegisterAttribute(ic, "BGCOLOR", NULL, winTextSetBgColorAttrib, IUPAF_SAMEASSYSTEM, "TXTBGCOLOR", IUPAF_NOT_MAPPED); - iupClassRegisterAttribute(ic, "VISIBLE", iupBaseGetVisibleAttrib, winTextSetVisibleAttrib, IUPAF_SAMEASSYSTEM, "YES", IUPAF_NO_INHERIT); + iupClassRegisterAttribute(ic, "BGCOLOR", NULL, winTextSetBgColorAttrib, IUPAF_SAMEASSYSTEM, "TXTBGCOLOR", IUPAF_DEFAULT); + iupClassRegisterAttribute(ic, "VISIBLE", iupBaseGetVisibleAttrib, winTextSetVisibleAttrib, "YES", "NO", IUPAF_DEFAULT); /* Special */ iupClassRegisterAttribute(ic, "FGCOLOR", NULL, NULL, IUPAF_SAMEASSYSTEM, "TXTFGCOLOR", IUPAF_NOT_MAPPED); /* usually black */ |