📄 simp.c
字号:
memcpy(&saved,event,sizeof(t_event));
clear_event (event);
if ( MSG_TOOL_MIN <= msg && msg <= MSG_TOOL_MAX ) {
l_long id = msg - MSG_TOOL_MIN;
editorx->tool = id;
} else if ( MSG_FILTERS_MIN <= msg && msg <= MSG_FILTERS_MAX ) {
l_int a = msg - MSG_FILTERS_MIN;
getimgfilter(a)->filterbox(editorx->picture);
view_draw_me(VIEW(editorx));
imgedit_undo_add(editorx);
} else
switch ( msg ) {
case MSG_TOOL_OPEN : {
l_text file = open_dialog(actual_path, "*.*", get_file_items());
if ( file ) {
editorx->load(editorx, file);
actual_path = io_path(file);
_free(file);
redraw_title();
};
}; break;
case MSG_TOOL_SAVEAS : {
l_text file = save_dialog(actual_path, "*.*", get_file_items());
if ( file ) {
editorx->load(editorx, file);
actual_path = io_path(file);
_free(file);
redraw_title();
}
}; break;
case MSG_TOOL_SAVE : {
l_text file = editorx->filename;
if ( file ) {
if ( !stricmp(file,INI_TEXT("New Image")) ) file = save_dialog(actual_path, "*.*", get_file_items());
editorx->save(editorx, file, 0);
actual_path = io_path(file);
_free(file);
redraw_title();
};
}; break;
case MSG_TOOL_NEW : {
l_int w = NULL;
l_int h = NULL;
l_text t = inputbox (INI_TEXT("New picture ..."),INI_TEXT("Width ?"),"300");
if (!t) return;
w = atoi(t);
_free(t);
t = inputbox (INI_TEXT("New picture ..."),INI_TEXT("Height ?"),"300");
if (!t) return;
h = atoi(t);
editorx->newbmp(editorx,w,h);
_free(t);
redraw_title();
}; break;
case MSG_TOOL_BORDER_P : {
editorx->border+=2;
imgedit_update_status(editorx);
}; break;
case MSG_TOOL_BORDER_M : {
if ( editorx->border > 1 ) {
editorx->border-=2;
imgedit_update_status(editorx);
};
}; break;
case MSG_TOOL_SET_TRANS_VALUE : {
l_int a = NULL;
l_text t = inputbox (INI_TEXT("Transparent"),INI_TEXT("Value ? (0-100) "),set_format_text(NULL,"%d",editorx->floodlevel));
if (!t) return;
a = atoi(t);
editorx->floodlevel = a;
_free(t);
}; break;
case MSG_TOOL_SET_TOLERANCE : {
l_int b = 0;
l_text t = inputbox (INI_TEXT("Flood Fill"),INI_TEXT("Flood tolerance (0-255) "),set_format_text(NULL,"%d",editorx->floodtol));
if (!t) return;
b = atoi(t);
if ((b < 0) || (b > 255)) return;
editorx->floodtol= b;
_free(t);
}; break;
case MSG_TOOL_SET_CENTER : {
if ( editorx->floodstyle == 1 ) {
l_int b = 0;
l_text t = inputbox (INI_TEXT("Flood Fill"),INI_TEXT("Angle (degree) (0-360) "),set_format_text(NULL,"%d",editorx->set1));
if (!t) return;
b = atoi(t);
if ((b < 0) || (b > 360)) return;
editorx->set1= b;
_free(t);
} else if ( editorx->floodstyle != 0 ){
l_int b = 0;
l_text t = inputbox (INI_TEXT("Flood Fill"),INI_TEXT("Center x (0-100) "),set_format_text(NULL,"%d",editorx->set1));
if (!t) return;
b = atoi(t);
if ((b < 0) || (b > 100)) return;
editorx->set1= b;
t = inputbox (INI_TEXT("Flood Fill"),INI_TEXT("Center y (0-100) "),set_format_text(NULL,"%d",editorx->set2));
if (!t) return;
b = atoi(t);
if ((b < 0) || (b > 100)) return;
editorx->set2= b;
_free(t);
} else {
msgbox( MW_INFO, MB_OK, INI_TEXT("No options"));
};
}; break;
case MSG_TOOL_UNDO : imgedit_undo( editorx ); break;
case MSG_TOOL_CFONT : msgbox( MW_INFO, MB_OK, "Not yet supported ..."); break;
case MSG_TOOL_COPY : imgedit_pcopy_act ( editorx , PCOPY_COPY ); break;
case MSG_TOOL_PASTASS : imgedit_pcopy_act ( editorx , PCOPY_PASTASNEWSEL ); break;
case MSG_TOOL_PASTASP : imgedit_pcopy_act ( editorx , PCOPY_PASTASNEWPIC ); break;
case MSG_xABOUT :
msgbox( MW_INFO, MB_OK, "Seal Image Manipulation Program 0.1\n by Julien Etelain <julien@pmad.net>\n\n(c) copyright 2001 Julien Etelain . All rights reserved");
break;
case MSG_xHELP : msgbox( MW_INFO, MB_OK, "Not yet supported ..."); break;
case MSG_TOOL_RESIZE : resizebox(); break;
case MSG_HISUPDATE : {
editorx->penstyle = pen_forme->current;
editorx->floodmode = pen_trans->current;
editorx->fillmode = forme_fill->current;
editorx->forme = forme_forme->current;
editorx->floodstyle = ffill_gardient->current;
}; break;
default : memcpy(event,&saved,sizeof(t_event)); break;
};
};
};
////////////////////////////////////////////////////////////////////////////////
static t_point xcolors_minimum ( p_view o )
{
return point_assign(20, 20);
};
////////////////////////////////////////////////////////////////////////////////
void loadtoolbox( t_rect r, l_int w ) {
p_icobutton bb = NULL;
p_button b = NULL;
conf_tab = tabbook_make(rect_assign(r.b.x-w-5, r.a.y+45, r.b.x-5, r.a.y+160));
conf_tab->add_tab(conf_tab,"pen",NULL);
conf_tab->add_tab(conf_tab,"forme",NULL);
conf_tab->add_tab(conf_tab,"flood",NULL);
OBJECT(xwin)->insert(OBJECT(xwin), OBJECT(conf_tab ));
r = rect_assign(3, 3, w-20, 23);
pen_forme = history_init(_malloc(sizeof(t_history)),
r,
pen_forme_list() ,
150,
HF_REWRITEUNABLE|LF_SELFLIST);
pen_forme->message = MSG_HISUPDATE;
conf_tab->insert(conf_tab,0, OBJECT(pen_forme));
r = rect_assign(3, 24, w-20, 44);
pen_trans = history_init(_malloc(sizeof(t_history)),
r,
pen_trans_list() ,
150,
HF_REWRITEUNABLE|LF_SELFLIST);
pen_trans->message = MSG_HISUPDATE;
conf_tab->insert(conf_tab,0, OBJECT(pen_trans));
r = rect_assign(3, 46, w-3, 66);
b = button_init(_malloc(sizeof(t_button)),
r,
INI_TEXT("Set trans value"),
MSG_TOOL_SET_TRANS_VALUE,
BF_DEFAULT);
conf_tab->insert(conf_tab,0, OBJECT(b));
r = rect_assign(3, 68, 50, 88);
bb = icobutton_init( _malloc(sizeof(t_icobutton)),
r,
Get_Bitmap(BORDER_P),
INI_TEXT("Border +"),
MSG_TOOL_BORDER_P,
BF_PUSH);
conf_tab->insert(conf_tab,0, OBJECT(bb));
r = rect_assign(53, 68, 103, 88);
bb = icobutton_init( _malloc(sizeof(t_icobutton)),
r,
Get_Bitmap(BORDER_M),
INI_TEXT("Border -"),
MSG_TOOL_BORDER_M,
BF_PUSH);
conf_tab->insert(conf_tab,0,OBJECT(bb));
r = rect_assign(3, 3, w-20, 23);
forme_forme = history_init(_malloc(sizeof(t_history)),
r,
forme_forme_list() ,
150,
HF_REWRITEUNABLE|LF_SELFLIST);
forme_forme->message = MSG_HISUPDATE;
conf_tab->insert(conf_tab,1, OBJECT(forme_forme));
/////
r = rect_assign(3, 24, w-20, 44);
forme_fill = history_init(_malloc(sizeof(t_history)),
r,
forme_fill_list() ,
150,
HF_REWRITEUNABLE|LF_SELFLIST);
forme_fill->message = MSG_HISUPDATE;
conf_tab->insert(conf_tab,1, OBJECT(forme_fill));
r = rect_assign(3, 45, 50, 65);
bb = icobutton_init( _malloc(sizeof(t_icobutton)),
r,
Get_Bitmap(BORDER_P),
INI_TEXT("Border +"),
MSG_TOOL_BORDER_P,
BF_PUSH);
conf_tab->insert(conf_tab,1, OBJECT(bb));
r = rect_assign(53, 45, 103, 65);
bb = icobutton_init( _malloc(sizeof(t_icobutton)),
r,
Get_Bitmap(BORDER_M),
INI_TEXT("Border -"),
MSG_TOOL_BORDER_M,
BF_PUSH);
conf_tab->insert(conf_tab,1, OBJECT(bb));
/////
r = rect_assign(3, 3, w-20, 23);
ffill_gardient = history_init(_malloc(sizeof(t_history)),
r,
ffill_gardient_list() ,
150,
HF_REWRITEUNABLE|LF_SELFLIST);
ffill_gardient->message = MSG_HISUPDATE;
conf_tab->insert(conf_tab,2, OBJECT(ffill_gardient));
r = rect_assign(3, 24, w-5, 44);
b = button_init(_malloc(sizeof(t_button)),
r,
INI_TEXT("Set tolerance"),
MSG_TOOL_SET_TOLERANCE,
BF_DEFAULT);
conf_tab->insert(conf_tab,2, OBJECT(b));
r = rect_assign(3, 46, w-5, 66);
b = button_init(_malloc(sizeof(t_button)),
r,
INI_TEXT("Gardient options"),
MSG_TOOL_SET_CENTER,
BF_DEFAULT);
conf_tab->insert(conf_tab,2, OBJECT(b));
};
////////////////////////////////////////////////////////////////////////////////
void init_window ( void ) {
t_rect r = rect_assign(0, 0, 755, 525);
xwin = appwin_init(_malloc(sizeof(t_appwin)),
r,
_strdup("SIMP - Seal Image Manupilation Program"),
WF_MINIMIZE,
ap_id,
&trans_ev);
if ( xwin ) VIEW(xwin)->align |= TX_ALIGN_CENTER;
xwin->icon16 = load_image("/system/bmp/simp.ico,16");
OBJECT(desktop)->insert(OBJECT(desktop), OBJECT(xwin));
if ( xwin ) {
p_menuview menu = NULL;
l_long a = 0;
p_icobutton bb =NULL;
l_int w = 110;
menu = hormenu_init(_malloc(sizeof(t_menuview)),
rect_assign(r.a.x+5,r.a.y+20,r.b.x-5,r.a.y+40),
editimg_menu_init());
OBJECT(xwin)->insert(OBJECT(xwin), OBJECT(menu));
sto = stattext_init(_malloc(sizeof(t_stattext)),rect_assign(r.a.x+5, r.b.y-20, r.b.x-5, r.b.y-5),TX_ALIGN_LEFT,"Loading... Please Wait...");
OBJECT(xwin)->insert(OBJECT(xwin), OBJECT(sto));
while ( a < 8 ) {
bb = icobutton_init( _malloc(sizeof(t_icobutton)), /* memory for class t_button */
rect_assign(r.a.x+5,r.a.y+45+(a*20),r.a.x+20,r.a.y+65+(a*20)), /* button area */
Get_Bitmap(txttoolint[a]),
txttool[a],
MSG_TOOL_MIN + a, /* message of the button */
BF_PUSH);
OBJECT(xwin)->insert(OBJECT(xwin), OBJECT(bb));
a++;
};
loadtoolbox(r,w);
cco = colsel2_init( _malloc(sizeof(t_colsel2)), rect_assign(r.b.x-w-5, r.a.y+165 , r.b.x-5, r.a.y+230) );
OBJECT(xwin)->insert(OBJECT(xwin), OBJECT(cco));
editorx = imgedit_init(_malloc(sizeof(t_imgedit)), rect_assign( r.a.x+25, r.a.y+45, r.b.x-w-10, r.b.y-25) , cco, sto);
OBJECT(xwin)->insert(OBJECT(xwin), OBJECT(editorx));
};
};
////////////////////////////////////////////////////////////////////////////////
SetInfoAppName("SIMP");
SetInfoDesciption("Seal Image Manipulation Image");
SetInfoCopyright("(c) Copyright 2001 Point Mad. All rights reserved");
SetInfoManufacturer("Point Mad");
app_begin ( void ) {
if ( ap_process == AP_INIT ) {
AP_SETNUMOFCALLS(1);
dat = conv_to_skipcolor_data(DLXGetFileData(ap_id), CO_SKIP_RED, CO_SKIP_GREEN, CO_SKIP_BLUE);
imgedit_xdl_init();
init_window();
if (ap_args != NULL ) if ( io_exist(ap_args) ) editorx->load(editorx,ap_args);
redraw_title();
};
if ( ap_process == AP_DONE ) {
};
} lib_end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -