Ignore:
Timestamp:
Aug 8, 2008, 8:34:55 PM (16 years ago)
Author:
Kevin Toppenberg
Message:

Added Colorful Tabs, Changable Tab positions, Demographics translation enabled

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cprs/branches/tmg-cprs/CPRS-Chart/fFrame.pas

    r472 r473  
    250250    procedure mnuViewInformationClick(Sender: TObject);
    251251    procedure EditDemographicsClick(Sender: TObject);
     252    procedure tabPageDrawTab(Control: TCustomTabControl; TabIndex: Integer;
     253      const Rect: TRect; Active: Boolean);
    252254  private
    253255    //kt Begin Mod (change Consts to Vars) 7/17/2007
     
    319321    procedure ClearPatient;
    320322    procedure ChangeFont(NewFontSize: Integer);
     323    procedure LoadTabColors(INIFile : TIniFile; ColorsList : TStringList);  //kt added 8/8/08
     324    procedure SaveTabColors(INIFile : TIniFile; ColorsList : TStringList);
    321325    //procedure CreateTab(var AnInstance: TObject; AClass: TClass; ATabID: integer; ALabel: string);
    322326    procedure CreateTab(ATabID: integer; ALabel: string);
     
    361365    procedure HandleCCOWError(AMessage: string);
    362366    procedure SetupVars;
     367    procedure DrawTab(Control: TCustomTabControl; TabIndex: Integer;
     368                      const Rect: TRect; Color : TColor; Active: Boolean); //kt added 8/8/08
    363369  public
    364370    EnduringPtSelSplitterPos: integer;
     
    393399  frmFrame: TfrmFrame;
    394400  uTabList: TStringList;
     401  uTabColorsList : TStringList;  //kt added 8/8/08
    395402  uRemoteType : string;
    396403  FlaggedPTList: TStringList;
     
    424431  , CCOW_const
    425432  {$ENDIF}
    426   , fPtDemoEdit;
     433  , fPtDemoEdit
     434  , fOptionsOther;
    427435
    428436var                                 //  RV 05/11/04
     
    720728  i : integer;  //kt added 6/29/07
    721729  CPRSChartINI: TINIFile;  //elh 6/23/08
     730  tempPosition : TTabPosition; //kt
    722731begin
    723732  //kt 6/29/07  Begin modification -------------------
     
    800809  Application.OnDeActivate := AppDeActivated;
    801810
    802   // load language ini settings
     811  // load language ini settings   //elh added
    803812  CPRSChartINI := TINIFile.Create(ExtractFilePath(ParamStr(0)) + 'CPRSChart.ini');  // Read from INI  elh  6/23/08
    804813  LangManager.LanguageID := CPRSChartINI.ReadInteger('Options','Language',1033);
    805   CPRSChartINI.Free;
     814  tempPosition := TTabPosition(CPRSChartINI.ReadInteger('TAB_POSITION','Tab Location',0));
     815  if tempPosition > tpRight then tempPosition := tpBottom;
     816  fOptionsOther.SetTabPosition(tempPosition);
     817  //kt -- end mod --
    806818
    807819  //frmFrame.Caption := TX_IN_USE + MixedCase(User.Name) + '  (' + RPCBrokerV.Server + ')';  //kt added
    808820  //frmFrame.RenameTabs;  //Resets names of tabs to correct translation  //kt
    809  
    810821
    811822  // create initial core objects
     
    897908  RemoteReports := TRemoteReportList.Create;
    898909  uTabList := TStringList.Create;
     910  uTabColorsList := TStringList.Create;  //kt added 8/8/08
    899911  FlaggedPTList := TStringList.Create;
    900912  HasFlag  := False;
     
    934946  end;
    935947  //kt replace later... CreateTab(CT_IMAGES,   'Images');   //kt  8/19/05
     948  LoadTabColors(CPRSChartINI,uTabColorsList);  //kt added 8/8/08
    936949
    937950  ShowHideChartTabMenus(mnuViewChart);
     
    971984//  if WindowState = wsMinimized then WindowState := wsNormal;
    972985  SetFormMonitoring(true);
     986  CPRSChartINI.Free;  //kt added 8/8/08
    973987end;
    974988
     
    10661080  if URL='<!HIDE!>' then begin
    10671081    SetATabVisibility(ATabID, false);
    1068   end else begin
     1082  end else if URL<>'<!NOCHANGE!>' then begin
    10691083    SetATabVisibility(ATabID, true, TabLabel);
    10701084    tempFrmWebTab := TfrmWebTab(frmWebTabs[WebTabNum-1]);
     
    11451159procedure TfrmFrame.FormDestroy(Sender: TObject);
    11461160{ free core objects used by CPRS }
     1161var
     1162  CPRSChartINI: TINIFile;  //kt 8/8/08
     1163
    11471164begin
    11481165  Application.OnActivate := FOldActivate;
     
    11501167  FNextButtonBitmap.Free;
    11511168  uTabList.Free;
     1169  //kt --- 8/8/08 start mod ---
     1170  CPRSChartINI := TINIFile.Create(ExtractFilePath(ParamStr(0)) + 'CPRSChart.ini');
     1171  CPRSChartINI.WriteInteger('Options','Language',LangManager.LanguageID);
     1172  SaveTabColors(CPRSChartINI,uTabColorsList);
     1173  uTabColorsList.Free;
     1174  CPRSChartINI.WriteInteger('TAB_POSITION','Tab Location',integer(tabPage.TabPosition));
     1175  //kt --- end mod ---
     1176
    11521177  FlaggedPTList.Free;
    11531178  RemoteSites.Free;
     
    37183743      tabPage.Tabs.Add(ALabel);
    37193744    end;
     3745  if uTabColorsList.IndexOf(ALabel) < 0 then                    //kt added 8/8/08
     3746    uTabColorsList.Add(ALabel);  //will put colors in later...  //kt
     3747end;
     3748
     3749procedure TfrmFrame.LoadTabColors(INIFile : TIniFile; ColorsList : TStringList);
     3750//kt added 8/8/08  Entire function
     3751var i : integer;
     3752    sValue : string;
     3753    value : longword;
     3754begin
     3755  value :=0;
     3756  for i := 0 to ColorsList.Count-1 do begin
     3757    sValue := INIFile.ReadString('TAB_COLORS',ColorsList.Strings[i],IntToStr($00FFFF));
     3758    try
     3759      value := StrToInt(sValue)
     3760    except
     3761      on EConvertError do value := $00FFFF;
     3762    end;
     3763    ColorsList.Objects[i] := pointer(value);
     3764  end;
     3765end;
     3766
     3767procedure TfrmFrame.SaveTabColors(INIFile : TIniFile; ColorsList : TStringList);
     3768//kt added 8/8/08  Entire function
     3769var i : integer;
     3770begin
     3771  for i := 0 to ColorsList.Count-1 do begin
     3772    INIFile.WriteInteger('TAB_COLORS',ColorsList.Strings[i],longword(ColorsList.Objects[i]));
     3773  end;
    37203774end;
    37213775
     
    48304884
    48314885procedure TfrmFrame.EditDemographicsClick(Sender: TObject);
    4832 //kt added Function 12/15/07, 6/6/08 
     4886//kt added Function 12/15/07, 6/6/08
    48334887var  EditResult: integer;
    48344888begin
     
    48374891end;
    48384892
     4893procedure TfrmFrame.tabPageDrawTab(Control: TCustomTabControl; TabIndex: Integer;
     4894                                   const Rect: TRect; Active: Boolean);
     4895var ALabel : string;
     4896    colorIndex : Integer;
     4897    color : TColor;
     4898begin
     4899  ALabel := TTabControl(Control).Tabs[TabIndex];
     4900  colorIndex := uTabColorsList.IndexOf(ALabel);
     4901  if colorIndex < 0 then color := clYellow
     4902  else color := TColor(uTabColorsList.Objects[colorIndex]);
     4903  DrawTab(Control,TabIndex,Rect,color,Active);
     4904end;
     4905
     4906procedure TfrmFrame.DrawTab(Control: TCustomTabControl; TabIndex: Integer;
     4907                           const Rect: TRect; Color : TColor; Active: Boolean);
     4908  var
     4909    oRect         : TRect;
     4910    sCaption,temp : String;
     4911    iTop          : Integer;
     4912    iLeft         : Integer;
     4913    i             : integer;
     4914    TabControl    : TTabControl;
     4915    lf            : TLogFont;  //Windows native font structure
     4916    tf            : TFont;
     4917    Degrees       : integer;
     4918    inactiveColor     : TColor;
     4919
     4920    (*
     4921    function DecRed(Color : TColor; Amount : byte) : TColor;
     4922    var red : longWord;
     4923    begin
     4924      red := (Color and $0000FF);
     4925      if red > Amount then red := red - Amount
     4926      else red := 0;
     4927      Result := (Color and $FFFF00) or red;
     4928    end;
     4929
     4930    function DecGreen(Color : TColor; Amount : byte) : TColor;
     4931    var green : longWord;
     4932    begin
     4933      green := (Color and $00FF00);
     4934      green := green shr 8;
     4935      if green > Amount then green := green - Amount
     4936      else green := 0;
     4937      green := green shl 8;
     4938      Result := (Color and $FF00FF) or green;
     4939    end;
     4940
     4941    function DecBlue(Color : TColor; Amount : byte) : TColor;
     4942    var blue : longWord;
     4943    begin
     4944      blue := (Color and $FF0000);
     4945      blue := blue shr 16;
     4946      if blue > Amount then blue := blue - Amount
     4947      else blue := 0;
     4948      blue := blue shl 16;
     4949      Result := (Color and $00FFFF) or blue;
     4950    end;
     4951
     4952   function Darken(Color : TColor; Amount : byte) : TColor;
     4953   begin
     4954     result:= DecRed(Color, Amount);
     4955     result := DecBlue(result,Amount);
     4956     result := DecGreen(result,Amount);
     4957   end;
     4958   *)
     4959
     4960  var
     4961    DecAmount : Byte;
     4962
     4963  begin
     4964    oRect    := Rect;
     4965    //DecAmount := 50;
     4966    //inactiveColor := Darken(Color,DecAmount);
     4967    inactiveColor := Color;
     4968
     4969    TabControl := TTabControl(Control);
     4970    if TabControl.Tabs.Count=0 then exit;
     4971    sCaption := TabControl.Tabs.Strings[TabIndex];
     4972    for i := 1 to length(temp) do begin
     4973      if temp[i] <> '&' then sCaption := sCaption + temp[i];
     4974    end;
     4975
     4976    Control.Canvas.Font.Name := 'Tahoma';
     4977    if Active then Control.Canvas.Font.Style := Control.Canvas.Font.Style + [fsBold];
     4978    if Active then Control.Canvas.Font.Color := clBlack
     4979    else Control.Canvas.Font.Color := clWhite;
     4980
     4981    if (TabControl.TabPosition = tpLeft) or (TabControl.TabPosition = tpRight) then begin
     4982
     4983      if (TabControl.TabPosition = tpLeft) then begin
     4984        iTop     := Rect.Bottom-4;
     4985        if Active then iTop := iTop - 2;
     4986        iLeft    := Rect.Left + 1;
     4987        Degrees  := 90;
     4988      end else begin
     4989        iTop     := Rect.Top  + 4;
     4990        if Active then iTop := iTop + 2;
     4991        iLeft    := Rect.Right - 2;
     4992        Degrees  := 270;
     4993      end;
     4994      tf := TFont.Create;
     4995      try
     4996        tf.Assign(Control.Canvas.Font);
     4997        GetObject(tf.Handle, sizeof(lf), @lf);
     4998        lf.lfEscapement := 10 * Degrees;  //degrees of desired rotation
     4999        lf.lfHeight := Control.Canvas.Font.Height - 2;
     5000        tf.Handle := CreateFontIndirect(lf);
     5001        Control.Canvas.Font.Assign(tf);
     5002      finally
     5003        tf.Free;
     5004      end;
     5005
     5006    end else begin
     5007      iTop     := Rect.Top  + ((Rect.Bottom - Rect.Top  - Control.Canvas.TextHeight(sCaption)) div 2) + 1;
     5008      iLeft    := Rect.Left + ((Rect.Right  - Rect.Left - Control.Canvas.TextWidth (sCaption)) div 2) + 1;
     5009    end;
     5010
     5011    if Active then begin
     5012      //Control.Canvas.Brush.Color := TColor($0000FFFF);  //Bright yellow
     5013      Control.Canvas.Brush.Color := Color;
     5014      Control.Canvas.FillRect(Rect);
     5015    end else begin
     5016      //Control.Canvas.Brush.Color := TColor($000079EFE8);  //dull yellow
     5017      Control.Canvas.Brush.Color := inactiveColor;
     5018      Control.Canvas.FillRect(Rect);
     5019    end;
     5020    Control.Canvas.TextOut(iLeft,iTop,sCaption);
     5021  end;
     5022
     5023
     5024
     5025
    48395026initialization
    48405027
Note: See TracChangeset for help on using the changeset viewer.