built titlebar factory to control all titlebar buttons