Skip to content

Commit

Permalink
Change various dialog's style (Open resource, quick outline, goto any…
Browse files Browse the repository at this point in the history
…thing)
  • Loading branch information
eranif committed Feb 25, 2020
1 parent 6b65668 commit 733f957
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 19 deletions.
38 changes: 28 additions & 10 deletions LiteEditor/quickoutlinedlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "windowattrmanager.h"

QuickOutlineDlg::QuickOutlineDlg(wxWindow* parent, int id, wxPoint pos, wxSize size, int style)
: wxDialog(parent, id, wxEmptyString, pos, size, wxRESIZE_BORDER)
: wxDialog(parent, id, wxEmptyString, pos, size, wxRESIZE_BORDER | wxCAPTION)
{
const wxColour& bgColour = DrawingUtils::GetColours().GetBgColour();
SetBackgroundColour(bgColour);
Expand Down Expand Up @@ -122,14 +122,18 @@ void QuickOutlineDlg::OnKeyDown(wxKeyEvent& e)
}
}
} else {
if(e.GetKeyCode() == WXK_ESCAPE) { DoHide(); }
if(e.GetKeyCode() == WXK_ESCAPE) {
DoHide();
}
}
}

bool QuickOutlineDlg::ParseActiveBuffer()
{
IEditor* editor = clGetManager()->GetActiveEditor();
if(!editor) { return false; }
if(!editor) {
return false;
}

wxString filename = editor->GetFileName().GetFullPath();
TagEntryPtrVector_t tags;
Expand All @@ -139,7 +143,9 @@ bool QuickOutlineDlg::ParseActiveBuffer()
TagsManagerST::Get()->GetFileCache()->Update(editor->GetFileName(), tags);
}

if(tags.empty()) { return false; }
if(tags.empty()) {
return false;
}
m_treeOutline->BuildTree(filename, tags);
m_treeOutline->ExpandAll();
wxTreeItemId selectItem = m_treeOutline->GetNextItem(m_treeOutline->GetRootItem());
Expand All @@ -152,17 +158,23 @@ void QuickOutlineDlg::DoFindNext()
{
m_treeOutline->ClearAllHighlights();
wxString find_what = m_searchCtrl->GetValue();
if(find_what.empty()) { return; }
if(find_what.empty()) {
return;
}

wxTreeItemId focusedItem = m_treeOutline->GetFocusedItem();
CHECK_ITEM_RET(focusedItem);

wxTreeItemId nextItem = m_treeOutline->GetNextItem(focusedItem);
if(!nextItem.IsOk()) { nextItem = focusedItem; }
if(!nextItem.IsOk()) {
nextItem = focusedItem;
}

wxTreeItemId item = m_treeOutline->FindNext(nextItem, find_what, 0, wxTR_SEARCH_DEFAULT);
// if we fail to move on, use the current focused item
if(!item.IsOk()) { item = m_treeOutline->FindPrev(focusedItem, find_what, 0, wxTR_SEARCH_DEFAULT); }
if(!item.IsOk()) {
item = m_treeOutline->FindPrev(focusedItem, find_what, 0, wxTR_SEARCH_DEFAULT);
}
if(item.IsOk()) {
m_treeOutline->SelectItem(item);
m_treeOutline->HighlightText(item, true);
Expand All @@ -174,17 +186,23 @@ void QuickOutlineDlg::DoFindPrev()
{
m_treeOutline->ClearAllHighlights();
wxString find_what = m_searchCtrl->GetValue();
if(find_what.empty()) { return; }
if(find_what.empty()) {
return;
}

wxTreeItemId focusedItem = m_treeOutline->GetFocusedItem();
CHECK_ITEM_RET(focusedItem);

wxTreeItemId prevItem = m_treeOutline->GetPrevItem(focusedItem);
if(!prevItem.IsOk()) { prevItem = focusedItem; }
if(!prevItem.IsOk()) {
prevItem = focusedItem;
}

wxTreeItemId item = m_treeOutline->FindPrev(prevItem, find_what, 0, wxTR_SEARCH_DEFAULT);
// if we fail to move on, use the current focused item
if(!item.IsOk()) { item = m_treeOutline->FindPrev(focusedItem, find_what, 0, wxTR_SEARCH_DEFAULT); }
if(!item.IsOk()) {
item = m_treeOutline->FindPrev(focusedItem, find_what, 0, wxTR_SEARCH_DEFAULT);
}
if(item.IsOk()) {
m_treeOutline->SelectItem(item);
m_treeOutline->HighlightText(item, true);
Expand Down
4 changes: 3 additions & 1 deletion Plugin/GotoAnythingBaseUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ GotoAnythingBaseDlg::GotoAnythingBaseDlg(wxWindow* parent, wxWindowID id, const

SetName(wxT("GotoAnythingBaseDlg"));
SetSize(wxDLG_UNIT(this, wxSize(-1, -1)));
if(GetSizer()) { GetSizer()->Fit(this); }
if(GetSizer()) {
GetSizer()->Fit(this);
}
if(GetParent()) {
CentreOnParent(wxBOTH);
} else {
Expand Down
2 changes: 1 addition & 1 deletion Plugin/GotoAnythingBaseUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class GotoAnythingBaseDlg : public wxDialog
clThemedListCtrl* GetDvListCtrl() { return m_dvListCtrl; }
GotoAnythingBaseDlg(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Goto Anything"),
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(-1, -1),
long style = wxBORDER_NONE);
long style = wxCAPTION | wxRESIZE_BORDER | wxBORDER_NONE);
virtual ~GotoAnythingBaseDlg();
};

Expand Down
2 changes: 1 addition & 1 deletion Plugin/GotoAnythingBaseUI.wxcp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"border": 5,
"gbSpan": "1,1",
"gbPosition": "0,0",
"m_styles": ["wxBORDER_NONE"],
"m_styles": ["wxCAPTION", "wxRESIZE_BORDER", "wxBORDER_NONE"],
"m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"],
"m_properties": [{
"type": "string",
Expand Down
10 changes: 6 additions & 4 deletions Plugin/openresourcedialogbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ OpenResourceDialogBase::OpenResourceDialogBase(wxWindow* parent, wxWindowID id,

m_textCtrlResourceName = new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition,
wxDLG_UNIT(this, wxSize(-1, -1)), wxTE_PROCESS_ENTER);
m_textCtrlResourceName->SetToolTip(_(
"Type resource name to open.\nYou may use a space delimited list of words to narrow down the list of "
"choices\ne.g. Typing: 'Open Dialog' will include results that contain both words \"Open\" _and_ \"Dialog\""));
m_textCtrlResourceName->SetToolTip(_("Type resource name to open.\nYou may use a space delimited list of words to "
"narrow down the list of choices\ne.g. Typing: 'Open Dialog' will include "
"results that contain both words \"Open\" _and_ \"Dialog\""));
m_textCtrlResourceName->SetFocus();
#if wxVERSION_NUMBER >= 3000
m_textCtrlResourceName->SetHint(wxT(""));
Expand Down Expand Up @@ -86,7 +86,9 @@ OpenResourceDialogBase::OpenResourceDialogBase(wxWindow* parent, wxWindowID id,

SetName(wxT("OpenResourceDialogBase"));
SetSize(wxDLG_UNIT(this, wxSize(-1, -1)));
if(GetSizer()) { GetSizer()->Fit(this); }
if(GetSizer()) {
GetSizer()->Fit(this);
}
if(GetParent()) {
CentreOnParent(wxBOTH);
} else {
Expand Down
3 changes: 2 additions & 1 deletion Plugin/openresourcedialogbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ class OpenResourceDialogBase : public wxDialog
wxCheckBox* GetCheckBoxFiles() { return m_checkBoxFiles; }
wxCheckBox* GetCheckBoxShowSymbols() { return m_checkBoxShowSymbols; }
OpenResourceDialogBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Open Resource"),
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(-1, -1), long style = 0);
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(-1, -1),
long style = wxCAPTION | wxRESIZE_BORDER);
virtual ~OpenResourceDialogBase();
};

Expand Down
2 changes: 1 addition & 1 deletion Plugin/openresourcedialogbase.wxcp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"border": 0,
"gbSpan": ",",
"gbPosition": ",",
"m_styles": [],
"m_styles": ["wxCAPTION", "wxRESIZE_BORDER"],
"m_sizerFlags": [],
"m_properties": [{
"type": "string",
Expand Down

0 comments on commit 733f957

Please sign in to comment.