Main Page | Alphabetical List | Data Structures | File List | Globals | Related Pages

gtalk.c File Reference

Main code for GPilotS. More...

#include <PalmOS.h>
#include <PalmCompatibility.h>
#include <string.h>
#include <stdio.h>
#include "gtalkRsc.h"
#include "latlong.h"
#include "MathLib.h"
#include "gpslib.h"
#include "gtalk.h"
#include "route.h"
#include "gpsutil.h"
#include "log.h"
#include "map.h"
#include "gpsio.h"
#include "memo.h"
#include "dbio.h"
#include "track.h"
#include <LstGlue.h>
#include <TxtGlue.h>

Defines

#define ALLOW_ACCESS_TO_INTERNALS_OF_LISTS
#define ourMinVersion   sysMakeROMVersion(3,0,0,sysROMStageRelease,0)
#define MaxDBNames   10 /* maximum data bases names managed by SetPreferences */
#define SymbH   14
#define SymbW   16
#define SymbO   2
#define XName   1 /* coord. aff. nom */
#define XCmnt   48 /* coord. aff. commentaire */
#define XBear   105 /* coord. aff. bearing */
#define XSymb   136 /* coord. aff. symbole */
#define XEnd   150

Functions

char * GetCharEncoding (void)
Boolean MainFormHandleEvent (EventPtr e)
 Event handler of main form.

Boolean ApplicationHandleEvent (EventPtr e)
 frmLoadEvent event handler

Word StartApplication (void)
 Open application data bases and retrieves preferences.

void StopApplication (void)
 Save preferences, close forms, close app database.

void EventLoop (void)
 The main event loop.

DWord PilotMain (Word cmd, Ptr cmdPBP, Word launchFlags)
 Main entry point.

Err OpenOrCreateDB (DmOpenRef *DBP, char *DBName, ULong DBType, ULong creator)
 Opens or creates GPilotS data base.

void UpdateMainForm (void)
 Updates variables and list display of main form.

void AlarmProc (void)
 Alarm callback.

Err RomVersionCompatible (UInt32 requiredVersion, UInt16 launchFlags)
 Test PalmOs version compatibility.

Boolean CatFormHandleEvent (EventPtr e)
 Category change form event handler.

Err RecSetSecret (DmOpenRef *DBP, UInt16 index, Boolean value)
 Sets the secret attribute of a record.

void NewDB (void)
 Displays a form to ask a new data base name to create and to switch to.

UInt16 FindDBNames (UInt32 type, UInt32 creator, char *namep, Int16 *matched, char *bufp, char **bufpp, UInt16 bufpsize)
 Returns the number of data bases of given type and creator and, optionaly, a list of their names.

Err SwitchDB (DmOpenRef *DBP, char *DBName, ULong DBType)
 Switch from current data base to the one whose name is given.

void ChangeDB (void)
 Moves selected records from current data base to another.

void SetDebug (void)
 Debug form handler.

void DrawSymbol (unsigned int lid, int x, int y)
 Draws a waypoint symbol centered at given coordinates.

Int CompareWpt (void *p1, void *p2, Int other, SortRecordInfoPtr sp1, SortRecordInfoPtr sp2, VoidHand aph)
 Compares two waypoints features according to Prefs.wptsortcrit.

void SortWpts (WptSortCritType s)
 Sort waypoints according to given criteria.

long SearchWptByName (char *name, Boolean exact, Boolean all)
 Search waypoint by name.

void MainListDraw (Int16 itemNum, RectanglePtr bounds, CharPtr *itemsText)
 Draws an item of the main page's list.

int SetReferencePt (UInt index, Boolean ask)
 Set reference point to waypoint whose index is passed if user confirms.

void UpdateScrollBar (ListPtr LstPtr, Word ScrollId)
 Updates scrollbar of main list.

void ScrollLines (ListPtr LstPtr, Word ScrollId, int numLinesToScroll, Boolean redraw)
 Scroll lines of a list and updates associated scrollbar.

void SetPreferences ()
 Display and setting of preferences with a modal form.

Boolean RecIsSecret (DmOpenRef *DBP, UInt16 index)
 Tests if a record has secret attribute.

Err SetBackupBit (DmOpenRef *DBP)
 Set the backup flag of the given data base.


Variables

char rcsid [] = "$Id: gtalk.c,v 1.41 2004/11/17 21:11:32 clavelei Exp $"
PrefType Prefs
int DebugLevel
const char * DistanceUnitNames [] = { "km", "nm", "mi" }
char * BeamTypes [] = { "Un", "Wp", "Rt", "Tk" }
EditWptMode EditMode
Semicircle_Type ReferencePt = { 0, 0 }
char ReferencePtName [32] = ""
UInt CurrentRecordIndex
UInt CurrentRouteIndex
UInt * CurrentCategory
UInt New
UInt Replaced
UInt Sent
char gbuf1 [512]
char gbuf2 [128]
char search_buf [6]
Semicircle_Type CurrentWGS84Pos
Boolean MustCallGpslibTicks = 0
Boolean OnlyNews
Boolean Furuno
Boolean CompactTracks = 0
Boolean MainListDirty = 1
DmOpenRef CurrentDB
DmOpenRef WptDB
DmOpenRef TrkDB
DmOpenRef RteDB
DmOpenRef LogDB
UInt lastrecordindex
UInt lastitemnum = -2
ULong CurrentRecordID
char CategoryName [dmCategoryLength]
WinHandle SymbolsWH


Detailed Description

Main code for GPilotS.

Author:
C. Claveleira
Date:
1999-2004
Contains entry point of GPilotS and management code of the main form, eg to display list of waypoints, routes or tracks. It's named gtalk.c for historical reasons...

Function Documentation

void AlarmProc void   )  [static]
 

Alarm callback.

Called on alarm wakeup.

Returns:
nothing

Boolean ApplicationHandleEvent EventPtr  e  )  [static]
 

frmLoadEvent event handler

Parameters:
e pointer on event received
Returns:
true if event was a frmLoadEvent

Boolean CatFormHandleEvent EventPtr  e  )  [static]
 

Category change form event handler.

Parameters:
e pointer on event received
Returns:
true if event handled

void ChangeDB void   )  [static]
 

Moves selected records from current data base to another.

Lets the user choose the new data base

Returns:
nothing

Int CompareWpt void *  p1,
void *  p2,
Int  other,
SortRecordInfoPtr  sp1,
SortRecordInfoPtr  sp2,
VoidHand  aph
 

Compares two waypoints features according to Prefs.wptsortcrit.

Used as callback.

Parameters:
p1 pointer on first waypoint
p2 pointer on second waypoint
other ignored
sp1 ignored
sp2 ignored
aph ignored
Returns:
>0 if *p1>*p2, 0 if *p1==*p2, <0 if *p1<*p2

void DrawSymbol unsigned int  lid,
int  x,
int  y
 

Draws a waypoint symbol centered at given coordinates.

Parameters:
lid local bitmap index
x x coordinate of center
y y coordinate of center
Returns:
nothing

void EventLoop void   )  [static]
 

The main event loop.

Returns:
nothing

UInt16 FindDBNames UInt32  type,
UInt32  creator,
char *  namep,
Int16 *  matched,
char *  bufp,
char **  bufpp,
UInt16  bufpsize
[static]
 

Returns the number of data bases of given type and creator and, optionaly, a list of their names.

Parameters:
type type to search
creator creator to search
namep if !=NULL points on name to compare with scanned data bases names
matched pointer on variable to receive index of db whose name match those passed in namep
bufp buffer to store names if != NULL
bufpp list of pointers on names stored in bufp
bufpsize size of bufpp list
Returns:
number of data bases found, 0 if none or error

Boolean MainFormHandleEvent EventPtr  e  )  [static]
 

Event handler of main form.

Parameters:
e pointer on event received
Returns:
true if event handled

void MainListDraw Int16  itemNum,
RectanglePtr  bounds,
CharPtr *  itemsText
 

Draws an item of the main page's list.

Take appropriate actions given the type of the object concerned and the display and sort options.

Parameters:
itemNum item number
bounds rectangle to draw into
itemsText ignored
Returns:
nothing

void NewDB void   )  [static]
 

Displays a form to ask a new data base name to create and to switch to.

Returns:
nothing

Err OpenOrCreateDB DmOpenRef *  DBP,
char *  DBName,
ULong  DBType,
ULong  creator
[static]
 

Opens or creates GPilotS data base.

Parameters:
DBP pointer were to store the DmOpenRef on the data base
DBName name of data base
DBType data base type
creator data base creator
Returns:
0 if ok

DWord PilotMain Word  cmd,
Ptr  cmdPBP,
Word  launchFlags
 

Main entry point.

Parameters:
cmd launch code
cmdPBP parameters
launchFlags flags
Returns:
error code

Boolean RecIsSecret DmOpenRef *  DBP,
UInt16  index
 

Tests if a record has secret attribute.

Parameters:
DBP pointer on an open data base
index index of record to test
Returns:
true if secret attribute set

Err RecSetSecret DmOpenRef *  DBP,
UInt16  index,
Boolean  value
[static]
 

Sets the secret attribute of a record.

Parameters:
DBP pointer on an open data base
index index of record to set the attribute
value value to put in attribute
Returns:
error code

Err RomVersionCompatible UInt32  requiredVersion,
UInt16  launchFlags
[static]
 

Test PalmOs version compatibility.

Parameters:
requiredVersion required version
launchFlags launch flag
Returns:

void ScrollLines ListPtr  LstPtr,
Word  ScrollId,
int  numLinesToScroll,
Boolean  redraw
[static]
 

Scroll lines of a list and updates associated scrollbar.

Parameters:
LstPtr pointer on list to scroll
ScrollId id of associated scrollbar to update
numLinesToScroll number of lines to scroll
redraw unused
Returns:
nothing

long SearchWptByName char *  name,
Boolean  exact,
Boolean  all
 

Search waypoint by name.

Parameters:
name part of name to search (null terminated)
exact if true, name contains the exact string to search si false,name contains the begining of the name to search
all si true, search in all categories else search in current category
Returns:
index of wayoint if found, -1 else

Err SetBackupBit DmOpenRef *  DBP  ) 
 

Set the backup flag of the given data base.

Parameters:
DBP DmOpenRef to the data base
Returns:
nothing

void SetDebug void   )  [static]
 

Debug form handler.

Displays a form to select debug levels of differents parts of GPilotS

Returns:
nothing

void SetPreferences void   ) 
 

Display and setting of preferences with a modal form.

Returns:
nothing

int SetReferencePt UInt  index,
Boolean  ask
 

Set reference point to waypoint whose index is passed if user confirms.

Parameters:
index index of waypoint record
ask 1 -> a confirmation dialog is displayed, 0 -> it's set without asking
Returns:
1 if user accepts, 0 otherwise

void SortWpts WptSortCritType  s  ) 
 

Sort waypoints according to given criteria.

If allready sorted following given criteria nothing is done except if s == Current.

Parameters:
s sort criteria. If s == Current, the sort is forced on current criteria
Returns:
nothing

Word StartApplication void   )  [static]
 

Open application data bases and retrieves preferences.

Also loads MathLib library.

Returns:
0 if ok

void StopApplication void   )  [static]
 

Save preferences, close forms, close app database.

Returns:
nothing

Err SwitchDB DmOpenRef *  DBP,
char *  DBName,
ULong  DBType
[static]
 

Switch from current data base to the one whose name is given.

If it doesn't exist the new data base is created. Displays message if error.

Parameters:
DBP pointer on DmOpenRef of data base to switch from
DBName name of data base to switch to
DBType type of new data base
Returns:
0 if OK

void UpdateMainForm void   )  [static]
 

Updates variables and list display of main form.

Takes into account changes of categories, of items to display,... Updates menus, buttons, title,...

Returns:
nothing

void UpdateScrollBar ListPtr  LstPtr,
Word  ScrollId
[static]
 

Updates scrollbar of main list.

Parameters:
LstPtr pointer on list associated with scrollbar
ScrollId id of the scrollbar in the form
Returns:
nothing


Variable Documentation

PrefType Prefs
 

Initial value:

    { DispWpt, dmAllCategories, 0, Alpha, metric, DMM, 0, WGS84Index, 0, DBVersion, GIIPlus, 10,
      dmAllCategories, dmAllCategories, dmAllCategories, false, 0, WptDBName, RteDBName, TrkDBName, 0
}


Generated on Sun Mar 13 09:36:01 2005 for GPilotS by doxygen 1.3.6