Bug 115 - Snap-to causes spurious 'toolbar' to appear momentarily at start of dragging.

Completes James' TimeConverter work

This completes the work that James started.  It moves most of the non-GUI
related processing from TimeTextCtrl to James' TimeConverter class.

Other changes include:

1)  TimeTextCtrl now expects the format name instead of the format string to be
passed when creating a new instance.  I found that almost all cases created the
instance with a blank format string and then set the string after creation.

2)  To simplify maintenance and prevent a possible discrepancy between the two,
Increase() and Decrease() were merged into a single routine.

As a result:

1)  All cases where a TimeTextCtrl was being used to extract information and
not actually display a control have been changed to use TimeConverter instead.

2)  All cases where TimeTextCtrl was being created with an empty format and
then immediately followed by something like this:

    tt.SetFormatString(tt.GetBuiltinFormat(c->GetFormat()))

    have been changed to pass the format name instead of the format string when
creating the TimeTextCtrl instance.
This commit is contained in:
lllucius 2013-10-23 21:01:52 +00:00
parent 0e1614f41c
commit 71fde85bfe
13 changed files with 619 additions and 627 deletions

View File

@ -59,7 +59,6 @@
#include "Resample.h"
#include "SampleFormat.h"
#include "Sequence.h"
#include "TimeDialog.h"
#include "TimeTrack.h"
#include "Track.h"
#include "UndoManager.h"

View File

@ -30,25 +30,18 @@ SnapManager::SnapManager(TrackList *tracks, TrackClipArray *exclusions,
// Grab time-snapping prefs (unless otherwise requested)
mSnapToTime = false;
TimeTextCtrl *ttc = NULL;
// TODO: Switch over from using TimeTextCtrl to TimeConverter.
// This will prevent an annoying tiny toolbar appearing in top left
// every time we click the mouse left button. It's the time text
// ctrl.
//TimeConverter *pTc=NULL;
if (gPrefs->Read(wxT("/SnapTo"), 0L) != 0L && !noTimeSnap)
{
// Look up the format string
AudacityProject *p = GetActiveProject();
wxASSERT(p);
if (p) {
mConverter.SetSampleRate(p->GetRate());
mSnapToTime = true;
ttc = new TimeTextCtrl(p, wxID_ANY, wxT(""), 0.0, p->GetRate());
wxString formatName;
gPrefs->Read(wxT("/SelectionFormat"), &formatName);
mFormat = ttc->GetBuiltinFormat(formatName);
ttc->SetFormatString(mFormat);
mConverter.SetFormatString(mConverter.GetBuiltinFormat(formatName));
}
}
@ -73,9 +66,9 @@ SnapManager::SnapManager(TrackList *tracks, TrackClipArray *exclusions,
LabelTrack *labelTrack = (LabelTrack *)track;
for(i = 0; i < labelTrack->GetNumLabels(); i++) {
const LabelStruct *label = labelTrack->GetLabel(i);
CondListAdd(label->t, labelTrack, ttc);
CondListAdd(label->t, labelTrack);
if (label->t1 != label->t) {
CondListAdd(label->t1, labelTrack, ttc);
CondListAdd(label->t1, labelTrack);
}
}
}
@ -94,30 +87,26 @@ SnapManager::SnapManager(TrackList *tracks, TrackClipArray *exclusions,
if (skip)
continue;
}
CondListAdd(clip->GetStartTime(), waveTrack, ttc);
CondListAdd(clip->GetEndTime(), waveTrack, ttc);
CondListAdd(clip->GetStartTime(), waveTrack);
CondListAdd(clip->GetEndTime(), waveTrack);
}
}
#ifdef USE_MIDI
else if (track->GetKind() == Track::Note) {
CondListAdd(track->GetStartTime(), track, ttc);
CondListAdd(track->GetEndTime(), track, ttc);
CondListAdd(track->GetStartTime(), track);
CondListAdd(track->GetEndTime(), track);
}
#endif
track = iter.Next();
}
if (ttc)
delete ttc;
}
// Adds to mSnapPoints, filtering by ttc if it's not NULL
void SnapManager::CondListAdd(double t, Track *tr, TimeTextCtrl *ttc)
// Adds to mSnapPoints, filtering by TimeConverter
void SnapManager::CondListAdd(double t, Track *tr)
{
if (ttc)
ttc->SetTimeValue(t);
mConverter.SetTimeValue(t);
if (!ttc || ttc->GetTimeValue() == t)
if (mConverter.GetTimeValue() == t)
mSnapPoints->Add(new SnapPoint(t, tr));
}
@ -260,27 +249,9 @@ bool SnapManager::Snap(Track *currentTrack,
}
else {
// Snap time to the grid
AudacityProject *p = GetActiveProject();
#if 0
// Old code for snapping.
// This created a new ctrl for every tiny drag.
TimeTextCtrl ttc(p, wxID_ANY, wxT(""), 0.0, p->GetRate());
ttc.SetFormatString(mFormat);
ttc.SetTimeValue(t);
*out_t = ttc.GetTimeValue();
#else
// Replacement code. It's still inefficient, since we
// repeatedly parse the format, but it now doesn't
// create a new ctrl too.
// TODO: Move Tc into being a member variable of
// SnapManager. Then we won't be repeatedly
// parsing the format string.
TimeConverter Tc;
Tc.mSampleRate = p->GetRate();
Tc.ParseFormatString( mFormat );
Tc.ValueToControls( t );
*out_t = Tc.ControlsToValue();
#endif
mConverter.ValueToControls(t, false);
mConverter.ControlsToValue();
*out_t = mConverter.GetTimeValue();
*snappedTime = true;
}
}

View File

@ -19,10 +19,9 @@
#include <wx/dynarray.h>
#include "Track.h"
#include "ViewInfo.h"
#include "widgets/TimeTextCtrl.h"
class TrackClipArray;
class TimeTextCtrl;
class SnapPoint {
public:
@ -38,8 +37,6 @@ WX_DEFINE_SORTED_ARRAY(SnapPoint *, SnapPointArray);
class SnapManager {
public:
// Set gridCtrl to a TimeTextCtrl to use for snap-to-time; if NULL we won't
// snap to time
SnapManager(TrackList *tracks, TrackClipArray *exclusions,
double zoom, int pixelTolerance, bool noTimeSnap = false);
@ -57,7 +54,7 @@ class SnapManager {
bool *snappedTime);
private:
void CondListAdd(double t, Track *tr, TimeTextCtrl *ttc);
void CondListAdd(double t, Track *tr);
double Get(int index);
double Diff(double t, int index);
int Find(double t, int i0, int i1);
@ -71,8 +68,8 @@ class SnapManager {
SnapPointArray *mSnapPoints;
// Info for snap-to-time
TimeConverter mConverter;
bool mSnapToTime;
wxString mFormat;
};
#endif

View File

@ -55,14 +55,13 @@ void TimeDialog::PopulateOrExchange(ShuttleGui &S)
mTimeCtrl = new
TimeTextCtrl(this,
wxID_ANY,
wxT(""),
mFormat,
mTime,
mRate,
wxDefaultPosition,
wxDefaultSize,
true);
mTimeCtrl->SetName(mPrompt);
mTimeCtrl->SetFormatString(mTimeCtrl->GetBuiltinFormat(mFormat));
S.AddWindow(mTimeCtrl);
mTimeCtrl->EnableMenu();
}

View File

@ -342,8 +342,9 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S)
m_pDatePickerCtrl_Start->SetRange(wxDateTime::Today(), wxInvalidDateTime); // No backdating.
S.AddWindow(m_pDatePickerCtrl_Start);
m_pTimeTextCtrl_Start = new TimeTextCtrl(this, ID_TIMETEXT_START, strFormat);
m_pTimeTextCtrl_Start = new TimeTextCtrl(this, ID_TIMETEXT_START);
m_pTimeTextCtrl_Start->SetName(_("Start Time"));
m_pTimeTextCtrl_Start->SetFormatString(strFormat);
m_pTimeTextCtrl_Start->SetTimeValue(wxDateTime_to_AudacityTime(m_DateTime_Start));
S.AddWindow(m_pTimeTextCtrl_Start);
m_pTimeTextCtrl_Start->EnableMenu(false);
@ -361,8 +362,9 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S)
m_pDatePickerCtrl_End->SetName(_("End Date"));
S.AddWindow(m_pDatePickerCtrl_End);
m_pTimeTextCtrl_End = new TimeTextCtrl(this, ID_TIMETEXT_END, strFormat);
m_pTimeTextCtrl_End = new TimeTextCtrl(this, ID_TIMETEXT_END);
m_pTimeTextCtrl_End->SetName(_("End Time"));
m_pTimeTextCtrl_End->SetFormatString(strFormat);
m_pTimeTextCtrl_End->SetTimeValue(wxDateTime_to_AudacityTime(m_DateTime_End));
S.AddWindow(m_pTimeTextCtrl_End);
m_pTimeTextCtrl_End->EnableMenu(false);
@ -380,8 +382,9 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S)
* seconds.
*/
wxString strFormat1 = _("099 days 024 h 060 m 060 s");
m_pTimeTextCtrl_Duration = new TimeTextCtrl(this, ID_TIMETEXT_DURATION, strFormat1);
m_pTimeTextCtrl_Duration = new TimeTextCtrl(this, ID_TIMETEXT_DURATION);
m_pTimeTextCtrl_Duration->SetName(_("Duration"));
m_pTimeTextCtrl_Duration->SetFormatString(strFormat1);
m_pTimeTextCtrl_Duration->SetTimeValue(m_TimeSpan_Duration.GetSeconds().ToDouble());
S.AddWindow(m_pTimeTextCtrl_Duration);
m_pTimeTextCtrl_Duration->EnableMenu(false);

View File

@ -22,6 +22,7 @@
#include "WaveClip.h"
#include "WaveTrack.h"
#include "UndoManager.h" //JKC: Included for PUSH_XXX definitions.
#include "widgets/TimeTextCtrl.h"
class wxMenu;
class wxRect;
@ -601,6 +602,8 @@ protected:
wxInt64 mSnapRight;
bool mSnapPreferRightEdge;
TimeConverter mConverter;
Track * mDrawingTrack; // Keeps track of which track you are drawing on between events cf. HandleDraw()
int mDrawingTrackTop; // Keeps track of the top position of the drawing track.
sampleCount mDrawingStartSample; // sample of last click-down

View File

@ -260,14 +260,13 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id,
mForegroundStartT = new
TimeTextCtrl(this,
ID_FOREGROUNDSTART_T,
wxT(""),
_("hh:mm:ss + hundredths"),
0.0,
mProjectRate,
wxDefaultPosition,
wxDefaultSize,
true);
mForegroundStartT->SetName(_("Foreground start time"));
mForegroundStartT->SetFormatString(mForegroundStartT->GetBuiltinFormat(_("hh:mm:ss + hundredths")));
mForegroundStartT->EnableMenu(false);
}
S.AddWindow(mForegroundStartT);
@ -277,14 +276,13 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id,
mForegroundEndT = new
TimeTextCtrl(this,
ID_FOREGROUNDEND_T,
wxT(""),
_("hh:mm:ss + hundredths"),
0.0,
mProjectRate,
wxDefaultPosition,
wxDefaultSize,
true);
mForegroundEndT->SetName(_("Foreground end time"));
mForegroundEndT->SetFormatString(mForegroundEndT->GetBuiltinFormat(_("hh:mm:ss + hundredths")));
mForegroundEndT->EnableMenu(false);
}
S.AddWindow(mForegroundEndT);
@ -300,14 +298,13 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id,
mBackgroundStartT = new
TimeTextCtrl(this,
ID_BACKGROUNDSTART_T,
wxT(""),
_("hh:mm:ss + hundredths"),
0.0,
mProjectRate,
wxDefaultPosition,
wxDefaultSize,
true);
mBackgroundStartT->SetName(_("Background start time"));
mBackgroundStartT->SetFormatString(mBackgroundStartT->GetBuiltinFormat(_("hh:mm:ss + hundredths")));
mBackgroundStartT->EnableMenu(false);
}
S.AddWindow(mBackgroundStartT);
@ -317,14 +314,13 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id,
mBackgroundEndT = new
TimeTextCtrl(this,
ID_BACKGROUNDEND_T,
wxT(""),
_("hh:mm:ss + hundredths"),
0.0,
mProjectRate,
wxDefaultPosition,
wxDefaultSize,
true);
mBackgroundEndT->SetName(_("Background end time"));
mBackgroundEndT->SetFormatString(mBackgroundEndT->GetBuiltinFormat(_("hh:mm:ss + hundredths")));
mBackgroundEndT->EnableMenu(false);
}
S.AddWindow(mBackgroundEndT);

View File

@ -458,18 +458,17 @@ void DtmfDialog::PopulateOrExchange( ShuttleGui & S )
mDtmfDurationT = new
TimeTextCtrl(this,
ID_DTMF_DURATION_TEXT,
wxT(""),
/* use this instead of "seconds" because if a selection is passed to the
* effect, I want it (dDuration) to be used as the duration, and with
* "seconds" this does not always work properly. For example, it rounds
* down to zero... */
dIsSelection ? _("hh:mm:ss + samples") : _("hh:mm:ss + milliseconds"),
dDuration,
mEffect->mProjectRate,
wxDefaultPosition,
wxDefaultSize,
true);
/* use this instead of "seconds" because if a selection is passed to the
* effect, I want it (dDuration) to be used as the duration, and with
* "seconds" this does not always work properly. For example, it rounds
* down to zero... */
mDtmfDurationT->SetName(_("Duration"));
mDtmfDurationT->SetFormatString(mDtmfDurationT->GetBuiltinFormat(dIsSelection==true?(_("hh:mm:ss + samples")):(_("hh:mm:ss + milliseconds"))));
mDtmfDurationT->EnableMenu();
}
S.AddWindow(mDtmfDurationT);

View File

@ -275,14 +275,13 @@ void ToneGenDialog::PopulateOrExchangeStandard( ShuttleGui & S )
mToneDurationT =
new TimeTextCtrl(this,
wxID_ANY,
wxT(""),
isSelection ? _("hh:mm:ss + samples") : _("hh:mm:ss + milliseconds"),
mDuration,
mEffect->mProjectRate,
wxDefaultPosition,
wxDefaultSize,
true);
mToneDurationT->SetName(_("Duration"));
mToneDurationT->SetFormatString(mToneDurationT->GetBuiltinFormat(isSelection==true?(_("hh:mm:ss + samples")):(_("hh:mm:ss + milliseconds"))));
mToneDurationT->EnableMenu();
}
S.AddWindow(mToneDurationT);
@ -323,14 +322,13 @@ void ToneGenDialog::PopulateOrExchangeExtended( ShuttleGui & S )
mToneDurationT = new
TimeTextCtrl(this,
wxID_ANY,
wxT(""),
isSelection ? _("hh:mm:ss + samples") : _("hh:mm:ss + milliseconds"),
mDuration,
mEffect->mProjectRate,
wxDefaultPosition,
wxDefaultSize,
true);
mToneDurationT->SetName(_("Duration"));
mToneDurationT->SetFormatString(mToneDurationT->GetBuiltinFormat(isSelection==true?(_("hh:mm:ss + samples")):(_("hh:mm:ss + milliseconds"))));
mToneDurationT->EnableMenu();
}
S.AddWindow(mToneDurationT);

View File

@ -114,11 +114,8 @@ void SelectionBar::Populate()
* to do some look-ups, so we'll have to create one. We can't make the
* look-ups static because they depend on translations which are done at
* runtime */
TimeTextCtrl *ttc = new TimeTextCtrl(this, wxID_ANY, wxT(""), 0.0, mRate);
wxString formatName;
gPrefs->Read(wxT("/SelectionFormat"), &formatName);
wxString format = ttc->GetBuiltinFormat(formatName);
delete ttc;
mainSizer = new wxFlexGridSizer(7, 1, 1);
Add(mainSizer, 0, wxALIGN_CENTER_VERTICAL);
@ -255,13 +252,12 @@ void SelectionBar::Populate()
NULL,
this);
mLeftTime = new TimeTextCtrl(this, OnLeftTimeID, wxT(""), 0.0, mRate);
mLeftTime->SetFormatString(format);
mLeftTime = new TimeTextCtrl(this, OnLeftTimeID, formatName, 0.0, mRate);
mLeftTime->SetName(_("Selection Start:"));
mLeftTime->EnableMenu();
mainSizer->Add(mLeftTime, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
mRightTime = new TimeTextCtrl(this, OnRightTimeID, format, 0.0, mRate);
mRightTime = new TimeTextCtrl(this, OnRightTimeID, formatName, 0.0, mRate);
mRightTime->SetName(wxString(_("Selection ")) + (showSelectionLength ?
_("Length") :
_("End")));
@ -273,7 +269,7 @@ void SelectionBar::Populate()
wxLI_VERTICAL),
0, wxRIGHT, 5);
mAudioTime = new TimeTextCtrl(this, -1, format, 0.0, mRate);
mAudioTime = new TimeTextCtrl(this, wxID_ANY, formatName, 0.0, mRate);
mAudioTime->SetName(_("Audio Position:"));
mAudioTime->EnableMenu();
mainSizer->Add(mAudioTime, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0);
@ -368,18 +364,17 @@ void SelectionBar::OnUpdate(wxCommandEvent &evt)
evt.Skip(false);
/* we don't actually need a TimeTextCtrl, but need it's
* translations which are done at runtime */
TimeTextCtrl *ttc = new TimeTextCtrl(this, wxID_ANY, wxT(""), 0.0, mRate);
wxString formatName(ttc->GetBuiltinName(index));
gPrefs->Write(wxT("/SelectionFormat"), formatName);
gPrefs->Flush();
#if wxUSE_TOOLTIPS
mSnapTo->SetToolTip(wxString::Format(_("Snap Clicks/Selections to %s"), formatName.c_str()));
#endif
delete ttc;
wxString format;
// Save format name before recreating the controls so they resize properly
format = mLeftTime->GetBuiltinName(index);
gPrefs->Write(wxT("/SelectionFormat"), format);
gPrefs->Flush();
#if wxUSE_TOOLTIPS
mSnapTo->SetToolTip(wxString::Format(_("Snap Clicks/Selections to %s"), format.c_str()));
#endif
// ToolBar::ReCreateButtons() will get rid of our sizers and controls
// so reset pointers first.
mLeftTime =
@ -396,10 +391,10 @@ void SelectionBar::OnUpdate(wxCommandEvent &evt)
ValuesToControls();
wxString formatString = mLeftTime->GetBuiltinFormat(index);
mLeftTime->SetFormatString(formatString);
mRightTime->SetFormatString(formatString);
mAudioTime->SetFormatString(formatString);
format = mLeftTime->GetBuiltinFormat(index);
mLeftTime->SetFormatString(format);
mRightTime->SetFormatString(format);
mAudioTime->SetFormatString(format);
if (leftFocus) {
mLeftTime->SetFocus();

View File

@ -46,18 +46,12 @@ void TimeEditor::Create(wxWindow *parent, wxWindowID id, wxEvtHandler *handler)
{
m_control = new TimeTextCtrl(parent,
wxID_ANY,
wxT(""),
mFormat,
mOld,
mRate,
wxDefaultPosition,
wxDefaultSize,
true);
/* look up provided format string name to a format string, then set that as
* the format string for the control. Unfortunately m_control is a base
* class pointer not a TimeTextCtrl pointer, so we have to cast it. It can't
* fail to cast, however unless the preceeding new operation failed, so it's
* reasonably safe. */
((TimeTextCtrl *)m_control)->SetFormatString(((TimeTextCtrl *)m_control)->GetBuiltinFormat(mFormat));
wxGridCellEditor::Create(parent, id, handler);
}
@ -164,13 +158,12 @@ void TimeRenderer::Draw(wxGrid &grid,
TimeTextCtrl tt(&grid,
wxID_ANY,
wxT(""),
te->GetFormat(),
value,
te->GetRate(),
wxPoint(10000, 10000), // create offscreen
wxDefaultSize,
true);
tt.SetFormatString(tt.GetBuiltinFormat(te->GetFormat()));
tstr = tt.GetTimeString();
te->DecRef();
@ -221,13 +214,12 @@ wxSize TimeRenderer::GetBestSize(wxGrid &grid,
table->GetValue(row, col).ToDouble(&value);
TimeTextCtrl tt(&grid,
wxID_ANY,
wxT(""),
te->GetFormat(),
value,
te->GetRate(),
wxPoint(10000, 10000), // create offscreen
wxDefaultSize,
true);
tt.SetFormatString(tt.GetBuiltinFormat(te->GetFormat()));
sz = tt.GetSize();
te->DecRef();
@ -742,13 +734,12 @@ wxAccStatus GridAx::GetName(int childId, wxString *name)
TimeTextCtrl tt(mGrid,
wxID_ANY,
wxT(""),
c->GetFormat(),
value,
c->GetRate(),
wxPoint(10000, 10000), // create offscreen
wxDefaultSize,
true);
tt.SetFormatString(tt.GetBuiltinFormat(c->GetFormat()));
v = tt.GetTimeString();
}

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,8 @@ DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_TIMETEXTCTRL_UPDATED, -1);
/** \brief struct to hold a formatting control string and it's user facing name
* Used in an array to hold the built-in time formats that are always available
* to the user */
struct BuiltinFormatString {
struct BuiltinFormatString
{
wxString name;
wxString formatStr;
};
@ -46,7 +47,49 @@ WX_DECLARE_OBJARRAY(DigitInfo, DigitInfoArray);
class TimeConverter
{
public:
TimeConverter();
TimeConverter::TimeConverter(const wxString & formatName = wxEmptyString,
double timeValue = 0.0f,
double sampleRate = 1.0f /* to prevent div by 0 */);
virtual void ValueToControls();
virtual void ValueToControls(double RawTime, bool nearest = true);
virtual void ControlsToValue();
virtual void ParseFormatString(const wxString & format);
void PrintDebugInfo();
void SetFormatString(const wxString & formatName);
void SetSampleRate(double sampleRate);
void SetTimeValue(double newTime);
double GetTimeValue();
wxString GetTimeString();
wxString GetFormatString();
int GetFormatIndex();
int GetNumBuiltins();
wxString GetBuiltinName(const int index);
wxString GetBuiltinFormat(const int index);
wxString GetBuiltinFormat(const wxString & name);
// Adjust the value by the number "steps" in the active format.
// Increment if "dir" is 1, descrement if "dir" is -1.
void Adjust(int steps, int dir);
void Increment();
void Decrement();
protected:
/** \brief array of formats the control knows about internally
* array of string pairs for name of the format and the format string
* needed to create that format output. This is used for the pop-up
* list of formats to choose from in the control. Note that the size will
* need adjusting if new time formats are added */
BuiltinFormatString BuiltinFormatStrings[16];
double mTimeValue;
wxString mFormatString;
TimeFieldArray mFields;
wxString mPrefix;
wxString mValueTemplate;
@ -57,13 +100,12 @@ public:
double mSampleRate;
bool mNtscDrop;
void ParseFormatString( const wxString & format );
void PrintDebugInfo();
void ValueToControls( double RawTime );
double ControlsToValue();
int mFocusedDigit;
DigitInfoArray mDigits;
};
class TimeTextCtrl: public wxControl{
class TimeTextCtrl: public wxControl, public TimeConverter
{
friend class TimeTextCtrlAx;
public:
@ -71,7 +113,7 @@ class TimeTextCtrl: public wxControl{
TimeTextCtrl(wxWindow *parent,
wxWindowID id,
wxString formatString = wxT(""),
wxString formatName = wxT(""),
double timeValue = 0.0,
double sampleRate = 44100,
const wxPoint &pos = wxDefaultPosition,
@ -83,23 +125,11 @@ class TimeTextCtrl: public wxControl{
virtual bool Layout();
virtual void Fit();
void SetFieldFocus(int digit);
void SetFormatString(wxString formatString);
void SetSampleRate(double sampleRate);
void SetTimeValue(double newTime);
void Increment();
void Decrement();
const double GetTimeValue();
void SetFormatString(const wxString & formatString);
wxString GetTimeString();
wxString GetFormatString();
int GetFormatIndex();
int GetNumBuiltins();
wxString GetBuiltinName(const int index);
wxString GetBuiltinFormat(const int index);
wxString GetBuiltinFormat(const wxString &name);
void SetFieldFocus(int digit);
void EnableMenu(bool enable = true);
@ -121,24 +151,13 @@ private:
void ValueToControls();
void ControlsToValue();
void PrintDebugInfo();
// If autoPos was enabled, focus the first non-zero digit
void UpdateAutoFocus();
void Updated(bool keyup = false);
void Increase(int steps);
void Decrease(int steps);
/** \brief array of formats the control knows about internally
* array of string pairs for name of the format and the format string
* needed to create that format output. This is used for the pop-up
* list of formats to choose from in the control. Note that the size will
* need adjusting if new time formats are added */
BuiltinFormatString BuiltinFormatStrings[16];
double mTimeValue;
private:
wxString mFormatString;
bool mMenuEnabled;
wxBitmap *mBackgroundBitmap;
@ -157,16 +176,11 @@ private:
int mHeight;
int mButtonWidth;
int mFocusedDigit;
int mLastField;
// If true, the focus will be set to the first non-zero digit
bool mAutoPos;
DigitInfoArray mDigits;
TimeConverter mConverter;
// Keeps track of extra fractional scrollwheel steps
double mScrollRemainder;