1480,1500d1479 < % JPH < % The class is WAY down there... (after the SimPP comments!) < Ref(JPHPopupMenu) PROCEDURE JPHMakePopupMenu( choices, default ); < Text choices, default; < BEGIN < Ref(JPHPopupMenu) wnd; < < wnd :- New JPHPopupMenu( THIS XWindow ); < wnd.SetMenu( choices, default ); < wnd.PlaceAfter( LastSubwindow ); < wnd.show; < JPHMakePopupMenu :- wnd; < END; < < ref(CheckBox) PROCEDURE MakeCheckBox( Temp ); < TEXT Temp; < MakeCheckBox :- NEW CheckBox(THIS XWindow) < .SetText( Temp ) < .PlaceAfter(LastSubwindow) < .Show; < 1567,1629d1545 < < % Replace the Make*ItemWindow currently present ---JPH < REF(ItemWindow) PROCEDURE PlaceItemWindow (Temp); < REF(ItemWindow) Temp; < PlaceItemWindow :- Temp.PlaceAfter(LastSubwindow) < .AllowInput < .Show; < < Ref(TextItemWindow) PROCEDURE JPHMakeTextItem(lb, nc); < TEXT lb; < INTEGER nc; < JPHMakeTextItem :- PlaceItemWindow(NEW TextItemWindow(THIS XWindow)) < .SetLabel(lb) < .SetMaxChars(nc); < < Ref(IntItemWindow) PROCEDURE JPHMakeIntItem(lb, nc); < TEXT lb; < INTEGER nc; < JPHMakeIntItem :- PlaceItemWindow(NEW IntItemWindow(THIS XWindow)) < .SetLabel(lb) < .SetMaxChars(nc); < < REF(RealItemWindow) PROCEDURE JPHMakeRealItem(lb, nc); < TEXT lb; < INTEGER nc; < BEGIN < ! REF(InputWindow) temp; < ! Temp :-; < JPHMakeRealItem :- PlaceItemWindow(NEW RealItemWindow(THIS XWindow)) < .SetLabel(lb) < .SetMaxChars(nc); < < !to add standard in WT (class RealItemWindow); < !therefore eliminating need for Temp; < ! Temp.LeftJustify; !just did may 28th; < END; < < REF(CharItemWindow) PROCEDURE JPHMakeCharItem(lb); < TEXT lb; < JPHMakeCharItem :- PlaceItemWindow(NEW CharItemWindow(THIS XWindow)) < .SetLabel(lb); < < REF(BoolItemWindow) PROCEDURE JPHMakeBoolItem(lb); < TEXT lb; < JPHMakeBoolItem :- PlaceItemWindow(NEW BoolItemWindow(THIS XWindow)) < .SetLabel(lb); < < REF(MenuButton) PROCEDURE JPHMakeMenuButton(lb, choices, default); < TEXT lb, choices, default; < BEGIN < REF(MenuButton) Temp; < Temp :- NEW MenuButton(THIS Xwindow, ""); < Temp.PlaceAfter(LastSubwindow); < Temp.SetLabel(lb); < Temp.SetMenu(choices, default); < Temp.Show; < JPHMakeMenuButton :- Temp; < END; < % END of replace; < < < < 2487,2501c2403 < % JPH < inspect This XWindow WHEN ItemWindow do < if Mapped then EraseCurrentLabel; !Erases existing label if label there is; < < INSPECT This XWindow < WHEN SubWindow do < IF Current_Label =/= notext then < Current_MinX := Max(MinX, parent.DepthBorder + sw_gap + label_width) < ELSE < Current_MinX := Max(-1, MinX) < !This is to prevent labels from getting out of the window; < OTHERWISE < current_minx := Max(0, minx); < !Just to be certain, because it shouldn't pass through here; < --- > current_minx := minx; 2503,2504d2404 < < 2511,2513d2410 < < % JPH < inspect This XWindow WHEN ItemWindow do if Mapped then ShowCurrentLabel; 2835c2732 < Integer !x, y, JPH; iang1, iang2; --- > Integer iang1, iang2; 3084,3110d2980 < % JPH < Ref(XWindow) PROCEDURE EraseText(x, y, t); < Integer x, y; < Text t; < EraseText :- ClearRectangle(x, y-font_ascent, width_of_text(t), font_ascent+font_descent); < < % JPH < Ref(XWindow) PROCEDURE EraseTextPos( x, y, t, hpos, vpos ); < Integer x, y; < Text t; < Integer hpos, vpos; < BEGIN < Integer tx, ty; < < tx := x-( IF hpos = CenterPos THEN < width_of_text( t )//2 < ELSE IF hpos = RightPos THEN < width_of_text( t ) < ELSE 0 ); < ty := y +( IF vpos = CenterPos THEN < ( font_ascent-font_descent )//2 < ELSE IF vpos = TopPos THEN font_ascent < ELSE-font_descent ); < < EraseTextPos :- EraseText( tx, ty, t ); < END; < 4496,4501d4365 < % JPH < PROCEDURE EraseCurrentLabel; < IF current_label =/= notext THEN < parent.EraseTextPos( min_x-parent.width_of_text( "x" ), min_y + height// < 2, current_label, RightPos, CenterPos ); < 5438,5440c5302 < % Align is usually left ---JPH < ! CenterJustify; < LeftJustify; --- > CenterJustify; 5496c5358 < % LeftJustify; Not needed anymore ---JPH --- > LeftJustify; 5801c5663 < % LeftJustify; not needed anymore ---JPH --- > LeftJustify; 6047c5909 < % answer_window.LeftJustify; !JPH --> It should be defined already; --- > answer_window.LeftJustify; 7575c7437 < sysout.outtext("SL1="&int_as_text(SelLine1)&":SC1="&int_as_text(SelCol1)&":"); sysout.outimage; --- > 7759d7620 < 8056,8057c7917 < !invert_line_nr := 0; < invert_line_nr := 1; --- > invert_line_nr := 0; 8068,8070d7927 < % JPH But this adds an empty line :( otherwise, bug when click 1st! < % InitPutLine(""); < 9122c8979 < Integer nblines; !nombre d'items; --- > Integer nblines; !nombre d items; 9156,9160c9013,9014 < % JPH added +&- for checking < % Ideally, it should have variables instead of hard-coded values... < % but I couldn't find the vars associated with text-only height < posx := posx-NoticeWindow.borderwidth + XNotice-1; < posy := posy-NoticeWindow.borderwidth + YNotice+3; --- > posx := posx-NoticeWindow.borderwidth + XNotice; > posy := posy-NoticeWindow.borderwidth + YNotice; 9163c9017 < !Verifier si la fenetre ne depasse pas l'ecran; --- > !Verifier si la fenetre ne depasse pas l ecran; 9285c9139 < % show; not sure it's needed ---JPH --- > show; 9321c9175 < !Text is LeftCentered and a triangle is drawn on the right; --- > !Text is LeftCentered ans a triangle is drawn on the right; 9330a9185 > 9350,9353c9205,9207 < % JPH < SetSize( max (width, width_of_text(heading_and_key)) , max(height, font_height + 6) ); < ! SetSize(( max( width, width_of_text( heading_and_key ) ) ), max( height, < head_height + font_height) ); --- > > SetSize(( max( width, width_of_text( heading_and_key ) ) ), max( height, > head_height + font_height ) ); 9385,9390d9238 < % JPH < Text PROCEDURE CurrentLabel; < CurrentLabel :- IF iselect > 0 THEN < Cle( iselect ) < ELSE Notext; < 10352,10615d10199 < < < % JPH Added classes!!! < < < % ******************************************** < % ******************************************** < % ******* ******* < % ******* J P H P o p u p M e n u ******* < % ******* ******* < % ******************************************** < % ******************************************** < < % JPHMakePopupMenu is with the other MakeBlablabl < < subwindow CLASS JPHPopupMenu; < BEGIN < TEXT ARRAY Etiq(1:25), !The labels; < Tags(1:25); !The associated tags; < < INTEGER CurSel, !The current selection; < DefSel, !The default value; < NumElems, !The number of elements in the menu; < TheWidth, !Width of the largest text; < TheHeight; !Height of a line; < < REF(PopupWindow) ThePopup; !The actual window that pops-up; < < TEXT PROCEDURE Window_Kind; < Window_Kind :- "JPHPopupMenu"; < < PROCEDURE SetMenu(choices, default); < TEXT choices, default; < BEGIN < TEXT ARRAY CA (1:25); < CHARACTER C; < INTEGER i; < < C := Choices.Sub(1,1).GetChar; !This defines the separator; < NumElems := Splitc(from(Choices, 2), C, CA); < DefSel := 1; < < FOR i := 1 STEP 1 UNTIL NumElems DO < BEGIN < Tags(i) :- scanto(CA(i), ':'); < Etiq(i) :- rest(CA(i)); < IF Etiq(i) == NOTEXT THEN !no tag specified; < BEGIN < TEXT tmp; < Etiq(i) :- Tags(i); !we take the first word from; < tmp :- Copy(Tags(i)); !the label in lowercase; < Tags(i) :- LowCase(GetWord(tmp)); < END; < IF Tags(i) = Default THEN !Setting the default value; < DefSel := i; < TheWidth := Max( TheWidth, Width_of_Text(Etiq(i)) + 30); < END; < CurSel := DefSel; < Redraw; < !Refresh; !was there b4... doesn't seem useful at all; < END --- SetMenu ---; < < PROCEDURE Redraw; < BEGIN < SetSize(TheWidth, TheHeight); < ClearRectangle(0, 0, width, height); < DrawTextPos(8, height//2, Etiq(CurSel), LeftPos, CenterPos); < DrawBorder; < DrawTriangle; < < END --- Redraw ---; < < PROCEDURE DrawBorder; < BEGIN < REF(XGraphicalContext) SavedGC; !to save line width; < SavedGC :- CopyGC; < SetLineWidth(2); < DrawLine( width, 0, width, height ); < DrawLine( 0, height, width, height ); < RestoreGC(SavedGC); < END --- DrawBorder ---; < < < PROCEDURE DrawTriangle; < BEGIN < Integer Array x_coord( 1: 3 ), y_coord( 1: 3 ); < < x_coord( 1 ) := width-4; < x_coord( 2 ) := width-15; < x_coord( 3 ) := width-10; < y_coord( 1 ) := height/2-3; < y_coord( 2 ) := y_coord( 1 ); < y_coord( 3 ) := height/2+3; < < FillPolygon( x_coord, y_coord, 3 ); < END --- DrawTriangle ---; < < PROCEDURE EraseTriangle; < BEGIN < Integer Array x_coord( 1: 3 ), y_coord( 1: 3 ); < REF(XgraphicalContext) SavedGC; < < x_coord( 1 ) := width-4; < x_coord( 2 ) := width-15; < x_coord( 3 ) := width-10; < y_coord( 1 ) := height/2-3; < y_coord( 2 ) := y_coord( 1 ); < y_coord( 3 ) := height/2+3; < < SavedGC :- CopyGC; < SetWhiteOnBlack; < FillPolygon( x_coord, y_coord, 3 ); < RestoreGC( SavedGC ); < END --- EraseTriangle ---; < < PROCEDURE Handle_Button_Down(b); < INTEGER b; < BEGIN < INTEGER i, < X_abs, Y_abs; !Absolute coordinates for the PopupWnd; < FindAbsolutePos(X_abs, Y_abs); < ThePopup :- NEW PopupWindow("Popup", TopWindow); < ThePopup.SetSize(TheWidth, NumElems*TheHeight) < .PlaceAt(X_abs-1, Y_abs-(CurSel-1)*TheHeight-1) < .Show; < FOR i := 1 STEP 1 UNTIL NumElems DO < ThePopup.DrawTextPos(8, (i-0.5)*TheHeight, Etiq(i), < LeftPos, CenterPos); < InvertSelection(DefSel); < END; < < PROCEDURE Handle_Button_Up(b); < INTEGER b; < BEGIN < ThePopup.Destroy; < ThePopup :- NONE; < IF 0 < CurSel AND CurSel <= NumElems THEN DefSel := CurSel; < CurSel := DefSel; < Redraw; < END; < < PROCEDURE Handle_Pointer_Motion(x, y); < INTEGER x, y; < IF ThePopup =/= NONE THEN < BEGIN < IF 0 < X AND X < TheWidth THEN < BEGIN < INTEGER ChoiceOn; !the choice onto which the cursor is; < ChoiceOn := Y//TheHeight + (IF Y < 0 THEN -1 ELSE 0)+DefSel; < IF ChoiceOn <> CurSel THEN < BEGIN < InvertSelection(CurSel); < CurSel := ChoiceOn; < InvertSelection(CurSel); < END; < END < ELSE IF 0 < CurSel AND CurSel < NumElems THEN < BEGIN < InvertSelection(CurSel); < CurSel := 0; < END; < END; < < PROCEDURE InvertSelection(Sel); < INTEGER Sel; !The selection to invert; < ThePopup.InvertRectangle(0, TheHeight*(Sel-1), TheWidth, TheHeight); < < Text PROCEDURE CurrentChoice; < CurrentChoice :- Etiq(DefSel); < < Text PROCEDURE CurrentTag; < CurrentTag :- Tags(DefSel); < < SetDepthBorder(3); < TheHeight := Max(height, head_height + font_height + 2*DepthBorder); < Show; < Button_Sensitize; < Pointer_Motion_Sensitize; < END --- JPHPopupMenu ---; < < < < % ******************************************** < % ******************************************** < % ******* ******* < % ******* C H E C K B O X ******* < % ******* ******* < % ******************************************** < % ******************************************** < < % MakeCheckBox is with the other Makeblabla... < < Subwindow CLASS Checkbox; < BEGIN < BOOLEAN Current_Value; < TEXT Current_Label; !Will this permit the search?; < INTEGER X_Rect, Y_Rect, !The upper left origin of the box; < Size_Of_Box; < < PROCEDURE Refresh; < IF Mapped THEN < BEGIN < REF(XGraphicalContext) SavedGC; < SavedGC :- CopyGC; < ClearRectangle(0, 0, width, height); < SetLineWidth(0); < RefreshBox; < DrawTextPos(SubwindowSpacing + 1.5*Size_Of_Box, Height//2, < Current_Label, LeftPos, CenterPos); < RestoreGC(SavedGC); < END --- Refresh ---; < < REF(Checkbox) PROCEDURE RefreshBox; < BEGIN < ClearRectangle(X_Rect, Y_Rect, Size_Of_Box, Size_Of_Box); < DrawRectangle(X_Rect, Y_Rect, Size_Of_Box, Size_Of_Box); < IF Current_Value THEN BEGIN < DrawLine(X_Rect, Y_Rect, X_Rect+Size_Of_Box, Y_Rect+Size_Of_Box); < DrawLine(X_Rect+Size_Of_Box, Y_Rect, X_Rect, Y_Rect+Size_Of_Box); < END; < RefreshBox :- THIS Checkbox; < END --- RefreshBox ---; < < REF(Checkbox) PROCEDURE SetText(t); TEXT t; < BEGIN < Current_Label :- t; < Size_Of_Box := Font_Height - 5; < SetSize(Width_Of_Text(Current_Label) + 1.5*Size_Of_Box < + 2*SubwindowSpacing, < Font_Height+2*SubwindowSpacing); < X_Rect := SubWindowSpacing; < Y_Rect := (Height - Size_Of_Box)//2; !Centered; < Refresh; < SetText :- THIS Checkbox; < END --- SetText ---; < < REF(Checkbox) PROCEDURE SetBox; < BEGIN < Current_Value := TRUE; < Refresh; < SetBox :- THIS Checkbox; < END; < < REF(Checkbox) PROCEDURE UnSetBox; < BEGIN < Current_Value := FALSE; < Refresh; < UnSetBox :- THIS Checkbox; < END; < < PROCEDURE Handle_Button_Click(b); INTEGER b; < BEGIN < Current_Value := NOT Current_Value; < RefreshBox; < END; < < BOOLEAN PROCEDURE Checked; < Checked := Current_Value; < < Button_Sensitize; < SetSubwindowSpacing(3); < SetBorderWidth(0); < < END --- Checkbox Class ---;