int get_font_setting(int ctrl) { char tmp[80]={0}; char key[80]={0}; get_control_name(ctrl,key,sizeof(key)); get_ini_str(INI_SETTINGS,key,tmp,sizeof(tmp)); return fontname_to_int(tmp); }
int set_context_font(HWND hwnd) { int font; char key[80]; char font_name[80]; if(binary) font=ANSI_FIXED_FONT; else{ key[0]=0; get_dropdown_name(IDC_LISTBOX_FONT,key,sizeof(key)); font_name[0]=0; get_ini_str("OPTIONS",key,font_name,sizeof(font_name)); font=fontname_to_int(font_name); } SendDlgItemMessage(hwnd,IDC_ROWNUMBER,WM_SETFONT,GetStockObject(font),0); SendDlgItemMessage(hwnd,IDC_CONTEXT,WM_SETFONT,GetStockObject(font),0); return TRUE; }
LRESULT CALLBACK settings_proc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam) { static HWND hedit=0; switch(msg){ case WM_INITDIALOG: { int i; HFONT hfont; LOGFONT lf={0}; hedit=lparam; for(i=0;i<sizeof(font_names)/sizeof(struct FONT_NAME);i++) SendDlgItemMessage(hwnd,IDC_FONTS,CB_ADDSTRING,0,font_names[i].font_name); hfont=SendMessage(hedit,WM_GETFONT,0,0); if(hfont){ GetObject(hfont,sizeof(LOGFONT),&lf); i=SendDlgItemMessage(hwnd,IDC_FONTS,CB_ADDSTRING,0,lf.lfFaceName); SendDlgItemMessage(hwnd,IDC_FONTS,CB_SETCURSEL,i,0); } populate_sample_list(GetDlgItem(hwnd,IDC_SAMPLELIST),src_sample); SendDlgItemMessage(hwnd,IDC_SAMPLELIST,CB_SETCURSEL,src_sample,0); if(load_preamble) SendDlgItemMessage(hwnd,IDC_LOAD_PREAMBLE,BM_SETCHECK,BST_CHECKED,0); } break; case WM_COMMAND: switch(LOWORD(wparam)){ case IDC_FONTS: if(HIWORD(wparam)==CBN_SELENDOK){ int font; char str[80]={0}; GetDlgItemText(hwnd,IDC_FONTS,str,sizeof(str)); font=fontname_to_int(str); SendDlgItemMessage(heditwin,IDC_EDIT1,WM_SETFONT,GetStockObject(font),0); InvalidateRect(GetDlgItem(heditwin,IDC_EDIT1),NULL,TRUE); } break; case IDC_LOAD_PREAMBLE: if(BST_CHECKED==SendMessage(lparam,BM_GETCHECK,0,0)) load_preamble=TRUE; else load_preamble=FALSE; break; case IDC_OPENINI: { int explore=FALSE; if((GetKeyState(VK_SHIFT)&0x8000) || (GetKeyState(VK_CONTROL)&0x8000)) explore=TRUE; open_ini(hwnd,explore); } break; case IDC_SAMPLELIST: { HWND hlist=lparam; if(HIWORD(wparam)==CBN_SELCHANGE){ int index=SendMessage(hlist,CB_GETCURSEL,0,0); if(index>=0){ char *str; src_sample=index; str=samples[src_sample]; load_shader_string(fragid,str,GetDlgItem(heditwin,IDC_EDIT1)); compile(heditwin); } } } break; case IDC_TINY_WINDOW: toggle_window_size(hwnd); break; case IDC_CHAN0: case IDC_CHAN1: case IDC_CHAN2: case IDC_CHAN3: if(HIWORD(wparam)==BN_CLICKED){ static char str[40]={0}; GetWindowText(lparam,str,sizeof(str)); DialogBoxParam(ghinstance,MAKEINTRESOURCE(IDD_TEXTURES),hwnd,texture_select,str); } break; case IDCANCEL: case IDOK: EndDialog(hwnd,0); break; } break; case WM_CLOSE: EndDialog(hwnd,0); } return 0; }
LRESULT CALLBACK options_proc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam) { static HWND grippy=0; switch(msg) { case WM_INITDIALOG: grippy=create_grippy(hwnd); init_options_win_anchor(hwnd); restore_options_rel_pos(hwnd); SendDlgItemMessage(hwnd,IDC_MATCH_PREFIX_LEN,EM_LIMITTEXT,4,0); populate_options(hwnd); return 0; case WM_DESTROY: save_options_rel_pos(hwnd); break; case WM_SIZE: grippy_move(hwnd,grippy); resize_options(hwnd); InvalidateRect(hwnd,NULL,TRUE); break; case WM_DRAWITEM: break; case WM_HELP: show_options_help(hwnd); return TRUE; break; case WM_COMMAND: switch(LOWORD(wparam)){ case IDC_SELECT_OPEN: if(HIWORD(wparam)==CBN_SELENDOK) populate_caption_open(hwnd); break; case IDC_COMBO_FONT: if(HIWORD(wparam)==CBN_SELENDOK){ int font; char str[80]={0}; GetDlgItemText(hwnd,IDC_COMBO_FONT,str,sizeof(str)); font=fontname_to_int(str); SendDlgItemMessage(GetParent(hwnd),IDC_COMBO_SEARCH,WM_SETFONT,GetStockObject(font),0); SendDlgItemMessage(GetParent(hwnd),IDC_COMBO_REPLACE,WM_SETFONT,GetStockObject(font),0); SendDlgItemMessage(GetParent(hwnd),IDC_COMBO_PATH,WM_SETFONT,GetStockObject(font),0); SendDlgItemMessage(GetParent(hwnd),IDC_COMBO_MASK,WM_SETFONT,GetStockObject(font),0); } break; case IDC_LISTBOX_FONT: if(HIWORD(wparam)==CBN_SELENDOK){ int font; char str[80]={0}; GetDlgItemText(hwnd,IDC_LISTBOX_FONT,str,sizeof(str)); font=fontname_to_int(str); SendDlgItemMessage(GetParent(hwnd),IDC_LIST1,WM_SETFONT,GetStockObject(font),0); reset_line_width(); InvalidateRect(GetDlgItem(GetParent(hwnd),IDC_LIST1),NULL,TRUE); } break; case IDC_OPEN_INI: open_ini(hwnd,GetKeyState(VK_CONTROL)&0x8000); break; case IDC_APPLY: save_options(hwnd); break; case IDOK: save_options(hwnd); EndDialog(hwnd,TRUE); return 0; case IDCANCEL: save_select_open(hwnd); EndDialog(hwnd,0); return 0; } break; } return 0; }
LRESULT CALLBACK settings_proc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam) { static HWND grippy=0; static int font_changed=FALSE; static int justify_changed=FALSE; switch(msg){ case WM_INITDIALOG: { extern int keep_closed; int val; get_ini_value(INI_SETTINGS,"KEEP_CLOSED",&keep_closed); if(!keep_closed) CheckDlgButton(hwnd,IDC_KEEP_CONNECTED,BST_CHECKED); val=0; get_ini_value(INI_SETTINGS,"SINGLE_INSTANCE",&val); if(val) CheckDlgButton(hwnd,IDC_SINGLE_INSTANCE,BST_CHECKED); val=0; get_ini_value(INI_SETTINGS,"DEBUG",&val); if(val) CheckDlgButton(hwnd,IDC_DEBUG,BST_CHECKED); get_ini_value(INI_SETTINGS,"TRIM_TRAILING",&trim_trailing); if(trim_trailing) CheckDlgButton(hwnd,IDC_TRIM_TRAILING,BST_CHECKED); get_ini_value(INI_SETTINGS,"LEFT_JUSTIFY",&left_justify); if(left_justify) CheckDlgButton(hwnd,IDC_LEFT_JUSTIFY,BST_CHECKED); get_ini_value(INI_SETTINGS,"SAVE_MDI_WIN_SIZE",&save_mdi_win_size); if(save_mdi_win_size) CheckDlgButton(hwnd,IDC_SAVE_MDI_WIN_SIZE,BST_CHECKED); add_fonts(hwnd,IDC_SQL_FONT); add_fonts(hwnd,IDC_LISTVIEW_FONT); add_fonts(hwnd,IDC_TREEVIEW_FONT); select_current_font(hwnd,IDC_SQL_FONT); select_current_font(hwnd,IDC_LISTVIEW_FONT); select_current_font(hwnd,IDC_TREEVIEW_FONT); font_changed=FALSE; justify_changed=FALSE; } grippy=create_grippy(hwnd); break; case WM_SIZE: grippy_move(hwnd,grippy); break; case WM_COMMAND: switch(LOWORD(wparam)){ case IDC_DEBUG: printf("debug %08X %08X\n",wparam,lparam); if(IsDlgButtonChecked(hwnd,IDC_DEBUG)==BST_CHECKED) open_console(); else hide_console(); break; case IDC_FILE_ASSOCIATIONS: DialogBoxParam(ghinstance,IDD_FILE_ASSOCIATIONS,hwnd,file_assoc_proc,0); break; case IDC_OPEN_INI: open_ini(hwnd,FALSE); break; case IDC_SQL_FONT: if(HIWORD(wparam)==CBN_SELENDOK){ int i,max=get_max_table_windows(); int font; char str[80]={0}; GetDlgItemText(hwnd,IDC_SQL_FONT,str,sizeof(str)); font=fontname_to_int(str); for(i=0;i<max;i++){ HWND hedit=0; if(get_win_hwnds(i,NULL,&hedit,NULL)){ SendMessage(hedit,WM_SETFONT,GetStockObject(font),0); InvalidateRect(hedit,NULL,TRUE); } } font_changed=TRUE; } break; case IDC_LISTVIEW_FONT: if(HIWORD(wparam)==CBN_SELENDOK){ int i,max=get_max_table_windows(); int font; char str[80]={0}; GetDlgItemText(hwnd,IDC_LISTVIEW_FONT,str,sizeof(str)); font=fontname_to_int(str); for(i=0;i<max;i++){ HWND hlistview; if(get_win_hwnds(i,NULL,NULL,&hlistview)){ SendMessage(hlistview,WM_SETFONT,GetStockObject(font),0); InvalidateRect(hlistview,NULL,TRUE); } } font_changed=TRUE; } break; case IDC_TREEVIEW_FONT: if(HIWORD(wparam)==CBN_SELENDOK){ extern HWND ghtreeview; int font; char str[80]={0}; GetDlgItemText(hwnd,IDC_TREEVIEW_FONT,str,sizeof(str)); font=fontname_to_int(str); if(ghtreeview!=0){ SendMessage(ghtreeview,WM_SETFONT,GetStockObject(font),0); InvalidateRect(ghtreeview,NULL,TRUE); } font_changed=TRUE; } break; case IDC_LEFT_JUSTIFY: if(HIWORD(wparam)==BN_CLICKED){ extern int left_justify; int i,max=get_max_table_windows(); if(IsDlgButtonChecked(hwnd,IDC_LEFT_JUSTIFY)==BST_CHECKED) left_justify=1; else left_justify=0; for(i=0;i<max;i++){ HWND hlistview; if(get_win_hwnds(i,NULL,NULL,&hlistview)) InvalidateRect(hlistview,NULL,TRUE); } justify_changed=TRUE; } break; case IDOK: { extern int keep_closed; char key[80],str[80]; int i,val,ctrls[3]={IDC_SQL_FONT,IDC_LISTVIEW_FONT,IDC_TREEVIEW_FONT}; if(IsDlgButtonChecked(hwnd,IDC_KEEP_CONNECTED)==BST_CHECKED) keep_closed=FALSE; else keep_closed=TRUE; write_ini_value(INI_SETTINGS,"KEEP_CLOSED",keep_closed); val=0; if(IsDlgButtonChecked(hwnd,IDC_SINGLE_INSTANCE)==BST_CHECKED) val=1; write_ini_value(INI_SETTINGS,"SINGLE_INSTANCE",val); set_single_instance(val); val=0; if(IsDlgButtonChecked(hwnd,IDC_DEBUG)==BST_CHECKED) val=1; write_ini_value(INI_SETTINGS,"DEBUG",val); if(IsDlgButtonChecked(hwnd,IDC_TRIM_TRAILING)==BST_CHECKED) trim_trailing=1; else trim_trailing=0; write_ini_value(INI_SETTINGS,"TRIM_TRAILING",trim_trailing); if(IsDlgButtonChecked(hwnd,IDC_LEFT_JUSTIFY)==BST_CHECKED) left_justify=1; else left_justify=0; write_ini_value(INI_SETTINGS,"LEFT_JUSTIFY",left_justify); if(IsDlgButtonChecked(hwnd,IDC_SAVE_MDI_WIN_SIZE)==BST_CHECKED) save_mdi_win_size=1; else save_mdi_win_size=0; write_ini_value(INI_SETTINGS,"SAVE_MDI_SIZE",save_mdi_win_size); for(i=0;i<sizeof(ctrls)/sizeof(int);i++){ key[0]=0; get_control_name(ctrls[i],key,sizeof(key)); str[0]=0; GetDlgItemText(hwnd,ctrls[i],str,sizeof(str)); write_ini_str(INI_SETTINGS,key,str); } } case IDCANCEL: if(font_changed){ int i,ctrls[3]={IDC_SQL_FONT,IDC_LISTVIEW_FONT,IDC_TREEVIEW_FONT}; for(i=0;i<sizeof(ctrls)/sizeof(int);i++){ char key[80],str[80]; key[0]=0; get_control_name(ctrls[i],key,sizeof(key)); str[0]=0; GetDlgItemText(hwnd,ctrls[i],str,sizeof(str)); get_ini_str(INI_SETTINGS,key,str,sizeof(str)); if(str[0]!=0){ int max=get_max_table_windows(); int font=fontname_to_int(str); if(ctrls[i]==IDC_SQL_FONT){ int j; for(j=0;j<max;j++){ HWND hedit=0; if(get_win_hwnds(j,NULL,&hedit,NULL)){ SendMessage(hedit,WM_SETFONT,GetStockObject(font),0); InvalidateRect(hedit,NULL,TRUE); } } } else if(ctrls[i]==IDC_LISTVIEW_FONT){ int j; for(j=0;j<max;j++){ HWND hlistview; if(get_win_hwnds(j,NULL,NULL,&hlistview)){ SendMessage(hlistview,WM_SETFONT,GetStockObject(font),0); InvalidateRect(hlistview,NULL,TRUE); } } } else if(ctrls[i]==IDC_TREEVIEW_FONT){ extern HWND ghtreeview; SendMessage(ghtreeview,WM_SETFONT,GetStockObject(font),0); } } } } if(justify_changed){ int i,max=get_max_table_windows(); get_ini_value(INI_SETTINGS,"LEFT_JUSTIFY",&left_justify); for(i=0;i<max;i++){ HWND hlistview; if(get_win_hwnds(i,NULL,NULL,&hlistview)) InvalidateRect(hlistview,NULL,TRUE); } } EndDialog(hwnd,0); break; } break; } return 0; }