OSDN Git Service

Color Setting Style Changed
authornaru <bottle@mikage.to>
Fri, 20 Dec 2002 03:22:10 +0000 (03:22 +0000)
committernaru <bottle@mikage.to>
Fri, 20 Dec 2002 03:22:10 +0000 (03:22 +0000)
bottleclient/ColorSettingFrame.dfm [new file with mode: 0755]
bottleclient/ColorSettingFrame.pas [new file with mode: 0755]
bottleclient/SettingForm.dfm
bottleclient/SettingForm.pas

diff --git a/bottleclient/ColorSettingFrame.dfm b/bottleclient/ColorSettingFrame.dfm
new file mode 100755 (executable)
index 0000000..490b374
--- /dev/null
@@ -0,0 +1,30 @@
+object frmColorSetting: TfrmColorSetting
+  Left = 0
+  Top = 0
+  Width = 310
+  Height = 130
+  HorzScrollBar.Visible = False
+  VertScrollBar.Visible = False
+  TabOrder = 0
+  object lstElement: TListBox
+    Left = 0
+    Top = 0
+    Width = 161
+    Height = 129
+    Style = lbOwnerDrawFixed
+    ItemHeight = 16
+    TabOrder = 0
+    OnClick = lstElementClick
+    OnDrawItem = lstElementDrawItem
+  end
+  object cbxColor: TColorBox
+    Left = 184
+    Top = 0
+    Width = 121
+    Height = 22
+    Style = [cbStandardColors, cbExtendedColors, cbCustomColor, cbPrettyNames]
+    ItemHeight = 16
+    TabOrder = 1
+    OnChange = cbxColorChange
+  end
+end
diff --git a/bottleclient/ColorSettingFrame.pas b/bottleclient/ColorSettingFrame.pas
new file mode 100755 (executable)
index 0000000..dbc4a40
--- /dev/null
@@ -0,0 +1,138 @@
+unit ColorSettingFrame;
+
+interface
+
+uses
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
+  Dialogs, StdCtrls, ExtCtrls;
+
+type
+  TfrmColorSetting = class(TFrame)
+    lstElement: TListBox;
+    cbxColor: TColorBox;
+    procedure lstElementDrawItem(Control: TWinControl; Index: Integer;
+      Rect: TRect; State: TOwnerDrawState);
+    procedure cbxColorChange(Sender: TObject);
+    procedure lstElementClick(Sender: TObject);
+  private
+    FColors: TStringList;
+    function Token(const Str: String; const Delimiter: char;
+      const Index: integer): String;
+    function SelectedColor: TColor;
+    function ColorIndex(Index: integer): TColor;
+    function GetColor(Key: String): TColor;
+    procedure SetColor(Key: String; const Value: TColor);
+  protected
+    procedure Loaded; override;
+  public
+    constructor Create(Owner: TComponent); override;
+    destructor Destroy; override;
+    property Color[Key: String]: TColor read GetColor write SetColor;
+  end;
+
+implementation
+
+{$R *.dfm}
+
+{ TfrmColorSetting }
+
+procedure TfrmColorSetting.lstElementDrawItem(Control: TWinControl;
+  Index: Integer; Rect: TRect; State: TOwnerDrawState);
+var ItemName: String;
+begin
+  ItemName := Token(lstElement.Items[Index], '|', 0);
+  with lstElement.Canvas do begin
+    TextRect(Rect, Rect.Left+lstElement.ItemHeight, Rect.Top+2, ItemName);
+    Pen.Color := clBlack;
+    Brush.Color := ColorIndex(Index); 
+    Rectangle(Rect.Left+2, Rect.Top+2, Rect.Left+lstElement.ItemHeight-4, Rect.Bottom-2);
+  end;
+end;
+
+function TfrmColorSetting.Token(const Str: String; const Delimiter: char;
+  const Index: integer): String;
+var i, c, len: integer;
+begin
+  i := 1;
+  c := 0;
+  len := length(Str);
+  Result := '';
+  while i <= len do begin
+    if Str[i] = Delimiter then begin
+      Inc(c);
+      if c > Index then Break;
+    end else if c = Index then Result := Result + Str[i];
+    Inc(i);
+  end;
+end;
+
+procedure TfrmColorSetting.cbxColorChange(Sender: TObject);
+begin
+  lstElement.Invalidate;
+  FColors.Values[Token(lstElement.Items[lstElement.ItemIndex], '|', 1)] := ColorToString(cbxColor.Selected);
+end;
+
+constructor TfrmColorSetting.Create(Owner: TComponent);
+begin
+  inherited;
+  FColors := TStringList.Create;
+end;
+
+destructor TfrmColorSetting.Destroy;
+begin
+  FColors.Free;
+  inherited;
+end;
+
+procedure TfrmColorSetting.Loaded;
+begin
+  inherited;
+end;
+
+procedure TfrmColorSetting.lstElementClick(Sender: TObject);
+begin
+  if lstElement.ItemIndex = -1 then begin
+    cbxColor.Enabled := false;
+  end else begin
+    cbxColor.Enabled := true;
+    cbxColor.Selected := SelectedColor;
+    cbxColor.Invalidate;
+  end;
+end;
+
+function TfrmColorSetting.SelectedColor: TColor;
+begin
+  Result := ColorIndex(lstElement.ItemIndex);
+end;
+
+function TfrmColorSetting.ColorIndex(Index: integer): TColor;
+var Key: String;
+begin
+  Key := Token(lstElement.Items[Index], '|', 1);
+  if FColors.Values[Key] <> '' then
+    Result := StringToColor(FColors.Values[Key])
+  else
+    Result := StringToColor(Token(lstElement.Items[Index], '|', 2));
+end;
+
+function TfrmColorSetting.GetColor(Key: String): TColor;
+var i: integer;
+begin
+  Result := clBlack;
+  if FColors.Values[Key] <> '' then
+    Result := StringToColor(FColors.Values[Key])
+  else begin
+    for i := 0 to lstElement.Items.Count-1 do
+      if Token(lstElement.Items[i], '|', 1) = Key then begin
+        Result := StringToColor(Token(lstElement.Items[i], '|', 2));
+        Exit;
+      end;
+  end;
+end;
+
+procedure TfrmColorSetting.SetColor(Key: String; const Value: TColor);
+begin
+  FColors.Values[Key] := ColorToString(Value);
+end;
+
+end.
index 1ebb6f6..c017231 100755 (executable)
@@ -1,6 +1,6 @@
 object frmSetting: TfrmSetting
-  Left = 245
-  Top = 490
+  Left = 243
+  Top = 579
   Anchors = [akLeft, akTop, akRight, akBottom]
   BorderStyle = bsDialog
   Caption = #35373#23450
@@ -27,7 +27,7 @@ object frmSetting: TfrmSetting
     Top = 8
     Width = 356
     Height = 306
-    ActivePage = tstGeneral
+    ActivePage = tstColor
     Anchors = [akLeft, akTop, akRight, akBottom]
     TabOrder = 0
     object tstGeneral: TTabSheet
@@ -150,7 +150,7 @@ object frmSetting: TfrmSetting
       end
       object cbxColorScript: TCheckBox
         Left = 8
-        Top = 16
+        Top = 8
         Width = 201
         Height = 17
         Hint = #12481#12455#12483#12463#12434#35299#38500#12377#12427#12392#36895#24230#12399#36895#24230#12399#36895#12367#12394#12427#12364#35211#12389#12425#12356
@@ -167,7 +167,7 @@ object frmSetting: TfrmSetting
         PageSize = 100
         Frequency = 100
         Position = 500
-        TabOrder = 2
+        TabOrder = 1
         ThumbLength = 15
       end
       object trkColorSpeed: TTrackBar
@@ -179,111 +179,34 @@ object frmSetting: TfrmSetting
         Max = 25
         Min = 5
         Position = 10
-        TabOrder = 3
+        TabOrder = 2
         ThumbLength = 15
       end
-      object grpColor: TGroupBox
+      object gbxColor: TGroupBox
         Left = 8
-        Top = 40
+        Top = 24
         Width = 337
-        Height = 137
+        Height = 153
         Caption = #33394
-        TabOrder = 1
-        object Label4: TLabel
-          Left = 176
-          Top = 56
-          Width = 66
-          Height = 12
-          Caption = #12513#12479#25991#23383#21015#33394
-        end
-        object Label2: TLabel
-          Left = 176
-          Top = 16
-          Width = 79
-          Height = 12
-          Caption = #12358#12395#12421#12358#12475#12522#12501#33394
-        end
-        object Label1: TLabel
-          Left = 16
-          Top = 16
-          Width = 66
-          Height = 12
-          Caption = #26412#20307#12475#12522#12501#33394
-        end
-        object Label3: TLabel
-          Left = 16
-          Top = 56
-          Width = 32
-          Height = 12
-          Caption = #12479#12464#33394
-        end
-        object Label5: TLabel
-          Left = 16
-          Top = 96
-          Width = 109
-          Height = 12
-          Caption = #12510#12540#12463#12450#12483#12503#12456#12521#12540#33394
-        end
-        object Label8: TLabel
-          Left = 176
-          Top = 96
-          Width = 36
-          Height = 12
-          Caption = #32972#26223#33394
-        end
-        object colTalkColorH: TColorBox
+        TabOrder = 3
+        inline frmColorSetting: TfrmColorSetting
           Left = 16
-          Top = 32
-          Width = 150
-          Height = 22
-          Style = [cbStandardColors, cbExtendedColors, cbCustomColor, cbPrettyNames]
-          ItemHeight = 16
+          Top = 18
+          Width = 310
+          Height = 130
+          HorzScrollBar.Visible = False
+          VertScrollBar.Visible = False
           TabOrder = 0
-        end
-        object colTalkColorU: TColorBox
-          Left = 176
-          Top = 32
-          Width = 150
-          Height = 22
-          Style = [cbStandardColors, cbExtendedColors, cbCustomColor, cbPrettyNames]
-          ItemHeight = 16
-          TabOrder = 1
-        end
-        object colMarkUpColor: TColorBox
-          Left = 16
-          Top = 72
-          Width = 150
-          Height = 22
-          Style = [cbStandardColors, cbExtendedColors, cbCustomColor, cbPrettyNames]
-          ItemHeight = 16
-          TabOrder = 2
-        end
-        object colMetaWordColor: TColorBox
-          Left = 176
-          Top = 72
-          Width = 150
-          Height = 22
-          Style = [cbStandardColors, cbExtendedColors, cbCustomColor, cbPrettyNames]
-          ItemHeight = 16
-          TabOrder = 3
-        end
-        object colMarkErrorColor: TColorBox
-          Left = 16
-          Top = 112
-          Width = 150
-          Height = 22
-          Style = [cbStandardColors, cbExtendedColors, cbCustomColor, cbPrettyNames]
-          ItemHeight = 16
-          TabOrder = 4
-        end
-        object colBgColor: TColorBox
-          Left = 176
-          Top = 112
-          Width = 150
-          Height = 22
-          Style = [cbStandardColors, cbExtendedColors, cbCustomColor, cbPrettyNames]
-          ItemHeight = 16
-          TabOrder = 5
+          inherited lstElement: TListBox
+            Items.Strings = (
+              #26412#20307#20596#12475#12522#12501'|H|clBlack'
+              #12358#12395#12421#12358#20596#12475#12522#12501'|U|clMaroon'
+              #12471#12531#12463#12525#12490#12452#12474#12489#12475#12483#12471#12519#12531'|Synchro|clPurple'
+              #12479#12464'|Tag|clGreen'
+              #12513#12479#25991#23383#21015'|Meta|clBlue'
+              #12456#12521#12540'|Error|clRed'
+              #32972#26223'|Background|clWhite')
+          end
         end
       end
     end
index 0615b65..ee2d7d9 100755 (executable)
@@ -5,7 +5,7 @@ interface
 uses
   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
   ComCtrls, StdCtrls, ExtCtrls, BottleDef, EllipsEd, Spin,
-  CPCConfigTreeView;
+  CPCConfigTreeView, ColorSettingFrame;
 
 type
   TfrmSetting = class(TForm)
@@ -23,16 +23,9 @@ type
     cbxColorScript: TCheckBox;
     trkColorTimeLag: TTrackBar;
     trkColorSpeed: TTrackBar;
-    grpColor: TGroupBox;
-    Label4: TLabel;
-    Label2: TLabel;
-    Label1: TLabel;
-    Label3: TLabel;
-    Label5: TLabel;
     cbxIgnoreTimeCritical: TCheckBox;
     lblColorTimeLag: TLabel;
     lblColorSpeed: TLabel;
-    Label8: TLabel;
     tstReceive: TTabSheet;
     cbxAutoStart: TCheckBox;
     tstChannel: TTabSheet;
@@ -63,12 +56,8 @@ type
     ctvBottle: TCPCConfigTreeView;
     lblGhostDropDownCount: TLabel;
     spnGhostDropDownCount: TSpinEdit;
-    colTalkColorH: TColorBox;
-    colTalkColorU: TColorBox;
-    colMarkUpColor: TColorBox;
-    colMetaWordColor: TColorBox;
-    colMarkErrorColor: TColorBox;
-    colBgColor: TColorBox;
+    gbxColor: TGroupBox;
+    frmColorSetting: TfrmColorSetting;
     procedure FormClose(Sender: TObject; var Action: TCloseAction);
     procedure edtSoundFileButtonClick(Sender: TObject);
     procedure tvwChannelsCompare(Sender: TObject; Node1, Node2: TTreeNode;
@@ -121,12 +110,21 @@ begin
   cbxConfirmOnExit.Checked := Pref.ConfirmOnExit;
   //
   cbxColorScript.Checked := Pref.ColorScript;
-  colTalkColorH.Selected := Pref.TalkColorH;
+  {colTalkColorH.Selected := Pref.TalkColorH;
   colTalkColorU.Selected := Pref.TalkColorU;
   colMarkUpColor.Selected := Pref.MarkUpColor;
   colMetaWordColor.Selected := Pref.MetaWordColor;
   colMarkErrorColor.Selected := Pref.MarkErrorColor;
-  colBgColor.Selected := Pref.BgColor;
+  colBgColor.Selected := Pref.BgColor;}
+  with frmColorSetting do begin
+    Color['H'] := Pref.TalkColorH;
+    Color['U'] := Pref.TalkColorU;
+    Color['Synchro'] := clBlack;
+    Color['Tag'] := Pref.MarkUpColor;
+    Color['Meta'] := Pref.MetaWordColor;
+    Color['Error'] := Pref.MarkErrorColor;
+    Color['Background'] := Pref.BgColor;
+  end;
   trkColorTimeLag.Position := Pref.ColorTimeLagValue;
   trkColorSpeed.Position := Pref.ColorSpeed;
   //
@@ -195,12 +193,21 @@ begin
   Pref.ConfirmOnExit := cbxConfirmOnExit.Checked;
   //
   Pref.ColorScript := cbxColorScript.Checked;
-  Pref.TalkColorH := colTalkColorH.Selected;
+  {Pref.TalkColorH := colTalkColorH.Selected;
   Pref.TalkColorU := colTalkColorU.Selected;
   Pref.MarkUpColor := colMarkUpColor.Selected;
   Pref.MetaWordColor := colMetaWordColor.Selected;
   Pref.MarkErrorColor := colMarkErrorColor.Selected;
-  Pref.BgColor := colBgColor.Selected;
+  Pref.BgColor := colBgColor.Selected;}
+  with frmColorSetting do begin
+    Pref.TalkColorH := Color['H'];
+    Pref.TalkColorU := Color['U'];
+    Pref.MarkUpColor := Color['Tag'];
+    {TODO: Synchronized}
+    Pref.MetaWordColor := Color['Meta'];
+    Pref.MarkErrorColor := Color['Error'];
+    Pref.BgColor := Color['Background'];
+  end;
   Pref.ColorTimeLagValue := trkColorTimeLag.Position;
   Pref.ColorSpeed := trkColorSpeed.Position;
   //