// File: /workspace/github_c_makefile_star2_O1/enzo1982[P]smooth/classes/gui/widgets/multi/menu/popupmenu.cpp
// Function: smooth::GUI::PopupMenu::CalculateSize()
S::Void S::GUI::PopupMenu::CalculateSize()
{
	SetSize(Size(50, 5));

	Int	 nextYPos		= 3;
	Int	 maxShortcutTextSize	= 0;

	for (Int i = 0; i < Length(); i++)
	{
		PopupMenuEntry	*entry = (PopupMenuEntry *) GetNthEntry(i);

		if (entry->GetObjectType() != PopupMenuEntry::classID) continue;

		maxShortcutTextSize = Math::Max(maxShortcutTextSize, entry->GetShortcutTextSize());
	}

	for (Int i = 0; i < Length(); i++)
	{
		PopupMenuEntry	*entry = (PopupMenuEntry *) GetNthEntry(i);

		if (entry->GetObjectType() != PopupMenuEntry::classID) continue;

		SetWidth(Math::Max(GetWidth(), 6 + entry->GetMinimumSize().cx - (entry->GetShortcutTextSize() > 0 ? entry->GetShortcutTextSize() - maxShortcutTextSize : 0)));
		SetHeight(GetHeight() + 5 + (entry->GetText() != NIL ? 11 : 0));

		entry->SetPosition(Point(3, nextYPos));

		nextYPos += entry->GetHeight() + 1;
	}

	for (Int i = 0; i < Length(); i++)
	{
		PopupMenuEntry	*entry = (PopupMenuEntry *) GetNthEntry(i);

		if (entry->GetObjectType() != PopupMenuEntry::classID) continue;

		entry->SetWidth(GetWidth() - 6);
		entry->SetShortcutOffset(maxShortcutTextSize + 21);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movabsq $0x500000032, %rax      # imm = 0x500000032
leaq 0x8(%rsp), %rdx
movq %rax, (%rdx)
leaq 0xa8(%rdi), %rsi
movq (%rdi), %rax
movq %rsi, 0x18(%rsp)
callq *0x150(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x178(%rax)
testl %eax, %eax
jle 0x8c32f
movq 0xe03a7(%rip), %rax     # 0x16c688
xorl %ebp, %ebp
movswl (%rax), %r14d
xorl %r15d, %r15d
movq (%rbx), %rax
movq %rbx, %rdi
movl %r15d, %esi
callq *0x180(%rax)
movq %rax, %r12
leaq 0x20(%rax), %rdi
movl %r14d, %esi
callq 0x57520
testb %al, %al
je 0x8c319
movq %r12, %rdi
callq 0x58de0
cmpl %eax, %ebp
cmovlel %eax, %ebp
incl %r15d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x178(%rax)
cmpl %eax, %r15d
jl 0x8c2ea
jmp 0x8c331
xorl %ebp, %ebp
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x178(%rax)
testl %eax, %eax
jle 0x8c4a0
movq 0xe033c(%rip), %rax     # 0x16c688
xorl %r15d, %r15d
movl $0x3, %r13d
movswl (%rax), %r12d
movl %r12d, 0x14(%rsp)
movl %ebp, 0x10(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
movl %r15d, %esi
callq *0x180(%rax)
movq %rax, %r14
leaq 0x20(%rax), %rdi
movl %r12d, %esi
callq 0x57520
testb %al, %al
je 0x8c488
movq %r13, 0x20(%rsp)
movl 0xb0(%rbx), %ebp
movq %r14, %rdi
callq 0x56ad0
movq %rax, %r13
movq %r14, %rdi
callq 0x58de0
testl %eax, %eax
jle 0x8c3ba
movq %r14, %rdi
callq 0x58de0
movl 0x10(%rsp), %ecx
subl %eax, %ecx
jmp 0x8c3bc
xorl %ecx, %ecx
addl $0x6, %r13d
addl %ecx, %r13d
cmpl %r13d, %ebp
cmovgl %ebp, %r13d
movl 0xb4(%rbx), %eax
movl %r13d, 0x8(%rsp)
movl %eax, 0xc(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
movq 0x18(%rsp), %rbp
movq %rbp, %rsi
leaq 0x8(%rsp), %r12
movq %r12, %rdx
callq *0x150(%rax)
movl 0xb4(%rbx), %r13d
movq (%r14), %rax
movq %r14, %rdi
callq *0xa8(%rax)
movq %rax, %rdi
xorl %esi, %esi
callq 0x56bd0
testb %al, %al
movl $0x0, %eax
movl $0xb, %ecx
cmovnel %ecx, %eax
addl %r13d, %eax
addl $0x5, %eax
movl 0xb0(%rbx), %ecx
movl %ecx, 0x8(%rsp)
movl %eax, 0xc(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq *0x150(%rax)
movl $0x3, 0x8(%rsp)
movq 0x20(%rsp), %r13
movl %r13d, 0xc(%rsp)
movq %r14, %rdx
addq $0xb0, %rdx
movq (%r14), %rax
movq %r14, %rdi
movq %r12, %rsi
callq *0x150(%rax)
movl 0xb4(%r14), %eax
addl %eax, %r13d
incl %r13d
movl 0x10(%rsp), %ebp
movl 0x14(%rsp), %r12d
incl %r15d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x178(%rax)
cmpl %eax, %r15d
jl 0x8c362
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x178(%rax)
testl %eax, %eax
jle 0x8c53c
movq 0xe01cd(%rip), %rax     # 0x16c688
addl $0x15, %ebp
xorl %r14d, %r14d
movswl (%rax), %r15d
leaq 0x8(%rsp), %r12
movq (%rbx), %rax
movq %rbx, %rdi
movl %r14d, %esi
callq *0x180(%rax)
movq %rax, %r13
leaq 0x20(%rax), %rdi
movl %r15d, %esi
callq 0x57520
testb %al, %al
je 0x8c528
movl 0xb0(%rbx), %eax
addl $-0x6, %eax
movq %r13, %rsi
addq $0xa8, %rsi
movl 0xb4(%r13), %ecx
movl %eax, 0x8(%rsp)
movl %ecx, 0xc(%rsp)
movq (%r13), %rax
movq %r13, %rdi
movq %r12, %rdx
callq *0x150(%rax)
movq %r13, %rdi
movl %ebp, %esi
callq 0x55880
incl %r14d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x178(%rax)
cmpl %eax, %r14d
jl 0x8c4ca
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop