close Warning: Can't synchronize with repository "(default)" (No changeset 184 in the repository). Look in the Trac log for more information.

Ignore:
Timestamp:
Aug 16, 2014, 11:02:07 PM (10 years ago)
Author:
chronos
Message:
  • Added: Support for switching large icons in toolbar.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r43 r46  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
    9   UGame, LCLType, Menus, ActnList, ComCtrls, types, dateutils;
     9  UGame, LCLType, Menus, ActnList, ComCtrls, types, dateutils, XMLConf;
    1010
    1111const
     
    1717
    1818  TFormMain = class(TForm)
     19    AToolBarBigIcons: TAction;
    1920    AZoomIn: TAction;
    2021    AZoomAll: TAction;
     
    3132    MenuItem16: TMenuItem;
    3233    MenuItem17: TMenuItem;
     34    MenuItem18: TMenuItem;
     35    MenuItem19: TMenuItem;
    3336    MenuItem2: TMenuItem;
     37    MenuItem20: TMenuItem;
    3438    MenuItem3: TMenuItem;
    3539    MenuItem4: TMenuItem;
     
    4044    MenuItem9: TMenuItem;
    4145    PaintBox1: TPaintBox;
     46    PopupMenuToolbar: TPopupMenu;
    4247    StatusBar1: TStatusBar;
    4348    Timer1: TTimer;
     
    4853    ToolButton4: TToolButton;
    4954    ToolButton5: TToolButton;
     55    procedure AToolBarBigIconsExecute(Sender: TObject);
    5056    procedure AZoomAllExecute(Sender: TObject);
    5157    procedure AZoomInExecute(Sender: TObject);
     
    5662    procedure FormDestroy(Sender: TObject);
    5763    procedure FormShow(Sender: TObject);
     64    procedure MenuItem19Click(Sender: TObject);
    5865    procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
    5966      Shift: TShiftState; X, Y: Integer);
     
    7784    RedrawPending: Boolean;
    7885  public
     86    procedure LoadConfig(Config: TXmlConfig; Path: string);
     87    procedure SaveConfig(Config: TXmlConfig; Path: string);
     88    procedure ReloadView;
    7989    procedure Redraw;
    8090  end;
     
    8696
    8797uses
    88   UFormNew, UFormMove, UCore;
     98  UCore;
    8999
    90100resourcestring
     
    132142      NewCaption := Core.Game.CurrentPlayer.Name + ' - ' + STurn + ' ' + IntToStr(Core.Game.TurnCounter) + ' - ' + NewCaption;
    133143    Caption := NewCaption;
     144  end;
     145end;
     146
     147procedure TFormMain.LoadConfig(Config: TXmlConfig; Path: string);
     148begin
     149  with Config do begin
     150    AToolBarBigIcons.Checked := GetValue(Path + '/LargeIcons', False);
     151  end;
     152end;
     153
     154procedure TFormMain.SaveConfig(Config: TXmlConfig; Path: string);
     155begin
     156  with Config do begin
     157    SetValue(Path + '/LargeIcons', AToolBarBigIcons.Checked);
     158  end;
     159end;
     160
     161procedure TFormMain.ReloadView;
     162begin
     163  if AToolBarBigIcons.Checked then begin
     164    ToolBar1.Images := Core.ImageListLarge;
     165    ToolBar1.ButtonWidth := 32 + 7;
     166    ToolBar1.ButtonHeight := 32 + 6;
     167    ToolBar1.Height := 32 + 10;
     168  end else begin
     169    ToolBar1.ButtonWidth := 16 + 7;
     170    ToolBar1.ButtonHeight := 16 + 6;
     171    ToolBar1.Height := 16 + 10;
     172    ToolBar1.Images := Core.ImageListSmall;
    134173  end;
    135174end;
     
    165204  end;
    166205  Redraw;
     206end;
     207
     208procedure TFormMain.AToolBarBigIconsExecute(Sender: TObject);
     209begin
     210  AToolBarBigIcons.Checked := not AToolBarBigIcons.Checked;
     211  ReloadView;
    167212end;
    168213
     
    194239begin
    195240  Core.Game.Running := False;
     241  SaveConfig(Core.XMLConfig1, 'FormMain');
    196242end;
    197243
     
    202248procedure TFormMain.FormShow(Sender: TObject);
    203249begin
    204   Redraw;
     250  LoadConfig(Core.XMLConfig1, 'FormMain');
     251  ReloadView;
     252  Redraw;
     253end;
     254
     255procedure TFormMain.MenuItem19Click(Sender: TObject);
     256begin
     257
    205258end;
    206259
Note: See TracChangeset for help on using the changeset viewer.