-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpeedBar.cpp
More file actions
89 lines (74 loc) · 2.25 KB
/
SpeedBar.cpp
File metadata and controls
89 lines (74 loc) · 2.25 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
/*
Open source not for commercial deployment
*/
//---------------------------------------------------------------------------
#pragma hdrstop
#include "SpeedBar.h"
#include "GlobalUnit.h"
//---------------------------------------------------------------------------
void SpeedBar::init(TWinControl * pParent, String programDir)
{
parent = pParent;
ProgramDir = programDir;
}
void SpeedBar::CleanUpToolBar()
{
delete SpeedButtonsIconList;
SpeedButtonsIconList = new TImageList(parent);
delete ToolBar; //this will also automicily delete all buttons.
ToolBar = new TToolBar(parent);
ToolBar->Parent = parent;
ToolBar->Color = clBtnShadow;
ToolBar->ShowHint = true;
SpeedButtonCount = 0;
IconCount=0;
}
void SpeedBar::addSpeedButton(String s)
{
if (s=="ClearAll")
{
CleanUpToolBar();
return;
}
else if (ToolBar == NULL)
{
CleanUpToolBar();
}
if (SpeedButtonCount == MAX_SPEEDBUTTONS)
{
MessageDlg("Maximum number of speed buttons reached.", mtInformation, TMsgDlgButtons()<<mbOK , 0);
return;
}
String PictureName = getUntil(s,"_");
s = getAfter(s,"_");
String ButtonHint = getUntil(s,"_");
String Commands = getAfter(s,"_");
Commands = replace(Commands, "|", ",");
SpeedButtonCommand[IconCount] = Commands;
ToolButton[SpeedButtonCount] = new TToolButton(ToolBar);
ToolButton[SpeedButtonCount]->Parent = ToolBar;
ToolButton[SpeedButtonCount]->ImageIndex = IconCount;
ToolButton[SpeedButtonCount]->OnClick = &ToolButtonClick;
ToolButton[SpeedButtonCount]->Hint = ButtonHint;
TIcon *Icone = new TIcon();
if (PictureName=="Separator")
{
ToolButton[SpeedButtonCount]->Style = tbsSeparator;
ToolButton[SpeedButtonCount]->Width = 7;
}
else
{
Icone->LoadFromFile(ProgramDir+"Icons\\"+PictureName);
IconCount++;
}
SpeedButtonsIconList->AddIcon(Icone);
ToolBar->Images=SpeedButtonsIconList;
delete Icone;
SpeedButtonCount++;
}
void __fastcall SpeedBar::ToolButtonClick(TObject *Sender)
{
MainForm->recurcingDepth =0;
MainForm->ProcessCommands( SpeedButtonCommand[((TToolButton*)Sender)->ImageIndex] );
}
#pragma package(smart_init)