merge code from cocogui