Exemplo n.º 1
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
wxEnumProperty*
PropertiesView::createEnum(I_Property& _property, const std::string& _label)
{
    I_EnumProperty* pProperty = dynamic_cast<I_EnumProperty*>(&_property);

    assert(pProperty != NULL);

    wxPGChoices choices;

    struct EnumVisitor
        : public I_EnumProperty::I_EnumVisitor
    {

        virtual void visit(const std::string& _label)
        {
            m_choices.Add(std2wx(_label));
        }

        EnumVisitor(wxPGChoices& _choices)
        :   m_choices(_choices)
        {
        }

        wxPGChoices& m_choices;
    };

    EnumVisitor visitor(choices);
    pProperty->getEnums(visitor);

    return new wxEnumProperty(std2wx(_property.getName()), std2wx(_label), visitor.m_choices);
}
Exemplo n.º 2
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
wxWindow*
Notebook::addPage(I_View* _pWindow, const std::string& _title)
{
    View* pWindow = dynamic_cast<View*>(_pWindow);

    // Get the number of pages
    const size_t pageCount = GetPageCount();

    // Add a page to the end
    AddPage(pWindow, std2wx(_title.c_str()), true);
    pWindow->SetLabel(std2wx(_title.c_str()));

    // Return that page.
    wxWindow* const pPage = GetPage(pageCount);

    pWindow->setPage(this, pPage);

    m_views[pPage] = pWindow;

    // Activate the page.
    SetSelection(pageCount);

    pPage->SetFocus();

    // If it's the first page, activate it. (um, didn't we just do that?)
    if (pageCount == 0)
    {
        notifyPageChange(_pWindow);
    }

    return pPage;
}
Exemplo n.º 3
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
void
PropertiesView::onValueModified(I_PropertiesPublisher& _publisher, I_Property& _property)
{
    // The name is a concatenation of the property set name and the property name.
    std::stringstream name;
    name << _publisher.getPropertiesName();

    if (_property.getParent() != NULL)
    {
        // Append the parent name.  This gives us the fully qualified
        // parent name.
        name << "\\" << _property.getParent()->getFullName();
    }

    // Now create the child name.
    name << "\\" << _property.getName();

    wxPGProperty* pProperty = m_pPropertyGrid->GetPropertyByName(std2wx(name.str()));

    if (pProperty != NULL)
    {
        pProperty->SetValueFromString(std2wx(_property.getValue()));
    }
    else
    {
        // Assert?  Shouldn't get here.
        throw Zen::Utility::runtime_exception("PropertiesView::onValueModified(): Property name not found.");
    }
}
Exemplo n.º 4
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
wxWindow*
Notebook::addPage(wxWindow* _pWindow, const std::string& _title)
{
    // Get the number of pages
    const size_t pageCount = GetPageCount();

    // Add a page to the end
    AddPage(_pWindow, std2wx(_title.c_str()), false);
    _pWindow->SetLabel(std2wx(_title.c_str()));

    // Return that page.
    return GetPage(pageCount);
}
Exemplo n.º 5
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
void
SpreadSheetView::onNewRow(const int _rowPosition, const std::string& _rowLabeltext)
{
    int rowPosition;

    // -1 means append
    if (_rowPosition == -1)
    {
        m_pGrid->AppendRows();

        // Adjust the row position.
        rowPosition = m_pGrid->GetRows() - 1;
    }
    else
    {
        // Not -1, insert at the correct position
        m_pGrid->InsertRows(_rowPosition);

        rowPosition = _rowPosition;
    }

    if (!_rowLabeltext.empty())
    {
        m_pGrid->SetRowLabelValue(rowPosition, std2wx(_rowLabeltext));
    }

    m_pGrid->Fit();
}
Exemplo n.º 6
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
void
SpreadSheetView::onNewColumn(const int _columnPosition, const std::string& _columnLabelText)
{
    int columnPosition;

    // -1 means append
    if (_columnPosition == -1)
    {
        m_pGrid->AppendCols();

        // Adjust the column position.
        columnPosition = m_pGrid->GetCols() - 1;
    }
    else
    {
        // Not -1, insert at the correct position
        m_pGrid->InsertCols(_columnPosition);
        columnPosition = _columnPosition;
    }

    if (!_columnLabelText.empty())
    {
        m_pGrid->SetColLabelValue(columnPosition, std2wx(_columnLabelText));
    }
}
Exemplo n.º 7
0
void product_stats::refresh()
{

    int type = Choice1->GetSelection(); //0 - by revenue, 1 - by quantity


    mysqlpp::Query query = conn->query();
    wxDateTime start_date = DatePickerCtrl1->GetValue();
    wxDateTime end_date = DatePickerCtrl2->GetValue();
    wxDateTime mysql_end_date = end_date;
    mysql_end_date.Add(wxTimeSpan::Day());

    switch(type)
    {
    case 0:
        query << "SELECT `name` , SUM( `qty` ) AS `qty`, SUM(`qty`*`price`) AS `money_net`,SUM(`qty`*`price`*`tax`) AS `money_tax`\
FROM `orders_dishes` WHERE `order_id` = ANY (SELECT `id` FROM `orders` \
WHERE `time` > '"<< wx2std(start_date.FormatISODate(),wxConvUI) <<"' AND `time` < '"<< wx2std(mysql_end_date.FormatISODate(),wxConvUI) <<"')\
 GROUP BY `name` ORDER BY `money_net` DESC LIMIT " << wx2std(Choice2->GetStringSelection(),wxConvUI);
        break;
    case 1:
        query << "SELECT `name` , SUM( `qty` ) AS `qty`, SUM(`qty`*`price`) AS `money_net`,SUM(`qty`*`price`*`tax`) AS `money_tax`\
FROM `orders_dishes` WHERE `order_id` = ANY (SELECT `id` FROM `orders` \
WHERE `time` > '"<< wx2std(start_date.FormatISODate(),wxConvUI) <<"' AND `time` < '"<< wx2std(mysql_end_date.FormatISODate(),wxConvUI) <<"')\
 GROUP BY `name` ORDER BY `qty` DESC LIMIT " << wx2std(Choice2->GetStringSelection(),wxConvUI);
        break;
    }
    mysqlpp::StoreQueryResult res = query.store();
    if (res)
    {
        wxString info;
        info << _("Name of the product       |   Qty   |   Net   |   Taxes   |   Gross\n\n");

        wxString infoVerse;
        mysqlpp::Row row;
        mysqlpp::StoreQueryResult::size_type i;
        for (i = 0; i < res.num_rows(); ++i)
        {
            row = res[i];
            infoVerse.Clear();
            std::string name = std::string(row["name"]);
            int qty = int(row["qty"]);
            double money_net = round_2(double(row["money_net"]));
            double money_tax = round_2(double(row["money_tax"]));


            infoVerse << addSpaces(std2wx(name,wxConvUI),31);
            wxString temp;
            temp << qty;
            infoVerse << addSpaces(temp,8);
            infoVerse << addSpaces(addZero(money_net),11);
            infoVerse << addSpaces(addZero(money_tax),12);
            infoVerse << addZero(money_net + money_tax) << _T("\n");
            info << infoVerse;

        }
        TextCtrl1->ChangeValue(info);
    }

}
Exemplo n.º 8
0
int  kitchenFrame::connect_to_db(void)
{

    host = config->Read(_T("/mysql/host"));
    user = config->Read(_T("/mysql/user"));
    pass = config->Read(_T("/mysql/pass"));
    dbase = config->Read(_T("/mysql/dbase"));



    if (conn->connect(wx2std(dbase,wxConvUI).c_str(),wx2std(host,wxConvUI).c_str(),wx2std(user,wxConvUI).c_str(),wx2std(pass,wxConvUI).c_str()))
    {
        StatusBar1->SetStatusText(_("Connected to the database."));
//        dbase_connected = true;
        return 0;
    }
    else
    {
        StatusBar1->SetStatusText(_("Unable no connect to database '") + dbase + _("' on ") + host,0);

        wxMessageBox(_("Unable to connect to the database. Reason:\n") + std2wx(conn -> error(),wxConvUI),_("Not connected."), wxOK);
        //      dbase_connected = false;
        return 1;
    }



}
Exemplo n.º 9
0
void taxes::fill_all()
{
    ListBox1 -> Clear();
    TextCtrl1 -> Clear();
    TextCtrl2 -> Clear();
    tax_ids.Clear();

    mysqlpp::Query query = conn_taxes -> query();
    query << "SELECT * FROM `taxes`";
    mysqlpp::StoreQueryResult res = query.store();
    if (res)
    {
        if (res.num_rows() != 0)
        {
            mysqlpp::Row row;
            mysqlpp::StoreQueryResult::size_type i;
            for (i = 0; i < res.num_rows(); ++i)
            {
                row = res[i];
                std::string tax_name = std::string(row["name"]);
                ListBox1->Append(std2wx(tax_name, wxConvUI));
                tax_ids.Add(int(row["id"]));
            }
        }
    }
}
Exemplo n.º 10
0
void taxes::OnListBox1Select(wxCommandEvent& event)
{
    if (ListBox1->GetSelection() != wxNOT_FOUND)
    {
        mysqlpp::Query query = conn_taxes->query();
        query << "SELECT * FROM `taxes` WHERE `id`=" << tax_ids[ListBox1 -> GetSelection()];
        mysqlpp::StoreQueryResult res = query.store();

        if (res)
        {
            if (res.num_rows() != 0)
            {
                mysqlpp::Row row = res.at(0);
                TextCtrl2 -> Clear();
                wxString percent;
                percent << double(row["value"]);
                TextCtrl2 -> AppendText(percent);
                TextCtrl1 -> Clear();
                TextCtrl1 -> AppendText(std2wx(std::string(row["name"]),wxConvUI));
            }
        }


    }
}
Exemplo n.º 11
0
void db_set_panel::Save(void){
    confi->Write(_T("/mysql/host"), TextCtrl1->GetValue());
    confi->Write(_T("/mysql/user"), TextCtrl2->GetValue());
    confi->Write(_T("/mysql/pass"), TextCtrl3->GetValue());
    confi->Write(_T("/mysql/dbase"), TextCtrl4->GetValue());
    confi->Write(_T("/program/run"), _T("1"));

if(CheckBox1->GetValue())
    confi->Write(_T("/program/run_again"), _T("1"));
    else
    confi->Write(_T("/program/run_again"), _T("0"));



if(dbase_connected == false){
conn->connect("", wx2std(TextCtrl1->GetValue(),wxConvUI).c_str(),wx2std(TextCtrl2->GetValue(),wxConvUI).c_str(),wx2std(TextCtrl3->GetValue(),wxConvUI).c_str());
   if (*conn)
    {
         dbase_connected = true;
}
    else
    {
       wxMessageBox(std2wx(conn -> error(),wxConvUI));
        dbase_connected = false;
    }
}




    }
Exemplo n.º 12
0
void kitchenFrame::fillPanels()
{
    int pages = Notebook1->GetPageCount()-1;
    for(int t = pages; t > 0; --t) //deleting unnecessary pages
    {
        Notebook1->RemovePage(t);
    }
    OrderPanels.Clear();

    wxDateTime current = wxDateTime::Now();
    mysqlpp::Query query = conn->query();
    query << "SELECT `id`, `number` FROM `orders` WHERE `time` > '"<< wx2std(current.FormatISODate(), wxConvUI) <<"' AND `status` = 3";
    mysqlpp::StoreQueryResult res = query.store();
    if (res)
    {
        if(res.num_rows() != 0)
        {
            mysqlpp::Row row;
            mysqlpp::StoreQueryResult::size_type i;
            wxString panTitle;
            wxArrayInt orderIds;
            for (i = 0; i < res.num_rows(); ++i)
            {
                row = res[i];

                if(i % 3 == 0 && i != 0)
                {
                    addPanel(panTitle, orderIds);
                    panTitle.Clear();
                    orderIds.Clear();
                    panTitle << std2wx(std::string(row["number"]), wxConvUI);
                    orderIds.Add(int(row["id"]));
                }
                else
                {
                    wxString delim;
                    if(i != 0) delim = _T(" - ");
                    panTitle <<  delim << std2wx(std::string(row["number"]), wxConvUI);
                    orderIds.Add(int(row["id"]));
                }
            }
            addPanel(panTitle, orderIds);
        }
    }
}
Exemplo n.º 13
0
void subPageSpells::OnIconXChange()
{
	subPageSpells *pPage = ((PageSpells*)currentPage)->pageSpells;
	int newPos = pPage->iconXScroll->GetThumbPosition();

	char buffer[16]; sprintf(buffer, "%i", newPos);
	pPage->iconXEdit->SetValue( std2wx( buffer ) );

	pPage->UpdateIcon();
Exemplo n.º 14
0
void subPageSpells::UpdatePage()
{
/**
	Schools
**/
	new wxStaticText(page, -1, L"Schools", wxPoint(10,10));
	schoolStrArray->Clear();
	for ( std::vector<School*>::iterator itr = dfSpells->data.begin(); itr != dfSpells->data.end(); itr++ )
		schoolStrArray->Add( std2wx( (*itr)->name ) );
	schoolList->Set(*schoolStrArray);
}
Exemplo n.º 15
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
void
View::setPageText(const std::string& _text)
{
    if (m_pNotebook != NULL && m_pPage != NULL)
    {
        m_pNotebook->SetPageText(m_pNotebook->GetPageIndex(m_pPage), std2wx(_text));
    }
    else
    {
        // m_pNotebook or m_pPage is invalid; don't do anything
    }
}
Exemplo n.º 16
0
}
void subPageSpells::UpdateIcon()
{
	wxImage image(std2wx(GetDataPath("%s/textures/spells.bmp")));
	wxBitmap bitmap(image);

	int icon_x = iconXScroll->GetThumbPosition();
	int icon_y = iconYScroll->GetThumbPosition();
	if ( icon_x == 0 ) icon_x = 1;
	if ( icon_y == 0 ) icon_y = 1;
	wxBitmap icon = bitmap.GetSubBitmap( wxRect(32*(icon_x-1),32*(icon_y-1),32,32) );

	wxClientDC dc(page);
	dc.DrawBitmap(icon, 35,230, false);
Exemplo n.º 17
0
wxString getPartName(mysqlpp::Connection* conn, int partId)
{

    mysqlpp::Query query = conn->query();
    query << "SELECT * FROM `parts` WHERE `id`=" << partId;
    mysqlpp::StoreQueryResult res = query.store();
    wxString partName;
    if (res)
    {
        mysqlpp::Row row = res.at(0);
        partName = std2wx(std::string(row["name"]),wxConvUI);

    }

    return partName;

}
Exemplo n.º 18
0
int time_loggerFrame::getEmployeeId(){
    int toRet;
    mysqlpp::Query query = conn->query();
    query << "SELECT `emp_id`, `emp_name` FROM `employees` WHERE `emp_ssn` ="<< wx2std(StaticText1->GetLabel(),wxConvUI) <<" LIMIT 1";
    mysqlpp::StoreQueryResult res = query.store();
if(res.num_rows() != 0){
if(res){
        mysqlpp::Row row = res.at(0);
        empId = int(row["emp_id"]);
        empName = std2wx(std::string(row["emp_name"]), wxConvUI);
toRet = 0;
}
}else{
        empId = 0;
toRet = 1;
}
return toRet;
    }
Exemplo n.º 19
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
void
SpreadSheetView::onCellModified(I_SpreadSheetCell& _cell, const int _column, const int _row)
{
    m_pGrid->SetCellValue(_row, _column, std2wx(_cell.getUserData()->getTextValue()));

    const bool isMutable = _cell.getUserData()->getMutable();

    // HACK If the cell is not mutable, make it italics
    // TODO Get the cell decorations from the cell or from a contributor.
    if (!isMutable)
    {
        wxFont cellFont = m_pGrid->GetCellFont(_row, _column);
        cellFont.SetStyle(wxFONTSTYLE_ITALIC);
        m_pGrid->SetCellFont(_row, _column, cellFont);
        m_pGrid->SetReadOnly(_row, _column, true);
    }

    m_pGrid->Fit();
}
Exemplo n.º 20
0
//-----------------------------------------------------------------------------
void Exception::loadProperties()
{
    setPropertiesLoaded(false);

    DatabasePtr db = getDatabase();
    MetadataLoader* loader = db->getMetadataLoader();
    MetadataLoaderTransaction tr(loader);

    IBPP::Statement& st1 = loader->getStatement(
        "select RDB$MESSAGE, RDB$EXCEPTION_NUMBER from RDB$EXCEPTIONS"
        " where RDB$EXCEPTION_NAME = ?");
    st1->Set(1, wx2std(getName_(), db->getCharsetConverter()));
    st1->Execute();
    st1->Fetch();
    std::string message;
    st1->Get(1, message);
    messageM = std2wx(message, db->getCharsetConverter());
    st1->Get(2, numberM);

    setPropertiesLoaded(true);
}
Exemplo n.º 21
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
void
PropertiesView::show(PropertiesHandle& _handle)
{
    // If the handle already has been shown (i.e. the handle has a valid category)
    // don't do this.

    if (_handle.getCategory() == NULL)
    {
        wxPropertyCategory* const pCategory =
            new wxPropertyCategory(std2wx(_handle.getPublisher().getPropertiesName()));

        wxPGProperty* pID = m_pPropertyGrid->Append(pCategory);

        _handle.setCategory(pCategory);

        // Subscribe to the publisher
        m_propertiesHandles[&_handle] = _handle.getPublisher().subscribe(this);

        // Refresh the grid
        m_pPropertyGrid->Refresh();
    }
}
Exemplo n.º 22
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
void
PropertiesView::onAddProperty(I_PropertiesPublisher& _publisher, I_Property& _property)
{
    // Get the handle associated with this publisher.
    PropertiesHandle* const pHandle = m_propertiesMap[&_publisher];

    // TODO Fix:  pHandle is sometimes NULL.  Why?

    // The name is a concatenation of the property set name and the property name.
    std::stringstream name;
    name << pHandle->getPublisher().getPropertiesName();

    // Get the parent category
    // Use pParent now.
    //wxPropertyCategory* const pCategory = pHandle->getCategory();

    if (_property.getParent() != NULL)
    {
        // Append the parent name.  This gives us the fully qualified
        // parent name.
        name << "\\" << _property.getParent()->getFullName();
    }

    // Get the parent by name.
    wxPGProperty* pParent = m_pPropertyGrid->GetPropertyByName(std2wx(name.str()));

    // Make sure the parent is not NULL.  It should at least return the
    // top category.
    assert(pParent != NULL);

    // Now create the child name.
    name << "\\" << _property.getName();

    wxPGProperty* pChild = NULL;

    switch(_property.getType())
    {
    case I_Property::STRING_TYPE:
        // The first parameter is the label which is shown on the screen.
        // The second parameter is the label, which is the unqiue identifier of the property.
        pChild = new wxStringProperty(std2wx(_property.getName()), std2wx(name.str()), std2wx(_property.getValue()));
        break;
    case I_Property::ENUM_TYPE:
        pChild = createEnum(_property, name.str());
        break;
    case I_Property::CATEGORY_TYPE:
        pChild = createCategory(_property, name.str());
        break;
    default:
        throw Zen::Utility::runtime_exception("Error, invalid property type.");
    }

    pChild->SetClientData(&_property);
    pParent->AppendChild(pChild);

    // Assume a string value type for now.

    // TEST See how to get the property (name or label)
    wxPGProperty* pByName = m_pPropertyGrid->GetPropertyByName(std2wx(name.str()));
#if 0
    m_pPropertyGrid->Insert(pCategory,
        new wxStringProperty(_property.getName(), name.str(), _property.getValue()));
#endif
}
Exemplo n.º 23
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
wxPropertyCategory*
PropertiesView::createCategory(I_Property& _property, const std::string& _label)
{
    return new wxPropertyCategory(std2wx(_property.getName()), std2wx(_label));
}
Exemplo n.º 24
0
 virtual void visit(const std::string& _label)
 {
     m_choices.Add(std2wx(_label));
 }
Exemplo n.º 25
0
wxString formatItem(mysqlpp::Connection* conn, int num, int dishId, bool main)
{

    wxArrayString parts; //getting parts from mysql-query
    wxString title;
    wxString comment;
    wxString qty;
    wxTimeSpan diff;
    bool ready = false;
    mysqlpp::Query query = conn->query();
    query << "SELECT `orders_dishes`.`qty`,`orders_dishes`.`name`,`orders_dishes`.`comment`  ,\
    `orders_dishes`.`ready`,`orders`.`time` FROM `orders_dishes`,`orders` WHERE \
    `orders_dishes`.`id` = "<< dishId <<" AND `orders_dishes`.`order_id`=`orders`.`id`";
    mysqlpp::StoreQueryResult res = query.store();
    if (res)
    {
        mysqlpp::Row row = res.at(0);
        title = std2wx(std::string(row["name"]), wxConvUI);
        comment = std2wx(std::string(row["comment"]), wxConvUI);
        qty = std2wx(std::string(row["qty"]), wxConvUI);
        ready = bool(row["ready"]);
        wxDateTime time;
        time.ParseDateTime(std2wx(std::string(row["time"]),wxConvUI));
        diff = wxDateTime::Now() - time;
    }

    query << "SELECT * FROM `orders_dishes_parts` WHERE `orders_dishes_id`=" << dishId;
    res = query.store();
    if (res)
    {
        mysqlpp::Row row;
        mysqlpp::StoreQueryResult::size_type i;
        for (i = 0; i < res.num_rows(); ++i)
        {
            row = res[i];

            wxString partNameToAdd = getPartName(conn, int(row["parts_id"]));
            if(!bool(row["using"]))
            {
                partNameToAdd  = _("<b>NO</b> ") + partNameToAdd;
            }
            parts.Add(partNameToAdd);
        }
    }



    wxString toRet;
    if(!main)
    {
        toRet << _T("<b><font size=4>") << title << _T(" X ")<< qty <<_T("</b></font>");
    }
    else
    {
        toRet << _T("<br align = left>") << _("Time:") << _T(" <b>") << diff.Format(_T("%M")) << _(" min") <<_T("</b>") << _(" Qty:") << _T(" <b>") << qty <<_T("</b></br>");
    }

    toRet << _T("<div align=right><table cellspacing=0 cellpadding=0 WIDTH=100%><tr><td>");

    for(int i = 0; i < parts.GetCount(); ++i)
    {
        toRet << _T("<br> * ") << parts[i];
    }
    wxString readyImage;
    if(ready)
    {
        readyImage = _T("done.png");
    }
    else
    {
        readyImage = _T("todo.png");
    }

    wxStandardPaths path;
    wxFileName imageName;
    imageName.Assign(path.GetDataDir(),readyImage);

    toRet << _T("</td><td width = 50><a href=") << num << _T(":") << dishId << _T("><img src=") << imageName.GetFullPath() << _T("></a></td></tr></table></div>");

    if(comment != _T(""))
    {
        toRet << _T("<font size=2><br align=left>Comment: <i>") << comment << _T("</i></font>");
    }

    return toRet;
}
Exemplo n.º 26
0
void subPageSpells::Init(wxNotebook *notebook, DF* dataFile, PageSpells *parent)
{
	dfSpells = (DFSpells*)dataFile;		// Make a copy of the datafile
	this->dataFile = dataFile;
	spellItr = dfSpells->GetCurrent()->spells.begin();
	currentSpell = *spellItr;
	currentSchool = *(dfSpells->data.begin());

	page = new wxNotebookPage(notebook, ID_Spells_subPage);
	this->parent = parent;

	School *school = dfSpells->GetCurrent();
	Spell *spell = *(school->spells.begin());

/**
	Schools
**/
	new wxStaticText(page, -1, L"Schools", wxPoint(10,10));
	for ( std::vector<School*>::iterator itr = dfSpells->data.begin(); itr != dfSpells->data.end(); itr++ )
		schoolStrArray->Add( std2wx( (*itr)->name ) );
	schoolList = new wxListBox(page, ID_subSpellsSchoolList, wxPoint(10,30), wxSize(200,90), *schoolStrArray);

	schoolNameText = new wxStaticText(page, -1, std2wx(school->name), wxPoint(220,40));
		schoolNameText->SetFont( wxFont(10,wxFONTFAMILY_DEFAULT,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD) );


	// name
	new wxStaticText(page, -1, _("Name"), wxPoint(220,60));
	nameEdit = new wxTextCtrl(page, -1, std2wx(spell->name), wxPoint(220,80), wxSize(200,25));

	// symbol
	new wxStaticText(page, -1, _("Symbol"), wxPoint(430,60));
	symbolEdit = new wxTextCtrl(page, -1, std2wx(spell->symbol), wxPoint(430,80), wxSize(150,25));

	// level
	new wxStaticText(page, -1, _("Level"), wxPoint(590,60));
	levelEdit = new wxTextCtrl(page, -1, std2wx(spell->level), wxPoint(590,80), wxSize(50,25));

	// mana
	new wxStaticText(page, -1, _("Mana"), wxPoint(650,60));
	manaEdit = new wxTextCtrl(page, -1, std2wx(spell->mana), wxPoint(650,80), wxSize(50,25));

	// exp
	new wxStaticText(page, -1, _("Exp"), wxPoint(10,130));
	expEdit = new wxTextCtrl(page, -1, std2wx(spell->exp), wxPoint(10,150), wxSize(50,-1));

	// failure rate
	new wxStaticText(page, -1, _("Failure Rate"), wxPoint(70,130));
	failureRateEdit = new wxTextCtrl(page, -1, std2wx(spell->failureRate), wxPoint(70,150), wxSize(50,25));

	// action
	new wxStaticText(page, -1, _("Action"), wxPoint(160,130));
	actionEdit = new wxTextCtrl(page, -1, std2wx(spell->action), wxPoint(160,150), wxSize(100,25));

	// distance
	new wxStaticText(page, -1, _("Distance"), wxPoint(270,130));
	distanceEdit = new wxTextCtrl(page, -1, std2wx(spell->distance), wxPoint(270,150), wxSize(50,25));

	// area
	new wxStaticText(page, -1, _("Area"), wxPoint(330,130));
	wxString choices[2] = { L"single", L"group" };
	areaCombo = new wxComboBox(page, -1, std2wx(spell->area), wxPoint(330,150),wxSize(80,25),
			2,choices, wxCB_READONLY);

	// CLIP
	new wxStaticText(page, -1, _("Targets"), wxPoint(420,130));
	wxString clipStr[] = { L"Creature", L"Location", L"Item", L"Party" };
	clipCheckList = new wxCheckListBox(page, -1, wxPoint(420,150), wxSize(85,90), 4,clipStr);
	clipCheckList->Check(0, spell->target.find("C") != std::string::npos );
	clipCheckList->Check(1, spell->target.find("L") != std::string::npos );
	clipCheckList->Check(2, spell->target.find("I") != std::string::npos );
	clipCheckList->Check(3, spell->target.find("P") != std::string::npos );

	// speed
	new wxStaticText(page, -1, _("Speed"), wxPoint(515,130));
	speedEdit = new wxTextCtrl(page, -1, std2wx(spell->speed), wxPoint(515,150), wxSize(50,25));

	// effect
	new wxStaticText(page, -1, _("Effect"), wxPoint(575,130));
	effectEdit = new wxTextCtrl(page, -1, std2wx(spell->effect), wxPoint(575,150), wxSize(150,25));

/**
	Icon
**/
	new wxStaticText(page, -1, _("Icon (x,y)"), wxPoint(25,180));
	// icon_x
	int x = atoi( spell->icon_x.c_str() );
	iconXEdit = new wxTextCtrl(page, -1, std2wx(spell->icon_x), wxPoint(10,200), wxSize(30,25));
	iconXScroll = new wxScrollBar(page, ID_subSpellsIconXScroll, wxPoint(40,200), wxSize(-1,25), wxSB_VERTICAL);
		iconXScroll->SetScrollbar(x,1,20,1);
	// icon_y
	int y = atoi( spell->icon_y.c_str() );
	iconYEdit = new wxTextCtrl(page, -1, std2wx(spell->icon_y), wxPoint(55,200), wxSize(30,25));
	iconYScroll = new wxScrollBar(page, ID_subSpellsIconYScroll, wxPoint(85,200), wxSize(-1,25), wxSB_VERTICAL);
		iconYScroll->SetScrollbar(y,1,17,1);
	// Make sure the icon is painted when tabs are changed
	page->Connect( wxEVT_PAINT, (wxObjectEventFunction)&subPageSpells::OnPaint, NULL, (wxEvtHandler*)this);


	// disposition
	new wxStaticText(page, -1, _("Disposition"), wxPoint(160,180));
	wxString dispositionChoices[2] = { L"Friendly", L"Hostile" };
	wxString disposition = L"Friendly";
	if ( spell->disposition == "H" )	disposition = L"Hostile";
	dispositionCombo = new wxComboBox(page, -1, disposition, wxPoint(160,200),wxSize(80,25),
			2,dispositionChoices, wxCB_READONLY);

	// prerequisite
	new wxStaticText(page, -1, _("Prerequisite"), wxPoint(250,180));
	wxString prereqChoices[] = { L"-none-", L"HP", L"AC",
			L"blessed", L"empowered", L"enraged", L"ac_protected", L"magic_protected", L"invisible",	// good
			L"drunk", L"poisoned", L"cursed", L"possessed", L"blinded", L"charmed", L"dead",			// bad
			L"overloaded", L"leveled" };																// neutral
	wxString prereq = std2wx(spell->prerequisite);
	if ( prereq == L"" )	prereq = L"-none-";
	prereqCombo = new wxComboBox(page, -1, std2wx(spell->prerequisite), wxPoint(250,200),wxSize(130,25),
			17,prereqChoices, wxCB_READONLY);

	// sound
	new wxStaticText(page, -1, _("Sound"), wxPoint(160,230));
	soundEdit = new wxTextCtrl(page, -1, std2wx(spell->sound), wxPoint(160,250), wxSize(200,25));

	// notes
	new wxStaticText(page, -1, _("Notes"), wxPoint(515,180));
	notesEdit = new wxTextCtrl(page, -1, std2wx(spell->notes), wxPoint(515,200), wxSize(230,90), wxTE_MULTILINE);


	notebook->AddPage(page, _("Spells"));
}
Exemplo n.º 27
0
void subPageSpells::UpdatePageNumber()
{
	char buffer[64];
	sprintf(buffer, "Page %i/%i", spellNumber, currentSchool->spells.size());
	g_pageNumText->SetLabel(std2wx(buffer));
}
Exemplo n.º 28
0
void subPageSpells::GetCurrent()
{
	Spell *spell = currentSpell;

	nameEdit->SetValue(std2wx(spell->name));
	symbolEdit->SetValue(std2wx(spell->symbol));
	levelEdit->SetValue(std2wx(spell->level));
	manaEdit->SetValue(std2wx(spell->mana));
	expEdit->SetValue(std2wx(spell->exp));
	failureRateEdit->SetValue(std2wx(spell->failureRate));
	actionEdit->SetValue(std2wx(spell->action));
	distanceEdit->SetValue(std2wx(spell->distance));
	areaCombo->SetValue(std2wx(spell->area));

	// CLIP
	clipCheckList->Check(0, spell->target.find("C") != std::string::npos );
	clipCheckList->Check(1, spell->target.find("L") != std::string::npos );
	clipCheckList->Check(2, spell->target.find("I") != std::string::npos );
	clipCheckList->Check(3, spell->target.find("P") != std::string::npos );


	speedEdit->SetValue(std2wx(spell->speed));
	effectEdit->SetValue(std2wx(spell->effect));

	// icon
	int x = atoi( spell->icon_x.c_str() );
	iconXEdit->SetValue( std2wx(spell->icon_x) );
		iconXScroll->SetScrollbar(x,1,20,1);
	int y = atoi( spell->icon_y.c_str() );
	iconYEdit->SetValue( std2wx(spell->icon_y) );
		iconYScroll->SetScrollbar(y,1,17,1);
	UpdateIcon();

	// disposition
	wxString disposition = L"Friendly";
	if ( spell->disposition == "H" )	disposition = L"Hostile";
	dispositionCombo->SetValue(disposition);

	wxString prereq = std2wx(spell->prerequisite);
	if ( prereq == L"" )	prereq = L"-none-";
	prereqCombo->SetValue(prereq);

	soundEdit->SetValue(std2wx(spell->sound));
	notesEdit->SetValue(std2wx(spell->notes));
Exemplo n.º 29
0
//-----------------------------------------------------------------------------
bool Server::getService(IBPP::Service& svc, ProgressIndicator* progressind,
                        bool sysdba)
{
    if (progressind)
    {
        progressind->initProgress(_("Connecting..."),
                                  databasesM.size() + 2, 0, 1);
    }

    // check if we already had some successful connections
    if (!serviceSysdbaPasswordM.isEmpty())  // we have sysdba pass
    {
        if (progressind)
        {
            progressind->setProgressMessage(_("Using current SYSDBA password"));
            progressind->stepProgress();
        }
        try
        {
            svc = IBPP::ServiceFactory(wx2std(getConnectionString()),
                                       "SYSDBA", wx2std(serviceSysdbaPasswordM));
            svc->Connect();
            return true;
        }
        catch(IBPP::Exception&)   // keep going if connect fails
        {
            serviceSysdbaPasswordM.clear();
        }
    }
    if (progressind && progressind->isCanceled())
        return false;
    // check if we have non-sysdba connection
    if (!sysdba && !serviceUserM.isEmpty())
    {
        if (progressind)
        {
            progressind->setProgressMessage(QString::fromLatin1("Using current %1 password")
                                            .arg(serviceUserM));
            progressind->stepProgress();
        }
        try
        {
            svc = IBPP::ServiceFactory(wx2std(getConnectionString()),
                                       wx2std(serviceUserM), wx2std(servicePasswordM));
            svc->Connect();
            return true;
        }
        catch(IBPP::Exception&)   // keep going if connect fails
        {
            serviceUserM.clear();
            servicePasswordM.clear();
        }
    }

    // first try connected databases
    for (DatabasePtrs::iterator ci = databasesM.begin();
            ci != databasesM.end(); ++ci)
    {
        if (progressind && progressind->isCanceled())
            return false;
        if (!(*ci)->isConnected())
            continue;
        // Use the user name and password of the connected user
        // instead of the stored ones.
        IBPP::Database& db = (*ci)->getIBPPDatabase();
        if (sysdba && std2wx(db->Username()).toUpper() != QString::fromLatin1("SYSDBA"))
            continue;
        if (progressind)
        {
            progressind->setProgressMessage(_("Using password of: ") +
                                            std2wx(db->Username()) + QString::fromLatin1("@") + (*ci)->getName_());
            progressind->stepProgress();
        }
        try
        {
            svc = IBPP::ServiceFactory(wx2std(getConnectionString()),
                                       db->Username(), db->UserPassword());
            svc->Connect();
            if (sysdba)
                serviceSysdbaPasswordM = std2wx(db->UserPassword());
            else
            {
                serviceUserM = std2wx(db->Username());
                servicePasswordM = std2wx(db->UserPassword());
            }
            return true;
        }
        catch(IBPP::Exception&)   // keep going if connect fails
        {
        }
    }

    // when the operation is not canceled try to user/pass of disconnected DBs
    for (DatabasePtrs::const_iterator ci = databasesM.begin();
            ci != databasesM.end(); ++ci)
    {
        if (progressind && progressind->isCanceled())
            return false;
        if ((*ci)->isConnected())
            continue;
        QString user = (*ci)->getUsername();
        QString pwd = (*ci)->getDecryptedPassword();
        if (pwd.isEmpty() || sysdba && user.toUpper() != QString::fromLatin1("SYSDBA"))
            continue;
        if (progressind)
        {
            progressind->setProgressMessage(_("Using password of: ") +
                                            user + QString::fromLatin1("@") + (*ci)->getName_());
            progressind->stepProgress();
        }
        try
        {
            svc = IBPP::ServiceFactory(wx2std(getConnectionString()),
                                       wx2std(user), wx2std(pwd));
            svc->Connect();
            if (sysdba)
                serviceSysdbaPasswordM = pwd;
            else
            {
                serviceUserM = user;
                servicePasswordM = pwd;
            }
            return true;
        }
        catch(IBPP::Exception&)   // keep going if connect fails
        {
        }
    }
    return false;
}
Exemplo n.º 30
0
void kitchenFrame::fillMain()
{
    ListBox2->Clear();
    Lst2.Clear();
    ListBox3->Clear();
    Lst3.Clear();
    ListBox4->Clear();
    wxDateTime current = wxDateTime::Now();
    mysqlpp::Query query = conn->query();
    wxString orderBy;
    if(ToggleButton2->GetValue())
    {
        orderBy = _T("`time_avg` ASC");
    }
    else if(ToggleButton1->GetValue())
    {
        orderBy = _T("`qty` DESC");
    }
    query << "SELECT SUM( `qty` ) AS `qty`,`orders_dishes`.`name`,MIN(`orders`.`time`) \
AS `time_min`,MAX(`orders`.`time`) AS `time_max`,FROM_UNIXTIME(AVG(UNIX_TIMESTAMP(`orders`.`time`)))\
 AS `time_avg` FROM `orders_dishes`,`orders` WHERE `orders`.`time` > '"<< wx2std(current.FormatISODate(), wxConvUI) <<"' \
 AND `orders`.`status`=3 AND `orders_dishes`.`kitchen`=1 AND `orders_dishes`.`ready`=0 AND `orders_dishes`.`order_id`=`orders`.`id` \
 GROUP BY `orders_dishes`.`name` ORDER BY "<< wx2std(orderBy, wxConvUI);
    mysqlpp::StoreQueryResult res = query.store();
    if (res)
    {
        mysqlpp::Row row;
        mysqlpp::StoreQueryResult::size_type i;
        bool first = true;
        wxDateTime avg;
        for (i = 0; i < res.num_rows(); ++i)
        {
            row = res[i];
            avg.ParseDateTime(std2wx(std::string(row["time_avg"]),wxConvUI));
            wxTimeSpan diff = wxDateTime::Now() - avg;
            wxString toAppend = _("<font size = 5>") + std2wx(std::string(row["name"]),wxConvUI) + _("</font><br align=center>Avg. time: <b>") + diff.Format(_T("%M")) + _(" min.</b> Quantity: <font size = 5>") + std2wx(std::string(row["qty"]),wxConvUI) + _T("</font>");

            if(first)
            {
                ListBox2->Append(toAppend);
                Lst2.Add(std2wx(std::string(row["name"]),wxConvUI));
                ListBox2->Append(_T("Preved!Medved"));
                if(!ListBox2->IsVisible(ListBox2->GetCount()-1))
                {
                    first = false;
                    ListBox2->Delete(ListBox2->GetCount()-2);
                    Lst2.RemoveAt(Lst2.GetCount()-1);
                    ListBox3->Append(toAppend);
                    Lst3.Add(std2wx(std::string(row["name"]),wxConvUI));
                }
                ListBox2->Delete(ListBox2->GetCount()-1);
            }
            else
            {
                ListBox3->Append(toAppend);
                Lst3.Add(std2wx(std::string(row["name"]),wxConvUI));
            }
        }
    }

//wxMessageBox(toSearch);

    int Lst2Index = Lst2.Index(toSearch);
    int Lst3Index = Lst3.Index(toSearch);
    if(Lst2Index != wxNOT_FOUND || Lst3Index != wxNOT_FOUND )
    {
        if(Lst2Index != wxNOT_FOUND)
        {
//making selection in first listbox
            fillDetails(Lst2[Lst2Index]);
            ListBox2->SetSelection(Lst2Index);
        }
        else
        {
//making selection in second listbox
            fillDetails(Lst3[Lst3Index]);
            ListBox3->SetSelection(Lst3Index);
        }
    }
    else if(Lst2.GetCount() != 0)   //if none of those has our dish - just selecting first one
    {
        fillDetails(Lst2[0]);
        ListBox2->SetSelection(0);
        toSearch = Lst2[0];
    }

}