1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/******************************************************************************
* swld.cpp - code for base class 'SWLD'. SWLD is the basis for all
* types of Lexicon and Dictionary modules (hence the 'LD').
*/
#include <swld.h>
SWORD_NAMESPACE_START
/******************************************************************************
* SWLD Constructor - Initializes data for instance of SWLD
*
* ENT: imodname - Internal name for module
* imoddesc - Name to display to user for module
* idisp - Display object to use for displaying
*/
SWLD::SWLD(const char *imodname, const char *imoddesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang) : SWModule(imodname, imoddesc, idisp, "Lexicons / Dictionaries", enc, dir, mark, ilang)
{
delete key;
key = CreateKey();
entkeytxt = new char [1];
*entkeytxt = 0;
}
/******************************************************************************
* SWLD Destructor - Cleans up instance of SWLD
*/
SWLD::~SWLD()
{
if (entkeytxt)
delete [] entkeytxt;
}
/******************************************************************************
* SWLD::KeyText - Sets/gets module KeyText, getting from saved text if key is
* persistent
*
* ENT: ikeytext - value which to set keytext
* [0] - only get
*
* RET: pointer to keytext
*/
const char *SWLD::KeyText(const char *ikeytext)
{
if (key->Persist() && !ikeytext) {
getRawEntry(); // force module key to snap to entry
return entkeytxt;
}
else return SWModule::KeyText(ikeytext);
}
/******************************************************************************
* SWLD::setPosition(SW_POSITION) - Positions this key if applicable
*/
void SWLD::setPosition(SW_POSITION p) {
if (!key->Traversable()) {
switch (p) {
case POS_TOP:
*key = "";
break;
case POS_BOTTOM:
*key = "zzzzzzzzz";
break;
}
}
else *key = p;
getRawEntry();
}
SWORD_NAMESPACE_END
|