Menu

[r357]: / trunk / Src / UMainDisplayMgr.pas  Maximize  Restore  History

Download this file

404 lines (364 with data), 13.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
{
* UMainDisplayMgr.pas
*
* Class that manages and co-ordinates the display of the program's main UI.
* Calls into subsidiary manager objects to perform display operations.
*
* $Rev$
* $Date$
*
* ***** BEGIN LICENSE BLOCK *****
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* The Original Code is UMainDisplayMgr.pas
*
* The Initial Developer of the Original Code is Peter Johnson
* (http://www.delphidabbler.com/).
*
* Portions created by the Initial Developer are Copyright (C) 2005-2009 Peter
* Johnson. All Rights Reserved.
*
* Contributor(s)
* NONE
*
* ***** END LICENSE BLOCK *****
}
unit UMainDisplayMgr;
interface
uses
// Project
IntfCompilers, IntfFrameMgrs, UView;
type
{
TMainDisplayMgr:
Manages and co-ordinates the display of the program's main UI. Calls into
subsidiary manager objects to perform display operations.
}
TMainDisplayMgr = class(TObject)
strict private
fOverviewMgr: IInterface; // Manager object for overview pane
fDetailsMgr: IInterface; // Manager object for details pane
fCurrentView: TViewItem; // Value of CurrentView property
procedure InternalDisplayViewItem(const ViewItem: TViewItem;
const Force: Boolean);
{Displays a view item. Updates current view item, selects item in overview
if possible and displays full details in detail pane. Optionally forces
redisplay of compiler pane.
@param ViewItem [in] Item to be displayed (may be nil).
@param Force [in] True if compiler pane redisplay is to be forced.
}
function GetInteractiveTabMgr: ITabbedDisplayMgr;
{Gets reference to manager object for interactive tab set.
@return Required tab manager or nil if no tab is interactive.
}
function GetSelectedOverviewTab: Integer;
{Read accessor for SelectedOverviewTab property. Gets currently selected
overview tab.
@return Index of selected tab.
}
procedure SetSelectedOverviewTab(const Value: Integer);
{Write accessor for SelectedOverviewTab property. Selects required tab.
@param Value [in] Index of tab to be selected.
}
function GetSelectedDetailTab: Integer;
{Read accessor for SelectedDetailTab property. Gets currently selected
overview tab.
@return Index of selected tab.
}
procedure SetSelectedDetailTab(const Value: Integer);
{Write accessor for SelectedDetailTab property. Selects required tab.
@param Value [in] Index of tab to be selected.
}
public
constructor Create(const OverviewMgr, DetailsMgr: IInterface);
{Class constructor. Sets up object to work with subsidiary manager
objects.
@param OverviewMgr [in] Manager object for Overview pane.
@param DetailsMgr [in] Manager object for Details pane.
}
destructor Destroy; override;
{Class destructor. Tears down object.
}
procedure Initialise;
{Initialises display. All snippets in database are shown in overview pane
and detail pane is cleared.
}
procedure Clear;
{Clears the main display, i.e. overview and detail panes.
}
procedure DisplayViewItem(const ViewItem: TViewItem);
{Displays a view item. Updates current view item, selects item in overview
if possible and displays full details in detail pane.
@param ViewItem [in] Item to be displayed (may be nil).
}
procedure Refresh;
{Refreshes current display, forcing redisplay of info and compiler check
panes.
}
procedure QueryUpdated;
{Notifies display manager that query current query has changed. Updates
display to reflect changes.
}
procedure SelectNextActiveTab;
{Selects next tab in currently active tab set. Does nothing if there is no
active tab set.
}
procedure SelectPreviousActiveTab;
{Selects previous tab in currently active tab set. Does nothing if there
is no active tab set.
}
procedure DisplayCompileResults(const ACompilers: ICompilers);
{Displays results of a test compilation in Compiler Check tab of Details
pane.
@param ACompilers [in] Compilers object containing required results.
}
function CanCopy: Boolean;
{Checks whether copying to clipboard is currently supported.
@return True if clipboard copying supported, false if not.
}
procedure UpdateOverviewTreeState(const State: TTreeNodeAction);
{Updates the expanded / collapsed state of nodes in the overview pane's
treeview control.
@param State [in] Determines which expand / collapse action is to be
performed.
}
function CanUpdateOverviewTreeState(const State: TTreeNodeAction): Boolean;
{Checks if a sepcified expand / collapse action on the overview pane's
treeview can be permitted.
@param State [in] Specifies the expand / collapse action being queried.
}
procedure CopyToClipboard;
{Copies selected text to clipboard.
}
function CanSelectAll: Boolean;
{Checks whether selection of all text in current detail view is permitted.
@return True if text can be selected, false otherwise.
}
procedure SelectAll;
{Selects all text in current tab of detail pane.
}
property CurrentView: TViewItem
read fCurrentView;
{Information about currently displayed view}
property SelectedOverviewTab: Integer
read GetSelectedOverviewTab write SetSelectedOverviewTab;
{Gets and sets an overview tab. Writing the property selects the required
tab}
property SelectedDetailTab: Integer
read GetSelectedDetailTab write SetSelectedDetailTab;
{Gets and sets a detail pane tab. Writing the property selects the
required tab}
end;
implementation
uses
// Delphi
SysUtils,
// Project
UQuery;
{ TMainDisplayMgr }
function TMainDisplayMgr.CanCopy: Boolean;
{Checks whether copying to clipboard is currently supported.
@return True if clipboard copying supported, false if not.
}
begin
Result := (fDetailsMgr as IClipboardMgr).CanCopy;
end;
function TMainDisplayMgr.CanSelectAll: Boolean;
{Checks whether selection of all text in current detail view is permitted.
@return True if text can be selected, false otherwise.
}
begin
Result := (fDetailsMgr as ISelectionMgr).CanSelectAll;
end;
function TMainDisplayMgr.CanUpdateOverviewTreeState(
const State: TTreeNodeAction): Boolean;
{Checks if a sepcified expand / collapse action on the overview pane's
treeview can be permitted.
@param State [in] Specifies the expand / collapse action being queried.
}
begin
Result := (fOverviewMgr as IOverviewDisplayMgr).CanUpdateTreeState(State);
end;
procedure TMainDisplayMgr.Clear;
{Clears the main display, i.e. overview and detail panes.
}
begin
fCurrentView.Assign(nil);
(fOverviewMgr as IOverviewDisplayMgr).Clear;
(fDetailsMgr as IViewItemDisplayMgr).Display(fCurrentView, False);
end;
procedure TMainDisplayMgr.CopyToClipboard;
{Copies selected text to clipboard.
}
begin
(fDetailsMgr as IClipboardMgr).CopyToClipboard;
end;
constructor TMainDisplayMgr.Create(const OverviewMgr, DetailsMgr: IInterface);
{Class constructor. Sets up object to work with subsidiary manager objects.
@param OverviewMgr [in] Manager object for Overview pane.
@param DetailsMgr [in] Manager object for Details pane.
}
begin
Assert(Assigned(OverviewMgr), ClassName + '.Create: OverviewMgr is nil');
Assert(Assigned(DetailsMgr), ClassName + '.Create: DetailsMgr is nil');
inherited Create;
// Record subsidiary display managers
fOverviewMgr := OverviewMgr;
fDetailsMgr := DetailsMgr;
// Create owned view object: stores current view
fCurrentView := TViewItem.Create;
end;
destructor TMainDisplayMgr.Destroy;
{Class destructor. Tears down object.
}
begin
FreeAndNil(fCurrentView);
inherited;
end;
procedure TMainDisplayMgr.DisplayCompileResults(const ACompilers: ICompilers);
{Displays results of a test compilation.
@param ACompilers [in] Compilers object containing required results.
}
begin
(fDetailsMgr as ICompCheckDisplayMgr).DisplayCompileResults(ACompilers);
end;
procedure TMainDisplayMgr.DisplayViewItem(const ViewItem: TViewItem);
{Displays a view item. Updates current view item, selects item in overview if
possible and displays full details in detail pane.
@param ViewItem [in] Item to be displayed (may be nil).
}
begin
InternalDisplayViewItem(ViewItem, False);
end;
function TMainDisplayMgr.GetInteractiveTabMgr: ITabbedDisplayMgr;
{Gets reference to manager object for interactive tab set.
@return Required tab manager or nil if no tab is interactive.
}
begin
Result := nil;
if (fOverviewMgr as IPaneInfo).IsInteractive then
Result := fOverviewMgr as ITabbedDisplayMgr
else if (fDetailsMgr as IPaneInfo).IsInteractive then
Result := fDetailsMgr as ITabbedDisplayMgr;
end;
function TMainDisplayMgr.GetSelectedDetailTab: Integer;
{Read accessor for SelectedDetailTab property. Gets currently selected
overview tab.
@return Index of selected tab.
}
begin
Result := (fDetailsMgr as ITabbedDisplayMgr).SelectedTab;
end;
function TMainDisplayMgr.GetSelectedOverviewTab: Integer;
{Read accessor for SelectedOverviewTab property. Gets currently selected
overview tab.
@return Index of selected tab.
}
begin
Result := (fOverviewMgr as ITabbedDisplayMgr).SelectedTab;
end;
procedure TMainDisplayMgr.Initialise;
{Initialises display. All snippets in database are shown in overview pane and
detail pane is cleared.
}
begin
// First we clear the display
Clear;
// Now we display current query in overview pane
QueryUpdated;
end;
procedure TMainDisplayMgr.InternalDisplayViewItem(const ViewItem: TViewItem;
const Force: Boolean);
{Displays a view item. Updates current view item, selects item in overview
if possible and displays full details in detail pane. Optionally forces
redisplay of compiler pane.
@param ViewItem [in] Item to be displayed (may be nil).
@param Force True [in] if compiler pane redisplay is to be forced.
}
begin
// Record view item
fCurrentView.Assign(ViewItem);
// Select item in overview pane and display in detail pane
(fOverviewMgr as IOverviewDisplayMgr).SelectItem(fCurrentView);
(fDetailsMgr as IViewItemDisplayMgr).Display(fCurrentView, Force);
end;
procedure TMainDisplayMgr.QueryUpdated;
{Notifies display manager that current query has changed. Updates display to
reflect changes.
}
begin
// Update overview to show only found snippets
(fOverviewMgr as IOverviewDisplayMgr).Display(Query.Selection);
// Force redisplay of current view item (overview list may not have it and it
// may need search items highlighting or unhighlighting in detail view)
Refresh;
end;
procedure TMainDisplayMgr.Refresh;
{Refreshes current display, forcing redisplay of info and compiler check
panes.
}
begin
InternalDisplayViewItem(fCurrentView, True);
end;
procedure TMainDisplayMgr.SelectAll;
{Selects all text in current tab of detail pane.
}
begin
// Only details pane supports text selection
(fDetailsMgr as ISelectionMgr).SelectAll;
end;
procedure TMainDisplayMgr.SelectNextActiveTab;
{Selects next tab in currently active tab set. Does nothing if there is no
active tab set.
}
var
TabMgr: ITabbedDisplayMgr; // reference to active tab manager object
begin
TabMgr := GetInteractiveTabMgr;
if Assigned(TabMgr) then
TabMgr.NextTab;
end;
procedure TMainDisplayMgr.SelectPreviousActiveTab;
{Selects previous tab in currently active tab set. Does nothing if there is no
active tab set.
}
var
TabMgr: ITabbedDisplayMgr; // reference to active tab manager object
begin
TabMgr := GetInteractiveTabMgr;
if Assigned(TabMgr) then
TabMgr.PreviousTab;
end;
procedure TMainDisplayMgr.SetSelectedDetailTab(const Value: Integer);
{Write accessor for SelectedDetailTab property. Selects required tab.
@param Value [in] Index of tab to be selected.
}
begin
(fDetailsMgr as ITabbedDisplayMgr).SelectTab(Value);
end;
procedure TMainDisplayMgr.SetSelectedOverviewTab(const Value: Integer);
{Write accessor for SelectedOverviewTab property. Selects required tab.
@param Value [in] Index of tab to be selected.
}
begin
(fOverviewMgr as ITabbedDisplayMgr).SelectTab(Value);
end;
procedure TMainDisplayMgr.UpdateOverviewTreeState(const State: TTreeNodeAction);
{Updates the expanded / collapsed state of nodes in the overview pane's
treeview control.
@param State [in] Determines which expand / collapse action is to be
performed.
}
begin
(fOverviewMgr as IOverviewDisplayMgr).UpdateTreeState(State);
end;
end.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.