ba4200.cpp Tolto #include <tabutil.h>

ba883.cpp    Aggiunto supporto per TTree_field
ba883.url    Menu new style


git-svn-id: svn://10.65.10.50/trunk@6209 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1998-02-17 11:25:46 +00:00
parent 38edbaf836
commit 7a49867232
3 changed files with 79 additions and 45 deletions

View File

@ -2,7 +2,6 @@
#include <golem.h>
#include <mailbox.h>
#include <relapp.h>
#include <tabutil.h>
#include <utility.h>
#include <urldefid.h>
#include <validate.h>

View File

@ -1,6 +1,8 @@
#include <time.h>
#include <browfile.h>
#include <relapp.h>
#include <tree.h>
#include <urldefid.h>
///////////////////////////////////////////////////////////
@ -50,7 +52,6 @@ TRelation* TTab_application::get_relation() const
return _rel;
}
bool TTab_application::user_create()
{
if (argc() < 3)
@ -152,26 +153,82 @@ int TTestrel_application::rewrite(const TMask& m)
// Testmask
///////////////////////////////////////////////////////////
class TTest_application : public TApplication
class TTest_application : public TSkeleton_application
{
TFilename _maskname;
protected:
bool create() { dispatch_e_menu(BAR_ITEM(1)); return TRUE; }
bool destroy() { return TRUE; }
bool menu(MENU_TAG);
virtual void main_loop();
static bool tree_handler(TMask_field& f, KEY k);
public:
void fill_trees(TMask& msk);
TTest_application(const char* name) : _maskname(name) {}
virtual~ TTest_application() {}
};
bool TTest_application::menu(MENU_TAG)
bool TTest_application::tree_handler(TMask_field& f, KEY k)
{
if (k == K_SPACE || k == K_CTRL+K_SPACE)
{
TMask_field& next_field = f.mask().field(f.dlg()+1);
if (next_field.class_id() == CLASS_BROWSEFILE_FIELD)
{
TTree_field& tf = (TTree_field&)f;
TBrowsefile_field& bf = (TBrowsefile_field&)next_field;
TString str;
tf.tree()->get_description(str);
str.insert("You clicked on ", 0);
if (k == K_CTRL+K_SPACE)
str.insert("double ", 4);
bf.add_line(str);
}
}
return TRUE;
}
void TTest_application::fill_trees(TMask& msk)
{
for (int f = msk.fields()-1; f >= 0; f--)
{
if (msk.fld(f).is_kind_of(CLASS_TREE_FIELD))
{
TString_tree* st = new TString_tree;
st->add_son("Root");
st->add_son("son 1");
st->add_son("child 1");
for (int i = 2; i <= 10; i++)
{
TString16 str; str.format("child %d", i);
st->add_rbrother(str);
}
st->add_son("Nephew 1");
st->add_rbrother("Nephew 2");
st->goto_father();
st->goto_father();
st->add_rbrother("son 2");
st->add_son("child 1");
st->add_rbrother("child 2");
// st->expand_all();
TTree_field& tf = (TTree_field&)msk.fld(f);
tf.set_tree(st);
tf.hide_leaves();
tf.set_handler(tree_handler);
}
}
}
void TTest_application::main_loop()
{
TMask m(_maskname);
KEY k = m.run();
if (k == K_QUIT) stop_run();
return k != K_QUIT;
#ifdef DBG
fill_trees(m);
#endif
while (m.run() != K_QUIT);
}
///////////////////////////////////////////////////////////
@ -181,9 +238,7 @@ class TBenchmark_application : public TApplication
clock_t _timer_start;
protected:
virtual bool create();
virtual bool destroy();
virtual bool menu(MENU_TAG);
virtual void main_loop();
void initializing();
void start_test(const char* msg);
@ -200,38 +255,22 @@ public:
virtual ~TBenchmark_application() { }
};
bool TBenchmark_application::create()
{
dispatch_e_menu(BAR_ITEM(1));
return TRUE;
}
bool TBenchmark_application::destroy()
{
return TRUE;
}
bool TBenchmark_application::menu(MENU_TAG mt)
void TBenchmark_application::main_loop()
{
if (mt == BAR_ITEM(1))
{
TString test = argv(1); test.upper();
const bool test_all = test.find('*') >= 0;
TString test = argv(1); test.upper();
const bool test_all = test.find('*') >= 0;
if (test_all || test.find('F') >= 0)
test_file_scan();
if (test_all || test.find('F') >= 0)
test_file_scan();
if (test_all || test.find('R') >= 0)
test_relation_scan();
if (test_all || test.find('R') >= 0)
test_relation_scan();
if (test_all || test.find('C') >= 0)
test_cursor_scan();
if (test_all || test.find('C') >= 0)
test_cursor_scan();
if (test_all || test.find('T') >= 0)
test_file_random();
}
return TRUE;
if (test_all || test.find('T') >= 0)
test_file_random();
}
void TBenchmark_application::initializing()
@ -288,7 +327,6 @@ void TBenchmark_application::test_file_scan()
start_test("Scansione file COMUNI di Reggio Emilia");
comuni.first();
for (TRecnotype rec = 0; !comuni.eof(); rec++)
{
@ -352,7 +390,7 @@ void TBenchmark_application::test_file_random()
TLocalisamfile comuni(LF_COMUNI);
start_test("Lettura randome del file COMUNI");
start_test("Lettura random del file COMUNI");
TRectype& rec = comuni.curr();
char code[8];

View File

@ -1,6 +1,3 @@
#include <default.url>
MENU TASK_MENUBAR
SUBMENU MENU_FILE "~File"
ITEM BAR_ITEM(1) "~Test"