The R Project SVN R

Rev

Rev 81360 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
51883 ripley 1
 
2
[Code]
3
 
4
var
5
  NoAdminPage: TOutputMsgWizardPage;
6
  SelectOptionsPage: TInputOptionWizardPage;
7
  MDISDIPage: TInputOptionWizardPage;
8
  HelpStylePage: TInputOptionWizardPage;
9
  INIFilename: String;
10
 
83528 kalibera 11
function RIsAdmin: boolean;
51883 ripley 12
begin
83528 kalibera 13
  Result := IsAdmin or IsPowerUserLoggedOn;
51883 ripley 14
end;
15
 
16
function NonAdmin: boolean;
17
begin
83528 kalibera 18
  Result := not RIsAdmin;
51883 ripley 19
end;
20
 
21
procedure InitializeWizard;
22
var
23
  option : String;
24
  index : Integer;
25
begin
81360 kalibera 26
  WizardForm.DiskSpaceLabel.Visible := False;
51883 ripley 27
  NoAdminPage := CreateOutputMsgPage(wpWelcome, SetupMessage(msgInformationTitle), 
28
    CustomMessage('adminprivilegesrequired'), CustomMessage('adminexplanation'));
29
 
30
  SelectOptionsPage := CreateInputOptionPage(wpSelectComponents,
31
    CustomMessage('startupt'), CustomMessage('startupq'),
32
    CustomMessage('startupi'), True, False);
33
  SelectOptionsPage.Add(CustomMessage('startup0'));
34
  SelectOptionsPage.Add(CustomMessage('startup1'));
35
  SelectOptionsPage.SelectedValueIndex := 1;
36
 
37
  MDISDIPage := CreateInputOptionPage(SelectOptionsPage.ID,
38
    CustomMessage('MDIt'), CustomMessage('MDIq'),
39
    CustomMessage('MDIi'), True, False);
40
  MDISDIPage.Add(CustomMessage('MDI0'));
41
  MDISDIPage.Add(CustomMessage('MDI1'));
42
 
43
  HelpStylePage := CreateInputOptionPage(MDISDIPage.ID,
44
    CustomMessage('HelpStylet'), CustomMessage('HelpStyleq'),
45
    CustomMessage('HelpStylei'), True, False);
46
  HelpStylePage.Add(CustomMessage('HelpStyle0'));
47
  HelpStylePage.Add(CustomMessage('HelpStyle1'));
48
 
49
  INIFilename := ExpandConstant('{param:LOADINF}');
50
  if INIFilename <> '' then INIFilename := ExpandFilename(INIFilename);
51
 
52
  { From highest to lowest, priority is:
53
    LOADINF value
54
    PreviousData value
55
    Default from build }
56
 
57
  option := GetPreviousData('MDISDI', '');
58
  if INIFilename <> '' then
59
    option := GetIniString('R', 'MDISDI', option, INIFilename);
60
  case option of
61
    'MDI': index := 0;
62
    'SDI': index := 1;
63
  else
64
    index := @MDISDI@;
65
  end;  
66
  MDISDIPage.SelectedValueIndex := index;
67
 
68
  option := GetPreviousData('HelpStyle', '');
69
  if INIFilename <> '' then
70
    option := GetIniString('R', 'HelpStyle', option, INIFilename);  
71
  case option of
72
    'plain': index := 0;
73
    'CHM':   index := 1;
74
    'HTML':  index := 1;
75
  else
76
    index := @HelpStyle@;
77
  end;
78
  HelpStylePage.SelectedValueIndex := index;
79
 
80
  { Get the save name now, because the current dir might change }
81
  INIFilename := ExpandConstant('{param:SAVEINF}');
82
  if INIFilename <> '' then INIFilename := ExpandFilename(INIFilename);    
83
end;
84
 
85
procedure RegisterPreviousData(PreviousDataKey: Integer);
86
var
87
  MDISDI: String;
88
  HelpStyle: String;
89
begin
90
 
91
  { Store the settings so we can restore them next time }
92
  case MDISDIPage.SelectedValueIndex of
93
    0: MDISDI := 'MDI';
94
    1: MDISDI := 'SDI';
95
  end;
96
  SetPreviousData(PreviousDataKey, 'MDISDI', MDISDI);
97
  if INIFilename <> '' then
98
    SetIniString('R', 'MDISDI', MDISDI, INIFilename);
99
 
100
  case HelpStylePage.SelectedValueIndex of
101
    0: HelpStyle := 'plain';
102
    1: HelpStyle := 'HTML';
103
  end;
104
  SetPreviousData(PreviousDataKey, 'HelpStyle', HelpStyle);  
105
  if INIFilename <> '' then
106
    SetIniString('R', 'HelpStyle', HelpStyle, INIFilename);
107
 
108
end;
109
 
62763 murdoch 110
function SetCommentMarker(var lines: TArrayOfString; option: String; active: boolean) : boolean;
51883 ripley 111
var
112
  i : integer;
62763 murdoch 113
  old : string;
51883 ripley 114
begin
62763 murdoch 115
  Result := false;
51883 ripley 116
  for i := 0 to pred(GetArrayLength(lines)) do
117
    if pos(option, lines[i]) > 0 then 
118
    begin
62763 murdoch 119
      old := lines[i];
51883 ripley 120
      if active then
121
        lines[i][1] := ' '
122
      else
123
        lines[i][1] := '#';
62763 murdoch 124
      if old <> lines[i] then
125
        Result := true;  
51883 ripley 126
      exit;
127
    end;
128
end;
129
 
130
procedure EditOptions();
131
var
132
  lines : TArrayOfString;
133
  filename : String;
62763 murdoch 134
  changed : boolean;
51883 ripley 135
begin
62763 murdoch 136
  changed := false;
51883 ripley 137
  filename := ExpandConstant(CurrentFilename);
138
  LoadStringsFromFile(filename, lines);
139
 
63077 murdoch 140
  if SetCommentMarker(lines, 'MDI = yes', MDISDIPage.SelectedValueIndex = 0) then changed := true;
141
  if SetCommentMarker(lines, 'MDI = no', MDISDIPage.SelectedValueIndex = 1) then changed := true;
51883 ripley 142
 
63077 murdoch 143
  if SetCommentMarker(lines, 'options(help_type="text"', HelpStylePage.SelectedValueIndex = 0) then changed := true;
144
  if SetCommentMarker(lines, 'options(help_type="html"', HelpStylePage.SelectedValueIndex = 1) then changed := true;
51883 ripley 145
 
62763 murdoch 146
  if changed then
147
    SaveStringsToFile(filename, lines, False);
51883 ripley 148
end;
149
 
150
function ShouldSkipPage(PageID: Integer): boolean;
151
begin
83528 kalibera 152
  if PageID = NoAdminPage.ID then Result := RIsAdmin
68631 murdoch 153
  else if (PageID = MDISDIPage.ID) or (PageID = HelpStylePage.ID) then 
51883 ripley 154
    Result := SelectOptionsPage.SelectedValueIndex = 1
155
  else Result := false;
156
end;
157
 
158
function UserPF(Param:String): String;
159
begin
160
  Result := ExpandConstant('{pf}');
83528 kalibera 161
  if (not RIsAdmin) then 
51883 ripley 162
  begin
163
    try
81360 kalibera 164
      Result := ExpandConstant('{userpf}');
51883 ripley 165
    except
81360 kalibera 166
    // Change nothing.
51883 ripley 167
    end;
168
  end;
169
end;