{ ------------------------------------------------------------- }
{ Purpose : Next DBGrid 6                                       }
{ By      : Bojan Nikolic                                       }
{ For     : BergSoft                                            }
{ ------------------------------------------------------------- }
{ Copyright (C) BergSoft.net 2016. All Rights Reserved.         }
{ ------------------------------------------------------------- }
unit NxDBColumnsEditor6;

interface

uses
  { NextGrid 6 }
  NxColumnsEditor6,
  { NextDBGrid 6 }
  NxDBGrid6, NxDBColumns6;

type
  { TNxDBColumnsEditor6 }

  TNxDBColumnsEditor6 = class(TNxColumnsEditor6)
  protected
    procedure AddButtons; override;
    { INxDBDesignNotificationRecipient }
    procedure DataLinkActiveChanged(Active: Boolean);
    function GetUniqueNameSuggestion(const Index: Integer): string; override;
    procedure UpdateStatusBarPanels(Index: Integer); override;
  end;

implementation

{ TNxDBColumnsEditor6 }

procedure TNxDBColumnsEditor6.AddButtons;
begin
  AddButton('Standard', TNxDBTextColumn6, 0);
  AddButton('Standard', TNxDBNumberColumn6, 1);
  AddButton('Standard', TNxDBCheckBoxColumn6, 2);
  AddButton('Standard', TNxDBComboBoxColumn6, 3);
  AddButton('Standard', TNxDBListColumn6, 4);
  AddButton('Standard', TNxDBIconColumn6, 5);
  AddButton('Standard', TNxDBDateColumn6, 6);
  AddButton('Standard', TNxDBTimeColumn6, 7);
  AddButton('Standard', TNxDBMemoColumn6, 8);
  AddButton('Standard', TNxDBIncrementColumn6, 9);
  AddButton('Standard', TNxDBButtonColumn6, 10);
  AddButton('Standard', TNxDBToolbarColumn6, 11);

  AddButton('Additional', TNxDBColorColumn6, 12);
  AddButton('Additional', TNxDBTrackbarColumn6, 13);
  AddButton('Additional', TNxDBProgressColumn6, 14);
  AddButton('Additional', TNxDBGraphicColumn6, 15);
  AddButton('Additional', TNxDBHTMLColumn6, 16);
  AddButton('Additional', TNxDBCheckComboBoxColumn6, 17);
  AddButton('Additional', TNxDBRateColumn6, 18);

  AddButton('Data', TNxDBLookupColumn6, 21);
end;

procedure TNxDBColumnsEditor6.DataLinkActiveChanged(Active: Boolean);
begin

end;

function TNxDBColumnsEditor6.GetUniqueNameSuggestion(const Index: Integer): string;
begin
  with Grid as TNextDBGrid6 do
  begin
    if DataBinding[Index].FieldName <> '' then
    begin
      Result := Designer.UniqueName(DataBinding[Index].FieldName + 'Column');
    end
    else Result := inherited GetUniqueNameSuggestion(Index);
  end;
end;

procedure TNxDBColumnsEditor6.UpdateStatusBarPanels(Index: Integer);
begin
  inherited;
  with Grid as TNextDBGrid6 do
  begin
    if Columns.Exist(Index) then
    begin
      if DataBinding[Index].FieldName <> '' then
      begin
        StatusBar1.Panels[3].Text := DataBinding[Index].FieldName;
      end
      else StatusBar1.Panels[3].Text := 'No Field Set';
    end else StatusBar1.Panels[3].Text := '';
  end;

end;

end.
