Skip to content

Commit 2cf7ca0

Browse files
committed
final edit
1 parent 597f1d6 commit 2cf7ca0

File tree

3 files changed

+152
-158
lines changed

3 files changed

+152
-158
lines changed

CPB/uMainForm.cpp

Lines changed: 145 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -1,149 +1,145 @@
1-
//---------------------------------------------------------------------------
2-
3-
#include <vcl.h>
4-
#pragma hdrstop
5-
6-
#include "uMainForm.h"
7-
//---------------------------------------------------------------------------
8-
#pragma package(smart_init)
9-
#pragma link "cxButtons"
10-
#pragma link "cxClasses"
11-
#pragma link "cxControls"
12-
#pragma link "cxCustomData"
13-
#pragma link "cxData"
14-
#pragma link "cxDataStorage"
15-
#pragma link "cxDBData"
16-
#pragma link "cxEdit"
17-
#pragma link "cxFilter"
18-
#pragma link "cxGraphics"
19-
#pragma link "cxGrid"
20-
#pragma link "cxGridCustomTableView"
21-
#pragma link "cxGridCustomView"
22-
#pragma link "cxGridDBTableView"
23-
#pragma link "cxGridLevel"
24-
#pragma link "cxGridTableView"
25-
#pragma link "cxLookAndFeelPainters"
26-
#pragma link "cxLookAndFeels"
27-
#pragma link "cxNavigator"
28-
#pragma link "cxStyles"
29-
#pragma link "dxDateRanges"
30-
#pragma link "dxReport"
31-
32-
#pragma link "dxScrollbarAnnotations"
33-
#pragma link "dxmdaset"
34-
#pragma link "cxImageList"
35-
#pragma link "dxLayoutContainer"
36-
#pragma link "dxLayoutControl"
37-
#pragma link "dxLayoutControlAdapters"
38-
#pragma link "dxBackend.Utils.WebBrowserForm"
39-
#pragma link "dxDashboard.Control"
40-
#pragma link "dxAI"
41-
#pragma link "dxAI.Commands.SmartPaste"
42-
#pragma link "cxTextEdit"
43-
#pragma resource "*.dfm"
44-
TMainForm *MainForm;
45-
//---------------------------------------------------------------------------
46-
__fastcall TMainForm::TMainForm(TComponent* Owner)
47-
: TForm(Owner)
48-
{
49-
50-
}
51-
//---------------------------------------------------------------------------
52-
void __fastcall TMainForm::FormCreate(TObject *Sender)
53-
{
54-
LoadLayoutAndState();
55-
}
56-
//---------------------------------------------------------------------------
57-
void __fastcall TMainForm::LoadLayoutAndState()
58-
{
59-
if ((DataModule1->mdLayouts->RecordCount == 0) &&
60-
(DataModule1->mdLayouts->State != dsInsert))
61-
{
62-
dxDashboardControl1->Clear();
63-
return;
64-
}
65-
66-
dxDashboardControl1->DashboardName = DataModule1->mdLayoutsName->AsString;
67-
dxDashboardControl1->Layout->Assign(DataModule1->mdLayoutsLayout);
68-
69-
if (!DataModule1->mdLayoutsState->IsNull)
70-
dxDashboardControl1->State->Assign(DataModule1->mdLayoutsState);
71-
}
72-
//---------------------------------------------------------------------------
73-
void __fastcall TMainForm::btnDeleteClick(TObject *Sender)
74-
{
75-
DataModule1->mdLayouts->Delete();
76-
}
77-
//---------------------------------------------------------------------------
78-
void __fastcall TMainForm::btnDesignClick(TObject *Sender)
79-
{
80-
dxDashboardControl1->ShowDesigner();
81-
}
82-
//---------------------------------------------------------------------------
83-
void __fastcall TMainForm::btnNewDashboardClick(TObject *Sender)
84-
{
85-
dxDashboardControl1->Clear();
86-
dxDashboardControl1->ShowDesigner();
87-
}
88-
//---------------------------------------------------------------------------
89-
void __fastcall TMainForm::gvLayoutsNamePropertiesValidate(TObject *Sender, TcxEditValue &DisplayValue,
90-
TCaption &ErrorText, bool &Error)
91-
{
92-
if (DisplayValue == "")
93-
{
94-
Error = true;
95-
ErrorText = L"Dashboard name cannot be blank.";
96-
}
97-
}
98-
//---------------------------------------------------------------------------
99-
void __fastcall TMainForm::gvLayoutsEditValueChanged(TcxCustomGridTableView *Sender,
100-
TcxCustomGridTableItem *AItem)
101-
{
102-
if (AItem == gvLayoutsName)
103-
dxDashboardControl1->DashboardName = AItem->EditValue;
104-
}
105-
//---------------------------------------------------------------------------
106-
107-
void __fastcall TMainForm::gvLayoutsFocusedRecordChanged(
108-
TcxCustomGridTableView *Sender,
109-
TcxCustomGridRecord *APrevFocusedRecord,
110-
TcxCustomGridRecord *AFocusedRecord,
111-
bool ANewItemRecordFocusingChanged)
112-
{
113-
if (AFocusedRecord == nullptr)
114-
dxDashboardControl1->Clear();
115-
116-
if ((AFocusedRecord != APrevFocusedRecord) &&
117-
(DataModule1->mdLayouts->State != dsInsert))
118-
{
119-
LoadLayoutAndState();
120-
}
121-
}
122-
//---------------------------------------------------------------------------
123-
124-
void __fastcall TMainForm::dxDashboardControl1LayoutChanged(
125-
TdxCustomDashboardControl *ASender)
126-
{
127-
if (DataModule1->mdLayoutsName->AsString != dxDashboardControl1->DashboardName)
128-
{
129-
DataModule1->mdLayouts->Append();
130-
DataModule1->mdLayoutsName->AsString = dxDashboardControl1->DashboardName;
131-
}
132-
else
133-
DataModule1->mdLayouts->Edit();
134-
135-
DataModule1->mdLayoutsLayout->Assign(dxDashboardControl1->Layout);
136-
DataModule1->mdLayouts->Post();
137-
}
138-
//---------------------------------------------------------------------------
139-
void __fastcall TMainForm::dxDashboardControl1StateChanged(
140-
TdxCustomDashboardControl *ASender)
141-
{
142-
DataModule1->mdLayouts->Edit();
143-
DataModule1->mdLayoutsState->Assign(dxDashboardControl1->State);
144-
DataModule1->mdLayouts->Post();
145-
}
146-
//---------------------------------------------------------------------------
147-
148-
149-
//---------------------------------------------------------------------------
1+
//---------------------------------------------------------------------------
2+
3+
#include <vcl.h>
4+
#pragma hdrstop
5+
6+
#include "uMainForm.h"
7+
//---------------------------------------------------------------------------
8+
#pragma package(smart_init)
9+
#pragma link "cxButtons"
10+
#pragma link "cxClasses"
11+
#pragma link "cxControls"
12+
#pragma link "cxCustomData"
13+
#pragma link "cxData"
14+
#pragma link "cxDataStorage"
15+
#pragma link "cxDBData"
16+
#pragma link "cxEdit"
17+
#pragma link "cxFilter"
18+
#pragma link "cxGraphics"
19+
#pragma link "cxGrid"
20+
#pragma link "cxGridCustomTableView"
21+
#pragma link "cxGridCustomView"
22+
#pragma link "cxGridDBTableView"
23+
#pragma link "cxGridLevel"
24+
#pragma link "cxGridTableView"
25+
#pragma link "cxLookAndFeelPainters"
26+
#pragma link "cxLookAndFeels"
27+
#pragma link "cxNavigator"
28+
#pragma link "cxStyles"
29+
#pragma link "dxDateRanges"
30+
#pragma link "dxReport"
31+
32+
#pragma link "dxScrollbarAnnotations"
33+
#pragma link "dxmdaset"
34+
#pragma link "dxLayoutContainer"
35+
#pragma link "dxLayoutControl"
36+
#pragma link "dxLayoutControlAdapters"
37+
#pragma link "dxDashboard.Control"
38+
#pragma resource "*.dfm"
39+
TMainForm *MainForm;
40+
//---------------------------------------------------------------------------
41+
__fastcall TMainForm::TMainForm(TComponent* Owner)
42+
: TForm(Owner)
43+
{
44+
45+
}
46+
//---------------------------------------------------------------------------
47+
void __fastcall TMainForm::FormCreate(TObject *Sender)
48+
{
49+
LoadLayoutAndState();
50+
}
51+
//---------------------------------------------------------------------------
52+
void __fastcall TMainForm::LoadLayoutAndState()
53+
{
54+
if ((DataModule1->mdLayouts->RecordCount == 0) &&
55+
(DataModule1->mdLayouts->State != dsInsert))
56+
{
57+
dxDashboardControl1->Clear();
58+
return;
59+
}
60+
61+
dxDashboardControl1->DashboardName = DataModule1->mdLayoutsName->AsString;
62+
dxDashboardControl1->Layout->Assign(DataModule1->mdLayoutsLayout);
63+
64+
if (!DataModule1->mdLayoutsState->IsNull)
65+
dxDashboardControl1->State->Assign(DataModule1->mdLayoutsState);
66+
}
67+
//---------------------------------------------------------------------------
68+
void __fastcall TMainForm::btnDeleteClick(TObject *Sender)
69+
{
70+
DataModule1->mdLayouts->Delete();
71+
}
72+
//---------------------------------------------------------------------------
73+
void __fastcall TMainForm::btnDesignClick(TObject *Sender)
74+
{
75+
dxDashboardControl1->ShowDesigner();
76+
}
77+
//---------------------------------------------------------------------------
78+
void __fastcall TMainForm::btnNewDashboardClick(TObject *Sender)
79+
{
80+
dxDashboardControl1->Clear();
81+
dxDashboardControl1->ShowDesigner();
82+
}
83+
//---------------------------------------------------------------------------
84+
void __fastcall TMainForm::gvLayoutsNamePropertiesValidate(TObject *Sender, TcxEditValue &DisplayValue,
85+
TCaption &ErrorText, bool &Error)
86+
{
87+
if (DisplayValue == "")
88+
{
89+
Error = true;
90+
ErrorText = L"Dashboard name cannot be blank.";
91+
}
92+
}
93+
//---------------------------------------------------------------------------
94+
void __fastcall TMainForm::gvLayoutsEditValueChanged(TcxCustomGridTableView *Sender,
95+
TcxCustomGridTableItem *AItem)
96+
{
97+
if (AItem == gvLayoutsName)
98+
dxDashboardControl1->DashboardName = AItem->EditValue;
99+
}
100+
//---------------------------------------------------------------------------
101+
102+
void __fastcall TMainForm::gvLayoutsFocusedRecordChanged(
103+
TcxCustomGridTableView *Sender,
104+
TcxCustomGridRecord *APrevFocusedRecord,
105+
TcxCustomGridRecord *AFocusedRecord,
106+
bool ANewItemRecordFocusingChanged)
107+
{
108+
if (AFocusedRecord == nullptr)
109+
dxDashboardControl1->Clear();
110+
111+
if ((AFocusedRecord != APrevFocusedRecord) &&
112+
(DataModule1->mdLayouts->State != dsInsert))
113+
{
114+
LoadLayoutAndState();
115+
}
116+
}
117+
//---------------------------------------------------------------------------
118+
119+
void __fastcall TMainForm::dxDashboardControl1LayoutChanged(
120+
TdxCustomDashboardControl *ASender)
121+
{
122+
if (DataModule1->mdLayoutsName->AsString != dxDashboardControl1->DashboardName)
123+
{
124+
DataModule1->mdLayouts->Append();
125+
DataModule1->mdLayoutsName->AsString = dxDashboardControl1->DashboardName;
126+
}
127+
else
128+
DataModule1->mdLayouts->Edit();
129+
130+
DataModule1->mdLayoutsLayout->Assign(dxDashboardControl1->Layout);
131+
DataModule1->mdLayouts->Post();
132+
}
133+
//---------------------------------------------------------------------------
134+
void __fastcall TMainForm::dxDashboardControl1StateChanged(
135+
TdxCustomDashboardControl *ASender)
136+
{
137+
DataModule1->mdLayouts->Edit();
138+
DataModule1->mdLayoutsState->Assign(dxDashboardControl1->State);
139+
DataModule1->mdLayouts->Post();
140+
}
141+
142+
//---------------------------------------------------------------------------
143+
144+
145+
//---------------------------------------------------------------------------

CPB/uMainForm.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
#include "dxLayoutContainer.hpp"
3939
#include "dxLayoutControl.hpp"
4040
#include "dxLayoutControlAdapters.hpp"
41-
#include <System.ImageList.hpp>
42-
#include <Vcl.ImgList.hpp>
4341
#include "dxBackend.Utils.WebBrowserForm.hpp"
4442
#include "dxDashboard.Control.hpp"
4543
#include "dxAI.Commands.SmartPaste.hpp"

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
# DevExpress Dashboards for Delphi/C++Builder — Store Dashboard Layouts and User Interaction State in a Database
99

10-
This example application allows users to create new layouts, modify existing layouts
11-
using the built-in Dashboard Designer, interact with dashboards, and save
10+
This example application allows users to create new layouts/modify existing layouts
11+
(using the built-in Dashboard Designer), interact with dashboard UI elements, and save
1212
[state][TdxCustomDashboardControl.State] or [layout][TdxCustomDashboardControl.Layout] changes to the data source.
1313

1414
![DevExpress Dashboards for Delphi/C++Builder - Database Layout Storage Example](./images/vcl-dashboard-layout-database-sample-app.png)
@@ -125,7 +125,7 @@ You can also clear the Dashboard Control using [TdxCustomDashboardControl.Clear]
125125

126126
### Step 3: Display the Dashboard Designer
127127

128-
Once you assigned a dashboard layout definition to the Dashboard Control,
128+
Once you assign a dashboard layout definition to the Dashboard Control,
129129
you can display the [Dashboard Designer][designer] dialog:
130130

131131
<!-- start-code-block -->
@@ -227,11 +227,11 @@ end;
227227

228228
## Files to Review
229229

230-
- [uData.pas]/[uData.cpp] stores dashboard layouts and supplies data to the dashboard.
231-
- [uMainForm.pas]/[uMainForm.cpp] loads dashboard layouts from the data module
230+
- [uData.pas]/[uData.cpp] stores dashboard layouts and supplies data to the dashboard.
231+
- [uMainForm.pas]/[uMainForm.cpp] loads dashboard layouts from the data module
232232
and displays Dashboard Control and Dashboard Designer.
233-
- [layout.dat] and [revenue.dat] store memory-based dataset states you can load to reproduce this example.
234-
- [data.dat] stores the memory-based dataset state between application sessions.
233+
- [layout.dat] and [revenue.dat] store memory-based dataset states you can load to reproduce this example.
234+
- [data.dat] stores the memory-based dataset state between application sessions.
235235

236236

237237
## Documentation

0 commit comments

Comments
 (0)