void PrefsKeybindingsWindow::Create()
{
    DarwiniaWindow::Create();

	int fontSize = GetMenuSize(11);
	int y = GetClientRectY1();
	int border = GetClientRectX1() + GetMenuSize(5);
	int x = m_w * 2 / 3;
	int buttonH = GetMenuSize(20);
	int buttonW = m_w - border * 2 - x;
	int h = buttonH + border;

	if ( 0 == m_controlMethod )
		s_indices = s_gesture_controls;
	else
		s_indices = s_icon_controls;

    ControlMethodDropDownMenu *controlMethod = new ControlMethodDropDownMenu();
    controlMethod->SetShortProperties( LANGUAGEPHRASE("newcontrols_prefsoption"), x, y+=border, buttonW, buttonH );
    controlMethod->AddOption( LANGUAGEPHRASE("newcontrols_prefs_gestures"), 0 );
    controlMethod->AddOption( LANGUAGEPHRASE("newcontrols_prefs_icons"), 1 );
    controlMethod->RegisterInt( &m_controlMethod );
	controlMethod->m_fontSize = GetMenuSize(11);
    RegisterButton( controlMethod );
	m_buttonOrder.PutData( controlMethod );

    InvertedBox *box = new InvertedBox();
	unsigned num_controls = 0;
	while ( s_indices[num_controls] >= 0 ) { num_controls++; }
    box->SetShortProperties( "invert", 10, y+h, m_w - 20, (num_controls * h) + border);
    RegisterButton( box );

    y += border;

    for (unsigned j = 0; j < num_controls; ++j)
	{
		int i = s_indices[ j ];
		ChangeKeybindingButton *but = new ChangeKeybindingButton( i, s_controls[i].instant );
		char const *eventName = LANGUAGEPHRASE( s_controls[i].name );
		but->SetShortProperties(eventName, x, y+=h, buttonW, buttonH);
		but->m_fontSize = GetMenuSize(15);
		but->m_centered = true;
		char const *keyName =  m_bindings[i]->noun.c_str();
		strcpy(but->m_caption, keyName);
		RegisterButton(but);
		m_buttonOrder.PutData( but );
	}

#ifdef TARGET_OS_MACOSX
	DropDownMenu *numMouseButtons = new DropDownMenu();
    numMouseButtons->SetShortProperties( " ", x, y+=h, buttonW, buttonH );
    numMouseButtons->AddOption( "1", 1 );
    numMouseButtons->AddOption( "3", 3 );
    numMouseButtons->RegisterInt( &m_numMouseButtons );
    RegisterButton( numMouseButtons );
	m_buttonOrder.PutData( numMouseButtons );
#endif

	y = m_h - (h+5);

	RestoreDefaultsButton *restore = new RestoreDefaultsButton();
	restore->SetShortProperties(LANGUAGEPHRASE("dialog_restoredefaults"), border, y - h, m_w - border*2, buttonH);
	restore->m_fontSize = fontSize;
	restore->m_centered = true;
	RegisterButton(restore);
	m_buttonOrder.PutData( restore );

	int buttonW2 = m_w / 2 - border * 2;

    CloseButton *cancel = new CloseButton();
    cancel->SetShortProperties( LANGUAGEPHRASE("dialog_close"), border, y, buttonW2, buttonH );
    cancel->m_fontSize = fontSize;
    cancel->m_centered = true;
    RegisterButton( cancel );
	m_buttonOrder.PutData( cancel );

    ApplyKeybindingsButton *apply = new ApplyKeybindingsButton();
    apply->SetShortProperties( LANGUAGEPHRASE("dialog_apply"), m_w - buttonW2 - border, y, buttonW2, buttonH );
    apply->m_fontSize = fontSize;
    apply->m_centered = true;
    RegisterButton( apply );
	m_buttonOrder.PutData( apply );
}