Proyek Besar dengan C++, WxWidget dan IBPP
Ini merupakan proyek utak-atik saja. tapi cukup masih memusingkan, berikut kode sumbernya :
/***************************************************************
* Name: HWMain.cpp
* Purpose: Code for Application Frame
* Author: almakammaji (radensunan@bismillah.com)
* Created: 2011-02-22
* Copyright: almakammaji (radensunan.blogspot.com)
* License:
**************************************************************/
#include "wx_pch.h"
#include "HWMain.h"
#include
//(*InternalHeaders(HWFrame)
#include
#include
#include
#include
#include
//*)
//Header kagem njawil database
#ifndef IBPP_WINDOWS
#define IBPP_WINDOWS
#endif
//#ifndef __GNUC_
//#define __GNUC_
//#endif
#include "core/ibpp.h"
//helper functions
enum wxbuildinfoformat {
short_f, long_f };
wxString wxbuildinfo(wxbuildinfoformat format)
{
wxString wxbuild(wxVERSION_STRING);
if (format == long_f )
{
#if defined(__WXMSW__)
wxbuild << _T("-Windows");
#elif defined(__UNIX__)
wxbuild << _T("-Linux");
#endif
#if wxUSE_UNICODE
wxbuild << _T("-Unicode build");
#else
wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
}
return wxbuild;
}
//(*IdInit(HWFrame)
const long HWFrame::ID_STATICTEXT2 = wxNewId();
const long HWFrame::ID_TEXTCTRL1 = wxNewId();
const long HWFrame::ID_STATICTEXT3 = wxNewId();
const long HWFrame::ID_TEXTCTRL2 = wxNewId();
const long HWFrame::ID_BUTTON3 = wxNewId();
const long HWFrame::ID_PANEL1 = wxNewId();
const long HWFrame::ID_BUTTON1 = wxNewId();
const long HWFrame::ID_STATICTEXT1 = wxNewId();
const long HWFrame::ID_COMBOBOX1 = wxNewId();
const long HWFrame::ID_PANEL3 = wxNewId();
const long HWFrame::ID_BUTTON2 = wxNewId();
const long HWFrame::ID_PANEL2 = wxNewId();
const long HWFrame::idMenuQuit = wxNewId();
const long HWFrame::idMenuAbout = wxNewId();
const long HWFrame::ID_STATUSBAR1 = wxNewId();
//*)
BEGIN_EVENT_TABLE(HWFrame,wxFrame)
//(*EventTable(HWFrame)
//*)
END_EVENT_TABLE()
HWFrame::HWFrame(wxWindow* parent,wxWindowID id)
{
//(*Initialize(HWFrame)
wxMenuItem* MenuItem2;
wxFlexGridSizer* FlexGridSizer3;
wxMenuItem* MenuItem1;
wxFlexGridSizer* FlexGridSizer2;
wxMenu* Menu1;
wxBoxSizer* BoxSizer1;
wxMenuBar* MenuBar1;
wxFlexGridSizer* FlexGridSizer1;
wxMenu* Menu2;
Create(parent, wxID_ANY, _("Zahir Bukak Tahun"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("wxID_ANY"));
{
wxIcon FrameIcon;
FrameIcon.CopyFromBitmap(wxBitmap(wxImage(_T("D:\\builder\\ZD5\\ZahirApp.ico"))));
SetIcon(FrameIcon);
}
FlexGridSizer1 = new wxFlexGridSizer(2, 1, 0, 0);
Panel1 = new wxPanel(this, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1"));
FlexGridSizer3 = new wxFlexGridSizer(2, 2, 0, 0);
StaticText2 = new wxStaticText(Panel1, ID_STATICTEXT2, _("Asmanipun Server"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2"));
FlexGridSizer3->Add(StaticText2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
TextCtrl1 = new wxTextCtrl(Panel1, ID_TEXTCTRL1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
FlexGridSizer3->Add(TextCtrl1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticText3 = new wxStaticText(Panel1, ID_STATICTEXT3, _("Asmanipun Data (Sak Panggonipun)"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT3"));
FlexGridSizer3->Add(StaticText3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
TextCtrl2 = new wxTextCtrl(Panel1, ID_TEXTCTRL2, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL2"));
FlexGridSizer3->Add(TextCtrl2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
Button3 = new wxButton(Panel1, ID_BUTTON3, _("Padosi Datanipun!"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON3"));
FlexGridSizer3->Add(Button3, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
Panel1->SetSizer(FlexGridSizer3);
FlexGridSizer3->Fit(Panel1);
FlexGridSizer3->SetSizeHints(Panel1);
FlexGridSizer1->Add(Panel1, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
Panel2 = new wxPanel(this, ID_PANEL2, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL2"));
FlexGridSizer2 = new wxFlexGridSizer(3, 1, 0, 0);
Button1 = new wxButton(Panel2, ID_BUTTON1, _("Dipun Sambungaken !"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));
FlexGridSizer2->Add(Button1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
Panel3 = new wxPanel(Panel2, ID_PANEL3, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL3"));
BoxSizer1 = new wxBoxSizer(wxVERTICAL);
StaticText1 = new wxStaticText(Panel3, ID_STATICTEXT1, _("Monggo dipun pilih tahun pundi engkang badhe dibukak"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
BoxSizer1->Add(StaticText1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
ComboBox1 = new wxComboBox(Panel3, ID_COMBOBOX1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_COMBOBOX1"));
ComboBox1->Append(_("2013"));
ComboBox1->Append(_("2012"));
ComboBox1->Append(_("2011"));
ComboBox1->SetSelection( ComboBox1->Append(_("2010")) );
ComboBox1->Append(_("2009"));
ComboBox1->Append(_("2008"));
ComboBox1->Append(_("2007"));
ComboBox1->Append(_("2006"));
ComboBox1->Append(_("2005"));
BoxSizer1->Add(ComboBox1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
Panel3->SetSizer(BoxSizer1);
BoxSizer1->Fit(Panel3);
BoxSizer1->SetSizeHints(Panel3);
FlexGridSizer2->Add(Panel3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
Button2 = new wxButton(Panel2, ID_BUTTON2, _("Bukak Tutup Tahunipun !!!"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON2"));
FlexGridSizer2->Add(Button2, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
Panel2->SetSizer(FlexGridSizer2);
FlexGridSizer2->Fit(Panel2);
FlexGridSizer2->SetSizeHints(Panel2);
FlexGridSizer1->Add(Panel2, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
SetSizer(FlexGridSizer1);
MenuBar1 = new wxMenuBar();
Menu1 = new wxMenu();
MenuItem1 = new wxMenuItem(Menu1, idMenuQuit, _("Methu\tAlt-F4"), _("Quit the application"), wxITEM_NORMAL);
Menu1->Append(MenuItem1);
MenuBar1->Append(Menu1, _("&Fail"));
Menu2 = new wxMenu();
MenuItem2 = new wxMenuItem(Menu2, idMenuAbout, _("Babagan\tF1"), _("Show info about this application"), wxITEM_NORMAL);
Menu2->Append(MenuItem2);
MenuBar1->Append(Menu2, _("Tulong"));
SetMenuBar(MenuBar1);
StatusBar1 = new wxStatusBar(this, ID_STATUSBAR1, 0, _T("ID_STATUSBAR1"));
int __wxStatusBarWidths_1[1] = { -1 };
int __wxStatusBarStyles_1[1] = { wxSB_NORMAL };
StatusBar1->SetFieldsCount(1,__wxStatusBarWidths_1);
StatusBar1->SetStatusStyles(1,__wxStatusBarStyles_1);
SetStatusBar(StatusBar1);
FileDialog1 = new wxFileDialog(this, _("Mang Pilih datanipun"), wxEmptyString, wxEmptyString, _("*.gdb"), wxFD_DEFAULT_STYLE, wxDefaultPosition, wxDefaultSize, _T("wxFileDialog"));
FlexGridSizer1->Fit(this);
FlexGridSizer1->SetSizeHints(this);
Connect(ID_BUTTON3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&HWFrame::OnButton3Click);
Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&HWFrame::OnButton1Click);
Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&HWFrame::OnButton2Click);
Connect(idMenuQuit,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&HWFrame::OnQuit);
Connect(idMenuAbout,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&HWFrame::OnAbout);
Connect(wxID_ANY,wxEVT_CLOSE_WINDOW,(wxObjectEventFunction)&HWFrame::OnClose);
//*)
}
HWFrame::~HWFrame()
{
//(*Destroy(HWFrame)
//*)
}
void HWFrame::OnQuit(wxCommandEvent& event)
{
Close();
}
void HWFrame::OnAbout(wxCommandEvent& event)
{
//wxString msg = wxbuildinfo(long_f);
wxString msg = wxT("Ibnul Mubarak berkata: Kadang amalan kecil diperbesar oleh niat, & terkadang amalan besar diperkecil oleh niat (Riwayat Ibnu Abid Dunya)");
wxMessageBox(msg, _("Sinten Dalem ?"));
}
void HWFrame::OnClose(wxCloseEvent& event)
{
Close();
}
void HWFrame::OnButton2Click(wxCommandEvent& event)
{
}
void HWFrame::OnButton3Click(wxCommandEvent& event)
{
if ( FileDialog1->ShowModal() != wxID_OK ) return;
wxString FileName = FileDialog1->GetPath();
if ( FileName.IsEmpty() ) return;
TextCtrl2->ChangeValue(FileName);
TextCtrl1->ChangeValue(_("Localhost"));
}
void HWFrame::OnButton1Click(wxCommandEvent& event)
{
wxString dbServer = TextCtrl1->GetValue();
wxString dbFile = TextCtrl2->GetValue();
wxString uName = _("SYSDBA");
wxString pWord = _("MASTERKEY");
try {
IBPP::Database db = IBPP::DatabaseFactory(dbServer,dbFile,uName,pWord);
db->Connect();
wxMessageBox(_("Sampun mlampah kaliyan "+dbFile), _("Kasil!"));
}
catch (IBPP::Exception& e) {
wxString msg = _("Salah iki");
wxMessageBox(msg,_("Nopo?"));
}
}
Langganan:
Posting Komentar (Atom)
0 ɹɐʇuǝɯoʞ:
Posting Komentar