⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jvqcolorprovider.pas

📁 East make Tray Icon in delphi
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    FCaption := Value;
    Changed;
  end;
end;

function TJvColorProviderAddColorSettings.GetStyle: TJvColorProviderAddColorStyle;
begin
  Result := FStyle;
end;

procedure TJvColorProviderAddColorSettings.SetStyle(Value: TJvColorProviderAddColorStyle);
begin
  if Value <> Style then
  begin
    FStyle := Value;
    Changed;
  end;
end;

//=== { TJvColorProviderCustomColorGroupSettings } ===========================

constructor TJvColorProviderCustomColorGroupSettings.Create(AConsumerService: TJvDataConsumerAggregatedObject;
  ACaption: string);
begin
  inherited Create(AConsumerService, ACaption);
  FAddColorSettings := TJvColorProviderAddColorSettings.Create(AConsumerService);
end;

destructor TJvColorProviderCustomColorGroupSettings.Destroy;
begin
  FreeAndNil(FAddColorSettings);
  inherited Destroy;
end;

procedure TJvColorProviderCustomColorGroupSettings.SetAddColorSettings(
  Value: TJvColorProviderAddColorSettings);
begin
end;

//=== { TJvColorMappingProvider } ============================================

function TJvColorMappingProvider.GetColorProviderIntf: IJvColorProvider;
begin
  Result := TJvColorMapItems(DataItemsImpl).ClientProvider as IJvColorProvider;
end;

procedure TJvColorMappingProvider.SetColorProviderIntf(Value: IJvColorProvider);
begin
  TJvColorMapItems(DataItemsImpl).ClientProvider := (Value as IJvDataProvider);
end;



class function TJvColorMappingProvider.ItemsClass: TJvDataItemsClass;
begin
  Result := TJvColorMapItems;
end;

function TJvColorMappingProvider.ConsumerClasses: TClassArray;
begin
  Result := inherited ConsumerClasses;
  AddToArray(Result, TJvColorProviderServerNotify);
end;

//=== { TJvColorProviderServerNotify } =======================================

procedure TJvColorProviderServerNotify.ItemSelected(Value: IJvDataItem);
var
  MapItem: IJvColorMapItem;
  Mapping: TJvColorProviderNameMapping;
  I: Integer;
  ConSet: IJvColorProviderSettings;
begin
  inherited ItemSelected(Value);
  if Supports(Value, IJvColorMapItem, MapItem) then
  begin
    Mapping := MapItem.NameMapping;
    for I := 0 to Clients.Count - 1 do
      if Supports(Clients[I], IJvColorProviderSettings, ConSet) then
        ConSet.NameMapping := Mapping;
  end;
end;

function TJvColorProviderServerNotify.IsValidClient(Client: IJvDataConsumerClientNotify): Boolean;
var
  ClientProv: IJvDataProvider;
  ConsumerProv: IJvDataConsumerProvider;
begin
  { Only allow client consumers who's Provider points to the ColorProvider of the mapping
    provider this consumer is linked to. }
  ClientProv := (ConsumerImpl.ProviderIntf as IJvColorMappingProvider).ClientProvider as
    IJvDataProvider;
  Result := Supports(Client, IJvDataConsumerProvider, ConsumerProv) and
    (ConsumerProv.GetProvider = ClientProv);
end;

//=== { TJvColorProviderColorAdderRegister } =================================

constructor TJvColorProviderColorAdderRegister.Create;
begin
  inherited Create;
  FList := TStringList.Create;
  FNotifiers := TList.Create;
end;

destructor TJvColorProviderColorAdderRegister.Destroy;
begin
  FreeAndNil(FNotifiers);
  FreeAndNil(FList);
  inherited Destroy;
end;

procedure TJvColorProviderColorAdderRegister.RegisterNotify(Value: TJvColorProviderAddColorSettings);
begin
  if FNotifiers.IndexOf(Value) = -1 then
    FNotifiers.Add(Value);
end;

procedure TJvColorProviderColorAdderRegister.UnregisterNotify(Value: TJvColorProviderAddColorSettings);
begin
  FNotifiers.Remove(Value);
end;

function TJvColorProviderColorAdderRegister.Add(Name: string;
  Callback: TJvColorProviderColorAdder): Integer;
begin
  Result := IndexOf(Name);
  if Result = -1 then
    Result := FList.AddObject(Name, TObject(@Callback))
  else
  if @Callbacks(Result) <> @Callback then
    raise EJVCLException.CreateResFmt(@RsEAlreadyRegistered, [Name]);
end;

procedure TJvColorProviderColorAdderRegister.Delete(Callback: TJvColorProviderColorAdder);
var
  Idx: Integer;
begin
  Idx := IndexOf(Callback);
  if Idx > -1 then
    Delete(Idx);
end;

procedure TJvColorProviderColorAdderRegister.Delete(Index: Integer);
var
  I: Integer;
begin
  FList.Delete(Index);
  if Index < DefaultAdder then
    Dec(FDefaultAdder)
  else
  if Index = DefaultAdder then
  begin
    if Count > 0 then
      FDefaultAdder := 0
    else
      FDefaultAdder := -1;
  end;
  for I := 0 to FNotifiers.Count -1 do
    with TJvColorProviderAddColorSettings(FNotifiers[I]) do
      if Style > Index then
        Dec(FStyle)
      else
      if Style = Index then
        FStyle := DefaultAdder;
end;

procedure TJvColorProviderColorAdderRegister.Delete(Name: string);
var
  Idx: Integer;
begin
  Idx := IndexOf(Name);
  if Idx > -1 then
    Delete(Idx);
end;

procedure TJvColorProviderColorAdderRegister.Clear;
var
  I: Integer;
begin
  while FList.Count > FMinimumKeep do
    FList.Delete(FList.Count);
  DefaultAdder := FDefaultAfterClear;
  for I := 0 to FNotifiers.Count - 1 do
    with TJvColorProviderAddColorSettings(FNotifiers[I]) do
      if Style >= FMinimumKeep then
        FStyle := DefaultAdder;
end;

function TJvColorProviderColorAdderRegister.IndexOf(Name: string): Integer;
begin
  Result := FList.IndexOf(Name);
end;

function TJvColorProviderColorAdderRegister.IndexOf(Callback: TJvColorProviderColorAdder): Integer;
begin
  Result := FList.IndexOfObject(TObject(@Callback));
end;

function TJvColorProviderColorAdderRegister.Count: Integer;
begin
  Result := FList.Count;
end;

function TJvColorProviderColorAdderRegister.Names(Index: Integer): string;
begin
  Result := FList[Index];
end;

function TJvColorProviderColorAdderRegister.Callbacks(Index: Integer): TJvColorProviderColorAdder;
begin
  Result := TJvColorProviderColorAdder(FList.Objects[Index]);
end;

//=== { TJvColorItems } ======================================================

function TJvColorItems.GetColorSettings: IJvColorProviderSettings;
begin
  if GetProvider = nil then
    Result := nil
  else
    Supports(GetProvider.SelectedConsumer, IJvColorProviderSettings, Result);
end;

function TJvColorItems.GetCount: Integer;
var
  Settings: IJvColorProviderSettings;
begin
  Settings := GetColorSettings;
  Result := 0;
  if Settings = nil then
    Exit;
  if Settings.GroupingSettings.Active and not Settings.GroupingSettings.FlatList then
  begin
    Inc(Result, Ord(Settings.StandardColorSettings.Active) +
      Ord(Settings.SystemColorSettings.Active) + Ord(Settings.CustomColorSettings.Active));
  end
  else
  begin
    if Settings.StandardColorSettings.Active then
      Inc(Result, ColorProvider.GetStandardCount +
        Ord(Settings.StandardColorSettings.ShowHeader and Settings.GroupingSettings.Active));
    if Settings.SystemColorSettings.Active then
      Inc(Result, ColorProvider.GetSystemCount +
        Ord(Settings.SystemColorSettings.ShowHeader and Settings.GroupingSettings.Active));
    if Settings.CustomColorSettings.Active then
      Inc(Result, ColorProvider.GetCustomCount +
        Ord(Settings.CustomColorSettings.ShowHeader and Settings.GroupingSettings.Active) +
        Ord(Settings.CustomColorSettings.AddColorSettings.Active and
          (Settings.CustomColorSettings.ShowHeader and Settings.GroupingSettings.Active or
          (Settings.CustomColorSettings.AddColorSettings.Location <> ailUseHeader))));
  end;
end;

function TJvColorItems.GetItem(I: Integer): IJvDataItem;
var
  OrgIdx: Integer;
  Settings: IJvColorProviderSettings;
  ListNum: Integer;
begin
  if I < 0 then
    TList.Error(SListIndexError, I);
  OrgIdx := I;
  Settings := GetColorSettings;
  if Settings = nil then
    Exit;
  ListNum := -1;
  if Settings.GroupingSettings.Active and not Settings.GroupingSettings.FlatList then
  begin
    if Settings.StandardColorSettings.Active then
      Dec(I);
    if I < 0 then
      ListNum := 0;
    if (ListNum < 0) and Settings.SystemColorSettings.Active then
    begin
      Dec(I);
      if I < 0 then
        ListNum := 1;
    end;
    if (ListNum < 0) and Settings.CustomColorSettings.Active then
    begin
      Dec(I);
      if I < 0 then
        ListNum := 2;
    end;
  end
  else
  begin
    if Settings.StandardColorSettings.Active then
    begin
      if Settings.StandardColorSettings.ShowHeader and Settings.GroupingSettings.Active then
        Dec(I);
      if I < ColorProvider.GetStandardCount then
        ListNum := 0
      else
        Dec(I, ColorProvider.GetStandardCount);
    end;
    if (ListNum < 0) and Settings.SystemColorSettings.Active then
    begin
      if Settings.SystemColorSettings.ShowHeader and Settings.GroupingSettings.Active then
        Dec(I);
      if I < ColorProvider.GetSystemCount then
        ListNum := 1
      else
        Dec(I, ColorProvider.GetSystemCount);
    end;
    if (ListNum < 0) and Settings.CustomColorSettings.Active then
    begin
      if Settings.CustomColorSettings.ShowHeader and Settings.GroupingSettings.Active then
        Dec(I);
      with Settings.CustomColorSettings.AddColorSettings do
        if Active and (Location = ailTop) and (I = 0) then
          I := -2;
      if I < ColorProvider.GetCustomCount then
        ListNum := 2
      else
      begin
        Dec(I, ColorProvider.GetCustomCount);
        with Settings.CustomColorSettings.AddColorSettings do
          if (I = 0) and Active and ((Location = ailBottom) or ((Location = ailUseHeader) and
            not (Settings.CustomColorSettings.ShowHeader and Settings.GroupingSettings.Active))) then
          begin
            ListNum := 2;
            I := -2;
          end;
      end;
    end;
  end;
  if ListNum < 0 then
    TList.Error(SListIndexError, OrgIdx);
  if I = -1 then
    Result := TJvColorHeaderItem.Create(Self, ListNum)
  else
  if I = -2 then
    Result := TJvColorAddItem.Create(Self)
  else
  if I >= 0 then
    Result := TJvColorItem.Create(Self, ListNum, I);
end;

procedure TJvColorItems.InitImplementers;
begin
  inherited InitImplementers;
  if GetParent = nil then
    TJvColorItemsRenderer.Create(Self);
end;

procedure TJvColorItems.AfterConstruction;
begin
  inherited AfterConstruction;
  Supports(GetProvider, IJvColorProvider, FColorProvider);
end;

//=== { TJvColorItemsList } ==================================================

function TJvColorItemsList.GetCount: Integer;
begin
  case ListNum of
    0:
      Result := ColorProvider.GetStandardCount;
    1:
      Result := ColorProvider.GetSystemCount;
    2:
      Result := ColorProvider.GetCustomCount;
    else
      Result := 0;
  end;
end;

function TJvColorItemsList.GetItem(I: Integer): IJvDataItem;
begin
  if I < 0 then
    TList.Error(SListIndexError, I);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -