📄 simp.c
字号:
/*
(c) Copyright 2001 Julien Etelain. All rights reserved.
*/
/* Revision History (as of 04/04/2002):
*
* 04/04/2002: Updated with new icon (orudge)
*/
#include<seal.h>
#include<app.h>
#include<dialogs.h>
#include<button.h>
#include<iodlg.h>
#include<inputbox.h>
#include<menus.h>
#include<grfx-f.H>
#include<seal/tabbook.h>
#include"simpdat.h"
static DATAFILE *dat = NULL;
#define Get_Bitmap(n) (BITMAP*)GET_DATA(dat, n)
#include"imgedit.c"
////////////////////////////////////////////////////////////////////////////////
#define MSG_TOOL_MIN 200000
#define MSG_TOOL_MAX 200010
#define MSG_HISUPDATE 200100
#define MSG_TOOL_OPEN 200101
#define MSG_TOOL_NEW 200102
#define MSG_TOOL_SAVE 200103
#define MSG_TOOL_BORDER_P 200104
#define MSG_TOOL_BORDER_M 200105
#define MSG_TOOL_SET_TRANS_VALUE 200106
#define MSG_xABOUT 200107
#define MSG_TOOL_UNDO 200108
#define MSG_TOOL_CFONT 200109
#define MSG_TOOL_COPY 200110
#define MSG_TOOL_PASTASS 200111
#define MSG_TOOL_PASTASP 200112
#define MSG_TOOL_SAVEAS 200113
#define MSG_xHELP 200114
#define MSG_TOOL_SET_TOLERANCE 200115
#define MSG_TOOL_SET_CENTER 200116
#define MSG_TOOLBOX 200117
#define MSG_TOOL_RESIZE 200118
#define MSG_FILTERS_MIN 200200
#define MSG_FILTERS_MAX 200250
////////////////////////////////////////////////////////////////////////////////
l_int oldset1x = 50;
l_int oldset1a = 90;
p_appwin xwin = NULL;
p_appwin xtoolbox = NULL;
p_appwin xcolors = NULL;
t_rect rtoolbox ;
t_rect rcolors ;
#define new_menu_item2(name,param,hk,msg,it,enable,img,next) new_menu_item_ex(name, param, hk, msg, enable, it, 0, NULL, img, NULL, 0, next)
#define new_sub_menu2(name,menu,enable,img,next) new_sub_menu_ex(name, enable, NULL, NULL, img, NULL, 0, menu, next)
////////////////////////////////////////////////////////////////////////////////
p_imgedit editorx = NULL;
p_colsel2 cco = NULL;
p_stattext sto = NULL;
p_tabbook conf_tab = NULL;
p_history pen_forme = NULL;
p_history pen_trans = NULL;
p_history forme_fill = NULL;
p_history forme_forme = NULL;
p_history ffill_gardient = NULL;
l_text txttool[] = { "MOVE", "ZOOM", "GET", "POINT", "FILL", "FORME" ,"SELECT","TEXT" };
l_int txttoolint[] = { MOVE_CUR,ZOOM,GET,PEN,FLOOD,FORME,SELECT,TEXT};
l_text actual_path = "/";
////////////////////////////////////////////////////////////////////////////////
static p_menu filters_menu_init ( )
{
p_menuitem v = NULL;
p_item x = imgfilters->first(imgfilters );
p_item f = x;
l_int a = 0;
do {
v = new_menu_item2(imgfilter(x->rec)->name, "", 0, MSG_FILTERS_MIN + a, NULL , true, NULL, v);
a++;
x = x->next;
} while ( x != f );
return new_menu(v);
};
////////////////////////////////////////////////////////////////////////////////
static p_list pen_forme_list ( void ) {
p_list p = list_init(_malloc(sizeof(t_list)), &free_history_item, 0);
p->insert(p, new_history_item(INI_TEXT("Rect") ,NULL,0,NULL));
p->insert(p, new_history_item(INI_TEXT("Circle") ,NULL,0,NULL));
return p;
};
////////////////////////////////////////////////////////////////////////////////
static p_list pen_trans_list ( void ) {
p_list p = list_init(_malloc(sizeof(t_list)), &free_history_item, 0);
p->insert(p, new_history_item(INI_TEXT("Full") ,NULL,0,NULL));
p->insert(p, new_history_item(INI_TEXT("Transparent") ,NULL,0,NULL));
p->insert(p, new_history_item(INI_TEXT("Linear Transparent") ,NULL,0,NULL));
return p;
};
////////////////////////////////////////////////////////////////////////////////
static p_list forme_fill_list ( void ) {
p_list p = list_init(_malloc(sizeof(t_list)), &free_history_item, 0);
p->insert(p, new_history_item(INI_TEXT("No fill") ,NULL,0,NULL));
p->insert(p, new_history_item(INI_TEXT("Fill with color 1") ,NULL,0,NULL));
p->insert(p, new_history_item(INI_TEXT("Fill with color 2") ,NULL,0,NULL));
return p;
};
////////////////////////////////////////////////////////////////////////////////
static p_list forme_forme_list ( void ) {
p_list p = list_init(_malloc(sizeof(t_list)), &free_history_item, 0);
p->insert(p, new_history_item(INI_TEXT("Line") ,NULL,0,NULL));
p->insert(p, new_history_item(INI_TEXT("Rect") ,NULL,0,NULL));
p->insert(p, new_history_item(INI_TEXT("Circle") ,NULL,0,NULL));
p->insert(p, new_history_item(INI_TEXT("Ellipse") ,NULL,0,NULL));
return p;
};
////////////////////////////////////////////////////////////////////////////////
static p_list ffill_gardient_list ( void ) {
p_list p = list_init(_malloc(sizeof(t_list)), &free_history_item, 0);
p->insert(p, new_history_item(INI_TEXT("Full") ,NULL,0,NULL));
p->insert(p, new_history_item(INI_TEXT("Linear Gradient") ,NULL,0,NULL));
p->insert(p, new_history_item(INI_TEXT("Rect Gradient") ,NULL,0,NULL));
p->insert(p, new_history_item(INI_TEXT("Circle Gradient") ,NULL,0,NULL));
p->insert(p, new_history_item(INI_TEXT("Radial Gradient") ,NULL,0,NULL));
return p;
};
////////////////////////////////////////////////////////////////////////////////
static p_menu editimg_menu_init ( void )
{
p_menu menu = new_menu(
new_sub_menu(INI_TEXT("File"), new_menu(
new_menu_item(INI_TEXT("New"), "", 0, MSG_TOOL_NEW, NULL,
new_menu_item(INI_TEXT("Open"), "", 0, MSG_TOOL_OPEN, NULL,
new_menu_item(INI_TEXT("Save"), "", 0, MSG_TOOL_SAVE, NULL,
new_menu_item(INI_TEXT("Save As"), "", 0, MSG_TOOL_SAVEAS, NULL,
new_menu_line(
new_menu_item(INI_TEXT("Exit"), "", TO_ALT(KB_F4), MSG_CLOSE, NULL,
NULL))))))),
new_sub_menu(INI_TEXT("Edit"), new_menu(
new_menu_item2(INI_TEXT("Copy"), "", 0, MSG_TOOL_COPY , NULL, true ,Get_Bitmap(COPY),
new_menu_item2(INI_TEXT("Paste As a New Selection"), "", 0, MSG_TOOL_PASTASS , NULL,true,Get_Bitmap(PASTE),
new_menu_item2(INI_TEXT("Paste As a New Picture"), "", 0, MSG_TOOL_PASTASP , NULL,true,Get_Bitmap(PASTE),
new_menu_line(
new_menu_item2(INI_TEXT("Undo"), "", 0, MSG_TOOL_UNDO , NULL,true,Get_Bitmap(UNDO),
NULL)))))),
new_sub_menu(INI_TEXT("Picture"), new_menu(
new_sub_menu2(INI_TEXT("Filters"), filters_menu_init(),true,Get_Bitmap(FILTERS),
new_menu_item(INI_TEXT("Resize"), "", 0, MSG_TOOL_RESIZE, NULL,
new_menu_item(INI_TEXT("Correct RGB"), "", 0, MSG_NOTHING, NULL,
NULL)))),
new_sub_menu(INI_TEXT("Options"), new_menu(
new_menu_item2(INI_TEXT("Select Font"), "", 0, MSG_TOOL_CFONT, NULL,true,Get_Bitmap(TEXT) ,
NULL)),
new_sub_menu(INI_TEXT("?"), new_menu(
new_menu_item(INI_TEXT("Help"), "", 0, MSG_xHELP, NULL,
new_menu_item(INI_TEXT("About..."), "", 0, MSG_xABOUT, NULL,
NULL))),
NULL))))));
return menu;
};
////////////////////////////////////////////////////////////////////////////////
static p_list get_file_items ( void ) {
p_list p = list_init(malloc(sizeof(t_list)), &free_filehistory_item, 0);
if ( p ) {
p->insert(p, new_filehistory_item("BMP (*.bmp)", "*.bmp"));
p->insert(p, new_filehistory_item("JPEG (*.jpg)", "*.jpg"));
p->insert(p, new_filehistory_item("GIF (*.gif)", "*.gif"));
p->insert(p, new_filehistory_item("All Files (*.*)", "*.*"));
};
return p;
};
////////////////////////////////////////////////////////////////////////////////
void resizebox ( ) {
if ( !editorx->select ) {
t_rect r = rect_assign(0, 0, 400, 120);
p_stattext lbl = NULL;
p_textline wx = NULL;
p_textline hx = NULL;
p_button b = NULL;
l_dword msg = NULL;
p_appwin w = appwin_init(_malloc(sizeof(t_appwin)),
r,
INI_TEXT("Resize Picture"),
NULL,
ap_id,
NULL);
if ( w ) VIEW(w)->align |= TX_ALIGN_CENTER;
OBJECT(desktop)->insert(OBJECT(desktop), OBJECT(w));
r = rect_assign(3, 20, 397, 40);
lbl = stattext_init(_malloc(sizeof(t_stattext)),
r,
TX_ALIGN_BOTTOM,
INI_TEXT ("New size ( width x height )"));
OBJECT(w)->insert(OBJECT(w), OBJECT(lbl));
r = rect_assign(3, 45, 195, 65);
wx = textline_init(_malloc(sizeof(t_textline)),
r,
IO_DIR_LIMIT,
0);
OBJECT(w)->insert(OBJECT(w), OBJECT(wx));
TEXTLINE(wx)->set_text(TEXTLINE(wx), set_format_text(NULL,"%d",IMAGE_WIDTH(editorx->picture)));
r = rect_assign(200, 45, 397, 65);
hx = textline_init(_malloc(sizeof(t_textline)),
r,
IO_DIR_LIMIT,
0);
OBJECT(w)->insert(OBJECT(w), OBJECT(hx));
TEXTLINE(hx)->set_text(TEXTLINE(hx), set_format_text(NULL,"%d",IMAGE_HEIGHT(editorx->picture)));
r = rect_assign(3, 101, 100, 117);
b = button_init(_malloc(sizeof(t_button)),
r,
INI_TEXT("Ok"),
MSG_OK, // Msg
BF_DEFAULT);
OBJECT(w)->insert(OBJECT(w), OBJECT(b));
r = rect_assign(103, 101, 203, 117);
b = button_init(_malloc(sizeof(t_button)),
r,
INI_TEXT("Undo"),
MSG_CLOSE, // Msg
BF_DEFAULT);
OBJECT(w)->insert(OBJECT(w), OBJECT(b));
msg = desktop->execute_view(desktop, VIEW(w));
if (msg == MSG_OK) {
t_point t = point_assign(atoi(wx->text),atoi(hx->text));
editorx->picture=resizebmp(editorx->picture,t.x,t.y);
view_draw_me(VIEW(editorx));
imgedit_undo_add(editorx);
};
dispose(OBJECT(w));
} else {
msgbox( MW_INFO, MB_OK, INI_TEXT("You can just resize a picture ... not a selection !"));
};
};
////////////////////////////////////////////////////////////////////////////////
void redraw_title ( void )
{
if ( xwin && editorx ) {
if ( WINDOW(xwin)->caption ) _free(WINDOW(xwin)->caption);
WINDOW(xwin)->caption = set_format_text(NULL, "Seal Image Manipulation Program - %s", editorx->filename);
TEST_SUB_VIEWS(VIEW(xwin), WINDOW(xwin)->draw_title(WINDOW(xwin)));
};
};
////////////////////////////////////////////////////////////////////////////////
static void trans_ev ( p_object o, p_event event )
{
if ( o->process == PH_PREPROCESS && event->type & EV_MESSAGE ) { /* if an event */
l_dword msg = event->message;
t_event saved;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -