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

📄 flag_frm.pas

📁 自己写的一个 RSS 阅读器
💻 PAS
字号:
unit flag_Frm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxControls, cxInplaceContainer, cxTL, StdCtrls, ExtCtrls,
  JvExStdCtrls, JvCombobox, JvColorCombo, Buttons,cxGraphics, JvExControls,
  JvComponent, JvSpeedButton, ActnList, ImgList, cxContainer, cxEdit,
  cxTextEdit, cxMaskEdit, cxDropDownEdit, cxImageComboBox;

type
  TfmFlag = class(TForm)
    FlagTreeList: TcxTreeList;
    cxTreeList1cxTreeListColumn1: TcxTreeListColumn;
    cxTreeList1cxTreeListColumn2: TcxTreeListColumn;
    Button1: TButton;
    Edit1: TEdit;
    CBoxFont: TJvColorComboBox;
    CBoxBg: TJvColorComboBox;
    Label1: TLabel;
    Label3: TLabel;
    Label5: TLabel;
    Bevel1: TBevel;
    SpeedButton4: TSpeedButton;
    SpeedButton5: TSpeedButton;
    Button2: TButton;
    ActionList1: TActionList;
    actSave: TAction;
    actDelete: TAction;
    ImageList1: TImageList;
    Label2: TLabel;
    ImageBox: TcxImageComboBox;
    FlagTreeListcxTreeListColumn1: TcxTreeListColumn;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SpeedButton4Click(Sender: TObject);
    procedure FlagTreeListCustomDrawCell(Sender: TObject;
      ACanvas: TcxCanvas; AViewInfo: TcxTreeListEditCellViewInfo;
      var ADone: Boolean);
    procedure FlagTreeListFocusedNodeChanged(Sender: TObject;
      APrevFocusedNode, AFocusedNode: TcxTreeListNode);
    procedure actSaveExecute(Sender: TObject);
    procedure actSaveUpdate(Sender: TObject);
    procedure actDeleteExecute(Sender: TObject);
    procedure actDeleteUpdate(Sender: TObject);
  private
    FCaption,FFontColor,FBGColor:string;
    FFontB,FFontI,FFontU:Boolean;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmFlag: TfmFlag;

implementation

uses uFlagBase, uMain;

{$R *.dfm}

procedure TfmFlag.Button1Click(Sender: TObject);
begin
  mainwindow.LoadFlags;
  Close;
end;

procedure TfmFlag.FormCreate(Sender: TObject);
var i:Integer;
  node:TcxTreeListNode;
begin
  if FlagList.Count>0 then
  for i := 0 to FlagList.Count - 1 do    // Iterate
  begin
     node:= FlagTreeList.Add;
     node.Data := FlagList.Item[i];
     node.Values[0]:=FlagList.Item[i].FlagID;
     node.Texts[1]:=FlagList.Item[i].Caption;
     node.Values[2] := FlagList.Item[i].ImageIndex;
  end;    // for
  FlagTreeList.ClearSorting;
end;

procedure TfmFlag.SpeedButton4Click(Sender: TObject);
var   node:TcxTreeListNode;
  FlagItem:TFlagItem;
begin
  node:= FlagTreeList.Add;
  FlagItem := FlagList.Add;
  node.Data:=FlagItem;
  node.Values[0]:=FlagItem.FlagID;
  node.Texts[1]:=FlagItem.Caption;
  node.Values[2] := 4;
  FlagTreeList.SetFocusedNode(node,[]);
end;

procedure TfmFlag.FlagTreeListCustomDrawCell(Sender: TObject;
  ACanvas: TcxCanvas; AViewInfo: TcxTreeListEditCellViewInfo;
  var ADone: Boolean);
var
  flagItem:TFlagItem;
begin
   flagItem := TFlagItem(AViewInfo.Node.Data);
   ACanvas.Font.Color := StringToColor(flagItem.FontColor);
   ACanvas.Brush.Color := StringToColor(flagItem.BGColor);
   {if AViewInfo.Node.Selected then
   begin
     ACanvas.Brush.Color := clHighlight;
     ACanvas.Font.Color := clHighlightText;
   end; }
end;

procedure TfmFlag.FlagTreeListFocusedNodeChanged(Sender: TObject;
  APrevFocusedNode, AFocusedNode: TcxTreeListNode);
var FlagItem:TFlagItem;
begin
  Edit1.Enabled:= AFocusedNode<>nil;
  CBoxFont.Enabled := AFocusedNode<>nil;
  CBoxBg.Enabled := AFocusedNode<>nil;
  ImageBox.Enabled := AFocusedNode<>nil;
  if AFocusedNode=nil then
  begin
    Exit;
  end;
  FlagItem :=TFlagItem(AFocusedNode.Data);
  CBoxFont.ColorValue := StringToColor(FlagItem.FontColor);
  CBoxBg.ColorValue := StringToColor(FlagItem.BGColor);
  ImageBox.ItemIndex := FlagItem.ImageIndex - 4;
  Edit1.Text := FlagItem.Caption;
end;

procedure TfmFlag.actSaveExecute(Sender: TObject);
var FlagItem:TFlagItem;
begin
  FlagItem:= TFlagItem(FlagTreeList.FocusedNode.Data);
  FlagItem.Caption := Edit1.Text;
  FlagTreeList.FocusedNode.Texts[1]:=FlagItem.Caption;

  FlagItem.FontColor := ColorToString(CBoxFont.ColorValue);
  FlagItem.BGColor := ColorToString(CBoxBg.ColorValue);
  FlagItem.ImageIndex := ImageBox.ItemIndex + 4;
  FlagTreeList.FocusedNode.Values[2]:=FlagItem.ImageIndex;
end;

procedure TfmFlag.actSaveUpdate(Sender: TObject);
var FlagItem:TFlagItem;
begin
  if FlagTreeList.FocusedNode=nil then
    actSave.Enabled := False
  else
  begin
  FlagItem:= TFlagItem(FlagTreeList.FocusedNode.Data);
  actSave.Enabled:=
  (FlagItem.Caption <> Edit1.Text) or
  (FlagTreeList.FocusedNode.Texts[1]<>FlagItem.Caption) or
  (FlagItem.FontColor <> ColorToString(CBoxFont.ColorValue)) or
  (FlagItem.BGColor <> ColorToString(CBoxBg.ColorValue)) or
  (FlagItem.ImageIndex <> ImageBox.ItemIndex + 4);
  end;
end;

procedure TfmFlag.actDeleteExecute(Sender: TObject);
var
  flagItem:TFlagItem;
begin
  flagItem:=TFlagItem(FlagTreeList.FocusedNode.Data);
  FlagList.Delete(flagItem);
  FlagTreeList.FocusedNode.Delete;
  MainWindow.cxTreeList1.Refresh;
end;

procedure TfmFlag.actDeleteUpdate(Sender: TObject);
begin
  actDelete.Enabled:=FlagTreeList.FocusedNode<>nil;
end;

end.

⌨️ 快捷键说明

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