I have a few multi select lists in play. I implement them in either of two
ways, depending on what I am displaying: 1) normal list, or 2) multi column
table. In each case I handle the select events so that the normal table or
list selection routines do not get called. To show selection, I draw
inverted or bold (depending on the situation).
Most of the special coding is in my "draw one thing in list" routine, which
is also a custom table item draw routine. The key point in doing this
(IMHO) is that I have an array of structures stored in a handle. Each item
in the list/table has a corresponding member in the array. This structure
allows me to keep track of things like record number in a database, state of
the item (for selection . . . this can obviously be many states, but I have
only ever used 4), data values (for table display), etc. I have routines to
add, remove, and sort this array which is tracked (contained) in a
MemHandle.
Here is sample drawing code simplified, but for a normal list:
static void DrawOnePersonInList(UInt16 itemNumber, RectanglePtr rec, Char*
text)
{
MemHandle h = NULL;
PersonRec *s = NULL;
Char Name[50];
Char* FirstName;
Char* LastName;
CTDataStruct * ds = GetData();
UInt16 NumPerson = ds->aPerson.count;
Int16 State = 0;
Int16 *iState;
fontID font;
// Use itemNumber as the index in student array
StrCopy(Name, "\0");
if(ds->aStudent.count==0)
StrCat(Name,"No People");
else
{
// here my state is just an array of Int16 for simplicity
iState = (Int16 *)MemHandleLock(hState);
State = iState[itemNumber];
MemHandleUnlock(hState);
if(itemNumber < NumPerson)
{
Int16 * iArray = (Int16 *)MemHandleLock(ds->aPerson.hArray);
// record
numbers
iArray+=itemNumber;
h = GetPersonInfo(gPersonDB, *iArray);
MemHandleUnlock(ds->aPerson.hArray);
}
if(h)
{
s = (PersonRec *)MemHandleLock(h);
StrCat(Name, s->Name);
MemHandleUnlock(h);
}
}
if(CheckState(State,LIST_SELECTED)) // Bit Check
{
//Display an inverted name
if(ds->OSVer >= kVer35) // check to make sure 3.5 features are present
{
WinSetDrawMode(winSwap); //invert
DrawCharsToFitWidth(Name,rec);
WinPaintRectangle(rec,2);
WinSetDrawMode(winSwap); //un-invert
}
else // if 3.5 set is not here, just do this
{
WinDrawInvertedChars(Name, StrLen(Name), rec->topLeft.x,
rec->topLeft.y);
}
}
else
DrawCharsToFitWidth(Name, rec);
}
The selection code (for selectEvents) just toggles the state given the item
number in the list. For tables, the RowID is set to be the index into the
array(s) that track the necessary info.
HTH
Paul
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Matt
Disher
Sent: Tuesday, July 02, 2002 8:27 PM
To: Palm Developer Forum
Subject: Re: Multi-Select Lists
Yes, but it was a table with checkboxes :D
--
Matt Disher
[EMAIL PROTECTED]
> From: "Brad Figler" <[EMAIL PROTECTED]>
> Reply-To: "Palm Developer Forum" <[EMAIL PROTECTED]>
> Newsgroups: palm-dev-forum
> Date: Tue, 2 Jul 2002 19:13:34 -0700
> To: "Palm Developer Forum" <[EMAIL PROTECTED]>
> Subject: Multi-Select Lists
>
> Has anyone written one of these( besides appforge )?
>
> Thanks in advance,
>
> Brad Figler
>
>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please
> see http://www.palmos.com/dev/support/forums/
>
--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/