📄 callbacks.c
字号:
eof_warn = 0; }; buf[0] = '0'; }; gdk_draw_rectangle (pixmap, buf[0] == '1' ? drawtable->style->black_gc : drawtable->style->white_gc, TRUE, (j - 1) * 6, (i - 1) * 6, 5, 5); gdk_draw_rectangle (pixmapSmall, buf[0] == '1' ? drawtableSmall->style->black_gc : drawtableSmall->style->white_gc, TRUE, (j - 1), (i - 1), 1, 1); image[j-1][i-1] = buf[0]; }; close(fd); refreshAll(); imgchanged = 0; }; if (FileAction == FA_SAVE) { fd = open(tempf, O_RDONLY); if (fd > 0) { close(fd); ask("File already exists.\nWould you like to overwrite this file?", ASK_REPLACE); return; }; FileAction = FA_NONE; gtk_widget_destroy(filewindow); if (zapisz(tempf)) return; }; strcpy(filename, tempf); tempf[0] = 0; sprintf(buf, "Nokia Logo Editor - %s", rindex(filename, '/')+1); gtk_window_set_title (GTK_WINDOW (MainWindow), buf);}voidon_cancel_button1_clicked (GtkButton *button, gpointer user_data){ FileAction = FA_NONE; AskAction = ASK_NONE; gtk_widget_destroy(filewindow);}voidon_askokbutton_clicked (GtkButton *button, gpointer user_data){ gtk_widget_destroy(askwindow); if (AskAction == ASK_QUITSAVE) { zapisz(filename); }; if (AskAction == ASK_NEWSAVE) { zapisz(filename); }; if (AskAction == ASK_OPENSAVE) { zapisz(filename); }; if (AskAction == ASK_REPLACE) { zapisz(tempf); tempf[0] = 0; };}voidon_asknobutton_clicked (GtkButton *button, gpointer user_data){ gtk_widget_destroy(askwindow); if (AskAction == ASK_QUITSAVE) { AskAction = ASK_NONE; gtk_widget_destroy(MainWindow); }; if (AskAction == ASK_NEWSAVE) { AskAction = ASK_NONE; imgchanged = 0; clear(1); }; if (AskAction == ASK_OPENSAVE) { AskAction = ASK_NONE; openfile(1); }; if (AskAction == ASK_REPLACE) { AskAction = ASK_NONE; };}voidon_clear1_activate (GtkMenuItem *menuitem, gpointer user_data){ clear(0);}void invert() { int i, j; char c; for (i = 1; i <= 14; i++ ) for (j = 1; j <= 72; j++ ) { c = image[j-1][i-1]; c = c == '1' ? '0' : '1'; gdk_draw_rectangle (pixmap, c == '1' ? drawtable->style->black_gc : drawtable->style->white_gc, TRUE, (j - 1) * 6, (i - 1) * 6, 5, 5); gdk_draw_rectangle (pixmapSmall, c == '1' ? drawtableSmall->style->black_gc : drawtableSmall->style->white_gc, TRUE, (j - 1), (i - 1), 1, 1); image[j-1][i-1] = c; }; refreshAll(); imgchanged = 1; return;};void moveleft() { int i, j; char c; char mem[14]; j = 72; for (i = 1; i <= 14; i++ ) { c = image[0][i-1]; mem[i - 1] = c; }; for (i = 1; i <= 14; i++ ) for (j = 1; j <= 71; j++ ) { c = image[j][i-1]; gdk_draw_rectangle (pixmap, c == '1' ? drawtable->style->black_gc : drawtable->style->white_gc, TRUE, (j - 1) * 6, (i - 1) * 6, 5, 5); gdk_draw_rectangle (pixmapSmall, c == '1' ? drawtableSmall->style->black_gc : drawtableSmall->style->white_gc, TRUE, (j - 1), (i - 1), 1, 1); image[j-1][i-1] = c; }; j = 72; for (i = 1; i <= 14; i++ ) { c = mem[i-1]; gdk_draw_rectangle (pixmap, c == '1' ? drawtable->style->black_gc : drawtable->style->white_gc, TRUE, (j - 1) * 6, (i - 1) * 6, 5, 5); gdk_draw_rectangle (pixmapSmall, c == '1' ? drawtableSmall->style->black_gc : drawtableSmall->style->white_gc, TRUE, (j - 1), (i - 1), 1, 1); image[j - 1][i-1] = c; }; refreshAll(); imgchanged = 1; return;};void moveright() { int i, j; char c; char mem[14]; j = 1; for (i = 1; i <= 14; i++ ) { c = image[71][i-1]; mem[i - 1] = c; }; for (i = 1; i <= 14; i++ ) for (j = 72; j >= 2; j-- ) { c = image[j-2][i-1]; gdk_draw_rectangle (pixmap, c == '1' ? drawtable->style->black_gc : drawtable->style->white_gc, TRUE, (j - 1) * 6, (i - 1) * 6, 5, 5); gdk_draw_rectangle (pixmapSmall, c == '1' ? drawtableSmall->style->black_gc : drawtableSmall->style->white_gc, TRUE, (j - 1), (i - 1), 1, 1); image[j-1][i-1] = c; }; j = 1; for (i = 1; i <= 14; i++ ) { c = mem[i-1]; gdk_draw_rectangle (pixmap, c == '1' ? drawtable->style->black_gc : drawtable->style->white_gc, TRUE, (j - 1) * 6, (i - 1) * 6, 5, 5); gdk_draw_rectangle (pixmapSmall, c == '1' ? drawtableSmall->style->black_gc : drawtableSmall->style->white_gc, TRUE, (j - 1), (i - 1), 1, 1); image[j - 1][i-1] = c; }; refreshAll(); imgchanged = 1; return;};void moveup() { int i, j; char c; char mem[72]; i = 1; for (j = 1; j <= 72; j++ ) { c = image[j-1][i-1]; mem[j-1] = c; }; for (i = 1; i <= 13; i++ ) for (j = 1; j <= 72; j++ ) { c = image[j-1][i]; gdk_draw_rectangle (pixmap, c == '1' ? drawtable->style->black_gc : drawtable->style->white_gc, TRUE, (j - 1) * 6, (i - 1) * 6, 5, 5); gdk_draw_rectangle (pixmapSmall, c == '1' ? drawtableSmall->style->black_gc : drawtableSmall->style->white_gc, TRUE, (j - 1), (i - 1), 1, 1); image[j-1][i-1] = c; }; i = 14; for (j = 1; j <= 72; j++ ) { c = mem[j-1]; gdk_draw_rectangle (pixmap, c == '1' ? drawtable->style->black_gc : drawtable->style->white_gc, TRUE, (j - 1) * 6, (i - 1) * 6, 5, 5); gdk_draw_rectangle (pixmapSmall, c == '1' ? drawtableSmall->style->black_gc : drawtableSmall->style->white_gc, TRUE, (j - 1), (i - 1), 1, 1); image[j-1][i-1] = c; }; refreshAll(); imgchanged = 1; return;};void movedown() { int i, j; char c; char mem[72]; i = 14; for (j = 1; j <= 72; j++ ) { c = image[j-1][i-1]; mem[j-1] = c; }; for (i = 14; i >= 2; i-- ) for (j = 1; j <= 72; j++ ) { c = image[j-1][i-2]; gdk_draw_rectangle (pixmap, c == '1' ? drawtable->style->black_gc : drawtable->style->white_gc, TRUE, (j - 1) * 6, (i - 1) * 6, 5, 5); gdk_draw_rectangle (pixmapSmall, c == '1' ? drawtableSmall->style->black_gc : drawtableSmall->style->white_gc, TRUE, (j - 1), (i - 1), 1, 1); image[j-1][i-1] = c; }; i = 1; for (j = 1; j <= 72; j++ ) { c = mem[j-1]; gdk_draw_rectangle (pixmap, c == '1' ? drawtable->style->black_gc : drawtable->style->white_gc, TRUE, (j - 1) * 6, (i - 1) * 6, 5, 5); gdk_draw_rectangle (pixmapSmall, c == '1' ? drawtableSmall->style->black_gc : drawtableSmall->style->white_gc, TRUE, (j - 1), (i - 1), 1, 1); image[j-1][i-1] = c; }; refreshAll(); imgchanged = 1; return;};voidon_invert1_activate (GtkMenuItem *menuitem, gpointer user_data){ invert();}voidon_move_left1_activate (GtkMenuItem *menuitem, gpointer user_data){ moveleft();}voidon_move_right1_activate (GtkMenuItem *menuitem, gpointer user_data){ moveright();}voidon_move_up1_activate (GtkMenuItem *menuitem, gpointer user_data){ moveup();}voidon_move_down1_activate (GtkMenuItem *menuitem, gpointer user_data){ movedown();}voidon_invertbutton_clicked (GtkButton *button, gpointer user_data){ invert();}voidon_mleftbutton_clicked (GtkButton *button, gpointer user_data){ moveleft();}voidon_mrightbutton_clicked (GtkButton *button, gpointer user_data){ moveright();}voidon_mupbutton_clicked (GtkButton *button, gpointer user_data){ moveup();}voidon_mdownbutton_clicked (GtkButton *button, gpointer user_data){ movedown();}void fliph() { int i, j; char c; char mem[72]; for (i = 1; i <= 7; i++ ) { for (j = 1; j <= 72; j++ ) mem[j-1] = image[j-1][i-1]; for (j = 1; j <= 72; j++ ) { c = image[j-1][15-i-1]; gdk_draw_rectangle (pixmap, c == '1' ? drawtable->style->black_gc : drawtable->style->white_gc, TRUE, (j - 1) * 6, (i - 1) * 6, 5, 5); gdk_draw_rectangle (pixmapSmall, c == '1' ? drawtableSmall->style->black_gc : drawtableSmall->style->white_gc, TRUE, (j - 1), (i - 1), 1, 1); image[j-1][i-1] = c; }; for (j = 1; j <= 72; j++ ) { c = mem[j-1]; gdk_draw_rectangle (pixmap, c == '1' ? drawtable->style->black_gc : drawtable->style->white_gc, TRUE, (j - 1) * 6, (15 - i - 1) * 6, 5, 5); gdk_draw_rectangle (pixmapSmall, c == '1' ? drawtableSmall->style->black_gc : drawtableSmall->style->white_gc, TRUE, (j - 1), (15 - i - 1), 1, 1); image[j-1][15-i-1] = c; }; }; imgchanged = 1; refreshAll(); return;};void flipv() { int i, j; char c; char mem[14]; for (j = 1; j <= (72/2); j++ ) { for (i = 1; i <= 14; i++ ) mem[i-1] = image[j-1][i-1]; for (i = 1; i <= 14; i++ ) { c = image[73-j-1][i-1]; gdk_draw_rectangle (pixmap, c == '1' ? drawtable->style->black_gc : drawtable->style->white_gc, TRUE, (j - 1) * 6, (i - 1) * 6, 5, 5); gdk_draw_rectangle (pixmapSmall, c == '1' ? drawtableSmall->style->black_gc : drawtableSmall->style->white_gc, TRUE, (j - 1), (i - 1), 1, 1); image[j-1][i-1] = c; }; for (i = 1; i <= 14; i++ ) { c = mem[i-1]; gdk_draw_rectangle (pixmap, c == '1' ? drawtable->style->black_gc : drawtable->style->white_gc, TRUE, (73 - j - 1) * 6, (i - 1) * 6, 5, 5); gdk_draw_rectangle (pixmapSmall, c == '1' ? drawtableSmall->style->black_gc : drawtableSmall->style->white_gc, TRUE, (73 - j - 1), (i - 1), 1, 1); image[73-j-1][i-1] = c; }; }; refreshAll(); imgchanged = 1; return;};voidon_fliph1_activate (GtkMenuItem *menuitem, gpointer user_data){ fliph();}voidon_flipv1_activate (GtkMenuItem *menuitem, gpointer user_data){ flipv();}voidon_fliphbutton_clicked (GtkButton *button, gpointer user_data){ fliph();}voidon_flipvbutton_clicked (GtkButton *button, gpointer user_data){ flipv();}gbooleanon_mainwindow_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data){ if (imgchanged) { ask("Image changed, would you like to save it?", ASK_QUITSAVE); return TRUE; }; return FALSE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -