int ShortcutMapper::update_col_width(const TCHAR *str,int col) { int w,col_w; w=gettextwidth(hlistview,str); col_w=ListView_GetColumnWidth(hlistview,col); if(w>col_w) ListView_SetColumnWidth(hlistview,col,w); return TRUE; }
void drawbookdepth() { int bid,cnt,h,len,lw,mw,my,ndx; int *yext; double del,max,mid,min,s,t,*size,*w,*y; axis *x; len=Size->n; bid=0;DO(len,bid+=0>Size->v[i]); size=g_malloc(len*sizeof(double)); DO(len,size[i]=fabs(Size->v[i])); min=dvec_min(Size); max=dvec_max(Size); cnt=MAX(2,MIN(8,(Rw-2*Lx)/XLabWid)); YLab=fmtlabel((dvec *)Data); yext=g_malloc(len*sizeof(int)); pango_layout_set_font_description(PL,LabelFont); DO(len,yext[i]=gettextwidth(YLab->v[i])); my=(int)My; lw=XLabWid/2; mw=TicLen+MAX(lw,maxi(len,yext)); setgxywh(Rx+mw,Ry+my,Rw-(mw+lw),Rh-(my+LabelHit+Ly)); x=getaxis(cnt,min,max); XPos=x->p; XLab=fmtlabel(XPos); XTic=dvec_dup(XPos); del=x->max-x->min; DO(XTic->n,XTic->v[i]=(XTic->v[i]-x->min)/del); YMin=x->min; YMax=x->max; YTic=dvec_dup(x->p); DO(YTic->n,YTic->v[i]=(YTic->v[i]-YMin)/(YMax-YMin)); h=Gh/(1+len); y=g_malloc(len*sizeof(double)); s=len;t=1.0/(2*s); DO(len,y[i]=Gy+Gh*(1-(t+i/s))); h=h/4; cairo_set_line_width(CR,1); cairo_set_source(CR,GridColor); DO(len,{ cairo_move_to(CR,Gx-TicLen,y[i]); cairo_line_to(CR,Gx+Gw,y[i]);});
void ShortcutMapper::initList() { int i; LV_COLUMN col={0}; TCHAR *col_names[3]={L"Index",L"Name",L"Shortcut"}; hlistview=GetDlgItem(_hSelf,IDC_SHORTCUT_LIST); for(i=0;i<sizeof(col_names)/sizeof(TCHAR *);i++){ col.mask=LVCF_FMT|LVCF_TEXT|LVCF_WIDTH; col.fmt=LVCFMT_LEFT; col.cx=gettextwidth(hlistview,col_names[i]); col.pszText=col_names[i]; ListView_InsertColumn(hlistview,i,&col); } ListView_SetExtendedListViewStyle(hlistview, ListView_GetExtendedListViewStyle(hlistview)|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES); }
void drawkeys() { int len,h2,x,y,*kx; len=Key->n; if (2>len) return; h2=LabelHit/2; kx=g_malloc(len*sizeof(int)); pango_layout_set_font_description(PL,LabelFont); DO(len,kx[i]=gettextwidth(Key->v[i])); x=Gx+Gw-(10+KeyWid+maxi(len,kx)); y=Gy+10+h2; cairo_set_line_width(CR,2); DO(len,{ cairo_set_source(CR,glcolor(i)); cairo_move_to(CR,x,y); cairo_line_to(CR,x+KeyWid,y); cairo_stroke(CR); y+=LabelHit; });
void ShortcutMapper::populateShortCuts() { TCHAR filter1[40]={0},filter2[40]={0}; NppParameters *nppParam = NppParameters::getInstance(); size_t nrItems = 0; switch(_currentState) { case STATE_MENU: { nrItems = nppParam->getUserShortcuts().size(); break; } case STATE_MACRO: { nrItems = nppParam->getMacroList().size(); break; } case STATE_USER: { nrItems = nppParam->getUserCommandList().size(); break; } case STATE_PLUGIN: { nrItems = nppParam->getPluginCommandList().size(); break; } case STATE_SCINTILLA: { nrItems = nppParam->getScintillaKeyList().size(); break; } } ListView_DeleteAllItems(hlistview); if(nrItems==0){ ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), false); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DISABLE), false); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false); return; } else ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DISABLE), true); switch(_currentState) { case STATE_MENU: { ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), true); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false); break; } case STATE_MACRO: { bool shouldBeEnabled = nrItems > 0; ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), shouldBeEnabled); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), shouldBeEnabled); break; } case STATE_USER: { bool shouldBeEnabled = nrItems > 0; ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), shouldBeEnabled); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), shouldBeEnabled); break; } case STATE_PLUGIN: { bool shouldBeEnabled = nrItems > 0; ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), shouldBeEnabled); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false); break; } case STATE_SCINTILLA: { ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), true); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false); break; } } int index=0; int widths[3]; widths[0]=gettextwidth(hlistview,L"Index"); widths[1]=gettextwidth(hlistview,L"Name"); widths[2]=gettextwidth(hlistview,L"Shortcut"); GetWindowText(GetDlgItem(_hSelf,IDC_SHORTCUT_FILTER1),filter1,sizeof(filter2)/sizeof(TCHAR)); GetWindowText(GetDlgItem(_hSelf,IDC_SHORTCUT_FILTER2),filter2,sizeof(filter2)/sizeof(TCHAR)); _tcslwr(filter1); _tcslwr(filter2); for(size_t i = 0; i < nrItems; i++) { TCHAR keys[40]={0}; const TCHAR *name=GetShortcutName(_currentState,i,nppParam); GetShortcutKeys(_currentState,i,nppParam,keys,sizeof(keys)/sizeof(TCHAR)); if((filter1[0]==L'\0' && filter2[0]==L'\0') || (filter1[0]!=L'\0' && CheckFilter(name,filter1)) || (filter2[0]!=L'\0' && CheckFilter(keys,filter2))){ TCHAR str[10]={0}; LV_ITEM lvitem={0}; int w; _sntprintf_s(str,sizeof(str)/sizeof(TCHAR),_TRUNCATE,L"%i",i); w=gettextwidth(hlistview,str); if(w>widths[0]) widths[0]=w; w=gettextwidth(hlistview,name); if(w>widths[1]) widths[1]=w; w=gettextwidth(hlistview,keys); if(w>widths[2]) widths[2]=w; lvitem.mask=LVIF_TEXT|LVIF_PARAM; lvitem.iItem=index; lvitem.pszText=(LPWSTR)str; lvitem.lParam=i; ListView_InsertItem(hlistview,&lvitem); lvitem.mask=LVIF_TEXT; lvitem.iSubItem=1; lvitem.pszText=(LPWSTR)name; ListView_SetItem(hlistview,&lvitem); lvitem.iSubItem=2; lvitem.pszText=(LPWSTR)keys; ListView_SetItem(hlistview,&lvitem); index++; } } ListView_SetColumnWidth(hlistview,0,widths[0]); ListView_SetColumnWidth(hlistview,1,widths[1]); ListView_SetColumnWidth(hlistview,2,widths[2]); ListView_SetItemState(hlistview,0,LVIS_SELECTED,LVIS_SELECTED); if(index==0){ ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), false); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false); } }