TaskList Manager - wxWidget GUI - WIP

BlitzMax Modules Forums/Brucey's Modules/TaskList Manager - wxWidget GUI - WIP

What it is:
A few years ago i needed a TaskList Manager to help me keep track of all the things i was doing at work. I have an MS Access Database and i built a VB6 frontend for it. I installed it at work and my whole department used it. Security policies changed and it had to be uninstalled. Recently the policies have changed again and i can reinstall it. I am now building it in BlitzMax using the wxWidgets for the frontend.
The gui and partial database structure is listed below.
On the top portion on the hard left is a list of SelectorTypes (currently Customers, Projects and Investigations). You click one. The list on the left of the middle portion shows the Companies/Projects/Investigations. Click one. Then there are 2 ListControls and a TextControl. The top one is for the Main Tasks. This includes the Team Member assigned the task, due dates, completed and cancelled flags. Click one. The second ListControl shows the Sub Tasks for the Main Task, again with the appropriate flags and fields. Click one. The last item (text control) displays the notes about that Sub Task.
On the bottom portion are filters in the form of radio buttons.
Lastly, back in the top portion there is a list control highlighting Main Tasks / Sub Tasks that are Overdue, based on the Choices on the right.

This is not a particularly complicated program but it added immense value to my working day and keeping track of every thing.

This is a learning exercise for me but i will be uploading the code, exe and database to the archives once completed. I suspect a lot of people would find this type of thing useful...

I will be asking for help along the way.
If anyone wants to install the Database and pictures (commented out currently but they work on my pc) then email me on glenn at c2d.co.nz

Cheers
Glenn

OK - here is my first problem and i think it is just of case of me making it too complicated.

DatabaseTypes.bmx

Type TDatabaseTables

	Global db:TDBConnection
	Field query:TDatabaseQuery
	Field record:TQueryRecord

	Method Init()
		If Not db Then
			db = LoadDatabase("ODBC", "C2D_TaskListManager_v4", Null, Null, Null, Null, "C2DTaskListManager.dsn")
		End If
	
		' Check that the DB connection has been made
		If Not db Then
			Notify("Unable to Open the Database C2D_TaskListManager_v4.mdb from the FILEDSN C2DTaskListManager.dsn")
			End
		End If
	
		' Check if the database has an error on opening
		If db.hasError() Then
			errorAndClose(db)
		End If
	End Method
	
	
	Function errorAndClose(db:TDBConnection)
		DebugLog(db.error().toString())
		db.close()
		End
	End Function

End Type

Type TSelectorType Extends TDatabaseTables
	
	Field SelectorTypeID:Int
	Field SelectorTypeName:String

	Global SelectorTypeList:TList

	Method Create()
		' Open the Database
		Self.init
		If db.isOpen() Then
			' Get the data from the table
			query = db.executeQuery("Select * from tblSelType")
			' Loop through each record and add the values to the TList
			For Local record:TQueryRecord = EachIn query
				Local SelectorType:TSelectorType = New TSelectorType
				SelectorType.SelectorTypeID = record.GetInt(0)
				SelectorType.SelectorTypeName = record.GetString(1)

				If Not SelectorTypeList Then SelectorTypeList = CreateList()
				ListAddLast(SelectorTypeList,SelectorType)
			Next
			' Close the Database
			db.close()
		EndIf
	EndMethod
	
End Type

Type TSelector Extends TDatabaseTables
	
	Field SelectorID:Int
	Field SelectorTypeID:Int
	Field Name:String
	Field Contact1:String
	Field Phone1:String
	Field Mobile1:String
	Field Email1:String
	Field Contact2:String
	Field Phone2:String
	Field Mobile2:String
	Field Email2:String
	
	Global SelectorList:TList

	Method Create()
		' Open the Database
		Self.init
		If db.isOpen() Then
			' Get the data from the table
			query = db.executeQuery("SELECT * FROM tblSelector")' WHERE SelTypeID = " + )
			' Loop through each record and add the values to the TList
			For Local record:TQueryRecord = EachIn query
				Local Selector:TSelector = New TSelector
				Selector.SelectorID = record.GetInt(0)
				Selector.SelectorTypeID = record.GetInt(1)
				Selector.Name = record.GetString(2)
				Selector.Contact1 = record.GetString(3)
				Selector.Phone1 = record.GetString(4)
				Selector.Mobile1 = record.GetString(5)
				Selector.Email1 = record.GetString(6)
				Selector.Contact2 = record.GetString(7)
				Selector.Phone2 = record.GetString(8)
				Selector.Mobile2 = record.GetString(9)
				Selector.Email2 = record.GetString(10)

				If Not SelectorList Then SelectorList = CreateList()
				ListAddLast(SelectorList,Selector)
			Next
			' Close the Database
			db.close()
		EndIf
	EndMethod
	
End Type


C2DTaskListManager_v0.04.bmx
'
' BlitzMax code generated with wxCodeGen v0.91 : 16 Feb 2008 10:16:57
' 
' 
' PLEASE DO "NOT" EDIT THIS FILE!
' 
SuperStrict

Framework wx.wxApp

Import wx.wxFrame
Import wx.wxListBox
Import wx.wxListCtrl
Import wx.wxPanel
Import wx.wxRadioBox
Import wx.wxStaticBitmap
Import wx.wxStatusBar
Import wx.wxTextCtrl
Import wx.wxWindow

Import BaH.DBODBC
Import brl.filesystem
Import brl.system

Include "DatabaseTypes.bmx"

New MyApp.run()


Type MyApp Extends wxApp

	Method OnInit:Int()

		wxInitAllImageHandlers()

		wxImage.AddHandler( New wxXPMHandler ) ' for Mac/Win32 (it is default on Linux)

		Local frame:MyFrameBase = MyFrameBase(New MyFrameBase.Create(, , "C2D TaskList Manager v0.02"))

		frame.show()
		
		SetTopWindow(frame)
	
		Return True
	
	End Method

End Type

Type MyFrameBase Extends wxFrame

	Field m_panel:wxPanel
	Field m_bitmapLeft:wxStaticBitmap
	Field m_listBoxSelectorType:wxListBox
	Field m_listCtrlDue:wxListCtrl
	Field m_radioBoxDue:wxRadioBox
	Field m_bitmapRight:wxStaticBitmap
	Field m_listBoxSelector:wxListBox
	Field m_listCtrlMainTask:wxListCtrl
	Field m_listCtrlSubTask:wxListCtrl
	Field m_textCtrlSubTaskNotes:wxTextCtrl
	Field m_radioBoxShowTasks:wxRadioBox
	Field m_radioBoxShowMainTasks:wxRadioBox
	Field m_statusBar:wxStatusBar

	Field iSelectorType:Int = 0

	Method Create:MyFrameBase(parent:wxWindow = Null,id:Int = wxID_ANY, title:String = "C2D Task List Manager", x:Int = -1, y:Int = -1, w:Int = 860, h:Int = 600, style:Int = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL)
		Return MyFrameBase(Super.Create(parent, id, title, x, y, w, h, style))
	End Method

	Method OnInit()
'		SetExtraStyle(wxFRAME_EX_CONTEXTHELP)
		SetMinSize(860,600)
		SetMaxSize(1024,768)

		Local bSizerFrame:wxBoxSizer
		bSizerFrame = New wxBoxSizer.Create(wxVERTICAL)
		bSizerFrame.SetMinSize(800,600)
		m_panel = New wxPanel.Create(Self, wxID_ANY,,,,, wxTAB_TRAVERSAL)

		Local bSizerPanel:wxBoxSizer
		bSizerPanel = New wxBoxSizer.Create(wxVERTICAL)

		Local bSizeTopPortion:wxBoxSizer
		bSizeTopPortion = New wxBoxSizer.Create(wxHORIZONTAL)
'		m_bitmapLeft = New wxStaticBitmap.Create(m_panel, wxID_ANY, wxBitmap.CreateFromFile("C:/C2D/BlitzBasic/C2DTaskListManager/Images/Dragon-Small.png", wxBITMAP_TYPE_ANY))
'		bSizeTopPortion.Add(m_bitmapLeft, 0, wxALL, 5)


Rem
Local tblSelectorType:TSelectorType = New TSelectorType
tblSelectorType.Create()	
Local counterSelectorTypeList:Int = CountList( tblSelectorType.SelectorTypeList:TList )
Local SelectorTypeListArray:String [counterSelectorTypeList]
For Local counter:Int = 0 To counterSelectorTypeList-1
	SelectorTypeListArray[counter] = tblSelectorType.SelectorTypeList.(1).ValueAtIndex(counter)
Next
End Rem
'		Local m_listBoxSelectorTypeChoices:String[] = SelectorTypeListArray[]
		Local m_listBoxSelectorTypeChoices:String[] = [ "Companies", "Investigations", "Projects" ]
		m_listBoxSelectorType = New wxListBox.Create(m_panel, wxID_ANY, m_listBoxSelectorTypeChoices,,,,, wxLB_HSCROLL|wxLB_SINGLE|wxLB_SORT)

		bSizeTopPortion.Add(m_listBoxSelectorType, 0, wxALL, 5)

		m_listCtrlDue = New wxListCtrl.Create(m_panel, wxID_ANY,,,,, wxLC_ICON)
		bSizeTopPortion.Add(m_listCtrlDue, 1, wxALL|wxEXPAND, 5)

		Local m_radioBoxDueChoices:String[] = [ "Over Due", "Due Today", "Due in Next 7 Days" ]
		m_radioBoxDue = New wxRadioBox.Create(m_panel, wxID_ANY, "Due Date Options",,,,, m_radioBoxDueChoices, 1, wxRA_SPECIFY_COLS)
		bSizeTopPortion.Add(m_radioBoxDue, 0, wxALL, 5)

'		m_bitmapRight = New wxStaticBitmap.Create(m_panel, wxID_ANY, wxBitmap.CreateFromFile("C:/C2D/BlitzBasic/C2DTaskListManager/Images/Dragon-Small.png", wxBITMAP_TYPE_ANY))
'		bSizeTopPortion.Add(m_bitmapRight, 0, wxALL, 5)

		bSizerPanel.AddSizer(bSizeTopPortion, 0, wxEXPAND, 5)


		Local bSizerMiddlePortion:wxBoxSizer
		bSizerMiddlePortion = New wxBoxSizer.Create(wxHORIZONTAL)
		m_listBoxSelector = New wxListBox.Create(m_panel, wxID_ANY, Null)

		bSizerMiddlePortion.Add(m_listBoxSelector, 1, wxALL|wxEXPAND, 5)


		Local bSizerTaskLists:wxBoxSizer
		bSizerTaskLists = New wxBoxSizer.Create(wxVERTICAL)
		m_listCtrlMainTask = New wxListCtrl.Create(m_panel, wxID_ANY,,,,, wxLC_ICON)
		bSizerTaskLists.Add(m_listCtrlMainTask, 2, wxALL|wxEXPAND, 5)

		m_listCtrlSubTask = New wxListCtrl.Create(m_panel, wxID_ANY,,,,, wxLC_ICON)
		bSizerTaskLists.Add(m_listCtrlSubTask, 3, wxALL|wxEXPAND, 5)

		m_textCtrlSubTaskNotes = New wxTextCtrl.Create(m_panel, wxID_ANY, "",,,,, wxTE_BESTWRAP|wxTE_LEFT|wxTE_MULTILINE|wxTE_NOHIDESEL)
		m_textCtrlSubTaskNotes.SetMaxLength(1000)
		bSizerTaskLists.Add(m_textCtrlSubTaskNotes, 1, wxALL|wxEXPAND, 5)

		bSizerMiddlePortion.AddSizer(bSizerTaskLists, 3, wxEXPAND, 5)

		bSizerPanel.AddSizer(bSizerMiddlePortion, 1, wxEXPAND, 5)


		Local bSizerBottomPortion:wxBoxSizer
		bSizerBottomPortion = New wxBoxSizer.Create(wxHORIZONTAL)
		Local m_radioBoxShowTasksChoices:String[] = [ "Show My Tasks", "Show My Depts Tasks", "Show ALL Tasks" ]
		m_radioBoxShowTasks = New wxRadioBox.Create(m_panel, wxID_ANY, "Show Team Member Main Tasks",,,,, m_radioBoxShowTasksChoices, 1, wxRA_SPECIFY_ROWS)
		bSizerBottomPortion.Add(m_radioBoxShowTasks, 0, wxALL, 5)

		Local m_radioBoxShowMainTasksChoices:String[] = [ "Active Tasks", "Completed Tasks", "Cancelled Tasks", "ALL Tasks" ]
		m_radioBoxShowMainTasks = New wxRadioBox.Create(m_panel, wxID_ANY, "Filter Main Tasks",,,,, m_radioBoxShowMainTasksChoices, 1, wxRA_SPECIFY_ROWS)
		bSizerBottomPortion.Add(m_radioBoxShowMainTasks, 0, wxALL, 5)

		bSizerPanel.AddSizer(bSizerBottomPortion, 0, wxEXPAND, 5)

		m_panel.SetSizer(bSizerPanel)
		m_panel.Layout()
		bSizerFrame.Add(m_panel, 1, wxALL|wxEXPAND, 5)

		m_statusBar = Self.CreateStatusBar(3, 0|wxST_SIZEGRIP, wxID_ANY)

		SetSizer(bSizerFrame)
		Layout()
		Center(wxBOTH)

		m_listBoxSelectorType.ConnectAny(wxEVT_COMMAND_LISTBOX_SELECTED, _SelectoTyperClicked, Null, Self)
		m_listBoxSelectorType.ConnectAny(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, _EditSelectorType, Null, Self)
		m_listCtrlDue.ConnectAny(wxEVT_COMMAND_LIST_COL_CLICK, _DueListSort, Null, Self)
		m_listCtrlDue.ConnectAny(wxEVT_COMMAND_LIST_DELETE_ITEM, _DueItemDeleted, Null, Self)
		m_listCtrlDue.ConnectAny(wxEVT_COMMAND_LIST_ITEM_SELECTED, _DueItemSelected, Null, Self)
		m_radioBoxDue.ConnectAny(wxEVT_COMMAND_RADIOBOX_SELECTED, _DueDateClicked, Null, Self)
		m_listBoxSelector.ConnectAny(wxEVT_COMMAND_LISTBOX_SELECTED, _SelectorClicked, Null, Self)
		m_listBoxSelector.ConnectAny(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, _EditSelector, Null, Self)
		m_listCtrlMainTask.ConnectAny(wxEVT_COMMAND_LIST_COL_CLICK, _MainTaskSort, Null, Self)
		m_listCtrlMainTask.ConnectAny(wxEVT_COMMAND_LIST_DELETE_ITEM, _MainTaskDeleted, Null, Self)
		m_listCtrlMainTask.ConnectAny(wxEVT_COMMAND_LIST_ITEM_SELECTED, _MainTaskSelected, Null, Self)
		m_listCtrlSubTask.ConnectAny(wxEVT_COMMAND_LIST_COL_CLICK, _SubTaskSort, Null, Self)
		m_listCtrlSubTask.ConnectAny(wxEVT_COMMAND_LIST_DELETE_ITEM, _SubTaskDeleted, Null, Self)
		m_listCtrlSubTask.ConnectAny(wxEVT_COMMAND_LIST_ITEM_SELECTED, _SubTaskHighlighted, Null, Self)
		m_radioBoxShowTasks.ConnectAny(wxEVT_COMMAND_RADIOBOX_SELECTED, _TMTasksClicked, Null, Self)
		m_radioBoxShowMainTasks.ConnectAny(wxEVT_COMMAND_RADIOBOX_SELECTED, _FilterMainTasksClicked, Null, Self)
	End Method

	Function _SelectoTyperClicked(event:wxEvent)
		MyFrameBase(event.sink).SelectoTyperClicked(wxCommandEvent(event))
	End Function

	Method SelectoTyperClicked(event:wxCommandEvent)
		DebugLog "Please override MyFrame.SelectoTyperClicked()"
		event.Skip()
	End Method

	Function _EditSelectorType(event:wxEvent)
		MyFrameBase(event.sink).EditSelectorType(wxCommandEvent(event))
	End Function

	Method EditSelectorType(event:wxCommandEvent)
		DebugLog "Please override MyFrame.EditSelectorType()"
		event.Skip()
	End Method

	Function _DueListSort(event:wxEvent)
		MyFrameBase(event.sink).DueListSort(wxListEvent(event))
	End Function

	Method DueListSort(event:wxListEvent)
		DebugLog "Please override MyFrame.DueListSort()"
		event.Skip()
	End Method

	Function _DueItemDeleted(event:wxEvent)
		MyFrameBase(event.sink).DueItemDeleted(wxListEvent(event))
	End Function

	Method DueItemDeleted(event:wxListEvent)
		DebugLog "Please override MyFrame.DueItemDeleted()"
		event.Skip()
	End Method

	Function _DueItemSelected(event:wxEvent)
		MyFrameBase(event.sink).DueItemSelected(wxListEvent(event))
	End Function

	Method DueItemSelected(event:wxListEvent)
		DebugLog "Please override MyFrame.DueItemSelected()"
		event.Skip()
	End Method

	Function _DueDateClicked(event:wxEvent)
		MyFrameBase(event.sink).DueDateClicked(wxCommandEvent(event))
	End Function

	Method DueDateClicked(event:wxCommandEvent)
		DebugLog "Please override MyFrame.DueDateClicked()"
		event.Skip()
	End Method

	Function _SelectorClicked(event:wxEvent)
		MyFrameBase(event.sink).SelectorClicked(wxCommandEvent(event))
	End Function

	Method SelectorClicked(event:wxCommandEvent)
		DebugLog "Please override MyFrame.SelectorClicked()"
		event.Skip()
	End Method

	Function _EditSelector(event:wxEvent)
		MyFrameBase(event.sink).EditSelector(wxCommandEvent(event))
	End Function

	Method EditSelector(event:wxCommandEvent)
		DebugLog "Please override MyFrame.EditSelector()"
		event.Skip()
	End Method

	Function _MainTaskSort(event:wxEvent)
		MyFrameBase(event.sink).MainTaskSort(wxListEvent(event))
	End Function

	Method MainTaskSort(event:wxListEvent)
		DebugLog "Please override MyFrame.MainTaskSort()"
		event.Skip()
	End Method

	Function _MainTaskDeleted(event:wxEvent)
		MyFrameBase(event.sink).MainTaskDeleted(wxListEvent(event))
	End Function

	Method MainTaskDeleted(event:wxListEvent)
		DebugLog "Please override MyFrame.MainTaskDeleted()"
		event.Skip()
	End Method

	Function _MainTaskSelected(event:wxEvent)
		MyFrameBase(event.sink).MainTaskSelected(wxListEvent(event))
	End Function

	Method MainTaskSelected(event:wxListEvent)
		DebugLog "Please override MyFrame.MainTaskSelected()"
		event.Skip()
	End Method

	Function _SubTaskSort(event:wxEvent)
		MyFrameBase(event.sink).SubTaskSort(wxListEvent(event))
	End Function

	Method SubTaskSort(event:wxListEvent)
		DebugLog "Please override MyFrame.SubTaskSort()"
		event.Skip()
	End Method

	Function _SubTaskDeleted(event:wxEvent)
		MyFrameBase(event.sink).SubTaskDeleted(wxListEvent(event))
	End Function

	Method SubTaskDeleted(event:wxListEvent)
		DebugLog "Please override MyFrame.SubTaskDeleted()"
		event.Skip()
	End Method

	Function _SubTaskHighlighted(event:wxEvent)
		MyFrameBase(event.sink).SubTaskHighlighted(wxListEvent(event))
	End Function

	Method SubTaskHighlighted(event:wxListEvent)
		DebugLog "Please override MyFrame.SubTaskHighlighted()"
		event.Skip()
	End Method

	Function _TMTasksClicked(event:wxEvent)
		MyFrameBase(event.sink).TMTasksClicked(wxCommandEvent(event))
	End Function

	Method TMTasksClicked(event:wxCommandEvent)
		DebugLog "Please override MyFrame.TMTasksClicked()"
		event.Skip()
	End Method

	Function _FilterMainTasksClicked(event:wxEvent)
		MyFrameBase(event.sink).FilterMainTasksClicked(wxCommandEvent(event))
	End Function

	Method FilterMainTasksClicked(event:wxCommandEvent)
		DebugLog "Please override MyFrame.FilterMainTasksClicked()"
		event.Skip()
	End Method

End Type



Currently i have the list for the top left being hard coded as Company/Project/Investigation but these values need to come from the database.
I am reading the values in from the table (TSelectorType) and putting them in a list. Why - because all the example i have seen do this.
What i need to do now is get the second field (SelectorTypeName) ready to be used by the ListBox in the main program.
So i need to get the values into an array for the line:
Local m_listBoxSelectorTypeChoices:String[] = [ "Companies", "Investigations", "Projects" ]

I am obviously doing this wrong. I also think i am trying to do too many steps to achieve this.
Maybe i don't need to use the table types to get the values. I was using this format because it made the readability easy plus i could add methods for Add/Edit/Delete/Save.

Once i have this first list being populated by the table data i can finish the other listboxes and listcontrols with no difficulty.

I would appreciate some help.

Cheers
Glenn

This works but it doesn't look elegant.
Any suggestions?
(see the code in between the ***********'s)

'
' BlitzMax code generated with wxCodeGen v0.91 : 16 Feb 2008 10:16:57
' 
' 
' PLEASE DO "NOT" EDIT THIS FILE!
' 
SuperStrict

Framework wx.wxApp

Import wx.wxFrame
Import wx.wxListBox
Import wx.wxListCtrl
Import wx.wxPanel
Import wx.wxRadioBox
Import wx.wxStaticBitmap
Import wx.wxStatusBar
Import wx.wxTextCtrl
Import wx.wxWindow

Import BaH.DBODBC
Import brl.filesystem
Import brl.system

Include "DatabaseTypes.bmx"

New MyApp.run()


Type MyApp Extends wxApp

	Method OnInit:Int()

		wxInitAllImageHandlers()

		wxImage.AddHandler( New wxXPMHandler ) ' for Mac/Win32 (it is default on Linux)

		Local frame:MyFrameBase = MyFrameBase(New MyFrameBase.Create(, , "C2D TaskList Manager v0.02"))

		frame.show()
		
		SetTopWindow(frame)
	
		Return True
	
	End Method

End Type

Type MyFrameBase Extends wxFrame

	Field m_panel:wxPanel
	Field m_bitmapLeft:wxStaticBitmap
	Field m_listBoxSelectorType:wxListBox
	Field m_listCtrlDue:wxListCtrl
	Field m_radioBoxDue:wxRadioBox
	Field m_bitmapRight:wxStaticBitmap
	Field m_listBoxSelector:wxListBox
	Field m_listCtrlMainTask:wxListCtrl
	Field m_listCtrlSubTask:wxListCtrl
	Field m_textCtrlSubTaskNotes:wxTextCtrl
	Field m_radioBoxShowTasks:wxRadioBox
	Field m_radioBoxShowMainTasks:wxRadioBox
	Field m_statusBar:wxStatusBar

	Field iSelectorType:Int = 0

	Method Create:MyFrameBase(parent:wxWindow = Null,id:Int = wxID_ANY, title:String = "C2D Task List Manager", x:Int = -1, y:Int = -1, w:Int = 860, h:Int = 600, style:Int = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL)
		Return MyFrameBase(Super.Create(parent, id, title, x, y, w, h, style))
	End Method

	Method OnInit()
'		SetExtraStyle(wxFRAME_EX_CONTEXTHELP)
		SetMinSize(860,600)
		SetMaxSize(1024,768)

		Local bSizerFrame:wxBoxSizer
		bSizerFrame = New wxBoxSizer.Create(wxVERTICAL)
		bSizerFrame.SetMinSize(800,600)
		m_panel = New wxPanel.Create(Self, wxID_ANY,,,,, wxTAB_TRAVERSAL)

		Local bSizerPanel:wxBoxSizer
		bSizerPanel = New wxBoxSizer.Create(wxVERTICAL)

		Local bSizeTopPortion:wxBoxSizer
		bSizeTopPortion = New wxBoxSizer.Create(wxHORIZONTAL)
'		m_bitmapLeft = New wxStaticBitmap.Create(m_panel, wxID_ANY, wxBitmap.CreateFromFile("C:/C2D/BlitzBasic/C2DTaskListManager/Images/Dragon-Small.png", wxBITMAP_TYPE_ANY))
'		bSizeTopPortion.Add(m_bitmapLeft, 0, wxALL, 5)


' *****************************************************
Local tblSelectorType:TSelectorType = New TSelectorType
tblSelectorType.Create()

Local s:String[tblSelectorType.SelectorTypeList.count()]

Local i:Int = 0
For Local all:TSelectorType = EachIn tblSelectorType.SelectorTypeList
	DebugLog all.SelectorTypeID
	DebugLog all.SelectorTypeName
	s[i] = all.SelectorTypeName
	DebugLog "i = " + i + " : S[" + i + "] = "+ s[i]
	i:+1
Next
For Local ss:String = EachIn s
	DebugLog "S = : " + ss
Next

		Local m_listBoxSelectorTypeChoices:String[] = s
'******************************************************
'		Local m_listBoxSelectorTypeChoices:String[] = [ "Companies", "Investigations", "Projects" ]
		m_listBoxSelectorType = New wxListBox.Create(m_panel, wxID_ANY, m_listBoxSelectorTypeChoices,,,,, wxLB_HSCROLL|wxLB_SINGLE|wxLB_SORT)

		bSizeTopPortion.Add(m_listBoxSelectorType, 0, wxALL, 5)

		m_listCtrlDue = New wxListCtrl.Create(m_panel, wxID_ANY,,,,, wxLC_ICON)
		bSizeTopPortion.Add(m_listCtrlDue, 1, wxALL|wxEXPAND, 5)

		Local m_radioBoxDueChoices:String[] = [ "Over Due", "Due Today", "Due in Next 7 Days" ]
		m_radioBoxDue = New wxRadioBox.Create(m_panel, wxID_ANY, "Due Date Options",,,,, m_radioBoxDueChoices, 1, wxRA_SPECIFY_COLS)
		bSizeTopPortion.Add(m_radioBoxDue, 0, wxALL, 5)

'		m_bitmapRight = New wxStaticBitmap.Create(m_panel, wxID_ANY, wxBitmap.CreateFromFile("C:/C2D/BlitzBasic/C2DTaskListManager/Images/Dragon-Small.png", wxBITMAP_TYPE_ANY))
'		bSizeTopPortion.Add(m_bitmapRight, 0, wxALL, 5)

		bSizerPanel.AddSizer(bSizeTopPortion, 0, wxEXPAND, 5)


		Local bSizerMiddlePortion:wxBoxSizer
		bSizerMiddlePortion = New wxBoxSizer.Create(wxHORIZONTAL)
		m_listBoxSelector = New wxListBox.Create(m_panel, wxID_ANY, Null)

		bSizerMiddlePortion.Add(m_listBoxSelector, 1, wxALL|wxEXPAND, 5)


		Local bSizerTaskLists:wxBoxSizer
		bSizerTaskLists = New wxBoxSizer.Create(wxVERTICAL)
		m_listCtrlMainTask = New wxListCtrl.Create(m_panel, wxID_ANY,,,,, wxLC_ICON)
		bSizerTaskLists.Add(m_listCtrlMainTask, 2, wxALL|wxEXPAND, 5)

		m_listCtrlSubTask = New wxListCtrl.Create(m_panel, wxID_ANY,,,,, wxLC_ICON)
		bSizerTaskLists.Add(m_listCtrlSubTask, 3, wxALL|wxEXPAND, 5)

		m_textCtrlSubTaskNotes = New wxTextCtrl.Create(m_panel, wxID_ANY, "",,,,, wxTE_BESTWRAP|wxTE_LEFT|wxTE_MULTILINE|wxTE_NOHIDESEL)
		m_textCtrlSubTaskNotes.SetMaxLength(1000)
		bSizerTaskLists.Add(m_textCtrlSubTaskNotes, 1, wxALL|wxEXPAND, 5)

		bSizerMiddlePortion.AddSizer(bSizerTaskLists, 3, wxEXPAND, 5)

		bSizerPanel.AddSizer(bSizerMiddlePortion, 1, wxEXPAND, 5)


		Local bSizerBottomPortion:wxBoxSizer
		bSizerBottomPortion = New wxBoxSizer.Create(wxHORIZONTAL)
		Local m_radioBoxShowTasksChoices:String[] = [ "Show My Tasks", "Show My Depts Tasks", "Show ALL Tasks" ]
		m_radioBoxShowTasks = New wxRadioBox.Create(m_panel, wxID_ANY, "Show Team Member Main Tasks",,,,, m_radioBoxShowTasksChoices, 1, wxRA_SPECIFY_ROWS)
		bSizerBottomPortion.Add(m_radioBoxShowTasks, 0, wxALL, 5)

		Local m_radioBoxShowMainTasksChoices:String[] = [ "Active Tasks", "Completed Tasks", "Cancelled Tasks", "ALL Tasks" ]
		m_radioBoxShowMainTasks = New wxRadioBox.Create(m_panel, wxID_ANY, "Filter Main Tasks",,,,, m_radioBoxShowMainTasksChoices, 1, wxRA_SPECIFY_ROWS)
		bSizerBottomPortion.Add(m_radioBoxShowMainTasks, 0, wxALL, 5)

		bSizerPanel.AddSizer(bSizerBottomPortion, 0, wxEXPAND, 5)

		m_panel.SetSizer(bSizerPanel)
		m_panel.Layout()
		bSizerFrame.Add(m_panel, 1, wxALL|wxEXPAND, 5)

		m_statusBar = Self.CreateStatusBar(3, 0|wxST_SIZEGRIP, wxID_ANY)

		SetSizer(bSizerFrame)
		Layout()
		Center(wxBOTH)

		m_listBoxSelectorType.ConnectAny(wxEVT_COMMAND_LISTBOX_SELECTED, _SelectoTyperClicked, Null, Self)
		m_listBoxSelectorType.ConnectAny(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, _EditSelectorType, Null, Self)
		m_listCtrlDue.ConnectAny(wxEVT_COMMAND_LIST_COL_CLICK, _DueListSort, Null, Self)
		m_listCtrlDue.ConnectAny(wxEVT_COMMAND_LIST_DELETE_ITEM, _DueItemDeleted, Null, Self)
		m_listCtrlDue.ConnectAny(wxEVT_COMMAND_LIST_ITEM_SELECTED, _DueItemSelected, Null, Self)
		m_radioBoxDue.ConnectAny(wxEVT_COMMAND_RADIOBOX_SELECTED, _DueDateClicked, Null, Self)
		m_listBoxSelector.ConnectAny(wxEVT_COMMAND_LISTBOX_SELECTED, _SelectorClicked, Null, Self)
		m_listBoxSelector.ConnectAny(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, _EditSelector, Null, Self)
		m_listCtrlMainTask.ConnectAny(wxEVT_COMMAND_LIST_COL_CLICK, _MainTaskSort, Null, Self)
		m_listCtrlMainTask.ConnectAny(wxEVT_COMMAND_LIST_DELETE_ITEM, _MainTaskDeleted, Null, Self)
		m_listCtrlMainTask.ConnectAny(wxEVT_COMMAND_LIST_ITEM_SELECTED, _MainTaskSelected, Null, Self)
		m_listCtrlSubTask.ConnectAny(wxEVT_COMMAND_LIST_COL_CLICK, _SubTaskSort, Null, Self)
		m_listCtrlSubTask.ConnectAny(wxEVT_COMMAND_LIST_DELETE_ITEM, _SubTaskDeleted, Null, Self)
		m_listCtrlSubTask.ConnectAny(wxEVT_COMMAND_LIST_ITEM_SELECTED, _SubTaskHighlighted, Null, Self)
		m_radioBoxShowTasks.ConnectAny(wxEVT_COMMAND_RADIOBOX_SELECTED, _TMTasksClicked, Null, Self)
		m_radioBoxShowMainTasks.ConnectAny(wxEVT_COMMAND_RADIOBOX_SELECTED, _FilterMainTasksClicked, Null, Self)
	End Method

	Function _SelectoTyperClicked(event:wxEvent)
		MyFrameBase(event.sink).SelectoTyperClicked(wxCommandEvent(event))
	End Function

	Method SelectoTyperClicked(event:wxCommandEvent)
		DebugLog "Please override MyFrame.SelectoTyperClicked()"
		event.Skip()
	End Method

	Function _EditSelectorType(event:wxEvent)
		MyFrameBase(event.sink).EditSelectorType(wxCommandEvent(event))
	End Function

	Method EditSelectorType(event:wxCommandEvent)
		DebugLog "Please override MyFrame.EditSelectorType()"
		event.Skip()
	End Method

	Function _DueListSort(event:wxEvent)
		MyFrameBase(event.sink).DueListSort(wxListEvent(event))
	End Function

	Method DueListSort(event:wxListEvent)
		DebugLog "Please override MyFrame.DueListSort()"
		event.Skip()
	End Method

	Function _DueItemDeleted(event:wxEvent)
		MyFrameBase(event.sink).DueItemDeleted(wxListEvent(event))
	End Function

	Method DueItemDeleted(event:wxListEvent)
		DebugLog "Please override MyFrame.DueItemDeleted()"
		event.Skip()
	End Method

	Function _DueItemSelected(event:wxEvent)
		MyFrameBase(event.sink).DueItemSelected(wxListEvent(event))
	End Function

	Method DueItemSelected(event:wxListEvent)
		DebugLog "Please override MyFrame.DueItemSelected()"
		event.Skip()
	End Method

	Function _DueDateClicked(event:wxEvent)
		MyFrameBase(event.sink).DueDateClicked(wxCommandEvent(event))
	End Function

	Method DueDateClicked(event:wxCommandEvent)
		DebugLog "Please override MyFrame.DueDateClicked()"
		event.Skip()
	End Method

	Function _SelectorClicked(event:wxEvent)
		MyFrameBase(event.sink).SelectorClicked(wxCommandEvent(event))
	End Function

	Method SelectorClicked(event:wxCommandEvent)
		DebugLog "Please override MyFrame.SelectorClicked()"
		event.Skip()
	End Method

	Function _EditSelector(event:wxEvent)
		MyFrameBase(event.sink).EditSelector(wxCommandEvent(event))
	End Function

	Method EditSelector(event:wxCommandEvent)
		DebugLog "Please override MyFrame.EditSelector()"
		event.Skip()
	End Method

	Function _MainTaskSort(event:wxEvent)
		MyFrameBase(event.sink).MainTaskSort(wxListEvent(event))
	End Function

	Method MainTaskSort(event:wxListEvent)
		DebugLog "Please override MyFrame.MainTaskSort()"
		event.Skip()
	End Method

	Function _MainTaskDeleted(event:wxEvent)
		MyFrameBase(event.sink).MainTaskDeleted(wxListEvent(event))
	End Function

	Method MainTaskDeleted(event:wxListEvent)
		DebugLog "Please override MyFrame.MainTaskDeleted()"
		event.Skip()
	End Method

	Function _MainTaskSelected(event:wxEvent)
		MyFrameBase(event.sink).MainTaskSelected(wxListEvent(event))
	End Function

	Method MainTaskSelected(event:wxListEvent)
		DebugLog "Please override MyFrame.MainTaskSelected()"
		event.Skip()
	End Method

	Function _SubTaskSort(event:wxEvent)
		MyFrameBase(event.sink).SubTaskSort(wxListEvent(event))
	End Function

	Method SubTaskSort(event:wxListEvent)
		DebugLog "Please override MyFrame.SubTaskSort()"
		event.Skip()
	End Method

	Function _SubTaskDeleted(event:wxEvent)
		MyFrameBase(event.sink).SubTaskDeleted(wxListEvent(event))
	End Function

	Method SubTaskDeleted(event:wxListEvent)
		DebugLog "Please override MyFrame.SubTaskDeleted()"
		event.Skip()
	End Method

	Function _SubTaskHighlighted(event:wxEvent)
		MyFrameBase(event.sink).SubTaskHighlighted(wxListEvent(event))
	End Function

	Method SubTaskHighlighted(event:wxListEvent)
		DebugLog "Please override MyFrame.SubTaskHighlighted()"
		event.Skip()
	End Method

	Function _TMTasksClicked(event:wxEvent)
		MyFrameBase(event.sink).TMTasksClicked(wxCommandEvent(event))
	End Function

	Method TMTasksClicked(event:wxCommandEvent)
		DebugLog "Please override MyFrame.TMTasksClicked()"
		event.Skip()
	End Method

	Function _FilterMainTasksClicked(event:wxEvent)
		MyFrameBase(event.sink).FilterMainTasksClicked(wxCommandEvent(event))
	End Function

	Method FilterMainTasksClicked(event:wxCommandEvent)
		DebugLog "Please override MyFrame.FilterMainTasksClicked()"
		event.Skip()
	End Method

End Type



How about a screenshot? :-)

Looking at the code immediately above my only real thought is that I'd be safety checking that your List is OK and count() <> 0. Otherwise I don't see any real drama?

An alternate route would be to create the wxListBox first with Null items and then use wxListBox.Insert() within your Eachin List loop and bypass the string array entirely.

Unless of course I entirely misunderstood you!

Without a DB schema, it's going to be hard to follow your example very well - and difficult to run it on Access from my Mac :-p
(Once we have a schema we could, in theory, have it running in any old database - which opens up your options somewhat - although I realise you'll only be running it on Win32).

Looking at DatabaseTypes.bmx, are you planning on loading all the data in at once, or will you be retrieving only the bits you need when you need them?
Caching is fine for "static" data (that which doesn't change very often), but for more volatile information there's no harm in only having it in memory when you need it. As you probably already know ;-)

SelectorTypeID : Is this going to be used to help you find things listed under a specific category? (eg. Companies)

Where you would have another table with SelectorTypeID as a foreign key...

So...

User clicks on "Companies" in the list box, you then select from the db all the matching data for that ID.. and put it into your other list. ?
SELECT * FROM otherTable WHERE selectortypeid = ?

(although you would replace "*" with the list of columns, for readability :-p )


I think David's onto the right idea about initially populating the listbox. Add to the listbox after it's been created. It also means you should never need to edit the generated UI file :-)

MVC... Keep the data model separate from the User Interface.

You also probably want some way to tie a specific row in your listbox to a Type instance.

With Insert() and Append(), there's an optional clientData parameter with which you can attach your Type instance. (and I even believe it is referenced in there too, so you might not need to keep your own list. ie. it shouldn't be GC'd if you don't store it in your own list).

Then, when you select something from the listbox, you can get more details out of the clientData field, which you can then use to do whatever..

Future version of wxWidgets are going to have a proper MVC style data/view model which should make working like this much easier.



Prev vb6 version



David, I have emailed a screenshot to you as i don't have anywhere to upload one to.
I will definitely be putting bounds checking in but i just needed to get over that "get data and display" hurdle.
I like the idea of wxListBox.Insert(). My first thought is to put this in the DatabaseTypes.bmx but that may not work (i will try later tonight).
I only get the data as i need it. So populate the lists on startup and update relevant lists on each click where relevant, using the "SELECT * FROM otherTable WHERE selectortypeid = ?" format. I haven't put those queries in yet but i planned to give them their own types. That should make Add/Edit and Delete easier too.

Brucey - i had seen that clientData option in the docs but hadn't figured out how to use it. The way you describe it makes it sound like what i want. Some reading and test apps to go...:)

In my Database types i like the idea of having the list for each type (table or query) so that i have the foreign key available to help build up the queries for Main Task and Sub Task. Other than that i probably don't need it.

I will open Access and see about dropping out the schema, although i haven't done it before. Can either of you just drop my database into a folder and use the FileDSN to make the code us it? i don't think you need Access to be installed, just the odbc driver?

I really appreciate your help.

oh and i better check that MVC link too.

Cheers
Glenn

i don't think you need Access to be installed

well, you need Windows... which precludes much in the way of testing outside of the office for me.
However, if you want, you can mail me an mdb (to work) and I can have a go at creating a set of Table definitions for SQLite. (table creates are generally DB specific, but if you make your SQLs ANSI friendly they should work on any database).

Brucey - Emailed.

The vb6 app had lots of buttons on the right hand side but i have removed them for the blitz version. A toolbar will be much better ie Add/Edit/Delete using the highlighted item on the active control.
I will add reports in later too using the pdf functionality in wxwidgets.

Cheers
Glenn

Thanks.

I've still to add toolbar support into wxCodeGen. I'll try to make some time for that this evening.

This small snippet is clearing frame.m_listBoxSelector DATA but doesn't seem to clear the actual listbox on the SCREEN.
I have looked under wxControlWithItems but i can't find a "refresh" command?

any ideas? Been sitting here reading and playing for over an hour...and getting nowwhere...

Cheers
Glenn


Function PopulateSelector(frame:MyFrame,searchString:String)

	' Get the data for the Selector ListBox
	Local tblSelector:TSelector = New TSelector
	tblSelector.Create(frame, searchString)
	' Now fill the ListBox
'DebugStop
	frame.m_listBoxSelector.clear()
	For Local ListContents:TSelector = EachIn tblSelector.SelectorList
		frame.m_listBoxSelector.append(ListContents.SelectorName)
	Next

End Function


How's about this small example?
SuperStrict

Framework wx.wxApp
Import wx.wxFrame
Import wx.wxListBox
Import wx.wxPanel
Import wx.wxButton

New MyApp.run()


Type MyApp Extends wxApp

	Field frame:wxFrame

	Method OnInit:Int()
	
		frame = New MyFrame.Create(,,"All Clear!")
		frame.Center()
		frame.show()

		Return True
	
	End Method


End Type

Type MyFrame Extends wxFrame

	Field lb:wxListBox
	
	Method OnInit()
	
		Local panel:wxPanel = New wxPanel.Create(Self, wxID_ANY)
		
		Local list:String[] = ["one", "two", "three", "four"]

		lb = New wxListBox.Create(panel, WXID_ANY, list, 10, 0)
		
		Local button:wxButton = New wxButton.Create(panel, 100, "clear", 10, 100)

		Connect(100, wxEVT_COMMAND_BUTTON_CLICKED, OnClear)

	End Method


	Function OnClear(event:wxEvent)
		MyFrame(event.parent).lb.Clear()
	End Function
	
End Type