2 TfmToolbarEditor = class(TForm)
\r
4 lvButtons: TListView;
\r
10 chkSeparator: TCheckBox;
\r
13 opDialog1: TOpenDialog;
\r
15 opDialog1: TOpenPictureDialog;
\r
17 ilImages: TImageList;
\r
18 chkStayOnTop: TCheckBox;
\r
19 chkDropDown: TCheckBox;
\r
20 {procedure lvButtonsSelectItem(Sender: TObject; Item: TListItem;
\r
21 Selected: Boolean);}
\r
22 procedure btnAddClick(Sender: TObject);
\r
23 procedure btnDeleteClick(Sender: TObject);
\r
24 procedure btnUpClick(Sender: TObject);
\r
25 procedure btnDownClick(Sender: TObject);
\r
26 procedure chkSeparatorClick(Sender: TObject);
\r
27 procedure lvButtonsEdited(Sender: TObject; Item: TListItem;
\r
29 procedure btnPictureClick(Sender: TObject);
\r
30 procedure FormShow(Sender: TObject);
\r
31 procedure btnOKClick(Sender: TObject);
\r
32 //procedure btnCancelClick(Sender: TObject);
\r
33 procedure FormKeyDown(Sender: TObject; var Key: Word;
\r
34 Shift: TShiftState);
\r
35 procedure FormClose(Sender: TObject; var Action: TCloseAction);
\r
36 procedure FormDestroy(Sender: TObject);
\r
37 procedure chkStayOnTopClick(Sender: TObject);
\r
38 procedure chkDropDownClick(Sender: TObject);
\r
40 { Private declarations }
\r
42 FToolbar: TComponent;
\r
43 procedure AdjustButtons;
\r
44 procedure SetToolbar(const Value: TComponent);
\r
45 procedure lvButtonsChange(Sender: TObject; Item: TListItem; Change: TItemChange);
\r
46 //function SeparatorsCount: Integer;
\r
47 procedure AssembleBitmap;
\r
48 procedure AssembleButtons;
\r
51 { Public declarations }
\r
53 ButtonCaptions: String;
\r
54 constructor Create( AOwner: TComponent ); override;
\r
55 destructor Destroy; override;
\r
56 property ToolbarControl: TComponent read FToolbar write SetToolbar;
\r
57 procedure MakeActive( SelectAny: Boolean );
\r
58 procedure RefreshItems;
\r
59 procedure ApplyImages;
\r
63 fmToolbarEditor: TfmToolbarEditor;
\r
68 mirror, mckCtrls, mckObjs;
\r
70 procedure TfmToolbarEditor.AdjustButtons;
\r
72 Bt: TKOLToolbarButton;
\r
74 LI := lvButtons.Selected;
\r
77 btnAdd.Enabled := lvButtons.Items.Count = 0;
\r
78 btnDelete.Enabled := FALSE;
\r
79 btnUp.Enabled := FALSE;
\r
80 btnDown.Enabled := FALSE;
\r
81 btnPicture.Enabled := FALSE;
\r
82 if chkSeparator.Checked then
\r
83 chkSeparator.Checked := FALSE;
\r
84 chkSeparator.Enabled := FALSE;
\r
85 btnOK.Enabled := TRUE;
\r
86 chkDropDown.Enabled := FALSE;
\r
87 //btnCancel.Enabled := CanCancel;
\r
91 btnAdd.Enabled := TRUE;
\r
92 btnDelete.Enabled := TRUE;
\r
93 btnUp.Enabled := LI.Index > 0;
\r
94 btnDown.Enabled := LI.Index < lvButtons.Items.Count - 1;
\r
95 btnPicture.Enabled := TRUE;
\r
96 chkSeparator.Enabled := TRUE;
\r
97 if chkSeparator.Checked <> (LI.Caption = '-') then
\r
98 chkSeparator.Checked := LI.Caption = '-';
\r
99 btnOK.Enabled := TRUE;
\r
100 chkDropDown.Enabled := TRUE;
\r
102 chkDropDown.Checked := Bt.DropDown;
\r
103 //btnCancel.Enabled := CanCancel;
\r
107 constructor TfmToolbarEditor.Create(AOwner: TComponent);
\r
110 BorderIcons := [biSystemMenu];
\r
111 BorderStyle := bsDialog;
\r
112 Caption := 'fmToolbarEditor';
\r
113 ClientHeight := 281;
\r
114 ClientWidth := 277;
\r
115 Color := clBtnFace;
\r
116 //Font.Charset := DEFAULT_CHARSET;
\r
117 Font.Color := clWindowText;
\r
118 Font.Height := -11;
\r
119 Font.Name := 'MS Sans Serif';
\r
121 KeyPreview := True;
\r
122 //OldCreateOrder = False
\r
124 OnShow := FormShow;
\r
125 OnClose := FormClose;
\r
126 OnDestroy := FormDestroy;
\r
127 OnKeyDown := FormKeyDown;
\r
128 //PixelsPerInch = 96
\r
130 ilImages := TImageList.Create( Self );
\r
131 lvButtons := TListView.Create( Self );
\r
132 lvButtons.Parent := Self;
\r
133 lvButtons.Left := 6;
\r
134 lvButtons.Top := 8;
\r
135 lvButtons.Width := 163;
\r
136 lvButtons.Height := 265;
\r
137 lvButtons.MultiSelect := FALSE;
\r
138 lvButtons.Columns.Add;
\r
139 lvButtons.Columns[ 0 ].Caption := 'Buttons';
\r
140 lvButtons.Columns[ 0 ].Width := -2;
\r
141 lvButtons.HideSelection := False;
\r
143 lvButtons.RowSelect := TRUE;
\r
145 lvButtons.ShowColumnHeaders := False;
\r
146 lvButtons.SmallImages := ilImages;
\r
147 //lvButtons.TabOrder := 0;
\r
148 lvButtons.ViewStyle := vsReport;
\r
149 lvButtons.OnEdited := lvButtonsEdited;
\r
150 //lvButtons.OnSelectItem := lvButtonsSelectItem;
\r
151 lvButtons.OnChange := lvButtonsChange;
\r
152 btnOK := TButton.Create( Self );
\r
153 btnOK.Parent := Self;
\r
157 btnOK.Height := 25;
\r
158 btnOK.Caption := 'Apply';
\r
159 //btnOK.TabOrder := 1;
\r
160 btnOK.OnClick := btnOKClick;
\r
161 chkStayOnTop := TCheckBox.Create( Self );
\r
162 chkStayOnTop.Parent := Self;
\r
163 chkStayOnTop.Left := 180;
\r
164 chkStayOnTop.Top := 40;
\r
165 chkStayOnTop.Width := 89;
\r
166 chkStayOnTop.Height := 17;
\r
167 chkStayOnTop.Caption := 'Stay on top';
\r
168 //chkStayOnTop.TabOrder := 2;
\r
169 chkStayOnTop.OnClick := chkStayOnTopClick;
\r
170 btnAdd := TButton.Create( Self );
\r
171 btnAdd.Parent := Self;
\r
172 btnAdd.Left := 180;
\r
174 btnAdd.Width := 89;
\r
175 btnAdd.Height := 25;
\r
176 btnAdd.Caption := 'Add';
\r
177 //btnAdd.TabOrder := 3;
\r
178 btnAdd.OnClick := btnAddClick;
\r
179 btnDelete := TButton.Create( Self );
\r
180 btnDelete.Parent := Self;
\r
181 btnDelete.Left := 180;
\r
182 btnDelete.Top := 112;
\r
183 btnDelete.Width := 89;
\r
184 btnDelete.Height := 25;
\r
185 btnDelete.Caption := 'Delete';
\r
186 //btnDelete.TabOrder := 4;
\r
187 btnDelete.OnClick := btnDeleteClick;
\r
188 btnUp := TButton.Create( Self );
\r
189 btnUp.Parent := Self;
\r
193 btnUp.Height := 25;
\r
194 btnUp.Caption := 'Up';
\r
195 //btnUp.TabOrder := 5;
\r
196 btnUp.OnClick := btnUpClick;
\r
197 btnDown := TButton.Create( Self );
\r
198 btnDown.Parent := Self;
\r
199 btnDown.Left := 228;
\r
200 btnDown.Top := 152;
\r
201 btnDown.Width := 41;
\r
202 btnDown.Height := 25;
\r
203 btnDown.Caption := 'Down';
\r
204 //btnDown.TabOrder := 6;
\r
205 btnDown.OnClick := btnDownClick;
\r
206 btnPicture := TButton.Create( Self );
\r
207 btnPicture.Parent := Self;
\r
208 btnPicture.Left := 180;
\r
209 btnPicture.Top := 192;
\r
210 btnPicture.Width := 89;
\r
211 btnPicture.Height := 25;
\r
212 btnPicture.Caption := 'Picture';
\r
213 //btnPicture.TabOrder := 7;
\r
214 btnPicture.OnClick := btnPictureClick;
\r
215 btnPicture.Visible := FALSE;
\r
216 chkSeparator := TCheckBox.Create( Self );
\r
217 chkSeparator.Parent := Self;
\r
218 chkSeparator.Left := 180;
\r
219 chkSeparator.Top := 227;
\r
220 chkSeparator.Width := 89;
\r
221 chkSeparator.Height := 17;
\r
222 chkSeparator.Caption := 'Separator';
\r
223 //chkSeparator.TabOrder := 8;
\r
224 chkSeparator.OnClick := chkSeparatorClick;
\r
225 chkDropDown := TCheckBox.Create( Self );
\r
226 chkDropDown.Parent := Self;
\r
227 chkDropDown.Left := 180;
\r
228 chkDropDown.Top := 255;
\r
229 chkDropDown.Width := 89;
\r
230 chkDropDown.Height := 17;
\r
231 chkDropDown.Caption := 'DropDown';
\r
232 //chkDropDown.TabOrder := 9;
\r
233 chkDropDown.OnClick := chkDropDownClick;
\r
235 opDialog1 := TOpenDialog.Create( Self );
\r
237 opDialog1 := TOpenPictureDialog.Create( Self );
\r
239 opDialog1.DefaultExt := 'bmp';
\r
241 opDialog1.Filter := 'All available image files|*.bmp;*.ico;*.wmf';
\r
243 opDialog1.Options := [ofHideReadOnly, ofPathMustExist, ofFileMustExist
\r
244 {$IFNDEF VER90}{$IFNDEF VER100}, ofEnableSizing{$ENDIF}{$ENDIF} ];
\r
245 opDialog1.Title := 'Open picture';
\r
248 Bitmap := TBitmap.Create;
\r
251 procedure TfmToolbarEditor.lvButtonsChange(Sender: TObject; Item: TListItem; Change: TItemChange);
\r
253 MakeActive( FALSE );
\r
257 procedure TfmToolbarEditor.btnAddClick(Sender: TObject);
\r
259 Bt: TKOLToolbarButton;
\r
260 Toolbar: TKOLToolbar;
\r
264 if ToolbarControl = nil then Exit;
\r
265 if not( ToolbarControl is TKOLToolbar ) then Exit;
\r
266 Toolbar := ToolbarControl as TKOLToolbar;
\r
267 LI := lvButtons.Selected;
\r
270 Bt := TKOLToolbarButton.Create( Toolbar );
\r
271 LI := lvButtons.Items.Add;
\r
276 if LI.Index >= lvButtons.Items.Count then
\r
277 Bt := TKOLToolbarButton.Create( Toolbar )
\r
280 Bt := TKOLToolbarButton.Create( Toolbar );
\r
281 Toolbar.Items.Move( lvButtons.Items.Count, LI.Index + 1 );
\r
283 LI := lvButtons.Items.Insert( LI.Index + 1 );
\r
287 if ToolbarControl <> nil then
\r
288 if ToolbarControl.Owner is TForm then
\r
289 for I := 1 to MaxInt do
\r
291 S := 'TB' + IntToStr( I );
\r
292 if (ToolbarControl.Owner as TForm).FindComponent( S ) = nil then
\r
293 if ToolbarControl.FindComponent( S ) = nil then
\r
300 Bt.imgIndex := Toolbar.MaxImgIndex;
\r
302 LI.ImageIndex := -1;
\r
304 lvButtons.Selected := nil;
\r
305 lvButtons.Selected := LI;
\r
306 lvButtons.ItemFocused := LI;
\r
307 LI.MakeVisible( FALSE );
\r
311 procedure TfmToolbarEditor.btnDeleteClick(Sender: TObject);
\r
314 Bt: TKOLToolbarButton;
\r
316 LI := lvButtons.Selected;
\r
323 if J >= lvButtons.Items.Count then
\r
327 lvButtons.Selected := lvButtons.Items[ J ];
\r
328 lvButtons.ItemFocused := lvButtons.Selected;
\r
333 if lvButtons.Items.Count = 0 then
\r
337 procedure TfmToolbarEditor.btnUpClick(Sender: TObject);
\r
338 var LI, LI1: TListItem;
\r
340 Toolbar: TKOLToolbar;
\r
342 if ToolbarControl = nil then Exit;
\r
343 if not(ToolbarControl is TKOLToolbar) then Exit;
\r
344 Toolbar := ToolbarControl as TKOLToolbar;
\r
345 LI := lvButtons.Selected;
\r
346 if LI = nil then Exit;
\r
348 LI1 := lvButtons.Items.Insert( I );
\r
349 LI1.Caption := LI.Caption;
\r
350 LI1.Data := LI.Data;
\r
351 Toolbar.Items.Move( I + 1, I );
\r
353 lvButtons.Selected := LI1;
\r
354 lvButtons.ItemFocused := LI1;
\r
358 procedure TfmToolbarEditor.btnDownClick(Sender: TObject);
\r
359 var LI, LI1: TListItem;
\r
360 Toolbar: TKOLToolbar;
\r
362 if ToolbarControl = nil then Exit;
\r
363 if not(ToolbarControl is TKOLToolbar) then Exit;
\r
364 Toolbar := ToolbarControl as TKOLToolbar;
\r
365 LI := lvButtons.Selected;
\r
366 if LI = nil then Exit;
\r
367 Toolbar.Items.Move( LI.Index, LI.Index + 1 );
\r
368 LI1 := lvButtons.Items.Insert( LI.Index + 2 );
\r
369 LI1.Caption := LI.Caption;
\r
370 LI1.Data := LI.Data;
\r
372 lvButtons.Selected := LI1;
\r
373 lvButtons.ItemFocused := LI1;
\r
377 procedure TfmToolbarEditor.chkSeparatorClick(Sender: TObject);
\r
381 Bt: TKOLToolbarButton;
\r
382 Toolbar: TKOLToolbar;
\r
384 LI := lvButtons.Selected;
\r
385 if LI = nil then Exit;
\r
387 if chkSeparator.Checked then
\r
389 if LI.Caption <> '-' then
\r
391 Bt.separator := TRUE;
\r
393 I := LI.ImageIndex;
\r
394 Bmp := TBitmap.Create;
\r
397 Bmp.Width := Bitmap.Width - Bitmap.Height;
\r
398 Bmp.Height := Bitmap.Height;
\r
399 Bmp.Canvas.Brush.Color := Bitmap.Canvas.Pixels[ 0, Bmp.Height - 1 ];
\r
400 Bmp.Canvas.FillRect( Rect( 0, 0, Bmp.Width, Bmp.Height ) );
\r
401 Bmp.Canvas.CopyRect( Rect( 0, 0, I * Bmp.Height, Bmp.Height ),
\r
403 Rect( 0, 0, I * Bmp.Height, Bmp.Height ) );
\r
404 Bmp.Canvas.CopyRect( Rect( I * Bmp.Height, 0, Bmp.Width, Bmp.Height ),
\r
406 Rect( (I + 1) * Bmp.Height, 0, Bitmap.Width, Bmp.Height ) );
\r
418 if LI.Caption = '-' then
\r
420 Bt.separator := FALSE;
\r
421 I := LI.ImageIndex;
\r
422 Bmp := TBitmap.Create;
\r
425 Bmp.Width := Bitmap.Width + Bitmap.Height;
\r
426 Bmp.Height := Bitmap.Height;
\r
427 Bmp.Canvas.Brush.Color := Bitmap.Canvas.Pixels[ 0, Bmp.Height - 1 ];
\r
428 Bmp.Canvas.FillRect( Rect( 0, 0, Bmp.Width, Bmp.Height ) );
\r
429 Bmp.Canvas.CopyRect( Rect( 0, 0, I * Bmp.Height, Bmp.Height ),
\r
431 Rect( 0, 0, I * Bmp.Height, Bmp.Height ) );
\r
432 Bmp.Canvas.CopyRect( Rect( (I + 1) * Bmp.Height, 0, Bmp.Width, Bmp.Height ),
\r
434 Rect( I * Bmp.Height, 0, Bitmap.Width, Bmp.Height ) );
\r
443 if ToolbarControl = nil then Exit;
\r
444 Toolbar := ToolbarControl as TKOLToolbar;
\r
445 Toolbar.Items2buttons;
\r
448 procedure TfmToolbarEditor.lvButtonsEdited(Sender: TObject;
\r
449 Item: TListItem; var S: String);
\r
450 var Bt: TKOLToolbarButton;
\r
452 chkSeparator.Checked := S = '-';
\r
457 procedure TfmToolbarEditor.btnPictureClick(Sender: TObject);
\r
461 (*var LI: TListItem;
\r
463 Bmp, Bmp2: TBitmap;
\r
465 Toolbar: TKOLToolbar;
\r
467 LI := lvButtons.Selected;
\r
468 if LI = nil then Exit;
\r
469 ImgIdx := ButtonImgIdx( LI.Index );
\r
470 if opDialog1.Execute then
\r
472 Pic := TPicture.Create;
\r
473 Bmp := TBitmap.Create;
\r
474 Bmp2 := TBitmap.Create;
\r
476 Pic.LoadFromFile( opDialog1.Filename );
\r
477 if not Pic.Graphic.Empty then
\r
479 if lvButtons.Items.Count = 1 then
\r
482 Bitmap.Height := 0;
\r
484 if (Bitmap.Height = 0) or (Bitmap.Width = 0) then
\r
486 Bitmap.Height := Pic.Graphic.Height;
\r
488 if Bitmap.Width < Bitmap.Height * (ImgIdx + 1) then
\r
490 Bmp2.Height := Bitmap.Height;
\r
491 Bmp2.Width := Bitmap.Height * (ImgIdx + 1);
\r
492 Bmp2.Canvas.Brush.Color := Bitmap.Canvas.Pixels[ 0, Bmp2.Height-1 ];
\r
493 Bmp2.Canvas.FillRect( Rect( 0, 0, Bmp2.Width, Bmp2.Height ) );
\r
494 Bmp2.Canvas.CopyRect( Rect( 0, 0, Bitmap.Width, Bitmap.Height ),
\r
496 Rect( 0, 0, Bitmap.Width, Bitmap.Height ) );
\r
499 Bmp2 := TBitmap.Create;
\r
501 Bmp2.Width := Bitmap.Height;
\r
502 Bmp2.Height := Bitmap.Height;
\r
503 Bmp2.Canvas.Brush.Color := Bitmap.Canvas.Pixels[ 0, Bitmap.Height - 1 ];
\r
504 Bmp2.Canvas.FillRect( Rect( 0, 0, Bmp2.Width, Bmp2.Height ) );
\r
506 Bmp.Width := Pic.Graphic.Width;
\r
507 Bmp.Height := Pic.Graphic.Height;
\r
508 Bmp.Canvas.Brush.Color := Bitmap.Canvas.Pixels[ 0, Bitmap.Height - 1 ];
\r
509 Bmp.Canvas.FillRect( Rect( 0, 0, Bmp.Width, Bmp.Height ) );
\r
511 Bmp.Canvas.Draw( 0, 0, Pic.Graphic );
\r
513 Bmp.TransparentColor := Bmp.Canvas.Pixels[ 0, Bmp.Height - 1 ];
\r
514 Bmp.Transparent := TRUE;
\r
516 Bmp2.Canvas.StretchDraw( Rect( 0, 0, Bmp2.Width, Bmp2.Height ), Bmp );
\r
517 Bitmap.Canvas.CopyRect( Rect( ImgIdx * Bitmap.Height, 0, (ImgIdx + 1) * Bitmap.Height, Bitmap.Height ),
\r
519 Rect( 0, 0, Bmp2.Width, Bmp2.Height ) );
\r
528 if ToolbarControl <> nil then
\r
529 if ToolbarControl is TKOLToolbar then
\r
531 Toolbar := ToolbarControl as TKOLToolbar;
\r
532 Toolbar.bitmap.Assign( Bitmap );
\r
533 Toolbar.bitmap2ItemPictures;
\r
537 destructor TfmToolbarEditor.Destroy;
\r
543 procedure TfmToolbarEditor.FormShow(Sender: TObject);
\r
546 Bt: TKOLToolbarButton;
\r
547 Toolbar: TKOLToolbar;
\r
549 lvButtons.Items.BeginUpdate;
\r
552 lvButtons.Items.Clear;
\r
553 if ToolbarControl <> nil then
\r
554 if ToolbarControl is TKOLToolbar then
\r
556 Toolbar := ToolbarControl as TKOLToolbar;
\r
557 for I := 0 to Toolbar.Items.Count-1 do
\r
559 LI := lvButtons.Items.Add;
\r
560 Bt := Toolbar.Items[ I ];
\r
562 LI.Caption := Bt.caption;
\r
568 lvButtons.Items.EndUpdate;
\r
572 procedure TfmToolbarEditor.ApplyImages;
\r
576 Bt: TKOLToolbarButton;
\r
582 TranColor := clNone;
\r
583 for I := 0 to lvButtons.Items.Count-1 do
\r
585 Bt := lvButtons.Items[ I ].Data;
\r
586 if Bt = nil then continue;
\r
587 if Bt.HasPicture then
\r
589 if Bt.picture.Width > W then
\r
590 W := Bt.picture.Width;
\r
591 if Bt.picture.Height > H then
\r
592 H := Bt.picture.Height;
\r
593 if TranColor = clNone then
\r
595 Bmp := TBitmap.Create;
\r
597 Bmp.Assign( Bt.picture.Graphic );
\r
598 TranColor := Bmp.Canvas.Pixels[ 0, Bmp.Height - 1 ];
\r
607 ilImages.Width := W;
\r
608 ilImages.Height := H;
\r
609 Bmp := TBitmap.Create;
\r
613 for I := 0 to lvButtons.Items.Count - 1 do
\r
615 Bt := lvButtons.Items[ I ].Data;
\r
616 if TranColor <> clNone then
\r
618 Bmp.Canvas.Brush.Color := TranColor;
\r
619 Bmp.Canvas.FillRect( Rect( 0, 0, Bmp.Width, Bmp.Height ) );
\r
621 if (Bt <> nil) and Bt.HasPicture then
\r
622 Bmp.Canvas.Draw( 0, 0, Bt.picture.Graphic );
\r
623 if Bt.HasPicture and (Bt.picture.Height > 0) then
\r
625 H1 := Bt.picture.Height;
\r
626 J := ilImages.AddMasked( Bmp, Bmp.Canvas.Pixels[ 0, H1 - 1 ] );
\r
627 lvButtons.Items[ I ].ImageIndex := J;
\r
630 lvButtons.Items[ I ].ImageIndex := -1;
\r
638 ilImages.Width := 16;
\r
639 ilImages.Height := 16;
\r
640 for I := 0 to lvButtons.Items.Count - 1 do
\r
641 lvButtons.Items[ I ].ImageIndex := -1;
\r
645 procedure TfmToolbarEditor.btnOKClick(Sender: TObject);
\r
650 Bt: TKOLToolbarButton;
\r
653 for I := 0 to lvButtons.Items.Count - 1 do
\r
655 LI := lvButtons.Items[ I ];
\r
659 //if LI.Data <> nil then
\r
662 S := S + LI.Caption;
\r
664 ButtonCaptions := S;
\r
665 if ToolbarControl <> nil then
\r
667 Tb := ToolbarControl as TKOLToolbar;
\r
668 Tb.Bitmap.Assign( Bitmap );
\r
669 if (Bitmap.Width > 0) and (Bitmap.Height > 0) then
\r
672 if Bitmap.Height > I - 4 then
\r
673 I := Bitmap.Height + 4;
\r
676 Tb.buttons := ButtonCaptions;
\r
682 {procedure TfmToolbarEditor.btnCancelClick(Sender: TObject);
\r
687 procedure TfmToolbarEditor.FormKeyDown(Sender: TObject; var Key: Word;
\r
688 Shift: TShiftState);
\r
691 VK_INSERT: btnAdd.Click;
\r
692 VK_DELETE: if not lvButtons.IsEditing then btnDelete.Click;
\r
693 VK_RETURN: if (ActiveControl = lvButtons) and not lvButtons.IsEditing and
\r
694 (lvButtons.Selected <> nil) then
\r
695 lvButtons.Selected.EditCaption;
\r
696 VK_UP: if (GetKeyState( VK_CONTROL ) < 0) then
\r
699 VK_DOWN: if (GetKeyState( VK_CONTROL ) < 0) then
\r
707 procedure TfmToolbarEditor.SetToolbar(const Value: TComponent);
\r
708 var Tb: TKOLToolbar;
\r
711 Tb := Value as TKOLToolbar;
\r
712 Caption := Tb.Name + ' buttons';
\r
713 ButtonCaptions := Tb.buttons;
\r
714 Bitmap.Assign( Tb.Bitmap );
\r
717 procedure TfmToolbarEditor.FormClose(Sender: TObject;
\r
718 var Action: TCloseAction);
\r
720 Rpt( 'Closing KOLToolbar form' );
\r
722 modalResult := mrOK;
\r
725 procedure TfmToolbarEditor.MakeActive( SelectAny: Boolean );
\r
729 Bt: TKOLToolbarButton;
\r
731 if lvButtons.Items.Count > 0 then
\r
732 if lvButtons.Selected = nil then
\r
734 lvButtons.Selected := lvButtons.Items[ 0 ];
\r
735 if lvButtons.Selected <> nil then
\r
737 Bt := lvButtons.Selected.Data;
\r
738 F := (ToolbarControl as TKOLToolbar).Owner as TForm;
\r
741 //*///////////////////////////////////////////////////////
\r
742 {$IFDEF _D6orHigher} //
\r
743 F.Designer.QueryInterface(IFormDesigner,D); //
\r
745 //*///////////////////////////////////////////////////////
\r
747 //*///////////////////////////////////////////////////////
\r
749 //*///////////////////////////////////////////////////////
\r
751 if QueryFormDesigner( D, FD ) then
\r
753 RemoveSelection( FD );
\r
754 FD.SelectComponent( Bt );
\r
761 procedure TfmToolbarEditor.FormDestroy(Sender: TObject);
\r
762 var Tb: TKOLToolbar;
\r
764 if ToolbarControl <> nil then
\r
766 Tb := ToolbarControl as TKOLToolbar;
\r
767 Tb.ActiveDesign := nil;
\r
772 procedure TfmToolbarEditor.chkStayOnTopClick(Sender: TObject);
\r
774 if chkStayOnTop.Checked then
\r
775 FormStyle := fsStayOnTop
\r
777 FormStyle := fsNormal;
\r
780 procedure TfmToolbarEditor.chkDropDownClick(Sender: TObject);
\r
782 Bt: TKOLToolbarButton;
\r
784 LI := lvButtons.Selected;
\r
785 if LI = nil then Exit;
\r
787 Bt.DropDown := chkDropDown.Checked;
\r
791 {function TfmToolbarEditor.SeparatorsCount: Integer;
\r
795 for I := 0 to lvButtons.Items.Count-1 do
\r
797 if lvButtons.Items[ I ].Caption = '-' then
\r
802 {function TfmToolbarEditor.ButtonImgIdx(BtnIdx: Integer): Integer;
\r
806 for I := 0 to BtnIdx - 1 do
\r
807 if lvButtons.Items[ I ].Caption <> '-' then
\r
811 procedure TfmToolbarEditor.RefreshItems;
\r
814 Bt: TKOLToolbarButton;
\r
816 for I := 0 to lvButtons.Items.Count-1 do
\r
818 LI := lvButtons.Items[ I ];
\r
822 if LI.Caption <> Bt.Caption then
\r
824 lvButtons.OnChange := nil;
\r
825 LI.Caption := Bt.caption;
\r
826 lvButtons.OnChange := lvButtonsChange;
\r
828 if lvButtons.Selected = LI then
\r
830 {ShowMessage( 'Bt.caption=' + Bt.caption +
\r
831 ' Bt.checked=' + IntToStr( Integer( Bt.checked ) ) +
\r
832 ' Bt.dropdown=' + IntToStr( Integer( Bt.dropdown ) ) +
\r
833 ' chkSeparator.Checked=' + IntToStr( Integer( chkSeparator.Checked ) ) +
\r
834 ' chkDropDown.Checked=' + IntToStr( Integer( chkDropDown.Checked ) ) );}
\r
835 if chkSeparator.Checked <> Bt.separator then
\r
837 chkSeparator.OnClick := nil;
\r
838 chkSeparator.Checked := Bt.separator;
\r
839 chkSeparator.OnClick := chkSeparatorClick;
\r
841 if chkDropDown.Checked <> Bt.dropdown then
\r
843 chkDropDown.OnClick := nil;
\r
844 chkDropDown.Checked := Bt.dropdown;
\r
845 chkDropDown.OnClick := chkDropDownClick;
\r
853 procedure TfmToolbarEditor.AssembleBitmap;
\r
854 var Toolbar: TKOLToolbar;
\r
856 if ToolbarControl = nil then Exit;
\r
857 if not( ToolbarControl is TKOLToolbar ) then Exit;
\r
858 Toolbar := ToolbarControl as TKOLToolbar;
\r
859 Toolbar.AssembleBitmap;
\r
862 procedure TfmToolbarEditor.AssembleButtons;
\r
863 var Toolbar: TKOLToolbar;
\r
865 if ToolbarControl = nil then Exit;
\r
866 if not( ToolbarControl is TKOLToolbar ) then Exit;
\r
867 Toolbar := ToolbarControl as TKOLToolbar;
\r
868 Toolbar.Items2buttons;
\r
872 procedure TfmToolbarEditor.SelectTB;
\r
877 if ToolbarControl <> nil then
\r
879 F := (ToolbarControl as TKOLToolbar).Owner as TForm;
\r
882 Rpt( 'Form found: ' + F.Name );
\r
884 //*///////////////////////////////////////////////////////
\r
885 {$IFDEF _D6orHigher} //
\r
886 F.Designer.QueryInterface(IFormDesigner,D); //
\r
888 //*///////////////////////////////////////////////////////
\r
890 //*///////////////////////////////////////////////////////
\r
892 //*///////////////////////////////////////////////////////
\r
896 Rpt( 'IDesigner interface returned' );
\r
897 if QueryFormDesigner( D, FD ) then
\r
899 Rpt( 'IFormDesigner interface quered' );
\r
901 RemoveSelection( FD );
\r
902 FD.SelectComponent( ToolbarControl );
\r
904 Rpt( 'EXCEPTION *** Could not clear selection!' )
\r