void StocksListCtrl::OnColClick(wxListEvent& event)
{
    int ColumnNr;
    if (event.GetId() != MENU_HEADER_SORT)
        ColumnNr = event.GetColumn();
    else
        ColumnNr = ColumnHeaderNr;
    if (0 >= ColumnNr || ColumnNr >= getColumnsNumber()) return;

    if (m_selected_col == ColumnNr && event.GetId() != MENU_HEADER_SORT) m_asc = !m_asc;

    wxListItem item;
    item.SetMask(wxLIST_MASK_IMAGE);
    item.SetImage(-1);
    SetColumn(m_selected_col, item);

    m_selected_col = ColumnNr;

    Model_Setting::instance().Set("STOCKS_ASC", m_asc);
    Model_Setting::instance().Set("STOCKS_SORT_COL", m_selected_col);

    int trx_id = -1;
    if (m_selected_row>=0) trx_id = m_stocks[m_selected_row].STOCKID;
    doRefreshItems(trx_id);
    stock_panel_->OnListItemSelected(-1);
}
void StocksListCtrl::OnColRightClick(wxListEvent& event)
{
    ColumnHeaderNr = event.GetColumn();
    if (0 > ColumnHeaderNr || ColumnHeaderNr >= getColumnsNumber()) return;
    wxMenu menu;
    menu.Append(MENU_HEADER_HIDE, _("Hide column"));
    menu.Append(MENU_HEADER_SORT, _("Order by this column"));
    menu.Append(MENU_HEADER_RESET, _("Reset columns size"));
    PopupMenu(&menu);
    this->SetFocus();
}
void StocksListCtrl::OnHeaderReset(wxCommandEvent& event)
{
    wxString parameter_name;
    for (int i = 0; i < getColumnsNumber(); i++)
         {
        StocksListCtrl::SetColumnWidth(i, wxLIST_AUTOSIZE_USEHEADER);
        parameter_name = wxString::Format("STOCKS_COL%i_WIDTH", i);
        Model_Setting::instance().Set(parameter_name, StocksListCtrl::GetColumnWidth(i));
        }
    wxListEvent e;
    e.SetId(MENU_HEADER_SORT);
    ColumnHeaderNr = col_sort();
    m_asc = true;
    StocksListCtrl::OnColClick(e);
}
void StocksListCtrl::OnColClick(wxListEvent& event)
{
    if(0 > event.GetColumn() || event.GetColumn() >= getColumnsNumber()) return;

    if (m_selected_col == event.GetColumn()) m_asc = !m_asc;

    wxListItem item;
    item.SetMask(wxLIST_MASK_IMAGE);
    item.SetImage(-1);
    SetColumn(m_selected_col, item);

    m_selected_col = event.GetColumn();

    Model_Setting::instance().Set("STOCKS_ASC", m_asc);
    Model_Setting::instance().Set("STOCKS_SORT_COL", m_selected_col);

    int trx_id = -1;
    if (m_selected_row>=0) trx_id = m_stocks[m_selected_row].STOCKID;
    doRefreshItems(trx_id);
    stock_panel_->OnListItemSelected(-1);
}