void TrackEditorPattern::paint_cursor(GUI::Painter &p,int p_row) { int rowsize=get_row_height(); int fontofs=(rowsize-get_font_height())/2; int textofs=p_row*rowsize+fontofs; int columnwidth=get_font_width()*4; int column=Editor::get_singleton()->get_cursor_col(); int field=Editor::get_singleton()->get_cursor_field(); int xofs=column*columnwidth+get_font_width(); //xofs+=VisualSettings::get_singleton()->get_pattern_cursor_offset().x; //textofs+=VisualSettings::get_singleton()->get_pattern_cursor_offset().y; switch( Editor::get_singleton()->get_track_edit_mode() ) { case Editor::EDIT_MODE_FRONT: { xofs+=2*field*get_font_width(); } break; case Editor::EDIT_MODE_BACK: { xofs+=get_font_width()+field*get_font_width(); } break; } p.draw_stylebox( stylebox( SB_TRACK_EDITOR_CURSOR ), GUI::Point(xofs,textofs), GUI::Size( get_font_width(), get_font_height() ) ); }
static gdouble e_contact_get_contact_height (EContact *contact, EContactPrintContext *ctxt) { gchar *file_as; gint field; gdouble cntct_height = 0.0; cntct_height += get_font_height (ctxt->style->headings_font) * .2; file_as = e_contact_get (contact, E_CONTACT_FILE_AS); cntct_height += e_contact_text_height ( ctxt->context, ctxt->style->headings_font, file_as); g_free (file_as); cntct_height += get_font_height (ctxt->style->headings_font) * .2; for (field = E_CONTACT_FILE_AS; field != E_CONTACT_LAST_SIMPLE_STRING; field++) { const gchar *value; gchar *text; value = e_contact_get_const (contact, field); if (value == NULL || *value == '\0') continue; text = g_strdup_printf ("%s: %s", e_contact_pretty_name (field), value); cntct_height += e_contact_text_height ( ctxt->context, ctxt->style->body_font, text); cntct_height += .2 * get_font_height (ctxt->style->body_font); g_free (text); } cntct_height += get_font_height (ctxt->style->headings_font) * .4 + 8; return cntct_height; }
static void focus_in_callback (GtkWidget *w, GdkEventFocus *event, dt_lib_module_t *self) { GtkWidget *win = darktable.gui->widgets.main_window; GtkEntry *entry = GTK_ENTRY(self->text); GtkTreeView *view; int count = 1 + count_film_rolls(gtk_entry_get_text(entry)); int ht = get_font_height(view, "Dreggn"); const int size = MAX(2*ht, MIN(win->allocation.height/2, count*ht)); gtk_widget_set_size_request(view, -1, size); }
/* * @breif 本函数功能是通过判断 * */ si_t shortcut_update_all_areas ( struct shortcut * sh ) { struct rectangle area; /* 总字数 , 单字宽度,单字高度,每行字数 ,总行数,最后一行的字数 */ si_t char_total_num ; si_t font_height; si_t font_width; si_t text_line_num; si_t maxlen; application_widget_absolute_area(WIDGET_POINTER(sh), &area); if(shortcut_get_is_text_visiable(sh) == 1) { /* 总字数 , 单字宽度,单字高度 */ char_total_num = strlen( sh->text ); font_height = get_font_height( sh->gd ) ; font_width = get_font_width( sh->gd ) ; maxlen = area.width * 2 / font_width; text_line_num = char_total_num / maxlen + 1; if( font_height > sh->area.height || font_width >sh->area.width) { EGUI_PRINT_ERROR("font for desktop shortcut is too large"); return -1; } sh->text_field.x = area.x ; sh->text_field.y = area.y + area.height - ( text_line_num * font_height ); sh->text_field.width = area.width; sh->text_field.height = text_line_num * font_height ; sh->img_field.x = area.x ; //sh->img_field.x = area.x + area.width/4 ; sh->img_field.y = area.y ; sh->img_field.width = area.width ; sh->img_field.height = area.height - sh->text_field.height; } else { sh->img_field.x = area.x ; sh->img_field.y = area.y ; sh->img_field.width = area.width ; sh->img_field.height = area.height ; } return 1; }
si_t shortcut_show_text(struct shortcut * sh) { /* 总字数 , 单字宽度,单字高度,每行字数 ,总行数,最后一行的字数 */ si_t char_total_num ; si_t font_width; si_t font_height; si_t maxlen; si_t text_line_num; si_t last_line_text_num; si_t i = 0; char_total_num = strlen( sh->text ); font_width = get_font_width( sh->gd ) ; font_height = get_font_height( sh->gd ) ; maxlen = (sh->area.width * 2 )/ font_width; last_line_text_num = char_total_num % maxlen ; text_line_num = char_total_num / maxlen + 1; set_color(sh->gd, sh->fore_color.r, sh->fore_color.g, sh->fore_color.b, sh->fore_color.a); /* 设置区域 , 文字区域*/ set_area(sh->gd, sh->text_field.x , sh->text_field.y , sh->text_field.width , sh->text_field.height); /* 填充矩形 fill_rectangle(sh->gd, sh->text_field.x, sh->text_field.y, sh->text_field.width , sh->text_field.height); * */ /* 显示文字 */ for( i = 0; i < text_line_num -1; i++ ) { show_text(sh->gd, sh->text_field.x, sh->text_field.y + i * font_height , sh->text + i*maxlen ,maxlen); } show_text( sh->gd, sh->text_field.x + ( sh->text_field.width - last_line_text_num * font_width ) / 2, sh->text_field.y + i * font_height , sh->text + i * maxlen , last_line_text_num ); return 0; }
/** * Refresh the dimensions of the block from the glyphs. */ void text_calculate_size(Text *text) { SDL_Rect r; char *c = text->value; int fheight = get_font_height(text); text->width = 0; while (*c != '\0') { font_get_glyph_rect(text->font, *c, &r); text->width += r.w; if (*c == '\n' || (*c == '\\' && *(c+1) == 'n')) text->height += fheight + text->line_spacing; c++; } }
/** * This function will simply print the 'text' at the given coordinate. */ void text_render(Text *text, SDL_Surface *s) { char *c = text->value; int cursor = 0; int rx = 0, ry = 0; int fheight = get_font_height(text); int count = 0; while (*c != '\0') { /* Real Newline */ if (*c == '\n') { cursor = 0; ry += fheight + text->line_spacing; c++; continue; } /* Forced Newline */ if (*c == '\\' && *(c+1) == 'n') { cursor = 0; ry += fheight + text->line_spacing; c += 2; continue; } if (text->effect & EFFECT_SHAKE) text_effect_shake(text, &rx, &ry); if (text->effect & EFFECT_WAVE) text_effect_wave(text, count, &ry); cursor += text_render_glyph(text, s, *c, cursor + rx, 0 + ry); c++; count++; } if (text->colorized == true) text_effect_colorize(text, s); }
extern si_t text_line_get_max_line_shown(struct text_line* t) { si_t fontx, fonty, max_line; /** * make sure the font size fits the area * the magic number 12 is: * 4 for outter frame * + 6 for inner frame * + 2 for margin between text and the inner frame **/ ++ t->font; do{ -- t->font; set_font(t->gd, t->font); fontx = get_font_width(t->gd); fonty = get_font_height(t->gd); }while(fonty > (t->area.height - 12) || fontx > t->area.width - 12); max_line = (t->area.height - 12) / fonty; t->chars_per_line = (t->area.width - 12) / fontx; return max_line; }
/** * Return an SDL Rectangle of the position and size of the text block. */ void text_get_rectangle(Text *text, SDL_Rect *r) { int fheight = get_font_height(text); int y = text->y; /* Make way for the wave! */ if (text->effect & EFFECT_WAVE) { fheight += 4; y -= 2; } r->w = text->width; r->h = fheight; r->y = y; if (text->centered == true) r->x = (screen->w - text->width) / 2 + text->x; else r->x = text->x; /* Float effect makes the text go up slowly... */ if (text->effect & EFFECT_FLOAT) text_effect_float(text, r); }
void gui_init (dt_lib_module_t *self) { dt_lib_styles_t *d = (dt_lib_styles_t *)malloc (sizeof (dt_lib_styles_t)); self->data = (void *)d; d->edit_button = NULL; self->widget = gtk_vbox_new (FALSE, 5); GtkWidget *w; /* list */ d->list = GTK_TREE_VIEW (gtk_tree_view_new ()); gtk_tree_view_set_headers_visible(d->list,FALSE); GtkListStore *liststore = gtk_list_store_new (DT_STYLES_NUM_COLS, G_TYPE_STRING, G_TYPE_STRING); GtkTreeViewColumn *col = gtk_tree_view_column_new (); gtk_tree_view_append_column (GTK_TREE_VIEW (d->list), col); GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (col, renderer, TRUE); gtk_tree_view_column_add_attribute (col, renderer, "text", DT_STYLES_COL_NAME); int ht = get_font_height( GTK_WIDGET (d->list), "Dreggn"); gtk_widget_set_size_request (GTK_WIDGET (d->list), -1, 5*ht); gtk_tree_selection_set_mode (gtk_tree_view_get_selection(GTK_TREE_VIEW(d->list)), GTK_SELECTION_SINGLE); gtk_tree_view_set_model (GTK_TREE_VIEW(d->list), GTK_TREE_MODEL(liststore)); g_object_unref (liststore); g_object_set(G_OBJECT(d->list), "tooltip-text", _("available styles,\ndoubleclick to apply"), (char *)NULL); g_signal_connect (d->list, "row-activated", G_CALLBACK(_styles_row_activated_callback), d); /* filter entry */ w = gtk_entry_new(); d->entry=GTK_ENTRY(w); g_object_set(G_OBJECT(w), "tooltip-text", _("enter style name"), (char *)NULL); g_signal_connect (d->entry, "changed", G_CALLBACK(entry_callback),d); g_signal_connect (d->entry, "activate", G_CALLBACK(entry_activated),d); dt_gui_key_accel_block_on_focus ( GTK_WIDGET (d->entry)); gtk_box_pack_start(GTK_BOX (self->widget),GTK_WIDGET (d->entry),TRUE,FALSE,0); gtk_box_pack_start(GTK_BOX (self->widget),GTK_WIDGET (d->list),TRUE,FALSE,0); GtkWidget *hbox=gtk_hbox_new (FALSE,5); GtkWidget *widget; d->duplicate = gtk_check_button_new_with_label(_("create duplicate")); gtk_box_pack_start(GTK_BOX (self->widget),GTK_WIDGET (d->duplicate),TRUE,FALSE,0); g_signal_connect (d->duplicate, "toggled", G_CALLBACK(duplicate_callback),d); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (d->duplicate), dt_conf_get_bool("ui_last/styles_create_duplicate")); g_object_set (d->duplicate, "tooltip-text", _("creates a duplicate of the image before applying style"), (char *)NULL); #if 0 // TODO: Unfinished stuff GtkWidget *widget=gtk_button_new_with_label(_("edit")); d->edit_button = widget; also add to the init function g_signal_connect (widget, "clicked", G_CALLBACK(edit_clicked),d); gtk_box_pack_start(GTK_BOX (hbox),widget,TRUE,TRUE,0); #endif widget=gtk_button_new_with_label(_("delete")); d->delete_button = widget; g_signal_connect (widget, "clicked", G_CALLBACK(delete_clicked),d); g_object_set (widget, "tooltip-text", _("deletes the selected style in list above"), (char *)NULL); gtk_box_pack_start(GTK_BOX (hbox),widget,TRUE,TRUE,0); gtk_box_pack_start(GTK_BOX (self->widget),hbox,TRUE,FALSE,0); // Export Button GtkWidget *exportButton = gtk_button_new_with_label(_("export")); d->export_button = exportButton; g_object_set (exportButton, "tooltip-text", _("export the selected style into a style file"), (char *)NULL); g_signal_connect (exportButton, "clicked", G_CALLBACK(export_clicked),d); gtk_box_pack_start(GTK_BOX (hbox),exportButton,TRUE,TRUE,0); // Import Button GtkWidget *importButton = gtk_button_new_with_label(C_("styles", "import")); d->import_button = importButton; g_object_set (importButton, "tooltip-text", _("import style from a style file"), (char *)NULL); g_signal_connect (importButton, "clicked", G_CALLBACK(import_clicked),d); gtk_box_pack_start(GTK_BOX (hbox),importButton,TRUE,TRUE,0); // add entry completion GtkEntryCompletion *completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, gtk_tree_view_get_model(GTK_TREE_VIEW(d->list))); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_set_completion(d->entry, completion); /* update filtered list */ _gui_styles_update_view(d); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //style_init //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int style_startup() { // -------------------- StyleItem * T = (StyleItem *)GetSettingPtr(SN_TOOLBAR); StyleItem * W = (StyleItem *)GetSettingPtr(SN_TOOLBARWINDOWLABEL); StyleItem * L = (StyleItem *)GetSettingPtr(SN_TOOLBARLABEL); StyleItem * C = (StyleItem *)GetSettingPtr(SN_TOOLBARCLOCK); StyleItem * B = (StyleItem *)GetSettingPtr(SN_TOOLBARBUTTON); StyleItem * X; if (T->validated & VALID_TEXTCOLOR) X = T; else if (W->parentRelative) X = W; else if (L->parentRelative) X = L; else if (C->parentRelative) X = C; else if (B->parentRelative) X = B; else X = L; COLORREF Color_N = X->TextColor; if (false == W->parentRelative) X = W; else if (false == L->parentRelative) X = L; else if (false == C->parentRelative) X = C; else if (false == B->parentRelative) X = B; else X = T; StyleItem * A = X; if (X == T) X = W; COLORREF Color_A = X->TextColor; style_fill[STYLETYPE_TOOLBAR] = *T; style_fill[STYLETYPE_TOOLBAR].TextColor = Color_N; style_fill[STYLETYPE_INSET] = *A; style_fill[STYLETYPE_INSET].TextColor = Color_A; style_fill[STYLETYPE_FLAT] = style_fill[STYLETYPE_TOOLBAR]; style_fill[STYLETYPE_FLAT].ColorTo = style_fill[STYLETYPE_TOOLBAR].Color; style_fill[STYLETYPE_SUNKEN] = style_fill[STYLETYPE_INSET]; style_fill[STYLETYPE_SUNKEN].ColorTo = style_fill[STYLETYPE_INSET].Color; style_fill[STYLETYPE_NONE].TextColor = Color_N; style_font = CreateStyleFont(T); *(FARPROC*)&pSetLayeredWindowAttributes = GetProcAddress(GetModuleHandle((LPCWSTR)"USER32"), "SetLayeredWindowAttributes"); // -------------------- style_bevel_width = *(int*)GetSettingPtr(SN_BEVELWIDTH); style_border_width = *(int*)GetSettingPtr(SN_BORDERWIDTH); style_color_border = *(COLORREF*)GetSettingPtr(SN_BORDERCOLOR); style_font_height = get_font_height(style_font); //No errors return 0; }
static si_t text_line_default_show_text(struct text_line* t, si_t x, si_t y) { si_t fontx, fonty, startx, starty, rulerx, rulery1, rulery2, max_line; /** * start axis; * the magic number 6 is: * 2 for outter frame * + 3 for inner frame * + 1 for margin between text and the inner frame **/ max_line = text_line_get_max_line_shown(t); fonty = get_font_height(t->gd); fontx = get_font_width(t->gd); startx = x + 6; starty = y + 6 + (t->area.height - 12 - fonty * max_line) / 2; /** * if there are text in buffer **/ if(strlen(t->buf) != 0) { char* strshow; char* start; si_t i = 0; si_t lines; /** * adjust start index * also, lines refers to the line that current ruler is in **/ lines = lines_between(t->show_start, t->ruler_cur, t->chars_per_line, t->is_enter_enable, t->is_linewrap); if(lines == -1) { start = get_prev_line_start(t->show_start, t->chars_per_line, t->is_enter_enable, t->is_linewrap); if(!start) return -1; t->show_start = start; lines = 0; /** * dispatch page up event to subscriber **/ event_to_be_dispatched = TEXT_LINE_EVENT_PAGE_UP; list_for_each(&t->subscribe_info_list, do_handle_event); } else if(lines == max_line) { start = get_next_line_start(t->show_start, t->chars_per_line, t->is_enter_enable, t->is_linewrap); if(!start) return -1; t->show_start = start; lines = max_line - 1; /** * dispatch page down event to subscriber **/ event_to_be_dispatched = TEXT_LINE_EVENT_PAGE_DOWN; list_for_each(&t->subscribe_info_list, do_handle_event); } /** * show line by line **/ strshow = t->show_start; while(i != max_line && strshow != NULL) { char* next = get_next_line_start(strshow, t->chars_per_line, t->is_enter_enable, t->is_linewrap); si_t showlen; if(next == NULL) { showlen = strlen(strshow); } else { showlen = next - strshow; } /** * locate ruler **/ if(i == lines) { t->ruler_line_start = strshow; rulerx = startx + (t->ruler_cur - strshow) * fontx; rulery1 = starty; rulery2 = starty + fonty; } /** * show text **/ set_color(t->gd, t->fore_color.r, t->fore_color.g, t->fore_color.b, t->fore_color.a); if(text_line_is_keybd_type_password(t)) { char tmpstr[MAXBUF]; si_t left = showlen; while(left > MAXBUF) { memset(tmpstr, '*', MAXBUF); show_text(t->gd, startx, starty, tmpstr, MAXBUF); left -= MAXBUF; startx += MAXBUF * fontx; } memset(tmpstr, '*', left - 1); if(t->keybd_focus) tmpstr[left - 1] = strshow[showlen - 1]; else tmpstr[left - 1] = '*'; show_text(t->gd, startx, starty, tmpstr, left); } else { /** * enter cannot be shown! **/ if(showlen > 0 && strshow[showlen - 1] == '\n') show_text(t->gd, startx, starty, strshow, showlen - 1); else show_text(t->gd, startx, starty, strshow, showlen); } ++ i; strshow = next; starty += fonty; } } /** * else if placeholder need to be displayed **/ else if(t->placeholder != NULL && !t->keybd_focus) { /* FIXME */ set_color(t->gd, t->frame_color.r, t->frame_color.g, t->frame_color.b, t->frame_color.a); show_text(t->gd, startx, starty, t->placeholder, strlen(t->placeholder) + 1); return 0; } /** * no input; just a ruler **/ else { rulerx = startx; rulery1 = starty; rulery2 = starty + fonty; } /** * show ruler **/ if(t->keybd_focus) { set_color(t->gd, t->fore_color.r, t->fore_color.g, t->fore_color.b, t->fore_color.a); draw_line(t->gd, rulerx, rulery1, rulerx, rulery2); } return 0; }
static LRESULT CALLBACK startup_wnd_proc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { MSG msg; Sint32 screenType; Sint32 drawMode; Sint32 drawMethod; Sint32 vsync; Sint32 psgType; Sint32 soundBuffer; switch (uMsg) { case WM_CREATE: EnableWindow(WINMAIN_GetHwnd(), FALSE);//メインウィンドウを無効化してモーダルに。 _hFontB = CreateFont( 0, // 高さ。0 = デフォルト 0, // 幅。0なら高さに合った幅 0, // 角度 0, // ベースラインとの角度 FW_NORMAL, // 太さ FALSE, // イタリック FALSE, // アンダーライン FALSE, // 打ち消し線 0, // 日本語を取り扱うときはSHIFTJIS_CHARSETにする。 0, // 出力精度 0, // クリッピング精度 0, // 出力品質 0, // ピッチとファミリー "" // 書体名 ); //英語のデフォルトフォントに設定 _FontWidth = get_font_width(hWnd); _FontHeight = get_font_height(hWnd); set_window_size(hWnd); break; case WM_PAINT: update_window(hWnd); break; case WM_COMMAND: switch(LOWORD(wParam)) { case BUTTON_CDROM: _CDorHu = 1; //戻り値を設定 PostMessage(hWnd, WM_CLOSE, 0, 0); break; case BUTTON_CUE: _CDorHu = 2; //戻り値を設定 PostMessage(hWnd, WM_CLOSE, 0, 0); break; case BUTTON_HUCARD: _CDorHu = 3; //戻り値を設定 PostMessage(hWnd, WM_CLOSE, 0, 0); break; case BUTTON_REPLAY: _CDorHu = 4; //戻り値を設定 PostMessage(hWnd, WM_CLOSE, 0, 0); break; case BUTTON_OPTION: soundBuffer = 0; //全項目の値が設定されたかどうかの判断にも使用。 OPTION_Init(_hInstance, &screenType, &drawMode, &drawMethod, &vsync, &psgType, &soundBuffer); //Optionウィンドウを表示 //メッセージループ while (soundBuffer == 0) //ダイアログが結果を返すまでループ { GetMessage(&msg ,NULL, 0, 0); TranslateMessage(&msg); DispatchMessage(&msg); } //Ok(SET)ボタンが押されていた場合、スクリーン設定を変更する。 if (screenType > 0) { switch (screenType) { case 1: APP_SetStartFullScreen(FALSE); break; case 2: APP_SetMagnification(2); //x2倍に設定 APP_SetStartFullScreen(FALSE); break; case 3: APP_SetMagnification(3); //x3倍に設定 APP_SetStartFullScreen(FALSE); break; case 4: APP_SetMagnification(4); //x4倍に設定 APP_SetStartFullScreen(FALSE); break; case 5: APP_SetStartFullScreen(TRUE); break; case 6: APP_SetFullScreen640(); //640x480に設定 APP_SetStartFullScreen(TRUE); break; } } //Ok(SET)ボタンが押されていた場合、DrawMode設定を変更する。 if (drawMode > 0) { switch (drawMode) { case 1: APP_SetScanLineType(1,TRUE); break; case 2: APP_SetScanLineType(4,TRUE); break; case 3: APP_SetScanLineType(2,TRUE); break; case 4: APP_SetScanLineType(0,TRUE); break; } } //Ok(SET)ボタンが押されていた場合、DrawMethod設定を変更する。 if (drawMethod > 0) { APP_SetDrawMethod(drawMethod); } //Ok(SET)ボタンが押されていた場合、V-Sync設定を変更する。 if (screenType > 0) { if (vsync == 2) APP_SetSyncTo60HzScreen(FALSE); else //==1 APP_SetSyncTo60HzScreen(TRUE); } //Ok(SET)ボタンが押されていた場合、PSGクォリティ設定を変更する。 if (psgType > 0) { if (psgType == 3) APP_SetPsgQuality(1); else if (psgType == 2) APP_SetPsgQuality(2); else //==1 APP_SetPsgQuality(4); } //Ok(SET)ボタンが押されていた場合、PSGクォリティ設定を変更する。 if (soundBuffer > 0) { switch (soundBuffer) { case 1: APP_SetSoundBufferSize(1024); break; case 2: APP_SetSoundBufferSize(1152); break; case 3: APP_SetSoundBufferSize(1280); break; case 4: APP_SetSoundBufferSize(1408); break; case 5: APP_SetSoundBufferSize(1536); break; case 7: APP_SetSoundBufferSize(1792); break; case 8: APP_SetSoundBufferSize(2048); break; case 9: APP_SetSoundBufferSize(2176); break; case 10: APP_SetSoundBufferSize(2304); break; case 11: APP_SetSoundBufferSize(2560); break; case 12: APP_SetSoundBufferSize(3072); break; default: //==6 APP_SetSoundBufferSize(1664); break; } } break; } break; case WM_KEYDOWN: if (wParam == VK_ESCAPE) PostMessage(hWnd, WM_CLOSE, 0, 0); if ((wParam == 'C')||(wParam == VK_RETURN)) //「C」キーまたは 「Enter」キー { _CDorHu = 1; //戻り値を設定 PostMessage(hWnd, WM_CLOSE, 0, 0); } if (wParam == 'P') //「P」キー { _CDorHu = 2; //戻り値を設定 PostMessage(hWnd, WM_CLOSE, 0, 0); } if ((wParam == 'H')||(wParam == 'O')||(wParam == VK_SPACE)) //「H」キー「O」キーまたは スペースキー { _CDorHu = 3; //戻り値を設定 PostMessage(hWnd, WM_CLOSE, 0, 0); } if (wParam == 'R') //「R」キー { _CDorHu = 4; //戻り値を設定 PostMessage(hWnd, WM_CLOSE, 0, 0); } break; case WM_CLOSE: STARTUP_Deinit(); return 0; } return DefWindowProc(hWnd, uMsg, wParam, lParam); }
void TrackEditorPattern::paint_multiple_nonvisible_events( GUI::Painter& p, int p_row, const NoteList& p_list) { int font_width=get_font_width(); int rowsize=get_row_size(); int fontofs=(rowsize-get_font_height())/2; int eventofs=p_row*rowsize+fontofs; int notewidth=get_font_width()*3; int columnwidth=get_font_width()*4; NoteList::const_iterator I=p_list.begin(); int howmany=p_list.size(); int maxevents=(rowsize-4)/2; if (howmany>maxevents) howmany=maxevents; int maxsize=(rowsize-4)-(howmany-1); for (int i=0;i<howmany;I++,i++) { NoteListElement note = *I; int xofs=font_width+note.pos.column*columnwidth; int from=i*maxsize/howmany; int to=((i+1)*maxsize/howmany); int eheight = to-from; if (eheight<=0) eheight=1; from+=i; //printf("%i - from %i, height %i\n",i,from,eheight); //GUI::Color col=color(COLOR_PATTERN_FONT); if (note.note.is_note()) { switch( Editor::get_singleton()->get_track_edit_mode() ) { case Editor::EDIT_MODE_FRONT: { GUI::Color bg=GUI::Color(COLOR_PATTERN_NOTE_BG); GUI::Color fg=color(COLOR_PATTERN_FONT); int note_w=get_note_display_column_pos(notewidth,note.note.note); p.draw_fill_rect(GUI::Point(xofs,eventofs+from),GUI::Size(notewidth,eheight),bg); p.draw_fill_rect(GUI::Point(xofs+note_w,eventofs+from),GUI::Size(constant(C_TRACK_EDITOR_VOL_NOTE_BAR_HEIGHT),eheight),fg); } break; case Editor::EDIT_MODE_BACK: { GUI::Color bg=GUI::Color(COLOR_PATTERN_VOLUME_BG); GUI::Color fg=color(COLOR_PATTERN_FONT_VOLUME); int vol_w=(note.note.volume*notewidth)/PatternTrack::Note::MAX_VOLUME; p.draw_fill_rect(GUI::Point(xofs,eventofs+from),GUI::Size(notewidth,eheight),bg); p.draw_fill_rect(GUI::Point(xofs,eventofs+from),GUI::Size(vol_w,eheight),fg); } break; } } else if (note.note.is_note_off()) { GUI::Color col = color(COLOR_PATTERN_SUBBEAT_LINE); p.draw_fill_rect(GUI::Point(xofs,eventofs+from),GUI::Size(notewidth,eheight),col); } else { //printf("WTF!!\n"); } } }
int main(int argc, char* argv[]) { struct scroll_bar* s; struct button* b1 = NULL, *b2 = NULL; char msg[LABEL_MAX]; char file_msg[LABEL_MAX]; si_t video_access_mode = VIDEO_ACCESS_MODE_BUFFER; si_t app_type = APPLICATION_TYPE_NORMAL; char* file_name = NULL; si_t fonty = 0; /** * open with file **/ if(argc == 2) { struct stat st; if(stat(argv[1], &st) == -1) { EGUI_PRINT_ERROR("file %s does not exists", argv[1]); return -1; } if(!S_ISREG(st.st_mode) || access(argv[1], R_OK | W_OK) != 0) { EGUI_PRINT_ERROR("file %s cannot access!", argv[1]); return -1; } /** * file too large **/ if(st.st_size > FILE_MAX) { EGUI_PRINT_ERROR("file %s does not exists\n", argv[1]); return -1; } file_name = argv[1]; } else if(argc != 1) { EGUI_PRINT_ERROR("wrong parameter!\nusage: \nediterbasic\nor:\nediterbasic [filename]"); return -1; } /* 初始化用户应用程序 */ application_init(video_access_mode, app_type, "editerbasic"); /** * window **/ main_window = window_init("editer_basic"); /* 申请失败 */ if(main_window == NULL) { application_exit(); return -1; } window_set_bounds(main_window, 300, 100, 550, 300); window_set_color(main_window, NULL, &light_green); /** * label that show process **/ if(file_name) { sprintf(file_msg, "%s", file_name); } else { sprintf(file_msg, "new file"); } file_label = label_init(file_msg); if(file_label == NULL) { application_exit(); return -1; } label_set_bounds(file_label, 10, 10, 365, 20); label_set_color(file_label, &barely_blue, &light_blue); label_set_font(file_label, FONT_MATRIX_12); /** * save button **/ b1 = button_init("save"); if(b1 == NULL) { application_exit(); return -1; } button_set_bounds(b1, 380, 5, 60, 30); button_set_color(b1, &dark_blue, &barely_blue); button_set_font(b1, FONT_MATRIX_12); b1->callback = save_button_callback; b2 = button_init("save as"); if(b2 == NULL) { application_exit(); return -1; } button_set_bounds(b2, 445, 5, 100, 30); button_set_color(b2, &dark_blue, &barely_blue); button_set_font(b2, FONT_MATRIX_12); b2->callback = save_as_button_callback; /** * text_line that shows file context **/ file_context_text_line = text_line_init(FILE_MAX, 0); if(file_context_text_line == NULL) { application_exit(); return -1; } text_line_set_bounds(file_context_text_line, 5, 40, 520, 230); text_line_set_color(file_context_text_line, &dark_blue, NULL, NULL); text_line_set_multilines(file_context_text_line); fonty = get_font_height(file_context_text_line->gd); if(file_name) { if(load_file(file_name, text_line_get_buf(file_context_text_line)) < 0) { EGUI_PRINT_ERROR("failed to load file %s", file_name); application_exit(); return -1; } s = scroll_bar_init(1, fonty * text_line_get_max_line_shown(file_context_text_line), fonty); } else { s = scroll_bar_init(1, file_context_text_line->area.height, fonty); } if(s == NULL) { application_exit(); return -1; } scroll_bar_set_bounds(s, 525, 40, 20, 230); text_line_register_move_handler(file_context_text_line, WIDGET_POINTER(s), TEXT_LINE_EVENT_ALL, scrollbar_subscribe_text_line); scroll_bar_register_move_handler(s, WIDGET_POINTER(file_context_text_line), SCROLL_BAR_EVENT_ALL, text_line_subscribe_scrollbar); log_label = label_init(msg); if(log_label == NULL) { application_exit(); return -1; } label_set_bounds(log_label, 5, 275, 450, 20); label_set_color(log_label, NULL, &light_green); sprintf(msg, "open file successfully!"); object_attach_child(OBJECT_POINTER(main_window), OBJECT_POINTER(file_label)); object_attach_child(OBJECT_POINTER(main_window), OBJECT_POINTER(file_context_text_line)); object_attach_child(OBJECT_POINTER(main_window), OBJECT_POINTER(log_label)); object_attach_child(OBJECT_POINTER(main_window), OBJECT_POINTER(b1)); object_attach_child(OBJECT_POINTER(main_window), OBJECT_POINTER(b2)); object_attach_child(OBJECT_POINTER(main_window), OBJECT_POINTER(s)); /* 添加顶层窗口 */ application_add_window(NULL, main_window); /* 设置主窗口 */ application_set_main_window(main_window); /* 运行 */ application_exec(); return 0; }
static void e_contact_print_contact (EContact *contact, EContactPrintContext *ctxt) { GtkPageSetup *setup; gchar *file_as; cairo_t *cr; gdouble page_height; gint field; setup = gtk_print_context_get_page_setup (ctxt->context); page_height = gtk_page_setup_get_page_height (setup, GTK_UNIT_POINTS); cr = gtk_print_context_get_cairo_context (ctxt->context); cairo_save (cr); ctxt->y += get_font_height (ctxt->style->headings_font) * .2; file_as = e_contact_get (contact, E_CONTACT_FILE_AS); if (ctxt->style->print_using_grey && ctxt->pages == ctxt->page_nr) { cairo_save (cr); cairo_set_source_rgb (cr, .85, .85, .85); cairo_rectangle (cr, ctxt->x, ctxt->y, ctxt->column_width, e_contact_text_height (ctxt->context, ctxt->style->headings_font, file_as)); cairo_fill (cr); cairo_restore (cr); } if (ctxt->pages == ctxt->page_nr) e_contact_output ( ctxt->context, ctxt->style->headings_font, ctxt->x, ctxt->y, ctxt->column_width + 4, file_as); ctxt->y += e_contact_text_height ( ctxt->context, ctxt->style->headings_font, file_as); g_free (file_as); ctxt->y += get_font_height (ctxt->style->headings_font) * .2; for (field = E_CONTACT_FILE_AS; field != E_CONTACT_LAST_SIMPLE_STRING; field++) { const gchar *value; gchar *text; gint wrapped_lines = 0; if (ctxt->y > page_height) e_contact_start_new_column (ctxt); value = e_contact_get_const (contact, field); if (value == NULL || *value == '\0') continue; text = g_strdup_printf ("%s: %s", e_contact_pretty_name (field), value); if (ctxt->pages == ctxt->page_nr) e_contact_output ( ctxt->context, ctxt->style->body_font, ctxt->x, ctxt->y, ctxt->column_width + 4, text); if (get_font_width (ctxt->context, ctxt->style->body_font, text) > ctxt->column_width) wrapped_lines = (get_font_width (ctxt->context, ctxt->style->body_font, text) / (ctxt->column_width + 4)) + 1; ctxt->y = ctxt->y + ((wrapped_lines + 1) * e_contact_text_height (ctxt->context, ctxt->style->body_font, text)); ctxt->y += .2 * get_font_height (ctxt->style->body_font); g_free (text); } ctxt->y += get_font_height (ctxt->style->headings_font) * .4 + 8; cairo_restore (cr); }