//--------------------------------------------------------------------------------------- void IdfyScalesCtrol::create_answer_buttons(LUnits height, LUnits spacing) { //create buttons for the answers, two rows ImoStyle* pDefStyle = m_pDoc->get_default_style(); ImoInlineWrapper* pBox; ImoStyle* pBtStyle = m_pDoc->create_private_style(); pBtStyle->font_name("sans")->font_size(8.0f); ImoStyle* pRowStyle = m_pDoc->create_private_style(); pRowStyle->font_size(10.0f)->margin_bottom(100.0f); USize buttonSize(3400.0f, height); LUnits rowWidth = 3520.0f; //rows with buttons LibraryScope* pLibScope = m_appScope.get_lomse().get_library_scope(); int iB=0; for (int iRow=0; iRow < k_num_rows; iRow++) { ImoParagraph* pKeyboardRow = m_pDyn->add_paragraph(pRowStyle); pBox = pKeyboardRow->add_inline_box(rowWidth, pDefStyle); m_pRowLabel[iRow] = pBox->add_text_item("?", pRowStyle); // the buttons for this row for (int iCol=0; iCol < k_num_cols; iCol++) { iB = iCol + iRow * k_num_cols; pBox = pKeyboardRow->add_inline_box(rowWidth, pDefStyle); m_pAnswerButton[iB] = pBox->add_button(*pLibScope, "?", buttonSize, pBtStyle); } } set_event_handlers(); //inform base class about the settings set_buttons(m_pAnswerButton, k_num_buttons); }
int main(int argc, char **argv) { xcb_connection_t *connection = xcb_connect(NULL, &wm_conf.default_screen_num); if (xcb_connection_has_error(connection)) { fprintf(stderr, "failed to open display\n"); exit(1); } init_wm_conf(); init_conf_dir(); wm_conf.connection = connection; const xcb_setup_t *setup = xcb_get_setup(connection); int num_screens = xcb_setup_roots_length(setup); fprintf(stderr, "init: num_screens = %d\n", num_screens); fprintf(stderr, "init: default_screen_num = %d\n", wm_conf.default_screen_num); xcb_screen_t *screen = xcb_setup_roots_iterator(xcb_get_setup(connection)).data; wm_conf.screen = screen; xcb_window_t root_window = screen->root; xcb_grab_server(connection); xcb_flush(connection); xcb_event_handlers_t *event_handlers = &wm_conf.event_handlers; xcb_event_handlers_init(connection, event_handlers); set_exclusive_error_handler(event_handlers, handle_startup_error); /* Try to get substructure redirect events from root window. * This will cause an error if a window manager is already running. */ const uint32_t sub_redirect = XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT; xcb_change_window_attributes(connection, root_window, XCB_CW_EVENT_MASK, &sub_redirect); /* Need to xcb_flush to validate error handler */ xcb_aux_sync(connection); /* Process all errors in the queue if any */ xcb_event_poll_for_event_loop(event_handlers); scan_windows(); xinerama_test(); set_exclusive_error_handler(event_handlers, handle_error); set_event_handlers(event_handlers); /* Allocate the key symbols */ wm_conf.key_syms = xcb_key_symbols_alloc(connection); fprintf(stderr, "selecting events from root window\n"); const uint32_t root_win_event_mask = XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_FOCUS_CHANGE; xcb_change_window_attributes(connection, root_window, XCB_CW_EVENT_MASK, &root_win_event_mask); xcb_ungrab_server(connection); xcb_flush(connection); wm_conf.repl_server = repl_server_init(); load_init_scheme(); fprintf(stderr, "entering event loop\n"); event_loop(); xcb_disconnect(connection); return 0; }