Lines Matching refs:widget

12 static void drawCDK<MIXED>Field (CDK<UPPER> *widget);
13 static int formattedSize (CDK<UPPER> *widget, <CTYPE> value);
18 * This function creates a widget.
39 CDK<UPPER> *widget = 0;
63 if ((widget = newCDKObject (CDK<UPPER>, &my_funcs)) == 0)
66 setCDK<MIXED>Box (widget, Box);
67 boxHeight = (BorderOf (widget) * 2) + 1;
69 /* *INDENT-EQLS* Set some basic values of the widget's data field. */
70 widget->label = 0;
71 widget->labelLen = 0;
72 widget->labelWin = 0;
74 widget->digits = digits;
76 highValueLen = MAXIMUM (formattedSize (widget, low),
77 formattedSize (widget, high));
89 widget->label = char2Chtype (label, &widget->labelLen, &junk);
90 boxWidth = widget->labelLen + fieldWidth + highValueLen + 2 * BorderOf (widget);
94 boxWidth = fieldWidth + highValueLen + 2 * BorderOf (widget);
98 boxWidth = setCdkTitle (ObjOf (widget), title, boxWidth);
101 boxHeight += TitleLinesOf (widget);
108 fieldWidth = (fieldWidth > (boxWidth - widget->labelLen - highValueLen - 1)
109 ? (boxWidth - widget->labelLen - highValueLen - 1)
115 /* Make the widget's window. */
116 widget->win = newwin (boxHeight, boxWidth, ypos, xpos);
119 if (widget->win == 0)
121 destroyCDKObject (widget);
125 /* Create the widget's label window. */
126 if (widget->label != 0)
128 widget->labelWin = subwin (widget->win,
129 1, widget->labelLen,
130 ypos + TitleLinesOf (widget) + BorderOf (widget),
131 xpos + horizontalAdjust + BorderOf (widget));
132 if (widget->labelWin == 0)
134 destroyCDKObject (widget);
139 /* Create the widget's data field window. */
140 widget->fieldWin = subwin (widget->win,
142 (ypos + TitleLinesOf (widget) + BorderOf (widget)),
144 + widget->labelLen
146 + BorderOf (widget)));
147 if (widget->fieldWin == 0)
149 destroyCDKObject (widget);
152 keypad (widget->fieldWin, TRUE);
153 keypad (widget->win, TRUE);
155 /* *INDENT-EQLS* Create the widget's data field. */
156 ScreenOf (widget) = cdkscreen;
157 widget->parent = cdkscreen->window;
158 widget->shadowWin = 0;
159 widget->boxWidth = boxWidth;
160 widget->boxHeight = boxHeight;
161 widget->fieldWidth = fieldWidth - 1;
162 widget->filler = filler;
163 widget->low = low;
164 widget->high = high;
165 widget->current = start;
166 widget->inc = inc;
167 widget->fastinc = fastInc;
168 initExitType (widget);
169 ObjOf (widget)->acceptsFocus = TRUE;
170 ObjOf (widget)->inputWindow = widget->win;
171 widget->shadow = shadow;
176 widget->current = low;
182 widget->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1);
183 if (widget->shadowWin == 0)
185 destroyCDKObject (widget);
193 widget,
198 registerCDKObject (cdkscreen, v<UPPER>, widget);
200 return (widget);
204 * This allows the person to use the widget's data field.
206 <CTYPE> activateCDK<MIXED> (CDK<UPPER> *widget, chtype *actions)
210 /* Draw the widget. */
211 drawCDK<MIXED> (widget, ObjOf (widget)->box);
220 input = (chtype)getchCDKObject (ObjOf (widget), &functionKey);
222 /* Inject the character into the widget. */
223 ret = (<CTYPE>)injectCDK<MIXED> (widget, input);
224 if (widget->exitType != vEARLY_EXIT)
238 ret = (<CTYPE>)injectCDK<MIXED> (widget, actions[x]);
239 if (widget->exitType != vEARLY_EXIT)
247 setExitType (widget, 0);
254 static void limitCurrentValue (CDK<UPPER> *widget)
256 if (widget->current < widget->low)
258 widget->current = widget->low;
261 else if (widget->current > widget->high)
263 widget->current = widget->high;
271 static int moveToEditPosition (CDK<UPPER> *widget, int newPosition)
273 return wmove (widget->fieldWin,
275 widget->fieldWidth +
276 formattedSize (widget, widget->current) -
284 static int validEditPosition (CDK<UPPER> *widget, int newPosition)
287 if (newPosition <= 0 || newPosition >= widget->fieldWidth)
289 if (moveToEditPosition (widget, newPosition) == ERR)
291 ch = winch (widget->fieldWin);
297 if (moveToEditPosition (widget, newPosition - 1) == ERR)
299 ch = winch (widget->fieldWin);
310 static void setEditPosition (CDK<UPPER> *widget, int newPosition)
318 widget->fieldEdit = newPosition;
320 else if (validEditPosition (widget, newPosition))
322 widget->fieldEdit = newPosition;
353 static bool performEdit (CDK<UPPER> *widget, chtype input)
357 int base = widget->fieldWidth;
358 int need = formattedSize (widget, widget->current);
362 int col = need - widget->fieldEdit;
380 wmove (widget->fieldWin, 0, base);
381 winnstr (widget->fieldWin, temp, need);
402 && value >= widget->low
403 && value <= widget->high)
405 setCDK<MIXED>Value (widget, (<CTYPE>)value);
417 * This function injects a single character into the widget.
421 CDK<UPPER> *widget = (CDK<UPPER> *)object;
427 setExitType (widget, 0);
430 drawCDK<MIXED>Field (widget);
433 if (PreProcessFuncOf (widget) != 0)
436 ppReturn = PreProcessFuncOf (widget) (v<UPPER>,
437 widget,
438 PreProcessDataOf (widget),
446 if (checkCDKObjectBind (v<UPPER>, widget, input) != 0)
448 checkEarlyExit (widget);
456 setEditPosition (widget, widget->fieldEdit + 1);
460 setEditPosition (widget, widget->fieldEdit - 1);
464 Decrement (widget->current, widget->inc);
468 Increment (widget->current, widget->inc);
472 Increment (widget->current, widget->fastinc);
476 Decrement (widget->current, widget->fastinc);
480 widget->current = widget->low;
484 widget->current = widget->high;
489 setExitType (widget, input);
490 ret = (widget->current);
495 setExitType (widget, input);
500 setExitType (widget, input);
505 eraseCDKScreen (ScreenOf (widget));
506 refreshCDKScreen (ScreenOf (widget));
510 if (widget->fieldEdit)
512 if (!performEdit (widget, input))
540 limitCurrentValue (widget);
543 if (!complete && (PostProcessFuncOf (widget) != 0))
545 PostProcessFuncOf (widget) (v<UPPER>,
546 widget,
547 PostProcessDataOf (widget),
554 drawCDK<MIXED>Field (widget);
555 setExitType (widget, 0);
558 ResultOf (widget).value<DTYPE> = ret;
563 * This moves the widget's data field to the given location.
572 CDK<UPPER> *widget = (CDK<UPPER> *)object;
573 int currentX = getbegx (widget->win);
574 int currentY = getbegy (widget->win);
586 xpos = getbegx (widget->win) + xplace;
587 ypos = getbegy (widget->win) + yplace;
591 alignxy (WindowOf (widget), &xpos, &ypos, widget->boxWidth, widget->boxHeight);
598 moveCursesWindow (widget->win, -xdiff, -ydiff);
599 moveCursesWindow (widget->labelWin, -xdiff, -ydiff);
600 moveCursesWindow (widget->fieldWin, -xdiff, -ydiff);
601 moveCursesWindow (widget->shadowWin, -xdiff, -ydiff);
604 refreshCDKWindow (WindowOf (widget));
609 drawCDK<MIXED> (widget, ObjOf (widget)->box);
614 * This function draws the widget.
618 CDK<UPPER> *widget = (CDK<UPPER> *)object;
621 if (widget->shadowWin != 0)
623 drawShadow (widget->shadowWin);
626 /* Box the widget if asked. */
629 drawObjBox (widget->win, ObjOf (widget));
632 drawCdkTitle (widget->win, object);
635 if (widget->labelWin != 0)
637 writeChtype (widget->labelWin, 0, 0,
638 widget->label,
640 widget->labelLen);
641 wrefresh (widget->labelWin);
643 wrefresh (widget->win);
646 drawCDK<MIXED>Field (widget);
650 * This draws the widget.
652 static void drawCDK<MIXED>Field (CDK<UPPER> *widget)
656 double step = ((double)widget->fieldWidth /
657 (double)(widget->high - widget->low));
660 fillerCharacters = (int)((widget->current - widget->low) * step);
662 werase (widget->fieldWin);
667 (void)mvwaddch (widget->fieldWin, 0, x, widget->filler);
674 int digits = MINIMUM (widget->digits, 30);
676 sprintf (temp, format, widget->current);
680 sprintf (temp, "%<PRINT>", widget->current);
682 writeCharAttrib (widget->fieldWin,
683 widget->fieldWidth,
691 moveToEditPosition (widget, widget->fieldEdit);
692 wrefresh (widget->fieldWin);
696 * This sets the background attribute of the widget.
702 CDK<UPPER> *widget = (CDK<UPPER> *)object;
705 wbkgd (widget->win, attrib);
706 wbkgd (widget->fieldWin, attrib);
707 if (widget->labelWin != 0)
709 wbkgd (widget->labelWin, attrib);
715 * This function destroys the widget.
721 CDK<UPPER> *widget = (CDK<UPPER> *)object;
724 freeChtype (widget->label);
727 deleteCursesWindow (widget->fieldWin);
728 deleteCursesWindow (widget->labelWin);
729 deleteCursesWindow (widget->shadowWin);
730 deleteCursesWindow (widget->win);
733 cleanCDKObjectBindings (v<UPPER>, widget);
736 unregisterCDKObject (v<UPPER>, widget);
741 * This function erases the widget from the screen.
747 CDK<UPPER> *widget = (CDK<UPPER> *)object;
749 eraseCursesWindow (widget->labelWin);
750 eraseCursesWindow (widget->fieldWin);
751 eraseCursesWindow (widget->win);
752 eraseCursesWindow (widget->shadowWin);
756 static int formattedSize (CDK<UPPER> *widget, <CTYPE> value)
761 int digits = MINIMUM (widget->digits, 30);
766 (void)widget;
773 * This function sets the low/high/current values of the widget.
775 void setCDK<MIXED> (CDK<UPPER> *widget,
781 setCDK<MIXED>LowHigh (widget, low, high);
782 setCDK<MIXED>Value (widget, value);
783 setCDK<MIXED>Box (widget, Box);
790 void setCDK<MIXED>Digits (CDK<UPPER> *widget, int digits)
792 widget->digits = MAXIMUM (0, digits);
795 int getCDK<MIXED>Digits (CDK<UPPER> *widget)
797 return widget->digits;
802 * This sets the widget's value.
804 void setCDK<MIXED>Value (CDK<UPPER> *widget, <CTYPE> value)
806 widget->current = value;
807 limitCurrentValue (widget);
809 <CTYPE> getCDK<MIXED>Value (CDK<UPPER> *widget)
811 return widget->current;
815 * This function sets the low/high values of the widget.
817 void setCDK<MIXED>LowHigh (CDK<UPPER> *widget, <CTYPE> low, <CTYPE> high)
822 widget->low = low;
823 widget->high = high;
827 widget->low = high;
828 widget->high = low;
832 limitCurrentValue (widget);
834 <CTYPE> getCDK<MIXED>LowValue (CDK<UPPER> *widget)
836 return widget->low;
838 <CTYPE> getCDK<MIXED>HighValue (CDK<UPPER> *widget)
840 return widget->high;
844 * This sets the widget's box attribute.
846 void setCDK<MIXED>Box (CDK<UPPER> *widget, boolean Box)
848 ObjOf (widget)->box = Box;
849 ObjOf (widget)->borderSize = Box ? 1 : 0;
851 boolean getCDK<MIXED>Box (CDK<UPPER> *widget)
853 return ObjOf (widget)->box;
858 CDK<UPPER> *widget = (CDK<UPPER> *)object;
860 drawCDK<MIXED> (widget, ObjOf (widget)->box);
865 CDK<UPPER> *widget = (CDK<UPPER> *)object;
867 drawCDK<MIXED> (widget, ObjOf (widget)->box);