void display_error_message(Interface *interface) { Area box, text_box_top, text_box_bottom; char align_message_top[ERROR_TEXTBOX], align_message_bottom[ERROR_TEXTBOX]; read_write_error(align_message_top, align_message_bottom); SDL_Event event; do { make_rect(&interface->window, &box, 0, 200, interface->text_editor_panel.rect.w, 100, 255,255,255); make_rect(&interface->window, &text_box_top, 0, box.rect.y + (box.rect.h / 4), interface->text_editor_panel.rect.w, CHALLENGE_FONT_SIZE*1.45, 255,255,255); make_text(&interface->window, &text_box_top.rect, interface->challenge_font, align_message_top, 241, 35, 65); make_rect(&interface->window, &text_box_bottom, 0, text_box_top.rect.y + text_box_top.rect.h, interface->text_editor_panel.rect.w, CHALLENGE_FONT_SIZE*1.45, 255,255,255); make_text(&interface->window, &text_box_bottom.rect, interface->challenge_font, align_message_bottom, 241, 35, 65); render_update(interface->window); SDL_PollEvent(&event); } while(event.type != SDL_MOUSEBUTTONDOWN && event.type != SDL_KEYDOWN); }
MainScreen::MainScreen() : LcdScreen(), m_HasMail( false ) { m_Font = new Font7x5(); m_TimeFont = new Font7x5Time(); #define make_text_c(lbl,dt) m_Texts->insert( make_pair( lbl, dt ) ) #define make_text(lbl,x,y,w) make_text_c( lbl, new DrawableText( x, y, w, m_Font ) ) #define make_text_time(lbl,x,y,w) make_text_c( lbl, new DrawableText( x, y, w, m_TimeFont ) ) make_text( TXT_ARTIST, 0, 0, m_Surface->GetWidth() ); make_text_time( TXT_PL_DISP, m_Surface->GetWidth(), 0, -53 ); make_text( TXT_TITLE, 0, 8, m_Surface->GetWidth() ); make_text( TXT_ALBUM, 0, 16, m_Surface->GetWidth() ); make_text( TXT_STATUS, 0, 23, 80 ); make_text( TXT_EMAIL, m_Surface->GetWidth(), 23, -70 ); #define TIME_YPOS (m_Surface->GetHeight() - 1 - 5 - 7) make_text_time( TXT_TIME_POS, 0, TIME_YPOS, 25 ); make_text_time( TXT_CLOCK, (m_Surface->GetWidth() / 2) - (39 / 2), TIME_YPOS, 39 ); make_text_time( TXT_TIME_LENGTH, m_Surface->GetWidth(), TIME_YPOS, -25 ); #undef make_text #undef make_text_time #undef make_text_c DrawInit(); }
void display_current_challenge(int win_width, int win_height, Interface* interface) { int curr_chall_x, curr_chall_y, curr_chall_w, curr_chall_h; char centred_string[MAX_CHALLENGE_LEN]; curr_chall_x = interface->previous_button.rect.x + interface->previous_button.rect.w; curr_chall_y = 0; curr_chall_w = win_width - (win_width / TEXT_ED_WIDTH) - (interface->previous_button.rect.w * 2); curr_chall_h = interface->menu_button.rect.h; make_rect(&interface->window, &interface->current_challenge, curr_chall_x, curr_chall_y, curr_chall_w, curr_chall_h, 240, 240, 240); make_rect(&interface->window, &interface->current_challenge_text, curr_chall_x, curr_chall_y + curr_chall_h / 5, curr_chall_w, CHALLENGE_FONT_SIZE * 1.45, 240, 240, 240); text_align_central(centred_string, interface->challenges[interface->challenge_num], MAX_CHALLENGE_LEN); make_text(&interface->window, &interface->current_challenge_text.rect, interface->challenge_font, centred_string, 0, 0, 0); }
void create_flashcard_layers(FlashCard *card) { // create text layers for the front and back of the flashcard front_layer = make_text(card->front, true); back_layer = make_text(card->back, false); // put the front and back into the window layer_add_child(window_get_root_layer(window), text_layer_get_layer(front_layer)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(back_layer)); // randomly hide either the front or the back at first bool hide_front_at_first = (rand() % 2 > 0); layer_set_hidden(text_layer_get_layer(hide_front_at_first ? front_layer : back_layer), true); // wake up the user //vibes_short_pulse(); //light_enable_interaction(); theState = SHOWING_ONE_FACE; }
Datum ipaddr_cast_to_text(PG_FUNCTION_ARGS) { IP_P ipp = PG_GETARG_IP_P(0); IP ip; int af = ip_unpack(ipp, &ip); text *out = NULL; switch (af) { case PGSQL_AF_INET: out = make_text(NULL, IP4_STRING_MAX); set_text_len(out, ip4_raw_output(ip.ip4, VARDATA(out), IP4_STRING_MAX)); break; case PGSQL_AF_INET6: out = make_text(NULL, IP6_STRING_MAX); set_text_len(out, ip6_raw_output(ip.ip6.bits, VARDATA(out), IP6_STRING_MAX)); break; } PG_RETURN_TEXT_P(out); }
void display_help_button(int win_width, int win_height, Interface* interface, Mode mode) { int help_button_x, help_button_y, help_button_w, help_button_h; char help_text[CHALLENGE_MODE_TEXTBOX]; char help_text_canvas[CANVAS_MODE_TEXTBOX]; if (mode == challenge_mode) { help_button_x = interface->learn_button.rect.x + interface->learn_button.rect.w; } else { help_button_x = interface->menu_button.rect.x + interface->menu_button.rect.w + 1; } help_button_y = 0; help_button_w = interface->menu_button.rect.w; help_button_h = interface->menu_button.rect.h; make_rect(&interface->window, &interface->help_button, help_button_x, help_button_y, help_button_w, help_button_h, 240, 240, 240); if (mode == challenge_mode){ text_align_central(help_text, "Help", CHALLENGE_MODE_TEXTBOX); make_text(&interface->window, &interface->help_button.rect, interface->button_font, help_text, 241, 35, 65); } else { text_align_central(help_text_canvas, "Help", CANVAS_MODE_TEXTBOX); make_text(&interface->window, &interface->help_button.rect, interface->button_font, help_text_canvas, 241, 35, 65); } }
void display_menu_button(int win_width, int win_height, Interface* interface, Mode mode) { int menu_button_x, menu_button_y, menu_button_w, menu_button_h; char challenge_text[CHALLENGE_MODE_TEXTBOX]; char canvas_text[CANVAS_MODE_TEXTBOX]; menu_button_x = 0; menu_button_y = 0; menu_button_h = interface->toolbar.rect.h - 1; if (mode == challenge_mode) { menu_button_w = interface->text_editor_panel.rect.w / 3; } else { menu_button_w = interface->text_editor_panel.rect.w / 2; } make_rect(&interface->window, &interface->menu_button, menu_button_x, menu_button_y, menu_button_w, menu_button_h, 240, 240, 240); if (mode == challenge_mode) { text_align_central(challenge_text, "Levels", CHALLENGE_MODE_TEXTBOX); make_text(&interface->window, &interface->menu_button.rect, interface->button_font, challenge_text, 241, 35, 65); } else { text_align_central(canvas_text, "Menu", CANVAS_MODE_TEXTBOX); make_text(&interface->window, &interface->menu_button.rect, interface->button_font, canvas_text, 241, 35, 65); } }
void display_next_button(int win_width, int win_height, Interface* interface) { int next_button_x, next_button_y, next_button_w, next_button_h; char next_text[PREV_NEXT_TEXTBOX]; next_button_x = interface->current_challenge.rect.x + interface->current_challenge.rect.w; next_button_y = interface->current_challenge.rect.y; next_button_w = (win_width / TEXT_ED_WIDTH) / PREV_NEXT_BUTTON; next_button_h = interface->menu_button.rect.h; make_rect(&interface->window, &interface->next_button, next_button_x, next_button_y, next_button_w, next_button_h, 241, 35, 65); text_align_central(next_text, "NEXT", PREV_NEXT_TEXTBOX); make_text(&interface->window, &interface->next_button.rect, interface->button_font, next_text, 255, 255, 255); }
void display_learn_button(int win_width, int win_height, Interface* interface) { int learn_button_x, learn_button_y, learn_button_w, learn_button_h; char learn_text[CHALLENGE_MODE_TEXTBOX]; learn_button_x = interface->menu_button.rect.x + interface->menu_button.rect.w; learn_button_y = 0; learn_button_w = interface->menu_button.rect.w; learn_button_h = interface->menu_button.rect.h; make_rect(&interface->window, &interface->learn_button, learn_button_x, learn_button_y, learn_button_w, learn_button_h, 240, 240, 240); text_align_central(learn_text, "Learn", CHALLENGE_MODE_TEXTBOX); make_text(&interface->window, &interface->learn_button.rect, interface->button_font, learn_text, 241, 35, 65); }
void display_previous_button(int win_width, int win_height, Interface* interface) { int previous_button_x, previous_button_y; int previous_button_w, previous_button_h; char prev_text[PREV_NEXT_TEXTBOX]; previous_button_x = interface->text_editor_panel.rect.w + 1; previous_button_y = 0; previous_button_w = (win_width / TEXT_ED_WIDTH) / PREV_NEXT_BUTTON; previous_button_h = interface->menu_button.rect.h; make_rect(&interface->window, &interface->previous_button, previous_button_x, previous_button_y, previous_button_w, previous_button_h, 241, 35, 65); text_align_central(prev_text, "PREV", PREV_NEXT_TEXTBOX); make_text(&interface->window, &interface->previous_button.rect, interface->button_font, prev_text, 255, 255, 255); }
void display_generate_button(int win_width, int win_height, Interface* interface) { int generate_button_x, generate_button_y; int generate_button_w, generate_button_h; char generate_text[RESET_GENERATE_TEXTBOX]; generate_button_w = (win_width / TEXT_ED_WIDTH) / 2 + 1; generate_button_h = win_height / BUTTON_HEIGHT; generate_button_x = (win_width / TEXT_ED_WIDTH) / 2; generate_button_y = win_height - generate_button_h; make_rect(&interface->window, &interface->generate_button, generate_button_x, generate_button_y, generate_button_w, generate_button_h, 241, 35, 65); text_align_central(generate_text, "Generate", RESET_GENERATE_TEXTBOX); make_text(&interface->window, &interface->generate_button.rect, interface->button_font, generate_text, 255, 255, 255); }
/* Here we draw the text description for the histograms */ void make_histogram_desc(long number_of_frames) { char framestat[25]; sprintf(framestat, "Y Stat till frame %ld", number_of_frames); make_text(sum1_x, sum1_y, framestat); sprintf(framestat, "U Stat till frame %ld", number_of_frames); make_text(sum2_x, sum2_y, framestat); sprintf(framestat, "V Stat till frame %ld", number_of_frames); make_text(sum3_x, sum3_y, framestat); sprintf(framestat, "Y Stat curent frame"); make_text(frm1_x, frm1_y, framestat); sprintf(framestat, "U Stat curent frame"); make_text(frm2_x, frm2_y, framestat); sprintf(framestat, "V Stat curent frame"); make_text(frm3_x, frm3_y, framestat); }
void display_reset_button(int win_width, int win_height, Interface* interface, Mode mode) { int reset_button_x, reset_button_y, reset_button_w, reset_button_h; char reset_text[RESET_GENERATE_TEXTBOX]; reset_button_w = (win_width / TEXT_ED_WIDTH) / 2; reset_button_h = win_height / BUTTON_HEIGHT; reset_button_x = 0; reset_button_y = win_height - reset_button_h; make_rect(&interface->window, &interface->reset_button, reset_button_x, reset_button_y, reset_button_w, reset_button_h, 241, 35, 65); if (mode == challenge_mode) { text_align_central(reset_text, "Reset", RESET_GENERATE_TEXTBOX); } else { text_align_central(reset_text, "Clear", RESET_GENERATE_TEXTBOX); } make_text(&interface->window, &interface->reset_button.rect, interface->button_font, reset_text, 255, 255, 255); }