// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/classes/gui/widgets/widget.cpp
// Function: smooth::GUI::Widget::Process(int, int, int)
S::Int S::GUI::Widget::Process(Int message, Int wParam, Int lParam)
{
	if (!IsRegistered()) return Error();
	if (!IsVisible())    return Success();

	Window	*window	= container->GetContainerWindow();

	if (window == NIL)   return Success();

	widgets.LockForWrite();

	foreach (Widget *widget, widgets)
	{
		if (widget->Process(message, wParam, lParam) == MessageProcessed) { widgets.Unlock(); return MessageProcessed; }
	}

	widgets.Unlock();

	if (!IsVisible())    return Success();
	if (!IsActive())     return Success();

	EnterProtectedRegion();

	Int	 returnValue = Success();
	Point	 mousePos    = window->GetMousePosition();

	switch (message)
	{
		case SM_MOUSEMOVE:
			{
				Point	 realPosition = GetRealPosition();
				Rect	 visibleArea  = GetVisibleArea();

				if (!mouseOver && window->IsMouseOn(visibleArea) && hitTest.Call(mousePos - realPosition))
				{
					mouseOver = True;

					if (statusText != NIL) window->SetStatusText(statusText);

					if ((tooltipText != NIL || tooltipLayer != NIL) && window->IsFocussed())
					{
						Application::Lock	 lock;

						tipPos	 = mousePos;
						tipTimer = new System::Timer();

						tipTimer->onInterval.Connect(&Widget::ActivateTooltip, this);
						tipTimer->Start(Setup::HoverTime);
					}

					Paint(SP_MOUSEIN);

					onMouseOver.Emit();
				}
				else if (mouseOver && !(window->IsMouseOn(visibleArea) && hitTest.Call(mousePos - realPosition)))
				{
					mouseOver = False;

					leftButtonDown	= False;
					rightButtonDown	= False;

					if (statusText != NIL && window->GetStatusText() == statusText) window->RestoreDefaultStatusText();

					DeactivateTooltip();

					Paint(SP_MOUSEOUT);

					onMouseOut.Emit();
				}
				else if (mouseOver && window->IsMouseOn(visibleArea) && hitTest.Call(mousePos - realPosition))
				{
					Application::Lock	 lock;

					if (tipTimer != NIL && wParam == 0 && (Math::Abs(tipPos.x - mousePos.x) > Setup::HoverWidth / 2 || Math::Abs(tipPos.y - mousePos.y) > Setup::HoverHeight / 2))
					{
						tipPos = mousePos;

						tipTimer->Stop();
						tipTimer->Start(Setup::HoverTime);
					}
				}
			}

			if (mouseDragging)
			{
				onMouseDrag.Emit(mousePos);
			}

			break;
		case SM_LBUTTONDOWN:
			if (mouseOver)
			{
				leftButtonDown = True;

				DeactivateTooltip();

				Paint(SP_MOUSEDOWN);

				if (!focussed)
				{
					focussed = True;

					onGetFocus.Emit();
				}
				else
				{
					onClickInFocus.Emit();
				}

				onLeftButtonDown.Emit(mousePos);

				if (!mouseDragging)
				{
					mouseDragging = True;

					onMouseDragStart.Emit(mousePos);
				}
			}
			else
			{
				if (focussed)
				{
					focussed = False;

					onLoseFocus.Emit();
				}
			}

			break;
		case SM_LBUTTONDBLCLK:
			if (mouseOver)
			{
				leftButtonDown = True;

				Paint(SP_MOUSEDOWN);

				onLeftButtonDown.Emit(mousePos);
				onLeftButtonDoubleClick.Emit(mousePos);
			}

			break;
		case SM_LBUTTONUP:
			if (mouseOver)
			{
				Paint(SP_MOUSEUP);

				onLeftButtonUp.Emit(mousePos);

				if (leftButtonDown)
				{
					leftButtonDown = False;

					onLeftButtonClick.Emit(mousePos);
				}
			}

			if (mouseDragging)
			{
				mouseDragging = False;

				onMouseDragEnd.Emit(mousePos);
			}

			break;
		case SM_RBUTTONDOWN:
		case SM_RBUTTONDBLCLK:
			if (mouseOver)
			{
				OpenContextMenu();

				/* Force mouseOut event.
				 */
				window->Process(SM_MOUSEMOVE, 0, 0);
			}

			break;
		case SM_MOUSEWHEEL:
			{
				UnsignedInt	 scrollLines = 0;

#ifdef __WIN32__
				SystemParametersInfo(104, NIL, &scrollLines, NIL);
#endif

				if (scrollLines <= 0) scrollLines = 3;

				onMouseWheel.Emit(Float(wParam) / 120.0 * scrollLines);
			}

			break;
		case SM_KEYDOWN:
			if (!focussed || !tabstopCapable) break;

			if (wParam == Input::Keyboard::KeyTab)
			{
				Widget	*widget = NIL;

				if (Input::Keyboard::GetKeyState(Input::Keyboard::KeyShift)) widget = container->GetPreviousTabstopWidget(GetHandle());
				else							     widget = container->GetNextTabstopWidget(GetHandle());

				if (widget != NIL)
				{
					focussed = False;

					onLoseFocus.Emit();

					widget->SetFocusByKeyboard();
				}

				returnValue = MessageProcessed;
			}

			break;
		case SM_LOSEFOCUS:
			if (focussed)
			{
				Window	*focusWnd = (Window *) Object::GetObject(wParam, Window::classID);

				if (focusWnd != NIL)
				{
					if ((focusWnd->GetObjectType() == ToolWindow::classID && focusWnd->GetOrder() >= window->GetOrder()) || focusWnd == window) break;
				}

				focussed = False;

				onLoseFocus.Emit();
			}

			break;
	}

	LeaveProtectedRegion();

	return returnValue;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, %r14d
movl %edx, %r12d
movl %esi, %r13d
movq %rdi, %rbx
movq (%rdi), %rax
callq *0x88(%rax)
testb %al, %al
je 0x6ee6f
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x90(%rax)
xorl %ebp, %ebp
testb %al, %al
je 0x6ee72
movq 0x190(%rbx), %rdi
callq 0x56a50
testq %rax, %rax
je 0x6ee72
movq %rax, 0x20(%rsp)
leaq 0x38(%rbx), %rbp
movq %rbp, %rdi
callq 0x56300
xorl %ecx, %ecx
pushq $-0x1
popq %r15
movq %rbx, 0x10(%rsp)
testl %ecx, %ecx
jne 0x6ee83
movl 0x40(%rbx), %eax
decl %eax
cmpl %eax, %r15d
jge 0x6ee83
incl %r15d
movq %rbp, %rdi
movl %r15d, %esi
callq 0x6180a
movq (%rax), %rbx
movb $0x1, %dl
pushq $-0x1
popq %rcx
testb $0x1, %dl
je 0x6ee60
movq (%rbx), %rax
movq %rbx, %rdi
movl %r13d, %esi
movl %r12d, %edx
movl %r14d, %ecx
callq *0x80(%rax)
xorl %edx, %edx
movl $0x0, %ecx
cmpl $-0x1, %eax
jne 0x6ee38
jmp 0x6ee67
movq 0x10(%rsp), %rbx
jmp 0x6ee14
movq %rbp, %rdi
callq 0x56da0
pushq $-0x1
popq %rbp
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbp, %rdi
callq 0x56da0
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x90(%rax)
xorl %ebp, %ebp
testb %al, %al
je 0x6ee72
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x98(%rax)
testb %al, %al
movq 0x20(%rsp), %r15
je 0x6ee72
leaq 0x1c(%rbx), %r14
movq %r14, %rdi
callq 0x58b40
movq %r15, %rdi
callq 0x57cc0
movq %rax, 0x8(%rsp)
xorl %ebp, %ebp
addl $0xffff8800, %r13d      # imm = 0xFFFF8800
cmpl $0x13, %r13d
ja 0x6f514
leaq 0x768eb(%rip), %rax     # 0xe57d0
movslq (%rax,%r13,4), %rcx
addq %rax, %rcx
jmpq *%rcx
cmpb $0x1, 0xd4(%rbx)
jne 0x6f514
movq %rbx, %rdi
callq 0x57d00
movq (%r15), %rax
xorl %ebp, %ebp
movq %r15, %rdi
movl $0x7800, %esi           # imm = 0x7800
xorl %edx, %edx
xorl %ecx, %ecx
callq *0x80(%rax)
jmp 0x6f514
cmpb $0x1, 0xd4(%rbx)
jne 0x6ef66
movq (%rbx), %rax
pushq $0x5
popq %rsi
movq %rbx, %rdi
callq *0x78(%rax)
leaq 0x318(%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0x70356
cmpb $0x1, 0xd5(%rbx)
jne 0x6ef66
movb $0x0, 0xd5(%rbx)
leaq 0x338(%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0x70356
cmpb $0x1, 0xd7(%rbx)
jne 0x6f514
movb $0x0, 0xd7(%rbx)
addq $0x438, %rbx            # imm = 0x438
jmp 0x6f4b6
addq $0x458, %rbx            # imm = 0x458
cvtsi2sd %r12d, %xmm0
divsd 0x76826(%rip), %xmm0    # 0xe57c0
mulsd 0x745de(%rip), %xmm0    # 0xe3580
movq %rbx, %rdi
callq 0x703cc
jmp 0x6f514
cmpb $0x1, 0xcd(%rbx)
jne 0x6f514
cmpl $0x9, %r12d
jne 0x6f514
cmpb $0x0, 0xd2(%rbx)
je 0x6f514
pushq $0x10
popq %rdi
callq 0x58710
movq 0x190(%rbx), %rdi
movl 0x8(%rbx), %esi
testb %al, %al
je 0x6f4e4
callq 0x58f80
jmp 0x6f4e9
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x48(%rax)
movq %rax, %r13
movq %rbx, %r15
movq %rax, %rbx
shrq $0x20, %rbx
movq (%r15), %rax
movq %r15, %rdi
callq *0x130(%rax)
movq %rax, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
cmpb $0x0, 0xd4(%r15)
movq 0x20(%rsp), %r15
jne 0x6f292
leaq 0x28(%rsp), %rsi
movq %r15, %rdi
callq 0x58ae0
testb %al, %al
je 0x6f292
movq 0x10(%rsp), %rax
leaq 0x1a8(%rax), %rdi
movl 0x8(%rsp), %eax
movl 0xc(%rsp), %ecx
subl %r13d, %eax
subl %ebx, %ecx
shlq $0x20, %rcx
orq %rcx, %rax
leaq 0x18(%rsp), %rsi
movq %rax, (%rsi)
callq 0x70f5a
testb %al, %al
je 0x6f292
movq 0x10(%rsp), %rax
movb $0x1, 0xd4(%rax)
leaq 0x108(%rax), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x57d40
testb %al, %al
je 0x6f0b2
movq 0x20(%rsp), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
callq *0xd0(%rax)
movq 0x10(%rsp), %rbx
leaq 0x120(%rbx), %rdi
xorl %esi, %esi
callq 0x57d40
testb %al, %al
jne 0x6f0d3
cmpq $0x0, 0x138(%rbx)
je 0x6f14f
movq 0x20(%rsp), %rax
cmpb $0x1, 0xcd(%rax)
jne 0x6f14f
callq 0x56460
movq 0x8(%rsp), %rax
movq %rax, 0x98(%rbx)
pushq $0x68
popq %rdi
callq 0x56700
movq %rax, %r15
movq %rax, %rdi
callq 0x56c00
movq 0x10(%rsp), %rcx
movq %r15, 0xa0(%rcx)
addq $0x48, %r15
movq 0xf271c(%rip), %rsi     # 0x161838
movq %r15, %rdi
xorl %edx, %edx
callq 0x702aa
movq 0x10(%rsp), %rax
movq 0xa0(%rax), %rdi
movq 0xf2b37(%rip), %rax     # 0x161c70
movl (%rax), %esi
callq 0x56100
leaq 0x18(%rsp), %rdi
callq 0x563d0
movq 0x10(%rsp), %rbx
movq (%rbx), %rax
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq *0x78(%rax)
leaq 0x2b8(%rbx), %rdi
jmp 0x6f4a1
cmpb $0x1, 0xd4(%rbx)
jne 0x6f40b
movb $0x1, 0xd5(%rbx)
movq %rbx, %rdi
callq 0x5a590
movq (%rbx), %rax
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq *0x78(%rax)
movl $0x538, %edi            # imm = 0x538
cmpb $0x0, 0xcd(%rbx)
jne 0x6f1a9
movb $0x1, 0xcd(%rbx)
movl $0x4d8, %edi            # imm = 0x4D8
addq %rbx, %rdi
callq 0x70196
leaq 0x2f8(%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0x70356
cmpb $0x0, 0xd7(%rbx)
jne 0x6f514
movb $0x1, 0xd7(%rbx)
addq $0x3f8, %rbx            # imm = 0x3F8
jmp 0x6f4b6
cmpb $0x1, 0xcd(%rbx)
jne 0x6f514
movq 0xf2632(%rip), %rax     # 0x161828
movswl (%rax), %esi
movl %r12d, %edi
callq 0x58940
testq %rax, %rax
je 0x6f4ca
movq %rax, %rbx
leaq 0x20(%rax), %rdi
movq 0xf2ac0(%rip), %rax     # 0x161cd8
movswl (%rax), %esi
callq 0x58720
testb %al, %al
je 0x6f4c5
cmpq %r15, %rbx
je 0x6f514
movl 0x5b8(%r15), %eax
cmpl %eax, 0x5b8(%rbx)
jl 0x6f4ca
jmp 0x6f514
cmpb $0x1, 0xd4(%rbx)
jne 0x6f514
movb $0x1, 0xd5(%rbx)
movq (%rbx), %rax
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq *0x78(%rax)
leaq 0x2f8(%rbx), %rdi
movq %rbx, %r15
leaq 0x8(%rsp), %rbx
movq %rbx, %rsi
callq 0x70356
addq $0x358, %r15            # imm = 0x358
movq %r15, %rdi
movq %rbx, %rsi
jmp 0x6f4be
movq 0x10(%rsp), %rax
movb 0xd4(%rax), %al
cmpb $0x1, %al
jne 0x6f2f6
leaq 0x28(%rsp), %rsi
movq %r15, %rdi
callq 0x58ae0
testb %al, %al
je 0x6f435
movq 0x10(%rsp), %rax
leaq 0x1a8(%rax), %rdi
movl 0x8(%rsp), %eax
movl 0xc(%rsp), %ecx
subl %r13d, %eax
subl %ebx, %ecx
shlq $0x20, %rcx
orq %rcx, %rax
leaq 0x18(%rsp), %rsi
movq %rax, (%rsi)
callq 0x70f5a
testb %al, %al
je 0x6f435
movq 0x10(%rsp), %rax
movb 0xd4(%rax), %al
testb $0x1, %al
je 0x6f42e
leaq 0x28(%rsp), %rsi
movq %r15, %rdi
callq 0x58ae0
testb %al, %al
je 0x6f42e
movq 0x10(%rsp), %rdx
leaq 0x1a8(%rdx), %rdi
movl 0x8(%rsp), %eax
movl 0xc(%rsp), %ecx
subl %r13d, %eax
subl %ebx, %ecx
movq %rdx, %rbx
shlq $0x20, %rcx
orq %rcx, %rax
leaq 0x18(%rsp), %rsi
movq %rax, (%rsi)
callq 0x70f5a
testb %al, %al
je 0x6f4a6
callq 0x56460
movq 0xa0(%rbx), %rdi
testq %rdi, %rdi
sete %al
testl %r12d, %r12d
setne %cl
orb %al, %cl
jne 0x6f3fc
movl 0x98(%rbx), %eax
movl 0x8(%rsp), %edx
movl %eax, %r8d
subl %edx, %r8d
sarl $0x1f, %r8d
orl $0x1, %r8d
xorl %ecx, %ecx
subl %edx, %eax
cmovel %ecx, %r8d
imull %eax, %r8d
movq 0xf2682(%rip), %rax     # 0x161a18
movl (%rax), %eax
pushq $0x2
popq %rsi
cltd
idivl %esi
cmpl %eax, %r8d
jg 0x6f3d6
movl 0x9c(%rbx), %eax
movl 0xc(%rsp), %edx
movl %eax, %r8d
subl %edx, %r8d
sarl $0x1f, %r8d
orl $0x1, %r8d
subl %edx, %eax
cmovel %ecx, %r8d
imull %eax, %r8d
movq 0xf2b2c(%rip), %rax     # 0x161ef8
movl (%rax), %eax
cltd
idivl %esi
cmpl %eax, %r8d
jle 0x6f3fc
movq 0x8(%rsp), %rax
movq %rax, 0x98(%rbx)
callq 0x5a518
movq 0xa0(%rbx), %rdi
movq 0xf287b(%rip), %rax     # 0x161c70
movl (%rax), %esi
callq 0x56100
leaq 0x18(%rsp), %rdi
callq 0x563d0
jmp 0x6f4a6
cmpb $0x1, 0xcd(%rbx)
jne 0x6f514
movb $0x0, 0xcd(%rbx)
addq $0x518, %rbx            # imm = 0x518
movq %rbx, %rdi
jmp 0x6f4dd
movq 0x10(%rsp), %rbx
jmp 0x6f4a6
movq 0x10(%rsp), %rax
andw $0x0, 0xd4(%rax)
movb $0x0, 0xd6(%rax)
leaq 0x108(%rax), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x57d40
testb %al, %al
je 0x6f481
movq (%r15), %rax
movq %r15, %rdi
callq *0xd8(%rax)
movq %rax, %rdi
movq %rbx, %rsi
callq 0x56960
testb %al, %al
je 0x6f481
movq %r15, %rdi
callq 0x56ea0
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x5a590
movq (%rbx), %rax
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq *0x78(%rax)
leaq 0x2d8(%rbx), %rdi
callq 0x70196
cmpb $0x1, 0xd7(%rbx)
jne 0x6f514
addq $0x418, %rbx            # imm = 0x418
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x70356
jmp 0x6f514
cmpq %r15, %rbx
je 0x6f514
movq 0x10(%rsp), %rdi
movb $0x0, 0xcd(%rdi)
addq $0x518, %rdi            # imm = 0x518
callq 0x70196
jmp 0x6f514
callq 0x570b0
movq %rax, %rbx
pushq $-0x1
popq %rbp
testq %rax, %rax
je 0x6f514
movq 0x10(%rsp), %rdi
movb $0x0, 0xcd(%rdi)
addq $0x518, %rdi            # imm = 0x518
callq 0x70196
movq %rbx, %rdi
callq 0x57300
movq %r14, %rdi
callq 0x56d60
jmp 0x6ee72
movq %rax, %rbx
pushq $0x68
popq %rsi
movq %r15, %rdi
callq 0x564c0
jmp 0x6f536
jmp 0x6f533
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x563d0
movq %rbx, %rdi
callq 0x58260