added GenYearTicks()
This commit is contained in:
@@ -476,6 +476,64 @@
|
||||
</inline>
|
||||
|
||||
|
||||
<inline loc="end" access="public">
|
||||
<content>
|
||||
$(api) void $(struct_prefix)_GenYearTicks($(struct_type) *st, int lvl);
|
||||
</content>
|
||||
</inline>
|
||||
|
||||
<inline loc="code">
|
||||
<content>
|
||||
void $(struct_prefix)_GenYearTicks($(struct_type) *st, int lvl) \n
|
||||
{ \n
|
||||
double minValue; \n
|
||||
double maxValue; \n
|
||||
GWEN_BUFFER *dbuf; \n
|
||||
GWEN_DATE *dt; \n
|
||||
int addSecs; \n
|
||||
\n
|
||||
addSecs=365*24*60*60; \n
|
||||
\n
|
||||
maxValue=st->maxValue; \n
|
||||
dt=GWEN_Date_fromLocalTime(maxValue); \n
|
||||
GWEN_Date_free(dt); \n
|
||||
\n
|
||||
minValue=st->minValue; \n
|
||||
dt=GWEN_Date_fromLocalTime(minValue); \n
|
||||
if (dt) { \n
|
||||
GWEN_DATE *dtMonthStart; \n
|
||||
\n
|
||||
dtMonthStart=GWEN_Date_GetThisMonthStart(dt); \n
|
||||
GWEN_Date_free(dt); \n
|
||||
dt=dtMonthStart; \n
|
||||
} \n
|
||||
\n
|
||||
dbuf=GWEN_Buffer_new(0, 256, 0, 1); \n
|
||||
while(1) { \n
|
||||
double v; \n
|
||||
GWEN_DATE *dtCurrent; \n
|
||||
\n
|
||||
dtCurrent=GWEN_Date_GetThisYearStart(dt); \n
|
||||
v=GWEN_Date_toLocalTime(dtCurrent); \n
|
||||
if (v>=minValue && v<maxValue) { \n
|
||||
GWEN_Buffer_AppendArgs(dbuf, "%04d", GWEN_Date_GetYear(dtCurrent)); \n
|
||||
if (!$(struct_prefix)_HasTickValue(st, v)) \n
|
||||
$(struct_prefix)_AddNewTick(st, GWEN_Buffer_GetStart(dbuf), v, lvl, 0, (double) addSecs); \n
|
||||
GWEN_Buffer_Reset(dbuf); \n
|
||||
} \n
|
||||
GWEN_Date_free(dt); \n
|
||||
dt=dtCurrent; \n
|
||||
GWEN_Date_AddDays(dt, 370); \n
|
||||
if (v>=maxValue) \n
|
||||
break; \n
|
||||
} \n
|
||||
GWEN_Buffer_free(dbuf); \n
|
||||
GWEN_Date_free(dt); \n
|
||||
} \n
|
||||
</content>
|
||||
</inline>
|
||||
|
||||
|
||||
<inline loc="end" access="public">
|
||||
<content>
|
||||
$(api) void $(struct_prefix)_GenTimeTicks($(struct_type) *st);
|
||||
@@ -488,6 +546,12 @@
|
||||
{ \n
|
||||
int nextLevel=0; \n
|
||||
\n
|
||||
$(struct_prefix)_GenYearTicks(st, nextLevel); \n
|
||||
if ($(struct_prefix)_HasAtLeastNLevelTicks(st, nextLevel, nextLevel?2:4)) \n
|
||||
nextLevel++; \n
|
||||
else \n
|
||||
$(struct_prefix)_RemoveLevelTicks(st, nextLevel); \n
|
||||
\n
|
||||
$(struct_prefix)_GenMonthTicks(st, nextLevel); \n
|
||||
if ($(struct_prefix)_HasAtLeastNLevelTicks(st, nextLevel, nextLevel?2:4)) \n
|
||||
nextLevel++; \n
|
||||
|
||||
Reference in New Issue
Block a user