mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-24 14:22:40 -06:00
changed svn layout
git-svn-id: svn://ultimatepp.org/upp/trunk@281 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
commit
263ff5f895
2665 changed files with 642923 additions and 0 deletions
73
examples/DbfView/DbfView.cpp
Normal file
73
examples/DbfView/DbfView.cpp
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
#include <plugin/dbf/dbf.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
struct DbfView : public TopWindow {
|
||||
Splitter s;
|
||||
ArrayCtrl table;
|
||||
ArrayCtrl row;
|
||||
DbfStream dbf;
|
||||
|
||||
void EnterRow();
|
||||
void Perform();
|
||||
|
||||
typedef DbfView CLASSNAME;
|
||||
|
||||
DbfView();
|
||||
};
|
||||
|
||||
String FormatField(const DbfStream::Field& f)
|
||||
{
|
||||
return f.name + Format(" (%c%d)", f.type, f.width);
|
||||
}
|
||||
|
||||
void DbfView::EnterRow()
|
||||
{
|
||||
row.Clear();
|
||||
if(!dbf.Fetch(table.GetCursor()))
|
||||
return;
|
||||
for(int i = 0; i < dbf.GetFieldCount(); i++)
|
||||
row.Add(FormatField(dbf.GetField(i)), dbf[i]);
|
||||
}
|
||||
|
||||
void DbfView::Perform()
|
||||
{
|
||||
FileSel fs;
|
||||
LoadFromFile(fs);
|
||||
fs.AllFilesType();
|
||||
fs.Type("*.dbf", "dbf");
|
||||
if(!fs.ExecuteOpen("DBF..")) return;
|
||||
StoreToFile(fs);
|
||||
if(!dbf.Open(~fs))
|
||||
Exclamation("Can't open input file");
|
||||
for(int i = 0; i < min(4, dbf.GetFieldCount()); i++)
|
||||
table.AddColumn(FormatField(dbf.GetField(i)));
|
||||
while(dbf.Fetch()) {
|
||||
Vector<Value> v;
|
||||
for(int i = 0; i < min(4, dbf.GetFieldCount()); i++)
|
||||
v.Add(dbf[i]);
|
||||
table.Add(v);
|
||||
}
|
||||
Run();
|
||||
}
|
||||
|
||||
DbfView::DbfView()
|
||||
{
|
||||
s.Set(table, row);
|
||||
s.SetPos(7000);
|
||||
Add(s.SizePos());
|
||||
Sizeable().Zoomable();
|
||||
table.WhenEnterRow = THISBACK(EnterRow);
|
||||
row.AddColumn("Column");
|
||||
row.AddColumn("Value", 2);
|
||||
}
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
SetDefaultCharset(CHARSET_WIN1250);
|
||||
SetLanguage(LNG_CZECH);
|
||||
Ctrl::NoLayoutZoom();
|
||||
|
||||
DbfView().Perform();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue