[comp.lang.pascal] TBackground in TV

sms16@po.CWRU.Edu (Steven M. Schwartz) (04/08/91)

	Netters,
		Does anyone out there know the proper procedure or function
        call for deleting the grid background on a TurboVision skeleton.  I
 	have tried deciphering the documentation much to my dismay.  I would 
	like to set the background of the skeleton (not one of the windows)
	to a palette color but GetPalette and GetColor have no effect on the 
	background, just the event background.  This does not seem like a
        more "efficient" way to program, just a pain in the neck.  Thanks.
					               Steve

Robert_Salesas@mindlink.UUCP (Robert Salesas) (04/08/91)

The following should help you out...

uses Objects,Menus,Drivers,Views,App,Gadgets;

type

PMyApp = ^TMyApp;
TMyApp = object(TApplication)
  constructor Init;
  procedure InitMenuBar;virtual;
  procedure InitStatusLine;virtual;
  Function GetPalette : PPalette; Virtual;
 end;

{ set up string array to hold palettes where we can fool with 'em }
Var Palette : Array [0..2] of String;

constructor TMyApp.Init;
var
 R : TRect;
begin

 { steal the default palettes into string variable array }
 Palette[0] := CColor;     { set up palettes BEFORE initting App }
 Palette[1] := CBlackWhite;
 Palette[2] := CMonochrome;
 { now change the background color in the "color" palette     }
 Palette[0,1] := #$27;     { <- change 1st entry in palette 0 }

 TApplication.Init;

 { you can also change the palette "pattern" like this: }
 { remove the comment delimiters and recompile!         }

 Desktop^.Background^.Pattern := #206;
 Desktop^.Redraw;


end;

procedure TMyApp.InitMenuBar;
var
 R : TRect;
begin
  GetExtent(R);
  R.B.Y := R.A.Y + 1;
  MenuBar := New(PMenuBar, Init(R, NewMenu(
              NewSubMenu('~T~est', hcNoContext, NewMenu(
                NewItem('~E~xit','Alt-X',kbAltX,cmQuit,hcNoContext,
              nil)),nil))));
end;

procedure TMyApp.InitStatusLine;
var
 R : TRect;
begin
 GetExtent(R);
 R.A.Y := R.B.Y - 1;
 StatusLine :=  New(PStatusLine,Init(R,
                  NewStatusDef(0,$FFFF,
                    NewStatusKey('~A~lt-X Quit',kbAltX,cmQuit,
                nil),nil)));
end;


{ index into the correct palette }
Function TMyApp.GetPalette : PPalette;
Begin
  GetPalette := @Palette[AppPalette];
End;

var
 MyApp: TMyApp;

begin
 MyApp.Init;
 MyApp.Run;
 MyApp.Done;
end.



The method shown here for altering the palette is NOT the greatest, but
it works.  I got this of CIS, it's not what I do, if you wnat I could
put something together.  This should give you a fairly good idea though.

To use just one color for the background make the background character
a space and set the background background color to whatever you want.
sorry for that weird sentence...

Rob
--
\--------------------------------------------------------------------/
\ Robert Salesas             + Usenet:  Robert_Salesas@MINDLINK.UUCP /
\ Eschalon Development Inc.  + CIS:     76625,1320    BYTE:  newdawn /
\--------------------------------------------------------------------/