Skip to content

Commit

Permalink
1. уточнение 4638.1: Dlg.* в раскрытом комбобоксе.
Browse files Browse the repository at this point in the history
  • Loading branch information
zg0 committed May 9, 2016
1 parent 89af403 commit a0d8769
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 36 deletions.
6 changes: 5 additions & 1 deletion far/changelog
@@ -1,4 +1,8 @@
zg 08.05.2016 13:27:59 +0200 - build 4665
zg 09.05.2016 14:00:08 +0200 - build 4666

1. уточнение 4638.1: Dlg.* в раскрытом комбобоксе.

zg 08.05.2016 13:27:59 +0200 - build 4665

1. уточнение 4638.1: макрообласть для комбобокса - "Dialog".

Expand Down
4 changes: 2 additions & 2 deletions far/dialog.cpp
Expand Up @@ -739,7 +739,7 @@ size_t Dialog::InitDialogObjects(size_t ID)
{
if (!DialogMode.Check(DMODE_OBJECTS_CREATED))
{
Items[I].ListPtr = VMenu::create({}, nullptr, 0, Items[I].Y2 - Items[I].Y1 + 1, VMENU_ALWAYSSCROLLBAR | VMENU_LISTBOX, this);
Items[I].ListPtr = VMenu::create({}, nullptr, 0, Items[I].Y2 - Items[I].Y1 + 1, VMENU_ALWAYSSCROLLBAR | VMENU_LISTBOX, std::static_pointer_cast<Dialog>(shared_from_this()));
}

auto& ListPtr = Items[I].ListPtr;
Expand Down Expand Up @@ -793,7 +793,7 @@ size_t Dialog::InitDialogObjects(size_t ID)

if (Type == DI_COMBOBOX)
{
Items[I].ListPtr = VMenu::create({}, nullptr, 0, Global->Opt->Dialogs.CBoxMaxHeight, VMENU_ALWAYSSCROLLBAR, this);
Items[I].ListPtr = VMenu::create({}, nullptr, 0, Global->Opt->Dialogs.CBoxMaxHeight, VMENU_ALWAYSSCROLLBAR, std::static_pointer_cast<Dialog>(shared_from_this()));
Items[I].ListPtr->SetVDialogItemID(I);
}
}
Expand Down
13 changes: 9 additions & 4 deletions far/macro.cpp
Expand Up @@ -1668,11 +1668,16 @@ intptr_t KeyMacro::CallFar(intptr_t CheckCode, FarMacroCall* Data)
case MCODE_V_DLGINFOID: // Dlg->Info.Id
case MCODE_V_DLGINFOOWNER: // Dlg->Info.Owner
{
if (CurrentWindow && CurrentWindow->GetType()==windowtype_menu)
if (CurrentWindow && CurrentWindow)
{
int idx = Global->WindowManager->IndexOfStack(CurrentWindow);
if(idx>0)
CurrentWindow = Global->WindowManager->GetModalWindow(idx-1);
if (CurrentWindow->GetType()==windowtype_menu)
{
int idx = Global->WindowManager->IndexOfStack(CurrentWindow);
if(idx>0)
CurrentWindow = Global->WindowManager->GetModalWindow(idx-1);
}
else if (CurrentWindow->GetType()==windowtype_combobox)
CurrentWindow = std::static_pointer_cast<VMenu>(CurrentWindow)->GetDialog();
}
if (!CurrentWindow || CurrentWindow->GetType()!=windowtype_dialog)
return (CheckCode==MCODE_V_DLGINFOID || CheckCode==MCODE_V_DLGINFOOWNER) ? PassString(L"", Data) : 0;
Expand Down
2 changes: 1 addition & 1 deletion far/plugapi.cpp
Expand Up @@ -718,7 +718,7 @@ intptr_t WINAPI apiAdvControl(const GUID* PluginId, ADVANCED_CONTROL_COMMANDS Co
wi->Id=(intptr_t)f.get(); // BUGBUG
break;
case WTYPE_COMBOBOX:
wi->Id=(intptr_t)std::static_pointer_cast<VMenu>(f)->GetDialog(); // BUGBUG
wi->Id=(intptr_t)std::static_pointer_cast<VMenu>(f)->GetDialog().get(); // BUGBUG
break;
default:
wi->Id=0;
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
@@ -1 +1 @@
m4_define(BUILD,4665)m4_dnl
m4_define(BUILD,4666)m4_dnl
45 changes: 23 additions & 22 deletions far/vmenu.cpp
Expand Up @@ -68,7 +68,7 @@ MenuItemEx FarList2MenuItem(const FarListItem& FItem)
return Result;
}

VMenu::VMenu(private_tag, const string& Title, int MaxHeight, Dialog *ParentDialog) :
VMenu::VMenu(private_tag, const string& Title, int MaxHeight, dialog_ptr ParentDialog) :
strTitle(Title),
SelectPos(-1),
SelectPosResult(-1),
Expand All @@ -91,7 +91,7 @@ VMenu::VMenu(private_tag, const string& Title, int MaxHeight, Dialog *ParentDial
{
}

vmenu_ptr VMenu::create(const string& Title, const MenuDataEx *Data, int ItemCount, int MaxHeight, DWORD Flags, Dialog *ParentDialog)
vmenu_ptr VMenu::create(const string& Title, const MenuDataEx *Data, int ItemCount, int MaxHeight, DWORD Flags, dialog_ptr ParentDialog)
{
auto VmenuPtr = std::make_shared<VMenu>(private_tag(), Title, MaxHeight, ParentDialog);
VmenuPtr->init(Data, ItemCount, Flags);
Expand Down Expand Up @@ -282,7 +282,8 @@ int VMenu::SetSelectPos(int Pos, int Direct, bool stop_on_edge)
if (stop_on_edge && CheckFlags(VMENU_WRAPMODE) && ((Direct > 0 && Pos < SelectPos) || (Direct<0 && Pos>SelectPos)))
Pos = SelectPos;

if (Pos != SelectPos && ParentDialog && !ParentDialog->CheckDialogMode(DMODE_ISMENU) && CheckFlags(VMENU_COMBOBOX|VMENU_LISTBOX) && ParentDialog->IsInited() && !ParentDialog->SendMessage(DN_LISTCHANGE, DialogItemID, ToPtr(Pos)))
auto Parent = GetDialog();
if (Pos != SelectPos && Parent && !Parent->CheckDialogMode(DMODE_ISMENU) && CheckFlags(VMENU_COMBOBOX|VMENU_LISTBOX) && Parent->IsInited() && !Parent->SendMessage(DN_LISTCHANGE, DialogItemID, ToPtr(Pos)))
{
UpdateItemFlags(SelectPos, Items[SelectPos].Flags|LIF_SELECTED);
return -1;
Expand Down Expand Up @@ -714,9 +715,7 @@ void VMenu::FilterStringUpdated()

void VMenu::FilterUpdateHeight(bool bShrink)
{
VMenu2 *Parent = nullptr;
if (ParentDialog && ParentDialog->GetType() == windowtype_menu)
Parent = static_cast<VMenu2*>(ParentDialog);
auto Parent = std::dynamic_pointer_cast<VMenu2>(GetDialog());

if (WasAutoHeight || Parent)
{
Expand All @@ -729,9 +728,9 @@ void VMenu::FilterUpdateHeight(bool bShrink)
NewY2 = ScrY;
if (NewY2 > m_Y2 || (bShrink && NewY2 < m_Y2))
{
if (Parent)
if (Parent)
Parent->Resize();
else
else
SetPosition(m_X1,m_Y1,m_X2,NewY2);
}
}
Expand Down Expand Up @@ -1104,7 +1103,8 @@ int VMenu::ProcessKey(const Manager::Key& Key)
auto LocalKey = Key();
SCOPED_ACTION(CriticalSectionLock)(CS);

if (IsComboBox() && !ParentDialog->GetDropDownOpened())
auto Parent = GetDialog();
if (IsComboBox() && !Parent->GetDropDownOpened())
{
Close(-1);
return FALSE;
Expand All @@ -1113,7 +1113,7 @@ int VMenu::ProcessKey(const Manager::Key& Key)
if (IsComboBox() && CheckFlags(VMENU_COMBOBOXEVENTKEY))
{
auto Event = Key.Event();
if (!ParentDialog->DlgProc(DN_INPUT, 0, &Event))
if (!Parent->DlgProc(DN_INPUT, 0, &Event))
return TRUE;
}

Expand All @@ -1123,7 +1123,7 @@ int VMenu::ProcessKey(const Manager::Key& Key)
if (IsComboBox() && CheckFlags(VMENU_COMBOBOXEVENTKEY))
{
auto Event = Key.Event();
if (ParentDialog->DlgProc(DN_CONTROLINPUT, ParentDialog->GetDlgFocusPos(), &Event))
if (Parent->DlgProc(DN_CONTROLINPUT, Parent->GetDlgFocusPos(), &Event))
return TRUE;
}

Expand Down Expand Up @@ -1201,7 +1201,7 @@ int VMenu::ProcessKey(const Manager::Key& Key)
case KEY_NUMENTER:
case KEY_ENTER:
{
if (!ParentDialog || CheckFlags(VMENU_COMBOBOX))
if (!Parent || CheckFlags(VMENU_COMBOBOX))
ProcessEnter();
break;
}
Expand All @@ -1212,7 +1212,7 @@ int VMenu::ProcessKey(const Manager::Key& Key)
{
Close(-1);
}
else if(!ParentDialog)
else if(!Parent)
{
SetExitCode(-1);
}
Expand Down Expand Up @@ -1453,11 +1453,11 @@ int VMenu::ProcessKey(const Manager::Key& Key)
int NewPos=SelectPos;

bool IsHotkey=true;
if (!CheckKeyHiOrAcc(LocalKey, 0, 0, !(ParentDialog && !ParentDialog->CheckDialogMode(DMODE_ISMENU) && CheckFlags(VMENU_COMBOBOX | VMENU_LISTBOX)), NewPos))
if (!CheckKeyHiOrAcc(LocalKey, 0, 0, !(Parent && !Parent->CheckDialogMode(DMODE_ISMENU) && CheckFlags(VMENU_COMBOBOX | VMENU_LISTBOX)), NewPos))
{
if (LocalKey == KEY_SHIFTF1 || LocalKey == KEY_F1)
{
if (ParentDialog)
if (Parent)
;//ParentDialog->ProcessKey(Key);
else
ShowHelp();
Expand All @@ -1466,15 +1466,15 @@ int VMenu::ProcessKey(const Manager::Key& Key)
}
else
{
if (!CheckKeyHiOrAcc(LocalKey,1,FALSE,!(ParentDialog && !ParentDialog->CheckDialogMode(DMODE_ISMENU) && CheckFlags(VMENU_COMBOBOX|VMENU_LISTBOX)),NewPos))
if (!CheckKeyHiOrAcc(LocalKey,1,TRUE,!(ParentDialog && !ParentDialog->CheckDialogMode(DMODE_ISMENU) && CheckFlags(VMENU_COMBOBOX|VMENU_LISTBOX)),NewPos))
if (!CheckKeyHiOrAcc(LocalKey,1,FALSE,!(Parent && !Parent->CheckDialogMode(DMODE_ISMENU) && CheckFlags(VMENU_COMBOBOX|VMENU_LISTBOX)),NewPos))
if (!CheckKeyHiOrAcc(LocalKey,1,TRUE,!(Parent && !Parent->CheckDialogMode(DMODE_ISMENU) && CheckFlags(VMENU_COMBOBOX|VMENU_LISTBOX)),NewPos))
IsHotkey=false;
}
}

if (IsHotkey && ParentDialog)
if (IsHotkey && Parent)
{
if (ParentDialog->SendMessage(DN_LISTHOTKEY,DialogItemID,ToPtr(NewPos)))
if (Parent->SendMessage(DN_LISTHOTKEY,DialogItemID,ToPtr(NewPos)))
{
ShowMenu(true);
ClearDone();
Expand Down Expand Up @@ -1506,7 +1506,8 @@ int VMenu::ProcessMouse(const MOUSE_EVENT_RECORD *MouseEvent)
{
SCOPED_ACTION(CriticalSectionLock)(CS);

if (IsComboBox() && !ParentDialog->GetDropDownOpened())
auto Parent = GetDialog();
if (IsComboBox() && !Parent->GetDropDownOpened())
{
Close(-1);
return FALSE;
Expand All @@ -1519,7 +1520,7 @@ int VMenu::ProcessMouse(const MOUSE_EVENT_RECORD *MouseEvent)
INPUT_RECORD Event = {};
Event.EventType = MOUSE_EVENT;
Event.Event.MouseEvent = *MouseEvent;
if (!ParentDialog->DlgProc(DN_INPUT, 0, &Event))
if (!Parent->DlgProc(DN_INPUT, 0, &Event))
return TRUE;
}

Expand Down Expand Up @@ -2522,7 +2523,7 @@ bool VMenu::CheckKeyHiOrAcc(DWORD Key, int Type, int Translate,bool ChangePos, i
ShowMenu(true);
}

if ((!ParentDialog || CheckFlags(VMENU_COMBOBOX|VMENU_LISTBOX)) && ItemCanBeEntered(Items[SelectPos].Flags))
if ((!GetDialog() || CheckFlags(VMENU_COMBOBOX|VMENU_LISTBOX)) && ItemCanBeEntered(Items[SelectPos].Flags))
{
SetExitCode(NewPos);
}
Expand Down
10 changes: 5 additions & 5 deletions far/vmenu.hpp
Expand Up @@ -181,9 +181,9 @@ class VMenu: public SimpleModal
{
struct private_tag {};
public:
static vmenu_ptr create(const string& Title, const MenuDataEx *Data, int ItemCount, int MaxHeight = 0, DWORD Flags = 0, Dialog *ParentDialog = nullptr);
static vmenu_ptr create(const string& Title, const MenuDataEx *Data, int ItemCount, int MaxHeight = 0, DWORD Flags = 0, dialog_ptr ParentDialog = nullptr);

VMenu(private_tag, const string& Title, int MaxHeight, Dialog *ParentDialog);
VMenu(private_tag, const string& Title, int MaxHeight, dialog_ptr ParentDialog);
virtual ~VMenu();

virtual void Show() override;
Expand Down Expand Up @@ -263,8 +263,8 @@ class VMenu: public SimpleModal
void SetVDialogItemID(size_t NewDialogItemID) { DialogItemID = NewDialogItemID; }
void SetId(const GUID& Id);
const GUID& Id() const;
bool IsComboBox() const { return ParentDialog && CheckFlags(VMENU_COMBOBOX); }
Dialog *GetDialog() {return ParentDialog;}
bool IsComboBox() const { return GetDialog() && CheckFlags(VMENU_COMBOBOX); }
dialog_ptr GetDialog() const {return ParentDialog.lock();}

template<class predicate>
void SortItems(predicate Pred, bool Reverse = false, int Offset = 0)
Expand Down Expand Up @@ -322,7 +322,7 @@ class VMenu: public SimpleModal
BitFlags VMFlags;
BitFlags VMOldFlags;
// Для LisBox - родитель в виде диалога
Dialog *ParentDialog;
std::weak_ptr<Dialog> ParentDialog;
size_t DialogItemID;
mutable CriticalSection CS;
bool bFilterEnabled;
Expand Down

0 comments on commit a0d8769

Please sign in to comment.