42
42
* $Log: vibforms.c,v $
43
* Revision 6.27 2007/07/17 13:09:33 bollin
44
* If deleting a row from a TagList, and the row is the last visible row and the
45
* offscreen row is empty, remove the last offscreen row and adjust the scrollbar.
47
* Revision 6.26 2007/06/28 15:57:14 bollin
48
* Added buttons to delete interval row from location editor.
50
* Revision 6.25 2007/06/12 14:21:32 bollin
51
* Made JustSaveStringFromText extern - do not strip spaces.
53
* Revision 6.24 2007/02/01 16:31:11 bollin
54
* Use Int4 instead of Int2 in EnumAssoc functions to allow larger lists.
43
56
* Revision 6.23 2006/05/09 19:12:19 kans
44
57
* CreateTagListDialogExEx protects against row or col being > maximum allowed
2103
static Boolean RowHasValue (TagListPtr tlp, Int4 row)
2107
Boolean has_value = FALSE;
2109
if (tlp == NULL || row < 0 || row > tlp->rows - 1) {
2113
for (j = 0; j < tlp->cols; j++) {
2114
switch (tlp->types [j]) {
2116
/*case TAGLIST_PROMPT :*/
2117
if ( !TextHasNoText((TexT)GetTagListControl(tlp, row, j)) )
2120
case TAGLIST_POPUP :
2122
if (tlp->alists != NULL &&
2123
GetEnumPopup ((PopuP)GetTagListControl (tlp, row - 1, j),
2124
tlp->alists [j], &num) &&
2137
static void ShortenTagListScrollBar (TagListPtr tlp)
2140
ValNodePtr vnp, prev = NULL;
2142
if (tlp == NULL || tlp->noExtend || tlp->rows < 2) return;
2144
max = GetBarMax (tlp->bar);
2145
if (max == 0) return;
2147
val = GetValue (tlp->bar);
2149
if (val == tlp->max - 1 && !RowHasValue(tlp, tlp->rows - 1)) {
2151
CorrectBarMax (tlp->bar, tlp->max);
2152
CorrectBarPage (tlp->bar, tlp->rows - 1, tlp->rows - 1);
2153
CorrectBarMax (tlp->left_bar, tlp->max);
2154
CorrectBarPage (tlp->left_bar, tlp->rows - 1, tlp->rows - 1);
2157
while (vnp->next != NULL) {
2162
prev->next = ValNodeFreeData (prev->next);
2168
static void ClearTagListRow (ButtoN b)
2173
tlp = (TagListPtr) GetObjectExtra (b);
2175
if (tlp->ask_before_clear)
2177
if (ANS_CANCEL == Message (MSG_OKC, "Are you sure you want to clear the row?"))
2181
tlp->ask_before_clear = FALSE;
2183
for (i = 0; i < tlp->rows; i++) {
2184
if (b == tlp->clear_btns[i])
2186
for (j = 0; j < tlp->cols; j++) {
2187
switch (tlp->types[j])
2189
case TAGLIST_PROMPT:
2193
SetValue (GetTagListControl (tlp, i, j), 1);
2194
PopupTagProc (GetTagListControl (tlp, i, j));
2197
SetValue (GetTagListControl (tlp, i, j), 1);
2198
ListTagProc (GetTagListControl (tlp, i, j));
2201
SetTitle (GetTagListControl (tlp, i, j), "");
2202
TextTagProc (GetTagListControl (tlp, i, j));
2206
/* fix scroll bar max if we have just deleted the last row */
2207
if (i == tlp->rows - 1 && !tlp->noExtend) {
2208
ShortenTagListScrollBar (tlp);
2089
2216
extern DialoG CreateTagListDialogEx (GrouP h, Uint2 rows, Uint2 cols,
2090
2217
Int2 spacing, Uint2Ptr types,
2091
2218
Uint2Ptr textWidths, EnumFieldAssocPtr PNTR alists,
2092
2219
Boolean useBar, Boolean noExtend,
2093
2220
ToDialogFunc tofunc, FromDialogFunc fromfunc);
2095
extern DialoG CreateTagListDialogExEx (GrouP h, Uint2 rows, Uint2 cols,
2222
extern DialoG CreateTagListDialogEx3 (GrouP h, Uint2 rows, Uint2 cols,
2096
2223
Int2 spacing, Uint2Ptr types,
2097
2224
Uint2Ptr textWidths, Nlm_EnumFieldAssocPtr PNTR alists,
2098
2225
Boolean useBar, Boolean noExtend,
2099
2226
Nlm_ToDialogFunc tofunc, Nlm_FromDialogFunc fromfunc,
2100
2227
TaglistCallback PNTR callbacks, Pointer callback_data,
2228
Boolean useLeftBar, Boolean useClearBtns)
2104
2231
EnumFieldAssocPtr al;
2163
2291
col = (Int2) cols;
2296
tlp->ask_before_clear = TRUE;
2164
2297
g = HiddenGroup (s, -col, 0, NULL);
2165
2298
SetGroupSpacing (g, spacing, spacing);
2166
2299
for (i = 0; i < tlp->rows; i++) {
2302
clr = HiddenGroup (g, 2, 0, NULL);
2303
tlp->clear_btns[i] = PushButton (clr, "X", ClearTagListRow);
2304
SetObjectExtra (tlp->clear_btns[i], tlp, NULL);
2305
StaticPrompt (clr, "", 5, MAX (dialogTextHeight, popupMenuHeight), systemFont, 'l');
2167
2307
for (j = 0; j < tlp->cols; j++) {
2168
2308
switch (types [j]) {
2169
2309
case TAGLIST_TEXT :
2250
2390
return (DialoG) p;
2393
extern DialoG CreateTagListDialogExEx (GrouP h, Uint2 rows, Uint2 cols,
2394
Int2 spacing, Uint2Ptr types,
2395
Uint2Ptr textWidths, Nlm_EnumFieldAssocPtr PNTR alists,
2396
Boolean useBar, Boolean noExtend,
2397
Nlm_ToDialogFunc tofunc, Nlm_FromDialogFunc fromfunc,
2398
TaglistCallback PNTR callbacks, Pointer callback_data,
2401
return CreateTagListDialogEx3 (h, rows, cols, spacing, types, textWidths, alists,
2402
useBar, noExtend, tofunc, fromfunc,
2403
callbacks, callback_data, useLeftBar, FALSE);
2253
2407
extern DialoG CreateTagListDialogEx (GrouP h, Uint2 rows, Uint2 cols,
2254
2408
Int2 spacing, Uint2Ptr types,
2255
2409
Uint2Ptr textWidths, EnumFieldAssocPtr PNTR alists,