-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NEW_FEATURE] Add Character Insertion Panel.
- Notepad-plus svn trunk @ 745
- Loading branch information
Showing
16 changed files
with
449 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
//this file is part of notepad++ | ||
//Copyright (C)2003 Don HO ( donho@altern.org ) | ||
// | ||
//This program is free software; you can redistribute it and/or | ||
//modify it under the terms of the GNU General Public License | ||
//as published by the Free Software Foundation; either | ||
//version 2 of the License, or (at your option) any later version. | ||
// | ||
//This program is distributed in the hope that it will be useful, | ||
//but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
//GNU General Public License for more details. | ||
// | ||
//You should have received a copy of the GNU General Public License | ||
//along with this program; if not, write to the Free Software | ||
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
|
||
#include "precompiledHeaders.h" | ||
#include "ListView.h" | ||
|
||
|
||
void ListView::init(HINSTANCE hInst, HWND parent) | ||
{ | ||
Window::init(hInst, parent); | ||
INITCOMMONCONTROLSEX icex; | ||
|
||
// Ensure that the common control DLL is loaded. | ||
icex.dwSize = sizeof(INITCOMMONCONTROLSEX); | ||
icex.dwICC = ICC_LISTVIEW_CLASSES; | ||
InitCommonControlsEx(&icex); | ||
|
||
// Create the list-view window in report view with label editing enabled. | ||
int listViewStyles = LVS_REPORT | LVS_NOSORTHEADER\ | ||
| LVS_SINGLESEL | LVS_AUTOARRANGE\ | ||
| LVS_SHAREIMAGELISTS; | ||
|
||
_hSelf = ::CreateWindow(WC_LISTVIEW, | ||
TEXT(""), | ||
WS_CHILD | listViewStyles, | ||
0, | ||
0, | ||
0, | ||
0, | ||
_hParent, | ||
(HMENU) NULL, | ||
hInst, | ||
NULL); | ||
if (!_hSelf) | ||
{ | ||
throw std::runtime_error("ListView::init : CreateWindowEx() function return null"); | ||
} | ||
|
||
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this); | ||
_defaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, (LONG_PTR)staticProc)); | ||
|
||
DWORD exStyle = ListView_GetExtendedListViewStyle(_hSelf); | ||
exStyle |= LVS_EX_FULLROWSELECT | LVS_EX_BORDERSELECT ; | ||
ListView_SetExtendedListViewStyle(_hSelf, exStyle); | ||
|
||
LVCOLUMN lvColumn; | ||
lvColumn.mask = LVCF_TEXT|LVCF_WIDTH; | ||
lvColumn.cx = 45; | ||
|
||
lvColumn.pszText = TEXT("Value"); | ||
ListView_InsertColumn(_hSelf, 0, &lvColumn); | ||
|
||
lvColumn.pszText = TEXT("Char"); | ||
ListView_InsertColumn(_hSelf, 1, &lvColumn); | ||
|
||
lvColumn.pszText = TEXT("Ctrl char"); | ||
lvColumn.cx = 90; | ||
ListView_InsertColumn(_hSelf, 2, &lvColumn); | ||
|
||
//ListView_SetImageList(_hSelf, hImaLst, LVSIL_SMALL); | ||
|
||
//ListView_SetItemState(_hSelf, _currentIndex, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED); | ||
//ListView_SetBkColor(_hSelf, lightYellow); | ||
} | ||
|
||
void ListView::resetValues(int codepage) | ||
{ | ||
ListView_DeleteAllItems(_hSelf); | ||
for (int i = 0 ; i < 256 ; i++) | ||
{ | ||
LVITEM item; | ||
item.mask = LVIF_TEXT; | ||
TCHAR num[8]; | ||
generic_sprintf(num, TEXT("%d"), i); | ||
item.pszText = num; | ||
item.iItem = i; | ||
item.iSubItem = 0; | ||
ListView_InsertItem(_hSelf, &item); | ||
|
||
char ascii[8]; | ||
ascii[0] = (unsigned char)i; | ||
ascii[1] = '\0'; | ||
#ifdef UNICODE | ||
wchar_t wCharStr[10]; | ||
MultiByteToWideChar(codepage, 0, ascii, -1, wCharStr, sizeof(wCharStr)); | ||
ListView_SetItemText(_hSelf, i, 1, wCharStr); | ||
#else | ||
codepage = 0; // make it compile in ANSI Release mode | ||
ListView_SetItemText(_hSelf, i, 1, ascii); | ||
#endif | ||
} | ||
} | ||
void ListView::destroy() | ||
{ | ||
::DestroyWindow(_hSelf); | ||
_hSelf = NULL; | ||
} | ||
|
||
|
||
LRESULT ListView::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) | ||
{ | ||
return ::CallWindowProc(_defaultProc, hwnd, Message, wParam, lParam); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//this file is part of notepad++ | ||
//Copyright (C)2003 Don HO ( donho@altern.org ) | ||
// | ||
//This program is free software; you can redistribute it and/or | ||
//modify it under the terms of the GNU General Public License | ||
//as published by the Free Software Foundation; either | ||
//version 2 of the License, or (at your option) any later version. | ||
// | ||
//This program is distributed in the hope that it will be useful, | ||
//but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
//GNU General Public License for more details. | ||
// | ||
//You should have received a copy of the GNU General Public License | ||
//along with this program; if not, write to the Free Software | ||
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
|
||
#ifndef LISTVIEW_H | ||
#define LISTVIEW_H | ||
|
||
#include "window.h" | ||
|
||
class ListView : public Window | ||
{ | ||
public: | ||
ListView() : Window() {}; | ||
|
||
virtual ~ListView() {}; | ||
virtual void init(HINSTANCE hInst, HWND hwnd); | ||
virtual void destroy(); | ||
|
||
void resetValues(int codepage = 0); | ||
|
||
protected: | ||
WNDPROC _defaultProc; | ||
LRESULT runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam); | ||
|
||
static LRESULT CALLBACK staticProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { | ||
return (((ListView *)(::GetWindowLongPtr(hwnd, GWL_USERDATA)))->runProc(hwnd, Message, wParam, lParam)); | ||
}; | ||
}; | ||
|
||
|
||
#endif // LISTVIEW_H |
94 changes: 94 additions & 0 deletions
94
PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
this file is part of notepad++ | ||
Copyright (C)2011 Don HO <donho@altern.org> | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either | ||
version 2 of the License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a Copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
*/ | ||
|
||
#include "precompiledHeaders.h" | ||
#include "ansiCharPanel.h" | ||
#include "ScintillaEditView.h" | ||
|
||
BOOL CALLBACK AnsiCharPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) | ||
{ | ||
switch (message) | ||
{ | ||
case WM_INITDIALOG : | ||
{ | ||
TCHAR asciiStr[2]; | ||
asciiStr[1] = '\0'; | ||
|
||
_listView.init(_hInst, _hSelf); | ||
int codepage = (*_ppEditView)->getCurrentBuffer()->getEncoding(); | ||
_listView.resetValues(codepage==-1?0:codepage); | ||
_listView.display(); | ||
|
||
return TRUE; | ||
} | ||
|
||
case WM_NOTIFY: | ||
{ | ||
switch (((LPNMHDR)lParam)->code) | ||
{ | ||
case NM_DBLCLK: | ||
{ | ||
//printStr(TEXT("OK")); | ||
LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam; | ||
int i = lpnmitem->iItem; | ||
|
||
if (i == -1) | ||
return TRUE; | ||
|
||
char charStr[2]; | ||
charStr[0] = (unsigned char)i; | ||
charStr[1] = '\0'; | ||
wchar_t wCharStr[10]; | ||
char multiByteStr[10]; | ||
int codepage = (*_ppEditView)->getCurrentBuffer()->getEncoding(); | ||
if (codepage == -1) | ||
{ | ||
multiByteStr[0] = charStr[0]; | ||
multiByteStr[1] = charStr[1]; | ||
} | ||
else | ||
{ | ||
MultiByteToWideChar(codepage, 0, charStr, -1, wCharStr, sizeof(wCharStr)); | ||
WideCharToMultiByte(CP_UTF8, 0, wCharStr, -1, multiByteStr, sizeof(multiByteStr), NULL, NULL); | ||
} | ||
(*_ppEditView)->execute(SCI_REPLACESEL, 0, (LPARAM)""); | ||
int len = (i < 128)?1:strlen(multiByteStr); | ||
(*_ppEditView)->execute(SCI_ADDTEXT, len, (LPARAM)multiByteStr); | ||
|
||
return TRUE; | ||
} | ||
default: | ||
break; | ||
} | ||
} | ||
return TRUE; | ||
|
||
case WM_SIZE: | ||
{ | ||
int width = LOWORD(lParam); | ||
int height = HIWORD(lParam); | ||
::MoveWindow(_listView.getHSelf(), 0, 0, width, height, TRUE); | ||
break; | ||
} | ||
|
||
default : | ||
return DockingDlgInterface::run_dlgProc(message, wParam, lParam); | ||
} | ||
return DockingDlgInterface::run_dlgProc(message, wParam, lParam); | ||
} |
Oops, something went wrong.