Commit 3b926cdb authored by nikolaus's avatar nikolaus
Browse files

Initial commit

parents
.svn
*~
.*.sw?
*.smw
*.sml
*.smp
*.sbm
.svn
*~
.*.sw?
*.smw
*.sml
*.smp
*.sbm
*.log
This diff is collapsed.
ignore this file
[NODE_1]
COMPONENT3=slib
MAKE_FILE=F
COMPONENT2=sbme
COMPONENT1=ppcs
PRJ_TYPE=NOR
SMA_PREFERENCE=T
COMPONENT0=lxml
SMP_FILE=bin\drilldownexample.smp
FATHER_SECTION=NODE_0
SML_FILE1=C:\SIMPOL\lib\drilldown.sml
SML_FILE0=C:\SIMPOL\lib\appframework.sml
COMPONENT6=wxwn
COMPONENT5=utos
FILE_FOLDER0=C:\SIMPOL\include\
COMPONENT4=sock
[NODE_2]
MODULE=drilldownexample\
SMP_FILE=drilldownexample\drilldownexample.smp
FATHER_SECTION=NODE_1
MAIN_FILE=drilldownexample\drilldownexample.sma
// dirlldownexample.sma - SIMPOL Drilldown Example
//
// Created on: August 8 2019
// Created by: Nikolaus-Maxim Zolnhofer
// Copyright © 2014-2020 Superbase Software Limited, all rights reserved
//
// Description
// ===========
// This project implements a very basic order system it will only make use of
// the CUSTOMER database provided with SIMPOL.
// This projects purpose is to display a record from this file and then allow
// the selection of a different record using the drilldown function
//
// This program will be reusing the CUSTOMER database from the SIMPOL Business
// example, we will only use a local database.
//
// We will also not implement a menu, statusbar or toolbar for this basic example
///////////////////////////////////////////////////////////////////////////////
constant sAPPTITLE "Customer Details"
constant sAPPMSGTITLE "SIMPOL Drilldown Error"
constant sEXITAPPQUESTION "Close SIMPOL Drilldown?"
// Included source files
include "errors.sma"
//////////////////////////////////////////////////////////////////////////
// main()
//
// Parameters
// ==========
//
// Description
// ===========
// This function runs the program. It initializes the menu bar, tool bar,
// status bar, creates the application object, which in turn creates the
// initial window and opens the data sources and tables, then opens the form
// and shows it in the window. At that point it waits for the user.
//////////////////////////////////////////////////////////////////////////
function main()
drillapp app
appwindow appw
string formfilename, cd
integer e
point lt, br
cd = getcurrentdirectory()
formfilename = cd + getdirectorysepchar() + 'drilldownmain.sxf'
e = 0
app =@ drillapp.new()
if app !@= .nul
appw =@ app.windows.getfirst()
e = 0
if not fileexists(formfilename)
wxmessagedialog(appw.w, "Form file 'drilldownmain.sxf' not found", sAPPMSGTITLE,icon="error")
else
appw.openformdirect(formfilename,sAPPMSGTITLE)
if appw.form !@= .nul
prepmainform(appw)
appw.resizewindowtoform()
lt =@ point.new(0,0)
br =@ point.new(0,0)
getcenteredwindowrect(appw.w.outerwidth, appw.w.outerheight, lt, br, error=e)
if e == 0
appw.w.setposition(lt.x, lt.y)
end if
appw.setcurrentpath(cd)
appw.w.setstate(visible=.true)
!beginthread(deferprocessing, startkludge, appw, appw.form)
app.run()
end if
end if
app.exit()
end if
end function
//////////////////////////////////////////////////////////////////////////
// startkludge()
//
// Parameters
// ==========
// appwindow appw
// dataform1 form
// boolean dodefer
//
// Description
// ===========
// This function is a workaround for a problem that is caused by the fact
// wxWidgets always puts focus on controls even if we have expressly
// removed it. Until that has been dealt with, this function uses a delay
// of 1 second to reselect the current record after the window has been
// displayed, ignoring any information implying the record is dirty and
// needs to be saved. This inhibits the otherwise annoying behavior that
// after starting the program, the first record shown is always marked as
// having been changed, causing the system to ask if it should be saved.
//////////////////////////////////////////////////////////////////////////
//
function startkludge(appwindow appw, dataform1 form, boolean dodefer)
selectrecord(appw, "selectcurrent", silent=.true)
end function
//////////////////////////////////////////////////////////////////////////
////////////// Functions called from the menu and tool bar ///////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// exit()
//
// Parameters
// ==========
// type(application) me
// wxwindow w
//
// Description
// ===========
// This is the event handler for the onexitrequest event of the
// addressbookapplication object (it is actually an event of the original
// application object). It is called if the application.run() routine
// determines that there are no visible windows remaining
//////////////////////////////////////////////////////////////////////////
function exit(type(application) me, wxwindow w)
string response
appwindow appw
boolean closeapp
response = ""
wxmessagedialog(w, sEXITAPPQUESTION, sAPPMSGTITLE, \
style="okcancel", icon="question", result=response)
if response != "ok"
closeapp = .false
else
closeapp = .true
appw =@ getappwindowfromwindow(w)
if appw !@= .nul
closeapp = checkneedsave(appw)
end if
if closeapp
me.running = .false
wxbreak()
end if
end if
end function closeapp
//////////////////////////////////////////////////////////////////////////
////////////////////// Functions for the main form ///////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// prepmainform()
//
// Parameters
// ==========
// appwindow appw
//
// Description
// ===========
// This function provides a place for initialization of the main form.
// It should be called after opening the form and before showing the
// form to the user.
//////////////////////////////////////////////////////////////////////////
function prepmainform(appwindow appw)
dataform1 form
form =@ appw.form
form!bOK.onclick.reference =@ appw
form!bFind.onclick.reference =@ appw
end function
//////////////////////////////////////////////////////////////////////////
// prepmainform()
//
// Parameters
// ==========
// appwindow appw
//
// Description
// ===========
// This function provides a place for initialization of the main form.
// It should be called after opening the form and before showing the
// form to the user.
//////////////////////////////////////////////////////////////////////////
function findcustomer(dataform1button me, appwindow appw)
type(db1record) r
type(db1index) idx
drillapp app
tdisplayformats dispfmt
array dispflds, colwidths
integer e
app =@ appw.app
dispfmt =@ app.displayformats
idx =@ app.customer!FamilyName.index;//Needs to be a string for indexing
dispflds =@ array.new()
dispflds[1] =@ app.customer!CustSerNo
dispflds[2] =@ app.customer!Honorific
dispflds[3] =@ app.customer!FirstNames
dispflds[4] =@ app.customer!FamilyName
dispflds[5] =@ app.customer!PostCode
colwidths =@ array.new()
colwidths[1] = 65
colwidths[2] = 30
colwidths[3] = 150
colwidths[4] = 120
colwidths[5] = 70
e = 0
r =@ drilldown(me.form.container,540,485, idx,maxentries=20,minactivationchars=1,"Select a customer","Customer list (by Surname)", \
dispflds = dispflds, colwidths = colwidths, defboolean = dispfmt.defboolean, \
definteger=dispfmt.definteger, defnumber=dispfmt.defnumber, defdate=dispfmt.defdate, \
deftime=dispfmt.deftime, defdatetime=dispfmt.defdatetime, caseinsensitive=.true, \
datelocale=app.SBLlocale.datelocale, numlocale=app.SBLlocale.numlocale, error=e)
if r !@= .nul
dataform1 f
type(db1index) searchidx
searchidx =@ app.customer!CustSerNo.index
f =@ appw.form
f.selectkey(r!CustSerNo,searchidx,error=e)
end if
end function
//////////////////////////////////////////////////////////////////////////
// ok_oc()
//
// Parameters
// ==========
// appwindow appw
//
// Description
// ===========
// This is the event handler for the onclick event of the OK button. This
// will simply perform the exit procedure for the program
//////////////////////////////////////////////////////////////////////////
function ok_oc(dataform1button me, appwindow appw)
exit(appw.app,appw.w)
end function
//////////////////////////////////////////////////////////////////////////
////////////////// End of functions for the main form ////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
/////////////////////////////// Types ////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// type drillapp (application)
//
// Description
// ===========
// The drillapp type simply adds a type(db1table) property
// for the address table to the normal facilities provided by the
// application type.
//
// The application type is meant to provide a placeholder for the items
// that need to have a quasi-global scope. This includes information about
// the display, the default font, the system colors, locales, display
// formats, etc. It also holds a dring of appwindow objects and a dring of
// datasourceinfo objects. Each data source opened should be done through
// the application object's methods, so that the data source can be held
// in the ring and used for opening tables in more than one window. This
// is essential for sbme1-based tables, since the file is opened
// exclusively the first time it is opened.
//////////////////////////////////////////////////////////////////////////
type drillapp (application)
reference
application __app resolve
type(db1table) customer
end type
function drillapp.new(drillapp me)
appwindow appw
datasourceinfo src
type(db1table) t
integer e
boolean ok
string file
ok = .false
e = 0
me.__app =@ application.new(appiconfile="", iconimagetype="", inifilename="", \
apptitle =sAPPTITLE)
me.__app.__ =@ me
me.onexitrequest.function =@ exit
me.running = .true
appw =@ appwindow.new(me,visible=.false,mb=.nul,tb=.nul,sb=.nul,border="simple",maxbutton=.false)
if appw =@= .nul
wxmessagedialog(appw.w, "Error creating window", sAPPMSGTITLE,icon="error")
else
file = getpublicdatadir() + "\SIMPOL Business\customer.sbm"; //this is where the database file will be found
src =@ me.opendatasource("sbme1", file, appw, error=e)
if src =@= .nul
wxmessagedialog(appw.w,"Error opening customer.sbm file",sAPPMSGTITLE,icon="error")
else
t =@ appw.opendatatable(src,"CUSTOMER",error=e)
if t =@= .nul
wxmessagedialog(appw.w,"Error opening the 'Customer' table", sAPPMSGTITLE,icon="error")
else
me.customer =@ t
ok =.true
end if
end if
end if
if not ok
me =@ .nul
end if
end function me
//////////////////////////////////////////////////////////////////////////
///////////////////////////// End of Types ///////////////////////////////
//////////////////////////////////////////////////////////////////////////
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment