From eed0eb6a476d54ce19aeff137984aa981d9e3976 Mon Sep 17 00:00:00 2001 From: Pixel Date: Tue, 15 Jun 2010 00:59:57 -0700 Subject: Upgrading to iup 3.1 --- iup/src/win/iupwin_list.c | 55 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 9 deletions(-) (limited to 'iup/src/win/iupwin_list.c') diff --git a/iup/src/win/iupwin_list.c b/iup/src/win/iupwin_list.c index 8fdadb6..cb510b5 100755 --- a/iup/src/win/iupwin_list.c +++ b/iup/src/win/iupwin_list.c @@ -154,6 +154,8 @@ void iupdrvListInsertItem(Ihandle* ih, int pos, const char* value) SendMessage(ih->handle, WIN_INSERTSTRING(ih), pos, (LPARAM)value); SendMessage(ih->handle, WIN_SETITEMDATA(ih), pos, (LPARAM)iupdrvFontGetStringWidth(ih, value)); winListUpdateScrollWidth(ih); + + iupListUpdateOldValue(ih, pos, 0); } void iupdrvListRemoveItem(Ihandle* ih, int pos) @@ -164,8 +166,14 @@ void iupdrvListRemoveItem(Ihandle* ih, int pos) int curpos = SendMessage(ih->handle, WIN_GETCURSEL(ih), 0, 0); if (pos == curpos) { - if (curpos > 0) curpos--; - else curpos++; + if (curpos > 0) + curpos--; + else + { + curpos=1; + if (iupdrvListGetCount(ih)==1) + curpos = -1; /* remove the selection */ + } SendMessage(ih->handle, WIN_SETCURSEL(ih), curpos, 0); } @@ -173,6 +181,8 @@ void iupdrvListRemoveItem(Ihandle* ih, int pos) SendMessage(ih->handle, WIN_DELETESTRING(ih), pos, 0L); winListUpdateScrollWidth(ih); + + iupListUpdateOldValue(ih, pos, 1); } void iupdrvListRemoveAllItems(Ihandle* ih) @@ -220,18 +230,29 @@ static void winListUpdateItemWidth(Ihandle* ih) } } +static int winListSetBgColorAttrib(Ihandle *ih, const char *value) +{ + (void)value; + if (ih->handle) + iupdrvPostRedraw(ih); + return 1; +} + static int winListSetStandardFontAttrib(Ihandle* ih, const char* value) { iupdrvSetStandardFontAttrib(ih, value); - winListUpdateItemWidth(ih); - winListUpdateScrollWidth(ih); + if (ih->handle) + { + winListUpdateItemWidth(ih); + winListUpdateScrollWidth(ih); + } return 1; } static char* winListGetIdValueAttrib(Ihandle* ih, const char* name_id) { int pos = iupListGetPos(ih, name_id); - if (pos != -1) + if (pos >= 0) { int len = SendMessage(ih->handle, WIN_GETTEXTLEN(ih), (WPARAM)pos, 0); char* str = iupStrGetMemory(len+1); @@ -514,8 +535,10 @@ static int winListSetNCAttrib(Ihandle* ih, const char* value) { HWND cbedit = (HWND)iupAttribGet(ih, "_IUPWIN_EDITBOX"); SendMessage(cbedit, 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 winListSetSelectionAttrib(Ihandle* ih, const char* value) @@ -995,13 +1018,27 @@ static int winListEditProc(Ihandle* ih, HWND cbedit, UINT msg, WPARAM wp, LPARAM if (msg==WM_KEYDOWN) /* process K_ANY before text callbacks */ { ret = iupwinBaseProc(ih, msg, wp, lp, result); - if (ret) return 1; + if (ret) + { + iupAttribSetStr(ih, "_IUPWIN_IGNORE_CHAR", "1"); + *result = 0; + return 1; + } + else + iupAttribSetStr(ih, "_IUPWIN_IGNORE_CHAR", NULL); } switch (msg) { case WM_CHAR: { + if (iupAttribGet(ih, "_IUPWIN_IGNORE_CHAR")) + { + iupAttribSetStr(ih, "_IUPWIN_IGNORE_CHAR", NULL); + *result = 0; + return 1; + } + if ((char)wp == '\b') { if (!winListCallEditCb(ih, cbedit, NULL, 0, -1)) @@ -1301,7 +1338,7 @@ static void winListLayoutUpdateMethod(Ihandle *ih) static int winListMapMethod(Ihandle* ih) { char* class_name; - DWORD dwStyle = WS_CHILD, + DWORD dwStyle = WS_CHILD|WS_CLIPSIBLINGS, dwExStyle = WS_EX_CLIENTEDGE; if (!ih->parent) @@ -1426,7 +1463,7 @@ void iupdrvListInitClass(Iclass* ic) iupClassRegisterAttribute(ic, "STANDARDFONT", NULL, winListSetStandardFontAttrib, IUPAF_SAMEASSYSTEM, "DEFAULTFONT", IUPAF_NOT_MAPPED); /* Visual */ - iupClassRegisterAttribute(ic, "BGCOLOR", NULL, NULL, IUPAF_SAMEASSYSTEM, "TXTBGCOLOR", IUPAF_NOT_MAPPED); + iupClassRegisterAttribute(ic, "BGCOLOR", NULL, winListSetBgColorAttrib, IUPAF_SAMEASSYSTEM, "TXTBGCOLOR", IUPAF_NOT_MAPPED); /* Special */ iupClassRegisterAttribute(ic, "FGCOLOR", NULL, NULL, IUPAF_SAMEASSYSTEM, "TXTFGCOLOR", IUPAF_NOT_MAPPED); -- cgit v1.2.3