00001
00002
00029 #include <config.h>
00030 #include "hugin_utils/utils.h"
00031 #include "panoinc_WX.h"
00032
00033 #include "hugin/LocalizedFileTipProvider.h"
00034
00035
00036 LocalizedFileTipProvider::LocalizedFileTipProvider(const wxString& filename,
00037 size_t currentTip)
00038 : wxTipProvider(currentTip), m_textfile(filename)
00039 {
00040 m_textfile.Open();
00041 }
00042
00043 wxString LocalizedFileTipProvider::GetTip()
00044 {
00045 size_t count = m_textfile.GetLineCount();
00046 if ( !count )
00047 {
00048 return _("Tips not available, sorry!");
00049 }
00050
00051 wxString tip;
00052
00053
00054
00055
00056
00057
00058
00059 for ( size_t i=0; i < count; i++ )
00060 {
00061
00062
00063
00064
00065 if ( m_currentTip >= count )
00066 {
00067
00068 m_currentTip = 0;
00069 }
00070
00071
00072 tip = m_textfile.GetLine(m_currentTip++);
00073
00074
00075
00076 tip = PreprocessTip(tip);
00077
00078
00079
00080 if ( !tip.StartsWith(wxT("#")) && (tip.Trim() != wxEmptyString) )
00081 {
00082 break;
00083 }
00084 }
00085
00086
00087
00088 if ( tip.StartsWith(wxT("_(\"" ), &tip))
00089 {
00090
00091 tip = tip.BeforeLast(wxT('\"'));
00092
00093 tip.Replace(wxT("\\\""), wxT("\""));
00094
00095 DEBUG_DEBUG("Tip before translation " << tip);
00096
00097 tip = wxGetTranslation(tip);
00098 DEBUG_DEBUG("Tip after translation " << tip);
00099 }
00100
00101 return tip;
00102 }
00103
00104 #ifdef ThisNeverHappens
00105
00106 wxLogMessage(_("&Next Tip"));
00107 wxLogMessage(_("&Show tips at startup"));
00108 wxLogMessage(_("Tip of the Day"));
00109 wxLogMessage(_("&Close"));
00110 wxLogMessaeg(_("Did you know..."));
00111 #endif