mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-01 07:42:40 -06:00
- CtrlLib: TreeCtrl bug fix - SyncInfo crashed on an empty tree
* CtrlLib: CtrlCore.h, Win32Wnd.cpp - Unicode support in coreCmdLine / SplitCommandLine to support dynamic application charset * Core: App.cpp - CommandLine() and Environment() support dynamic charset switching - Geom/Draw: plotter.h & cpp - fixed orientation bug in PlotterTool::Circle routine git-svn-id: svn://ultimatepp.org/upp/trunk@2211 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
12f7f51a91
commit
ec3ec7ae33
6 changed files with 67 additions and 45 deletions
|
|
@ -173,11 +173,25 @@ String ConfigFile() {
|
|||
return ConfigFile(GetExeTitle() + ".cfg");
|
||||
}
|
||||
|
||||
GLOBAL_VAR(Vector<String>, coreCmdLine__)
|
||||
GLOBAL_VAR(Vector<WString>, coreCmdLine__)
|
||||
|
||||
const Vector<String>& CommandLine()
|
||||
{
|
||||
return coreCmdLine__();
|
||||
Vector<String> *ptr;
|
||||
INTERLOCKED {
|
||||
static ArrayMap< byte, Vector<String> > charset_cmd;
|
||||
byte cs = GetDefaultCharset();
|
||||
int f = charset_cmd.Find(cs);
|
||||
if(f >= 0)
|
||||
ptr = &charset_cmd[f];
|
||||
else {
|
||||
ptr = &charset_cmd.Add(cs);
|
||||
const Vector<WString>& src = coreCmdLine__();
|
||||
for(int i = 0; i < src.GetCount(); i++)
|
||||
ptr->Add(src[i].ToString());
|
||||
}
|
||||
}
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
VectorMap<WString, WString>& EnvMap()
|
||||
|
|
@ -188,16 +202,18 @@ VectorMap<WString, WString>& EnvMap()
|
|||
|
||||
const VectorMap<String, String>& Environment()
|
||||
{
|
||||
static VectorMap<String, String> *ptr = NULL;
|
||||
VectorMap<String, String> *ptr;
|
||||
INTERLOCKED {
|
||||
static VectorMap<String, String> env;
|
||||
static int echrset;
|
||||
if(!ptr || GetDefaultCharset() != echrset) {
|
||||
env.Clear();
|
||||
echrset = GetDefaultCharset();
|
||||
for(int i = 0; i < EnvMap().GetCount(); i++)
|
||||
env.Add(EnvMap().GetKey(i).ToString(), EnvMap()[i].ToString());
|
||||
ptr = &env;
|
||||
static ArrayMap< byte, VectorMap<String, String> > charset_env;
|
||||
byte cs = GetDefaultCharset();
|
||||
int f = charset_env.Find(cs);
|
||||
if(f >= 0)
|
||||
ptr = &charset_env[f];
|
||||
else {
|
||||
ptr = &charset_env.Add(cs);
|
||||
const VectorMap<WString, WString>& env_map = EnvMap();
|
||||
for(int i = 0; i < env_map.GetCount(); i++)
|
||||
ptr->Add(env_map.GetKey(i).ToString(), env_map[i].ToString());
|
||||
}
|
||||
}
|
||||
return *ptr;
|
||||
|
|
@ -231,9 +247,12 @@ void CommonInit()
|
|||
LoadLangFiles(GetHomeDirectory());
|
||||
#endif
|
||||
|
||||
Vector<String>& cmd = coreCmdLine__();
|
||||
Vector<WString>& cmd = coreCmdLine__();
|
||||
static WString exp_cmd = "--export-tr";
|
||||
static WString brk_cmd = "--memory-breakpoint__";
|
||||
|
||||
for(int i = 0; i < cmd.GetCount();) {
|
||||
if(cmd[i] == "--export-tr") {
|
||||
if(cmd[i] == exp_cmd) {
|
||||
{
|
||||
i++;
|
||||
int lang = 0;
|
||||
|
|
@ -243,8 +262,8 @@ void CommonInit()
|
|||
if(cmd[i].GetLength() != 4 && cmd[i].GetLength() != 5)
|
||||
lang = 0;
|
||||
else {
|
||||
lang = LNGFromText(cmd[i]);
|
||||
fn = cmd[i];
|
||||
lang = LNGFromText(cmd[i].ToString());
|
||||
fn = cmd[i].ToString();
|
||||
int c = cmd[i][4];
|
||||
if(c >= '0' && c <= '8')
|
||||
charset = c - '0' + CHARSET_WIN1250;
|
||||
|
|
@ -268,8 +287,8 @@ void CommonInit()
|
|||
exit(0);
|
||||
}
|
||||
#if defined(_DEBUG) && defined(UPP_HEAP)
|
||||
if(cmd[i] == "--memory-breakpoint__" && i + 1 < cmd.GetCount()) {
|
||||
MemoryBreakpoint(atoi(cmd[i + 1]));
|
||||
if(cmd[i] == brk_cmd && i + 1 < cmd.GetCount()) {
|
||||
MemoryBreakpoint(atoi(cmd[i + 1].ToString()));
|
||||
cmd.Remove(i, 2);
|
||||
}
|
||||
else
|
||||
|
|
@ -312,9 +331,9 @@ void AppInit__(int argc, const char **argv, const char **envptr)
|
|||
var++;
|
||||
EnvMap().Add(varname.ToWString(), String(var).ToWString());
|
||||
}
|
||||
Vector<String>& cmd = coreCmdLine__();
|
||||
Vector<WString>& cmd = coreCmdLine__();
|
||||
for(int i = 1; i < argc; i++)
|
||||
cmd.Add(argv[i]);
|
||||
cmd.Add(FromSystemCharset(argv[i]));
|
||||
CommonInit();
|
||||
signal(SIGILL, s_ill_handler);
|
||||
signal(SIGSEGV, s_segv_handler);
|
||||
|
|
@ -352,7 +371,7 @@ void AppInitEnvironment__()
|
|||
void AppInit__(int argc, const char **argv)
|
||||
{
|
||||
SetLanguage(LNG_ENGLISH);
|
||||
Vector<String>& cmd = coreCmdLine__();
|
||||
Vector<WString>& cmd = coreCmdLine__();
|
||||
for(int i = 1; i < argc; i++)
|
||||
cmd.Add(argv[i]);
|
||||
AppInitEnvironment__();
|
||||
|
|
|
|||
|
|
@ -1744,8 +1744,8 @@ RichText ParseRTF(const char *rtf);
|
|||
|
||||
#ifdef PLATFORM_WIN32
|
||||
|
||||
Vector<String>& coreCmdLine__();
|
||||
Vector<String> SplitCmdLine__(const char *cmd);
|
||||
Vector<WString>& coreCmdLine__();
|
||||
Vector<WString> SplitCmdLine__(const char *cmd);
|
||||
|
||||
#ifdef PLATFORM_WINCE
|
||||
|
||||
|
|
|
|||
|
|
@ -1251,25 +1251,23 @@ ViewDraw::~ViewDraw()
|
|||
LeaveGuiMutex();
|
||||
}
|
||||
|
||||
Vector<String> SplitCmdLine__(const char *cmd)
|
||||
Vector<WString> SplitCmdLine__(const char *cmd)
|
||||
{
|
||||
Vector<String> out;
|
||||
Vector<WString> out;
|
||||
while(*cmd)
|
||||
if((byte)*cmd <= ' ')
|
||||
cmd++;
|
||||
else if(*cmd == '\"')
|
||||
{
|
||||
String quoted;
|
||||
else if(*cmd == '\"') {
|
||||
WString quoted;
|
||||
while(*++cmd && (*cmd != '\"' || *++cmd == '\"'))
|
||||
quoted.Cat(*cmd);
|
||||
quoted.Cat(FromSystemCharset(String(cmd, 1)).ToWString());
|
||||
out.Add(quoted);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
const char *begin = cmd;
|
||||
while((byte)*cmd > ' ')
|
||||
cmd++;
|
||||
out.Add(String(begin, cmd));
|
||||
out.Add(String(begin, cmd).ToWString());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -836,19 +836,21 @@ void TreeCtrl::SyncInfo()
|
|||
Size sz = GetSize();
|
||||
Point p = GetMouseViewPos();
|
||||
Point org = sb;
|
||||
if(p.y + org.y > sb.GetTotal().cy)
|
||||
return;
|
||||
// if(p.y + org.y > sb.GetTotal().cy)
|
||||
// return;
|
||||
int i = FindLine(p.y + org.y);
|
||||
const Line& l = line[i];
|
||||
const Item& m = item[l.itemi];
|
||||
int x = levelcx + l.level * levelcx - org.x + m.image.GetSize().cx;
|
||||
Rect r = RectC(x, l.y - org.y, sz.cx - x, m.GetSize(display).cy);
|
||||
if(r.Contains(p)) {
|
||||
Color fg, bg;
|
||||
dword st;
|
||||
const Display *d = GetStyle(i, fg, bg, st);
|
||||
info.Set(this, r, m.value, d, fg, bg, st, m.margin);
|
||||
return;
|
||||
if(i < line.GetCount()) {
|
||||
const Line& l = line[i];
|
||||
const Item& m = item[l.itemi];
|
||||
int x = levelcx + l.level * levelcx - org.x + m.image.GetSize().cx;
|
||||
Rect r = RectC(x, l.y - org.y, sz.cx - x, m.GetSize(display).cy);
|
||||
if(r.Contains(p)) {
|
||||
Color fg, bg;
|
||||
dword st;
|
||||
const Display *d = GetStyle(i, fg, bg, st);
|
||||
info.Set(this, r, m.value, d, fg, bg, st, m.margin);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
info.Cancel();
|
||||
|
|
|
|||
|
|
@ -618,7 +618,8 @@ void Plotter::Set(Draw& _draw, const Matrixf& _transform, const Rect& _clip, dou
|
|||
{
|
||||
physical = _transform;
|
||||
logical = MatrixfInverse(_transform);
|
||||
measure = fabs(MatrixfMeasure(physical));
|
||||
signed_measure = MatrixfMeasure(physical);
|
||||
measure = fabs(signed_measure);
|
||||
logprec = 1.0 / measure;
|
||||
ortho = (physical.x.y == 0 && physical.y.x == 0);
|
||||
ltop = (ortho ? &Plotter::LtoPOrtho : &Plotter::LtoPFull);
|
||||
|
|
@ -1210,7 +1211,8 @@ bool PathTool::ArcToRaw(Pointf pt, double bulge)
|
|||
return true;
|
||||
}
|
||||
Pointf pt_phys = plotter.LtoP(pt);
|
||||
pathdraw.Arc(PointfToPoint(last_phys), PointfToPoint(pt_phys), fround(bulge * fabs(plotter.measure)));
|
||||
pathdraw.Arc(PointfToPoint(last_phys), PointfToPoint(pt_phys),
|
||||
fround(bulge * plotter.signed_measure));
|
||||
last_point = pt;
|
||||
last_phys = pt_phys;
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -179,6 +179,7 @@ public:
|
|||
Rect clip;
|
||||
double logdiag;
|
||||
double logprec;
|
||||
double signed_measure;
|
||||
double measure;
|
||||
double physical_scale;
|
||||
bool ortho;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue