Skip to content

Commit

Permalink
Merge branch 'devel/nvda-static-ids'
Browse files Browse the repository at this point in the history
  • Loading branch information
vslavik committed Aug 21, 2024
2 parents f12937f + d89f226 commit 5d365cd
Show file tree
Hide file tree
Showing 15 changed files with 132 additions and 51 deletions.
1 change: 1 addition & 0 deletions Poedit.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
<ClInclude Include="src\recent_files.h" />
<ClInclude Include="src\sidebar.h" />
<ClInclude Include="src\spellchecking.h" />
<ClInclude Include="src\static_ids.h" />
<ClInclude Include="src\str_helpers.h" />
<ClInclude Include="src\syntaxhighlighter.h" />
<ClInclude Include="src\text_control.h" />
Expand Down
3 changes: 3 additions & 0 deletions Poedit.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,9 @@
<ClInclude Include="src\app_updates.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\static_ids.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="src\poedit.rc">
Expand Down
2 changes: 2 additions & 0 deletions Poedit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@
B224558419A3B11400120FFE /* bs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = bs; path = bs.lproj/InfoPlist.strings; sourceTree = "<group>"; };
B224558619A3B16300120FFE /* gl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = gl; path = gl.lproj/InfoPlist.strings; sourceTree = "<group>"; };
B224558819A3B18D00120FFE /* ms */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ms; path = ms.lproj/MoveApplication.strings; sourceTree = "<group>"; };
B228096E2C4AD007005F2CA3 /* static_ids.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = static_ids.h; sourceTree = "<group>"; };
B2284A50183BE3B300E097C7 /* PFMoveApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PFMoveApplication.h; path = deps/letsmove/PFMoveApplication.h; sourceTree = "<group>"; };
B2284A51183BE3B300E097C7 /* PFMoveApplication.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PFMoveApplication.m; path = deps/letsmove/PFMoveApplication.m; sourceTree = "<group>"; };
B2284A54183BE68200E097C7 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -813,6 +814,7 @@
B2DFCCFA19B5FD15003DFAD0 /* sidebar.h */,
B2F25F0C199E327C00127FF9 /* spellchecking.cpp */,
B2F25F0B199E23B300127FF9 /* spellchecking.h */,
B228096E2C4AD007005F2CA3 /* static_ids.h */,
B2E2184A199A76B100EA2784 /* syntaxhighlighter.cpp */,
B2E2184B199A76B100EA2784 /* syntaxhighlighter.h */,
B2E11F101A2C66FB00E4E42C /* text_control.cpp */,
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ poedit_SOURCES = \
recent_files.cpp recent_files.h \
sidebar.cpp sidebar.h \
spellchecking.h spellchecking.cpp \
static_ids.h \
str_helpers.h \
syntaxhighlighter.cpp syntaxhighlighter.h \
text_control.h text_control.cpp \
Expand Down
2 changes: 1 addition & 1 deletion src/attentionbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ AttentionBar::AttentionBar(wxWindow *parent)
#ifdef __WXMSW__
m_icon = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap);
#endif
m_label = new AutoWrappingText(this, "");
m_label = new AutoWrappingText(this, wxID_ANY, "");
m_explanation = new ExplanationLabel(this, "");
m_buttons = new wxBoxSizer(wxHORIZONTAL);
m_checkbox = new wxCheckBox(this, wxID_ANY, "");
Expand Down
12 changes: 6 additions & 6 deletions src/customcontrols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ HeadingLabel::HeadingLabel(wxWindow *parent, const wxString& label)
}


AutoWrappingText::AutoWrappingText(wxWindow *parent, const wxString& label)
: wxStaticText(parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxST_NO_AUTORESIZE),
AutoWrappingText::AutoWrappingText(wxWindow *parent, wxWindowID winid, const wxString& label)
: wxStaticText(parent, winid, "", wxDefaultPosition, wxDefaultSize, wxST_NO_AUTORESIZE),
m_text(label),
m_wrapWidth(-1)
{
Expand Down Expand Up @@ -262,8 +262,8 @@ bool AutoWrappingText::RewrapForWidth(int width)
}


SelectableAutoWrappingText::SelectableAutoWrappingText(wxWindow *parent, const wxString& label)
: AutoWrappingText(parent, label)
SelectableAutoWrappingText::SelectableAutoWrappingText(wxWindow *parent, wxWindowID winid, const wxString& label)
: AutoWrappingText(parent, winid, label)
{
#if defined(__WXOSX__)
NSTextField *view = (NSTextField*)GetHandle();
Expand All @@ -273,7 +273,7 @@ SelectableAutoWrappingText::SelectableAutoWrappingText(wxWindow *parent, const w
gtk_label_set_selectable(view, TRUE);
#else
// at least allow copying
static wxWindowID idCopy = wxNewId();
static wxWindowIDRef idCopy = NewControlId();
Bind(wxEVT_CONTEXT_MENU, [=](wxContextMenuEvent&){
wxMenu menu;
menu.Append(idCopy, _("&Copy"));
Expand All @@ -288,7 +288,7 @@ SelectableAutoWrappingText::SelectableAutoWrappingText(wxWindow *parent, const w


ExplanationLabel::ExplanationLabel(wxWindow *parent, const wxString& label)
: AutoWrappingText(parent, label)
: AutoWrappingText(parent, wxID_ANY, label)
{
#if defined(__WXOSX__) || defined(__WXGTK__)
SetWindowVariant(wxWINDOW_VARIANT_SMALL);
Expand Down
4 changes: 2 additions & 2 deletions src/customcontrols.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class HeadingLabel : public wxStaticText
class AutoWrappingText : public wxStaticText
{
public:
AutoWrappingText(wxWindow *parent, const wxString& label);
AutoWrappingText(wxWindow *parent, wxWindowID winid, const wxString& label);

void SetLanguage(Language lang);
void SetAlignment(TextDirection dir);
Expand Down Expand Up @@ -121,7 +121,7 @@ class WindowWith2DSizingConstraints : public Base
class SelectableAutoWrappingText : public AutoWrappingText
{
public:
SelectableAutoWrappingText(wxWindow *parent, const wxString& label);
SelectableAutoWrappingText(wxWindow *parent, wxWindowID winid, const wxString& label);
};


Expand Down
30 changes: 7 additions & 23 deletions src/edframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
#include "recent_files.h"
#include "sidebar.h"
#include "spellchecking.h"
#include "static_ids.h"
#include "str_helpers.h"


Expand Down Expand Up @@ -222,19 +223,8 @@ class ThinSplitter : public wxSplitterWindow

} // anonymous namespace

// this should be high enough to not conflict with any wxNewId-allocated value,
PoeditFrame::PoeditFramesList PoeditFrame::ms_instances;

// but there's a check for this in the PoeditFrame ctor, too
const wxWindowID ID_POEDIT_FIRST = wxID_HIGHEST + 10000;
const unsigned ID_POEDIT_STEP = 1000;

const wxWindowID ID_POPUP_REFS = ID_POEDIT_FIRST + 1*ID_POEDIT_STEP;
const wxWindowID ID_POPUP_DUMMY = ID_POEDIT_FIRST + 3*ID_POEDIT_STEP;

const wxWindowID ID_POEDIT_LAST = ID_POEDIT_FIRST + 4*ID_POEDIT_STEP;


#ifdef __VISUALC__
// Disabling the useless and annoying MSVC++'s
// warning C4800: 'long' : forcing value to bool 'true' or 'false'
Expand Down Expand Up @@ -357,7 +347,7 @@ BEGIN_EVENT_TABLE(PoeditFrame, wxFrame)
EVT_MENU (XRCID("go_next_unfinished"), PoeditFrame::OnNextUnfinished)
EVT_MENU (XRCID("go_prev_pluralform"), PoeditFrame::OnPrevPluralForm)
EVT_MENU (XRCID("go_next_pluralform"), PoeditFrame::OnNextPluralForm)
EVT_MENU_RANGE (ID_POPUP_REFS, ID_POPUP_REFS + 999, PoeditFrame::OnReference)
EVT_MENU_RANGE (WinID::ListContextReferencesStart, WinID::ListContextReferencesEnd, PoeditFrame::OnReference)
EVT_COMMAND (wxID_ANY, EVT_SUGGESTION_SELECTED, PoeditFrame::OnSuggestion)
EVT_MENU (XRCID("menu_pretranslate"), PoeditFrame::OnPreTranslateAll)
EVT_CLOSE (PoeditFrame::OnCloseWindow)
Expand Down Expand Up @@ -482,13 +472,6 @@ PoeditFrame::PoeditFrame() :
m_sidebarSplitter = nullptr;
m_sidebar = nullptr;

// make sure that the [ID_POEDIT_FIRST,ID_POEDIT_LAST] range of IDs is not
// used for anything else:
wxASSERT_MSG( wxGetCurrentId() < ID_POEDIT_FIRST ||
wxGetCurrentId() > ID_POEDIT_LAST,
"detected ID values conflict!" );
wxRegisterId(ID_POEDIT_LAST);

wxConfigBase *cfg = wxConfig::Get();

m_displayIDs = (bool)cfg->Read("display_lines", (long)false);
Expand Down Expand Up @@ -2059,7 +2042,7 @@ void PoeditFrame::OnReferencesMenuUpdate(wxUpdateUIEvent& event)

void PoeditFrame::OnReference(wxCommandEvent& event)
{
ShowReference(event.GetId() - ID_POPUP_REFS);
ShowReference(event.GetId() - WinID::ListContextReferencesStart);
}


Expand Down Expand Up @@ -3018,7 +3001,7 @@ wxMenu *PoeditFrame::CreatePopupMenu(int item)
{
menu->AppendSeparator();
// TRANSLATORS: Meaning occurrences of the string in source code
wxMenuItem *it1 = new wxMenuItem(menu, ID_POPUP_DUMMY+0, MSW_OR_OTHER(_("Code occurrences"), _("Code Occurrences")));
wxMenuItem *it1 = new wxMenuItem(menu, wxID_ANY, MSW_OR_OTHER(_("Code occurrences"), _("Code Occurrences")));
#ifdef __WXMSW__
it1->SetFont(it1->GetFont().Bold());
menu->Append(it1);
Expand All @@ -3027,8 +3010,9 @@ wxMenu *PoeditFrame::CreatePopupMenu(int item)
it1->Enable(false);
#endif

for (int i = 0; i < (int)refs.GetCount(); i++)
menu->Append(ID_POPUP_REFS + i, " " + refs[i]);
int count = std::min((int)refs.GetCount(), WinID::ListContextReferencesEnd - WinID::ListContextReferencesStart);
for (int i = 0; i < count; i++)
menu->Append(WinID::ListContextReferencesStart + i, " " + refs[i]);
}

return menu;
Expand Down
9 changes: 5 additions & 4 deletions src/editing_area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "edlistctrl.h"
#include "hidpi.h"
#include "spellchecking.h"
#include "static_ids.h"
#include "text_control.h"
#include "utility.h"

Expand Down Expand Up @@ -179,11 +180,11 @@ class EditingArea::TagLabel : public wxWindow
Ellipsize
};

TagLabel(wxWindow *parent, Color fg, Color bg) : wxWindow(parent, wxID_ANY)
TagLabel(wxWindow *parent, Color fg, Color bg, wxWindowID labelChildID = wxID_ANY) : wxWindow(parent, wxID_ANY)
{
m_icon = nullptr;

m_label = new wxStaticText(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
m_label = new wxStaticText(this, labelChildID, "", wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
#ifdef __WXOSX__
m_label->SetWindowVariant(wxWINDOW_VARIANT_SMALL);
#endif
Expand Down Expand Up @@ -299,7 +300,7 @@ class EditingArea::IssueLabel : public EditingArea::TagLabel
{
public:
IssueLabel(wxWindow *parent)
: TagLabel(parent, Color::TagErrorLineFg, Color::TagErrorLineBg)
: TagLabel(parent, Color::TagErrorLineFg, Color::TagErrorLineBg, WinID::TranslationIssueText)
{
m_iconError = wxArtProvider::GetBitmap("StatusErrorBlack");
m_iconWarning = wxArtProvider::GetBitmap("StatusWarningBlack");
Expand Down Expand Up @@ -497,7 +498,7 @@ void EditingArea::CreateEditControls(wxBoxSizer *sizer)
// "needs review" implies that somebody else should review the string after
// I am done with it (i.e. consider it good), while "needs work" implies I
// need to return to it and finish the translation.
m_fuzzy = new SwitchButton(this, wxID_ANY, MSW_OR_OTHER(_("Needs work"), _("Needs Work")));
m_fuzzy = new SwitchButton(this, WinID::NeedsWorkSwitch, MSW_OR_OTHER(_("Needs work"), _("Needs Work")));
#ifdef __WXOSX__
m_fuzzy->SetWindowVariant(wxWINDOW_VARIANT_SMALL);
#endif
Expand Down
8 changes: 4 additions & 4 deletions src/prefsdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,10 @@ class TMPageWindow : public PrefsPanel

void OnManageTM(wxCommandEvent& e)
{
static const auto idLearn = wxNewId();
static const auto idImportTMX = wxNewId();
static const auto idExportTMX = wxNewId();
static const auto idReset = wxNewId();
static wxWindowIDRef idLearn = NewControlId();
static wxWindowIDRef idImportTMX = NewControlId();
static wxWindowIDRef idExportTMX = NewControlId();
static wxWindowIDRef idReset = NewControlId();

wxMenu menu;
#ifdef __WXOSX__
Expand Down
8 changes: 4 additions & 4 deletions src/propertiesdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,9 @@ class PropertiesDialog::PathsList : public wxPanel

void OnAddMenu(wxCommandEvent& e)
{
static const auto idFolder = wxNewId();
static const auto idFile = wxNewId();
static const auto idWild = wxNewId();
static wxWindowIDRef idFolder = NewControlId();
static wxWindowIDRef idFile = NewControlId();
static wxWindowIDRef idWild = NewControlId();

wxMenu *menu = new wxMenu();
#ifdef __WXOSX__
Expand Down Expand Up @@ -473,7 +473,7 @@ class PropertiesDialog::PathsList : public wxPanel

event.Skip(false);

static wxWindowID idShowInFolder = wxNewId();
static wxWindowIDRef idShowInFolder = NewControlId();
wxMenu menu;
auto menuItem = menu.Append(idShowInFolder,
#if defined(__WXOSX__)
Expand Down
2 changes: 1 addition & 1 deletion src/recent_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ class RecentFiles::impl
};

private:
const wxWindowID m_idClear = wxNewId();
wxWindowIDRef m_idClear = wxWindow::NewControlId();

file_icons_ptr m_icons_cache;
MyHistory m_history;
Expand Down
11 changes: 6 additions & 5 deletions src/sidebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "configuration.h"
#include "errors.h"
#include "hidpi.h"
#include "static_ids.h"
#include "utility.h"
#include "unicode_helpers.h"

Expand Down Expand Up @@ -136,7 +137,7 @@ class OldMsgidSidebarBlock : public SidebarBlock
m_innerSizer->Add(new ExplanationLabel(parent, _("The old source text (before it changed during an update) that the now-inaccurate translation corresponds to.")),
wxSizerFlags().Expand());
m_innerSizer->AddSpacer(PX(5));
m_text = new SelectableAutoWrappingText(parent, "");
m_text = new SelectableAutoWrappingText(parent, WinID::PreviousSourceText, "");
m_innerSizer->Add(m_text, wxSizerFlags().Expand());
}

Expand All @@ -162,7 +163,7 @@ class ExtractedCommentSidebarBlock : public SidebarBlock
: SidebarBlock(parent, _("Notes for translators"))
{
m_innerSizer->AddSpacer(PX(5));
m_comment = new SelectableAutoWrappingText(parent, "");
m_comment = new SelectableAutoWrappingText(parent, WinID::NotesForTranslator, "");
m_innerSizer->Add(m_comment, wxSizerFlags().Expand());
}

Expand Down Expand Up @@ -195,7 +196,7 @@ class CommentSidebarBlock : public SidebarBlock
: SidebarBlock(parent, _("Comment"))
{
m_innerSizer->AddSpacer(PX(5));
m_comment = new SelectableAutoWrappingText(parent, "");
m_comment = new SelectableAutoWrappingText(parent, WinID::TranslatorComment, "");
m_innerSizer->Add(m_comment, wxSizerFlags().Expand());
}

Expand Down Expand Up @@ -266,7 +267,7 @@ class SuggestionWidget : public wxWindow
m_parentBlock = block;
m_isHighlighted = false;
m_icon = new StaticBitmap(this, "SuggestionTMTemplate");
m_text = new AutoWrappingText(this, "TEXT");
m_text = new AutoWrappingText(this, wxID_ANY, "TEXT");
m_info = new InfoStaticText(this);
m_moreActions = new ImageButton(this, "DownvoteTemplate");

Expand Down Expand Up @@ -474,7 +475,7 @@ class SuggestionWidget : public wxWindow

auto sidebar = m_sidebar;
auto suggestion = m_value;
static const auto idDelete = wxNewId();
static wxWindowIDRef idDelete = NewControlId();

wxMenu menu;
#ifdef __WXOSX__
Expand Down
Loading

0 comments on commit 5d365cd

Please sign in to comment.