Small array optimizations
This commit is contained in:
parent
2d9103c102
commit
91023e3a76
|
@ -3,7 +3,7 @@
|
||||||
* *
|
* *
|
||||||
* This file is part of the Final Cut widget toolkit *
|
* This file is part of the Final Cut widget toolkit *
|
||||||
* *
|
* *
|
||||||
* Copyright 2017 Markus Gans *
|
* Copyright 2017-2018 Markus Gans *
|
||||||
* *
|
* *
|
||||||
* The Final Cut is free software; you can redistribute it and/or *
|
* The Final Cut is free software; you can redistribute it and/or *
|
||||||
* modify it under the terms of the GNU Lesser General Public License *
|
* modify it under the terms of the GNU Lesser General Public License *
|
||||||
|
@ -27,10 +27,10 @@
|
||||||
#include <final/final.h>
|
#include <final/final.h>
|
||||||
|
|
||||||
|
|
||||||
// global FVTerm object
|
// Global FVTerm object
|
||||||
static FVTerm* terminal;
|
static FVTerm* terminal;
|
||||||
|
|
||||||
// function prototype
|
// Function prototype
|
||||||
void tcapBooleans (const std::string&, bool);
|
void tcapBooleans (const std::string&, bool);
|
||||||
void tcapNumeric (const std::string&, int);
|
void tcapNumeric (const std::string&, int);
|
||||||
void tcapString (const std::string&, const char[]);
|
void tcapString (const std::string&, const char[]);
|
||||||
|
@ -39,8 +39,109 @@ void booleans();
|
||||||
void numeric();
|
void numeric();
|
||||||
void string(FTermcap::tcap_map*&);
|
void string(FTermcap::tcap_map*&);
|
||||||
|
|
||||||
|
#pragma pack(push)
|
||||||
|
#pragma pack(1)
|
||||||
|
|
||||||
|
struct termcap_string
|
||||||
|
{
|
||||||
|
const std::string name;
|
||||||
|
const fc::termcaps cap;
|
||||||
|
|
||||||
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
// String data array
|
||||||
|
static termcap_string strings[] =
|
||||||
|
{
|
||||||
|
{ "t_bell", fc::t_bell },
|
||||||
|
{ "t_erase_chars", fc::t_erase_chars },
|
||||||
|
{ "t_clear_screen", fc::t_clear_screen },
|
||||||
|
{ "t_clr_eos", fc::t_clr_eos },
|
||||||
|
{ "t_clr_eol", fc::t_clr_eol },
|
||||||
|
{ "t_clr_bol", fc::t_clr_bol },
|
||||||
|
{ "t_cursor_home", fc::t_cursor_home },
|
||||||
|
{ "t_cursor_to_ll", fc::t_cursor_to_ll },
|
||||||
|
{ "t_carriage_return", fc::t_carriage_return },
|
||||||
|
{ "t_tab", fc::t_tab },
|
||||||
|
{ "t_back_tab", fc::t_back_tab },
|
||||||
|
{ "t_insert_padding", fc::t_insert_padding },
|
||||||
|
{ "t_insert_character", fc::t_insert_character },
|
||||||
|
{ "t_parm_ich", fc::t_parm_ich },
|
||||||
|
{ "t_repeat_char", fc::t_repeat_char },
|
||||||
|
{ "t_initialize_color", fc::t_initialize_color },
|
||||||
|
{ "t_initialize_pair", fc::t_initialize_pair },
|
||||||
|
{ "t_set_a_foreground", fc::t_set_a_foreground },
|
||||||
|
{ "t_set_a_background", fc::t_set_a_background },
|
||||||
|
{ "t_set_foreground", fc::t_set_foreground },
|
||||||
|
{ "t_set_background", fc::t_set_background },
|
||||||
|
{ "t_set_color_pair", fc::t_set_color_pair },
|
||||||
|
{ "t_orig_pair", fc::t_orig_pair },
|
||||||
|
{ "t_orig_colors", fc::t_orig_colors },
|
||||||
|
{ "t_no_color_video", fc::t_no_color_video },
|
||||||
|
{ "t_cursor_address", fc::t_cursor_address },
|
||||||
|
{ "t_column_address", fc::t_column_address },
|
||||||
|
{ "t_row_address", fc::t_row_address },
|
||||||
|
{ "t_cursor_visible", fc::t_cursor_visible },
|
||||||
|
{ "t_cursor_invisible", fc::t_cursor_invisible },
|
||||||
|
{ "t_cursor_normal", fc::t_cursor_normal },
|
||||||
|
{ "t_cursor_up", fc::t_cursor_up },
|
||||||
|
{ "t_cursor_down", fc::t_cursor_down },
|
||||||
|
{ "t_cursor_left", fc::t_cursor_left },
|
||||||
|
{ "t_cursor_right", fc::t_cursor_right },
|
||||||
|
{ "t_parm_up_cursor", fc::t_parm_up_cursor },
|
||||||
|
{ "t_parm_down_cursor", fc::t_parm_down_cursor },
|
||||||
|
{ "t_parm_left_cursor", fc::t_parm_left_cursor },
|
||||||
|
{ "t_parm_right_cursor", fc::t_parm_right_cursor },
|
||||||
|
{ "t_save_cursor", fc::t_save_cursor },
|
||||||
|
{ "t_restore_cursor", fc::t_restore_cursor },
|
||||||
|
{ "t_scroll_forward", fc::t_scroll_forward },
|
||||||
|
{ "t_scroll_reverse", fc::t_scroll_reverse },
|
||||||
|
{ "t_enter_ca_mode", fc::t_enter_ca_mode },
|
||||||
|
{ "t_exit_ca_mode", fc::t_exit_ca_mode },
|
||||||
|
{ "t_enable_acs", fc::t_enable_acs },
|
||||||
|
{ "t_enter_bold_mode", fc::t_enter_bold_mode },
|
||||||
|
{ "t_exit_bold_mode", fc::t_exit_bold_mode },
|
||||||
|
{ "t_enter_dim_mode", fc::t_enter_dim_mode },
|
||||||
|
{ "t_exit_dim_mode", fc::t_exit_dim_mode },
|
||||||
|
{ "t_enter_italics_mode", fc::t_enter_italics_mode },
|
||||||
|
{ "t_exit_italics_mode", fc::t_exit_italics_mode },
|
||||||
|
{ "t_enter_underline_mode", fc::t_enter_underline_mode },
|
||||||
|
{ "t_exit_underline_mode", fc::t_exit_underline_mode },
|
||||||
|
{ "t_enter_blink_mode", fc::t_enter_blink_mode },
|
||||||
|
{ "t_exit_blink_mode", fc::t_exit_blink_mode },
|
||||||
|
{ "t_enter_reverse_mode", fc::t_enter_reverse_mode },
|
||||||
|
{ "t_exit_reverse_mode", fc::t_exit_reverse_mode },
|
||||||
|
{ "t_enter_standout_mode", fc::t_enter_standout_mode },
|
||||||
|
{ "t_exit_standout_mode", fc::t_exit_standout_mode },
|
||||||
|
{ "t_enter_secure_mode", fc::t_enter_secure_mode },
|
||||||
|
{ "t_exit_secure_mode", fc::t_exit_secure_mode },
|
||||||
|
{ "t_enter_protected_mode", fc::t_enter_protected_mode },
|
||||||
|
{ "t_exit_protected_mode", fc::t_exit_protected_mode },
|
||||||
|
{ "t_enter_crossed_out_mode", fc::t_enter_crossed_out_mode },
|
||||||
|
{ "t_exit_crossed_out_mode", fc::t_exit_crossed_out_mode },
|
||||||
|
{ "t_enter_dbl_underline_mode", fc::t_enter_dbl_underline_mode },
|
||||||
|
{ "t_exit_dbl_underline_mode", fc::t_exit_dbl_underline_mode },
|
||||||
|
{ "t_set_attributes", fc::t_set_attributes },
|
||||||
|
{ "t_exit_attribute_mode", fc::t_exit_attribute_mode },
|
||||||
|
{ "t_enter_alt_charset_mode", fc::t_enter_alt_charset_mode },
|
||||||
|
{ "t_exit_alt_charset_mode", fc::t_exit_alt_charset_mode },
|
||||||
|
{ "t_enter_pc_charset_mode", fc::t_enter_pc_charset_mode },
|
||||||
|
{ "t_exit_pc_charset_mode", fc::t_exit_pc_charset_mode },
|
||||||
|
{ "t_enter_insert_mode", fc::t_enter_insert_mode },
|
||||||
|
{ "t_exit_insert_mode", fc::t_exit_insert_mode },
|
||||||
|
{ "t_enter_am_mode", fc::t_enter_am_mode },
|
||||||
|
{ "t_exit_am_mode", fc::t_exit_am_mode },
|
||||||
|
{ "t_acs_chars", fc::t_acs_chars },
|
||||||
|
{ "t_keypad_xmit", fc::t_keypad_xmit },
|
||||||
|
{ "t_keypad_local", fc::t_keypad_local },
|
||||||
|
{ "t_key_mouse", fc::t_key_mouse }
|
||||||
|
};
|
||||||
|
|
||||||
|
const int last_item = int ( sizeof(strings) / sizeof(strings[0]) ) - 1;
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// functions
|
// Functions
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void tcapBooleans (const std::string& name, bool cap_bool)
|
void tcapBooleans (const std::string& name, bool cap_bool)
|
||||||
{
|
{
|
||||||
|
@ -164,170 +265,13 @@ void numeric()
|
||||||
void string(FTermcap::tcap_map*& tcap)
|
void string(FTermcap::tcap_map*& tcap)
|
||||||
{
|
{
|
||||||
std::cout << "\r\n[String]\r\n";
|
std::cout << "\r\n[String]\r\n";
|
||||||
tcapString ("t_bell"
|
|
||||||
, tcap[fc::t_bell].string);
|
for (int n = 0; n <= last_item; n++ )
|
||||||
tcapString ("t_erase_chars"
|
{
|
||||||
, tcap[fc::t_erase_chars].string);
|
const std::string name = strings[n].name;
|
||||||
tcapString ("t_clear_screen"
|
const fc::termcaps cap = strings[n].cap;
|
||||||
, tcap[fc::t_clear_screen].string);
|
tcapString (name, tcap[cap].string);
|
||||||
tcapString ("t_clr_eos"
|
}
|
||||||
, tcap[fc::t_clr_eos].string);
|
|
||||||
tcapString ("t_clr_eol"
|
|
||||||
, tcap[fc::t_clr_eol].string);
|
|
||||||
tcapString ("t_clr_bol"
|
|
||||||
, tcap[fc::t_clr_bol].string);
|
|
||||||
tcapString ("t_cursor_home"
|
|
||||||
, tcap[fc::t_cursor_home].string);
|
|
||||||
tcapString ("t_cursor_to_ll"
|
|
||||||
, tcap[fc::t_cursor_to_ll].string);
|
|
||||||
tcapString ("t_carriage_return"
|
|
||||||
, tcap[fc::t_carriage_return].string);
|
|
||||||
tcapString ("t_tab"
|
|
||||||
, tcap[fc::t_tab].string);
|
|
||||||
tcapString ("t_back_tab"
|
|
||||||
, tcap[fc::t_back_tab].string);
|
|
||||||
tcapString ("t_insert_padding"
|
|
||||||
, tcap[fc::t_insert_padding].string);
|
|
||||||
tcapString ("t_insert_character"
|
|
||||||
, tcap[fc::t_insert_character].string);
|
|
||||||
tcapString ("t_parm_ich"
|
|
||||||
, tcap[fc::t_parm_ich].string);
|
|
||||||
tcapString ("t_repeat_char"
|
|
||||||
, tcap[fc::t_repeat_char].string);
|
|
||||||
tcapString ("t_initialize_color"
|
|
||||||
, tcap[fc::t_initialize_color].string);
|
|
||||||
tcapString ("t_initialize_pair"
|
|
||||||
, tcap[fc::t_initialize_pair].string);
|
|
||||||
tcapString ("t_set_a_foreground"
|
|
||||||
, tcap[fc::t_set_a_foreground].string);
|
|
||||||
tcapString ("t_set_a_background"
|
|
||||||
, tcap[fc::t_set_a_background].string);
|
|
||||||
tcapString ("t_set_foreground"
|
|
||||||
, tcap[fc::t_set_foreground].string);
|
|
||||||
tcapString ("t_set_background"
|
|
||||||
, tcap[fc::t_set_background].string);
|
|
||||||
tcapString ("t_set_color_pair"
|
|
||||||
, tcap[fc::t_set_color_pair].string);
|
|
||||||
tcapString ("t_orig_pair"
|
|
||||||
, tcap[fc::t_orig_pair].string);
|
|
||||||
tcapString ("t_orig_colors"
|
|
||||||
, tcap[fc::t_orig_colors].string);
|
|
||||||
tcapString ("t_no_color_video"
|
|
||||||
, tcap[fc::t_no_color_video].string);
|
|
||||||
tcapString ("t_cursor_address"
|
|
||||||
, tcap[fc::t_cursor_address].string);
|
|
||||||
tcapString ("t_column_address"
|
|
||||||
, tcap[fc::t_column_address].string);
|
|
||||||
tcapString ("t_row_address"
|
|
||||||
, tcap[fc::t_row_address].string);
|
|
||||||
tcapString ("t_cursor_visible"
|
|
||||||
, tcap[fc::t_cursor_visible].string);
|
|
||||||
tcapString ("t_cursor_invisible"
|
|
||||||
, tcap[fc::t_cursor_invisible].string);
|
|
||||||
tcapString ("t_cursor_normal"
|
|
||||||
, tcap[fc::t_cursor_normal].string);
|
|
||||||
tcapString ("t_cursor_up"
|
|
||||||
, tcap[fc::t_cursor_up].string);
|
|
||||||
tcapString ("t_cursor_down"
|
|
||||||
, tcap[fc::t_cursor_down].string);
|
|
||||||
tcapString ("t_cursor_left"
|
|
||||||
, tcap[fc::t_cursor_left].string);
|
|
||||||
tcapString ("t_cursor_right"
|
|
||||||
, tcap[fc::t_cursor_right].string);
|
|
||||||
tcapString ("t_parm_up_cursor"
|
|
||||||
, tcap[fc::t_parm_up_cursor].string);
|
|
||||||
tcapString ("t_parm_down_cursor"
|
|
||||||
, tcap[fc::t_parm_down_cursor].string);
|
|
||||||
tcapString ("t_parm_left_cursor"
|
|
||||||
, tcap[fc::t_parm_left_cursor].string);
|
|
||||||
tcapString ("t_parm_right_cursor"
|
|
||||||
, tcap[fc::t_parm_right_cursor].string);
|
|
||||||
tcapString ("t_save_cursor"
|
|
||||||
, tcap[fc::t_save_cursor].string);
|
|
||||||
tcapString ("t_restore_cursor"
|
|
||||||
, tcap[fc::t_restore_cursor].string);
|
|
||||||
tcapString ("t_scroll_forward"
|
|
||||||
, tcap[fc::t_scroll_forward].string);
|
|
||||||
tcapString ("t_scroll_reverse"
|
|
||||||
, tcap[fc::t_scroll_reverse].string);
|
|
||||||
tcapString ("t_enter_ca_mode"
|
|
||||||
, tcap[fc::t_enter_ca_mode].string);
|
|
||||||
tcapString ("t_exit_ca_mode"
|
|
||||||
, tcap[fc::t_exit_ca_mode].string);
|
|
||||||
tcapString ("t_enable_acs"
|
|
||||||
, tcap[fc::t_enable_acs].string);
|
|
||||||
tcapString ("t_enter_bold_mode"
|
|
||||||
, tcap[fc::t_enter_bold_mode].string);
|
|
||||||
tcapString ("t_exit_bold_mode"
|
|
||||||
, tcap[fc::t_exit_bold_mode].string);
|
|
||||||
tcapString ("t_enter_dim_mode"
|
|
||||||
, tcap[fc::t_enter_dim_mode].string);
|
|
||||||
tcapString ("t_exit_dim_mode"
|
|
||||||
, tcap[fc::t_exit_dim_mode].string);
|
|
||||||
tcapString ("t_enter_italics_mode"
|
|
||||||
, tcap[fc::t_enter_italics_mode].string);
|
|
||||||
tcapString ("t_exit_italics_mode"
|
|
||||||
, tcap[fc::t_exit_italics_mode].string);
|
|
||||||
tcapString ("t_enter_underline_mode"
|
|
||||||
, tcap[fc::t_enter_underline_mode].string);
|
|
||||||
tcapString ("t_exit_underline_mode"
|
|
||||||
, tcap[fc::t_exit_underline_mode].string);
|
|
||||||
tcapString ("t_enter_blink_mode"
|
|
||||||
, tcap[fc::t_enter_blink_mode].string);
|
|
||||||
tcapString ("t_exit_blink_mode"
|
|
||||||
, tcap[fc::t_exit_blink_mode].string);
|
|
||||||
tcapString ("t_enter_reverse_mode"
|
|
||||||
, tcap[fc::t_enter_reverse_mode].string);
|
|
||||||
tcapString ("t_exit_reverse_mode"
|
|
||||||
, tcap[fc::t_exit_reverse_mode].string);
|
|
||||||
tcapString ("t_enter_standout_mode"
|
|
||||||
, tcap[fc::t_enter_standout_mode].string);
|
|
||||||
tcapString ("t_exit_standout_mode"
|
|
||||||
, tcap[fc::t_exit_standout_mode].string);
|
|
||||||
tcapString ("t_enter_secure_mode"
|
|
||||||
, tcap[fc::t_enter_secure_mode].string);
|
|
||||||
tcapString ("t_exit_secure_mode"
|
|
||||||
, tcap[fc::t_exit_secure_mode].string);
|
|
||||||
tcapString ("t_enter_protected_mode"
|
|
||||||
, tcap[fc::t_enter_protected_mode].string);
|
|
||||||
tcapString ("t_exit_protected_mode"
|
|
||||||
, tcap[fc::t_exit_protected_mode].string);
|
|
||||||
tcapString ("t_enter_crossed_out_mode"
|
|
||||||
, tcap[fc::t_enter_crossed_out_mode].string);
|
|
||||||
tcapString ("t_exit_crossed_out_mode"
|
|
||||||
, tcap[fc::t_exit_crossed_out_mode].string);
|
|
||||||
tcapString ("t_enter_dbl_underline_mode"
|
|
||||||
, tcap[fc::t_enter_dbl_underline_mode].string);
|
|
||||||
tcapString ("t_exit_dbl_underline_mode"
|
|
||||||
, tcap[fc::t_exit_dbl_underline_mode].string);
|
|
||||||
tcapString ("t_set_attributes"
|
|
||||||
, tcap[fc::t_set_attributes].string);
|
|
||||||
tcapString ("t_exit_attribute_mode"
|
|
||||||
, tcap[fc::t_exit_attribute_mode].string);
|
|
||||||
tcapString ("t_enter_alt_charset_mode"
|
|
||||||
, tcap[fc::t_enter_alt_charset_mode].string);
|
|
||||||
tcapString ("t_exit_alt_charset_mode"
|
|
||||||
, tcap[fc::t_exit_alt_charset_mode].string);
|
|
||||||
tcapString ("t_enter_pc_charset_mode"
|
|
||||||
, tcap[fc::t_enter_pc_charset_mode].string);
|
|
||||||
tcapString ("t_exit_pc_charset_mode"
|
|
||||||
, tcap[fc::t_exit_pc_charset_mode].string);
|
|
||||||
tcapString ("t_enter_insert_mode"
|
|
||||||
, tcap[fc::t_enter_insert_mode].string);
|
|
||||||
tcapString ("t_exit_insert_mode"
|
|
||||||
, tcap[fc::t_exit_insert_mode].string);
|
|
||||||
tcapString ("t_enter_am_mode"
|
|
||||||
, tcap[fc::t_enter_am_mode].string);
|
|
||||||
tcapString ("t_exit_am_mode"
|
|
||||||
, tcap[fc::t_exit_am_mode].string);
|
|
||||||
tcapString ("t_acs_chars"
|
|
||||||
, tcap[fc::t_acs_chars].string);
|
|
||||||
tcapString ("t_keypad_xmit"
|
|
||||||
, tcap[fc::t_keypad_xmit].string);
|
|
||||||
tcapString ("t_keypad_local"
|
|
||||||
, tcap[fc::t_keypad_local].string);
|
|
||||||
tcapString ("t_key_mouse"
|
|
||||||
, tcap[fc::t_key_mouse].string);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* *
|
* *
|
||||||
* This file is part of the Final Cut widget toolkit *
|
* This file is part of the Final Cut widget toolkit *
|
||||||
* *
|
* *
|
||||||
* Copyright 2017 Markus Gans *
|
* Copyright 2017-2018 Markus Gans *
|
||||||
* *
|
* *
|
||||||
* The Final Cut is free software; you can redistribute it and/or *
|
* The Final Cut is free software; you can redistribute it and/or *
|
||||||
* modify it under the terms of the GNU Lesser General Public License *
|
* modify it under the terms of the GNU Lesser General Public License *
|
||||||
|
@ -54,6 +54,12 @@ class Treeview : public FDialog
|
||||||
|
|
||||||
// Method
|
// Method
|
||||||
void adjustSize();
|
void adjustSize();
|
||||||
|
TreeItem* getAfrica();
|
||||||
|
TreeItem* getAsia();
|
||||||
|
TreeItem* getEurope();
|
||||||
|
TreeItem* getNorthAmerica();
|
||||||
|
TreeItem* getSouthAmerica();
|
||||||
|
TreeItem* getOceania();
|
||||||
|
|
||||||
// Event handlers
|
// Event handlers
|
||||||
void onClose (FCloseEvent*);
|
void onClose (FCloseEvent*);
|
||||||
|
@ -88,28 +94,8 @@ struct Treeview::TreeItem
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
Treeview::Treeview (FWidget* parent)
|
Treeview::TreeItem* Treeview::getAfrica()
|
||||||
: FDialog(parent)
|
|
||||||
, listView()
|
|
||||||
, Quit()
|
|
||||||
{
|
{
|
||||||
// Create FListView object
|
|
||||||
listView = new FListView (this);
|
|
||||||
listView->setGeometry(2, 1, 53, 14);
|
|
||||||
|
|
||||||
// Add columns to the view
|
|
||||||
listView->addColumn ("Name", 23);
|
|
||||||
listView->addColumn ("Population");
|
|
||||||
listView->addColumn ("Density/km²");
|
|
||||||
|
|
||||||
// Set right alignment for the second and third column
|
|
||||||
listView->setColumnAlignment (2, fc::alignRight);
|
|
||||||
listView->setColumnAlignment (3, fc::alignRight);
|
|
||||||
|
|
||||||
// Activate tree view
|
|
||||||
listView->setTreeView();
|
|
||||||
|
|
||||||
// Populate FListView with a list of items
|
|
||||||
static TreeItem africa[] =
|
static TreeItem africa[] =
|
||||||
{
|
{
|
||||||
{ "Algeria", "40,400,000", "15.9", 0 },
|
{ "Algeria", "40,400,000", "15.9", 0 },
|
||||||
|
@ -137,6 +123,12 @@ Treeview::Treeview (FWidget* parent)
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return africa;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
Treeview::TreeItem* Treeview::getAsia()
|
||||||
|
{
|
||||||
static TreeItem asia[] =
|
static TreeItem asia[] =
|
||||||
{
|
{
|
||||||
{ "Afghanistan", "34,656,032", "49.88", 0 },
|
{ "Afghanistan", "34,656,032", "49.88", 0 },
|
||||||
|
@ -161,6 +153,12 @@ Treeview::Treeview (FWidget* parent)
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return asia;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
Treeview::TreeItem* Treeview::getEurope()
|
||||||
|
{
|
||||||
static TreeItem europe[] =
|
static TreeItem europe[] =
|
||||||
{
|
{
|
||||||
{ "Austria", "8,794,267", "104.0", 0 },
|
{ "Austria", "8,794,267", "104.0", 0 },
|
||||||
|
@ -185,6 +183,12 @@ Treeview::Treeview (FWidget* parent)
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return europe;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
Treeview::TreeItem* Treeview::getNorthAmerica()
|
||||||
|
{
|
||||||
static TreeItem north_america[] =
|
static TreeItem north_america[] =
|
||||||
{
|
{
|
||||||
{ "Canada", "35,151,728", "3.92", 0 },
|
{ "Canada", "35,151,728", "3.92", 0 },
|
||||||
|
@ -198,6 +202,12 @@ Treeview::Treeview (FWidget* parent)
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return north_america;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
Treeview::TreeItem* Treeview::getSouthAmerica()
|
||||||
|
{
|
||||||
static TreeItem south_america[] =
|
static TreeItem south_america[] =
|
||||||
{
|
{
|
||||||
{ "Argentina", "43,847,430", "14.4", 0 },
|
{ "Argentina", "43,847,430", "14.4", 0 },
|
||||||
|
@ -213,6 +223,12 @@ Treeview::Treeview (FWidget* parent)
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return south_america;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
Treeview::TreeItem* Treeview::getOceania()
|
||||||
|
{
|
||||||
static TreeItem oceania[] =
|
static TreeItem oceania[] =
|
||||||
{
|
{
|
||||||
{ "Australia", "24,675,900", "3.2", 0 },
|
{ "Australia", "24,675,900", "3.2", 0 },
|
||||||
|
@ -231,6 +247,39 @@ Treeview::Treeview (FWidget* parent)
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return oceania;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
Treeview::Treeview (FWidget* parent)
|
||||||
|
: FDialog(parent)
|
||||||
|
, listView()
|
||||||
|
, Quit()
|
||||||
|
{
|
||||||
|
// Create FListView object
|
||||||
|
listView = new FListView (this);
|
||||||
|
listView->setGeometry(2, 1, 53, 14);
|
||||||
|
|
||||||
|
// Add columns to the view
|
||||||
|
listView->addColumn ("Name", 23);
|
||||||
|
listView->addColumn ("Population");
|
||||||
|
listView->addColumn ("Density/km²");
|
||||||
|
|
||||||
|
// Set right alignment for the second and third column
|
||||||
|
listView->setColumnAlignment (2, fc::alignRight);
|
||||||
|
listView->setColumnAlignment (3, fc::alignRight);
|
||||||
|
|
||||||
|
// Activate tree view
|
||||||
|
listView->setTreeView();
|
||||||
|
|
||||||
|
// Populate FListView with a list of items
|
||||||
|
TreeItem* africa = getAfrica();
|
||||||
|
TreeItem* asia = getAsia();
|
||||||
|
TreeItem* europe = getEurope();
|
||||||
|
TreeItem* north_america = getNorthAmerica();
|
||||||
|
TreeItem* south_america = getSouthAmerica();
|
||||||
|
TreeItem* oceania = getOceania();
|
||||||
|
|
||||||
static TreeItem continent[] =
|
static TreeItem continent[] =
|
||||||
{
|
{
|
||||||
{ "Africa", "944,000,000", "31.2", africa },
|
{ "Africa", "944,000,000", "31.2", africa },
|
||||||
|
|
Loading…
Reference in New Issue