// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/classes/gui/widgets/multi/list/combobox.cpp
// Function: smooth::GUI::ComboBox::OpenListBox()
S::Void S::GUI::ComboBox::OpenListBox()
{
	if (listBox != NIL) return;

	Window	*window	     = container->GetContainerWindow();
	Surface	*surface     = GetDrawSurface();

	if (S::System::System::Clock() - listBoxClosed < 100)
	{
		if (window->IsMouseOn(Rect(buttonHotspot->GetRealPosition(), buttonHotspot->GetRealSize()))) buttonHotspot->Paint(SP_MOUSEUP);

		return;
	}

	Rect	 monitor     = System::Screen::GetActiveScreenWorkArea();
	Float	 scaleFactor = surface->GetSurfaceDPI() / 96.0;

	Size	 listBoxSize = Size(GetWidth(), 16 * Math::Min(Length(), Math::Max(5, Math::Min(16, Length() / 3))) + 4);
	Point	 listBoxPos  = Point(GetRealPosition() + Point(0, GetRealSize().cy));

	if (window->GetY() + listBoxPos.y + Math::Round(listBoxSize.cy * scaleFactor) >= monitor.bottom) listBoxPos = Point(GetRealPosition() - Point(0, Math::Round(listBoxSize.cy * scaleFactor)));

	listBox	   = new ListBox(Point(), listBoxSize);
	listBox->onSelectEntry.Connect(&onSelectEntry);

	toolWindow = new ToolWindow(listBoxPos, listBoxSize);
	toolWindow->onLoseFocus.Connect(&ComboBox::CloseListBox, this);

	window->onChangePosition.Connect(&ComboBox::CloseListBox, this);
	window->onChangeSize.Connect(&ComboBox::CloseListBox, this);

	listBox->SetFlags(LF_ALLOWRESELECT | LF_HIDEHEADER);
	listBox->AddTab(NIL, 32768);

	ListEntry	*selectedEntry = GetSelectedEntry();

	if (selectedEntry != NIL) prevSelectedEntry = selectedEntry->GetHandle();

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

		entry->SetRegisteredFlag(False);

		listBox->Add(entry);

		if (entry->GetUnscaledTextWidth() >= listBoxSize.cx - (listBoxSize.cy < 16 * Length() ? 22 : 5)) entry->SetTooltipText(entry->GetText());
		else												 entry->SetTooltipText(NIL);

		entry->Activate();
	}

	toolWindow->Add(listBox);

	Add(toolWindow);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
cmpq $0x0, 0x6d0(%rdi)
jne 0x8047e
movq %rdi, %rbx
movq 0x190(%rdi), %rdi
callq 0x56a50
movq %rax, %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x40(%rax)
movq %rax, %r12
callq 0x582b0
subq 0x6d8(%rbx), %rax
cmpq $0x63, %rax
ja 0x80174
movq 0x6f0(%rbx), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
movq %rax, %r15
movq %rax, %r12
shrq $0x20, %r12
movq 0x6f0(%rbx), %rdi
movq (%rdi), %rax
callq *0x50(%rax)
leal (%rax,%r15), %ecx
shrq $0x20, %rax
leaq 0x18(%rsp), %rsi
movl %r15d, (%rsi)
movl %r12d, 0x4(%rsi)
movl %ecx, 0x8(%rsi)
addl %r12d, %eax
movl %eax, 0xc(%rsi)
movq %r14, %rdi
callq 0x58ae0
testb %al, %al
je 0x8047e
movq 0x6f0(%rbx), %rdi
movq (%rdi), %rax
pushq $0x5
popq %rsi
callq *0x78(%rax)
jmp 0x8047e
callq 0x59120
movq %rdx, %r15
movq %r12, %rdi
callq 0x59c60
cwtl
cvtsi2sd %eax, %xmm0
divsd 0x6337f(%rip), %xmm0    # 0xe3510
movsd %xmm0, 0x30(%rsp)
movl 0xb0(%rbx), %r12d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x178(%rax)
movl %eax, %ebp
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x178(%rax)
pushq $0x3
popq %rcx
cltd
idivl %ecx
cmpl $0x10, %eax
pushq $0x10
popq %rcx
cmovll %eax, %ecx
cmpl $0x6, %ecx
movq %rbx, (%rsp)
pushq $0x5
popq %r13
cmovgel %ecx, %r13d
cmpl %r13d, %ebp
cmovll %ebp, %r13d
movabsq $-0x100000000, %rbp     # imm = 0xFFFFFFFF00000000
shll $0x4, %r13d
orl $0x4, %r13d
movl %r12d, 0x8(%rsp)
movl %r13d, 0xc(%rsp)
movq (%rsp), %rax
movq (%rax), %rax
movq (%rsp), %rdi
callq *0x48(%rax)
movq %rax, %r12
movq (%rsp), %rax
movq (%rax), %rax
movq (%rsp), %rdi
callq *0x50(%rax)
andq %rbp, %rax
addq %r12, %rax
movq %rax, 0x10(%rsp)
movslq 0xac(%r14), %rcx
sarq $0x20, %rax
addq %rcx, %rax
cvtsi2sd %r13d, %xmm0
movq (%rsp), %r13
mulsd 0x30(%rsp), %xmm0
xorpd %xmm1, %xmm1
xorl %ecx, %ecx
ucomisd %xmm0, %xmm1
seta %cl
leaq 0x6355c(%rip), %rdx     # 0xe37b0
addsd (%rdx,%rcx,8), %xmm0
cvttsd2si %xmm0, %r12
addq %r12, %rax
sarq $0x20, %r15
cmpq %r15, %rax
jl 0x80288
movq (%r13), %rax
movq %r13, %rdi
callq *0x48(%rax)
shlq $0x20, %r12
movl %eax, %ecx
subq %r12, %rax
andq %rbp, %rax
orq %rax, %rcx
movq %rcx, 0x10(%rsp)
movl $0x718, %edi            # imm = 0x718
callq 0x56700
movq %rax, %r15
leaq 0x18(%rsp), %rsi
andq $0x0, (%rsi)
leaq 0x8(%rsp), %rdx
movq %rax, %rdi
callq 0x57d20
movq %r15, 0x6d0(%r13)
movl $0x688, %esi            # imm = 0x688
addq %rsi, %r15
addq %r13, %rsi
movq %r15, %rdi
callq 0x80f32
movl $0x6d8, %edi            # imm = 0x6D8
callq 0x56700
movq %rax, %r15
leaq 0x10(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq %rax, %rdi
callq 0x5a380
movq %r15, 0x6c8(%r13)
addq $0x518, %r15            # imm = 0x518
movq 0xe1bb7(%rip), %r12     # 0x161eb0
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x80e96
leaq 0x278(%r14), %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x80cc2
addq $0x298, %r14            # imm = 0x298
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x80fc0
movq 0x6d0(%r13), %r14
movl $0xa, 0x30(%r14)
leaq 0x18(%rsp), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x5a180
pushq $0x10
popq %rcx
movq %r14, %rdi
movq %r15, %rsi
movl $0x8000, %edx           # imm = 0x8000
callq 0x58220
leaq 0x18(%rsp), %rdi
callq 0x5a588
movq %r13, %rdi
callq 0x57060
testq %rax, %rax
je 0x80386
movl 0x8(%rax), %eax
movl %eax, 0x6e0(%r13)
xorl %ebp, %ebp
leaq 0x18(%rsp), %rbx
movq (%r13), %rax
movq %r13, %rdi
callq *0x178(%rax)
cmpl %eax, %ebp
jge 0x80459
movq (%r13), %rax
movq %r13, %rdi
movl %ebp, %esi
callq *0x180(%rax)
movq %rax, %r15
movb $0x0, 0xca(%rax)
movq 0x6d0(%r13), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x30(%rax)
movq (%r15), %rax
movq %r15, %rdi
callq *0xf0(%rax)
movl %eax, %r12d
movq %r13, %rdi
movl 0x8(%rsp), %r13d
movl 0xc(%rsp), %r14d
movq (%rdi), %rax
callq *0x178(%rax)
shll $0x4, %eax
cmpl %eax, %r14d
pushq $-0x5
popq %rax
pushq $-0x16
popq %rcx
cmovll %ecx, %eax
addl %r13d, %eax
cmpl %eax, %r12d
jge 0x8042a
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5a180
movq (%r15), %rax
movq %r15, %rdi
movq %rbx, %rsi
callq *0xb0(%rax)
movq %rbx, %rdi
callq 0x5a588
jmp 0x80445
movq (%r15), %rax
movq %r15, %rdi
callq *0xa8(%rax)
movq (%r15), %rcx
movq %r15, %rdi
movq %rax, %rsi
callq *0xb0(%rcx)
movq (%rsp), %r13
movq (%r15), %rax
movq %r15, %rdi
callq *0x68(%rax)
incl %ebp
jmp 0x8038d
movq 0x6c8(%r13), %rdi
movq 0x6d0(%r13), %rsi
movq (%rdi), %rax
callq *0x30(%rax)
movq 0x6c8(%r13), %rsi
movq (%r13), %rax
movq %r13, %rdi
callq *0x30(%rax)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x804ab
movq %rax, %rbx
movl $0x6d8, %esi            # imm = 0x6D8
jmp 0x804a1
movq %rax, %rbx
movl $0x718, %esi            # imm = 0x718
movq %r15, %rdi
callq 0x564c0
jmp 0x804b8
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x5a588
movq %rbx, %rdi
callq 0x58260