Skip to content

Commit

Permalink
Merge pull request #704 from ds14050/BackImg_opacity
Browse files Browse the repository at this point in the history
[拾い物です] 背景画像表示の不透明度を設定出来るように変更
  • Loading branch information
beru authored Dec 14, 2018
2 parents d6cc548 + 55056f0 commit 6b81742
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 7 deletions.
5 changes: 5 additions & 0 deletions help/sakura/Cshelp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,11 @@ TAB

�w�i�摜�̕\���ʒu���w�肵���s�N�Z�����������Ɉړ����܂��B

.topic 11429
�y�s�����x�z

�w�i�摜�̕s�����x���w�肵�܂��B

.topic 11430
�y�����L�[���[�h�P�Z�b�g���z

Expand Down
16 changes: 16 additions & 0 deletions sakura_core/apiwrap/StdControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,22 @@ namespace ApiWrap{
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- //
inline HICON StCtl_SetIcon(HWND hwndCtl, HICON hIcon) { return (HICON)(UINT_PTR)::SendMessage(hwndCtl, STM_SETICON, (WPARAM)hIcon, 0L); }

// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- //
// スタティック コントロール //
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- //
inline void TrackBarCtl_SetRange(HWND hwndCtl, BOOL bRedraw, WORD minimum, WORD maximum)
{
::SendMessage(hwndCtl, TBM_SETRANGE, (WPARAM)bRedraw, (LPARAM)MAKELONG(minimum, maximum));
}
inline void TrackBarCtl_SetPos(HWND hwndCtl, BOOL bRedraw, LPARAM pos)
{
::SendMessage(hwndCtl, TBM_SETPOS, (WPARAM)bRedraw, pos);
}
inline LRESULT TrackBarCtl_GetPos(HWND hwndCtl)
{
return ::SendMessage(hwndCtl, TBM_GETPOS, (WPARAM)0, (LPARAM)0);
}

// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- //
// ダイアログ内 //
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- //
Expand Down
5 changes: 4 additions & 1 deletion sakura_core/config/system_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -538,12 +538,15 @@
Version 172:
キーワードヘルプの右クリックメニュー表示選択
Version 173:
STypeConfigにm_backImgOpacity 追加
-- 統合されたので元に戻す(1000~1023が使用済み) 2008.11.16 nasukoji
-- Version 1000:
-- バージョン1000以降を本家統合までの間、使わせてください。かなり頻繁に構成が変更されると思われるので。by kobake 2008.03.02
*/
#define N_SHAREDATA_VERSION 172
#define N_SHAREDATA_VERSION 173
#define STR_SHAREDATA_VERSION NUM_TO_STR(N_SHAREDATA_VERSION)
#define GSTR_SHAREDATA (_T("SakuraShareData") _T(CON_SKR_MACHINE_SUFFIX_) _T(_CODE_SUFFIX_) _T(_DEBUG_SUFFIX_) _T(STR_SHAREDATA_VERSION))

Expand Down
1 change: 1 addition & 0 deletions sakura_core/env/CShareData_IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1633,6 +1633,7 @@ void CShareData_IO::ShareData_IO_Type_One( CDataProfile& cProfile, STypeConfig&
cProfile.IOProfileData( pszSecName, L"bgImgRepeartY", types.m_backImgRepeatY );
cProfile.IOProfileData_WrapInt( pszSecName, L"bgImgPosOffsetX", types.m_backImgPosOffset.x );
cProfile.IOProfileData_WrapInt( pszSecName, L"bgImgPosOffsetY", types.m_backImgPosOffset.y );
cProfile.IOProfileData_WrapInt( pszSecName, L"bgImgOpacity", types.m_backImgOpacity );

// 2005.11.08 Moca 指定桁縦線
for(j = 0; j < MAX_VERTLINES; j++ ){
Expand Down
1 change: 1 addition & 0 deletions sakura_core/sakura.hh
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@
#define HIDC_CHECK_BACKIMG_REP_Y 11426 //背景画像RepeatY
#define HIDC_EDIT_BACKIMG_OFFSET_X 11427 //背景画像OffsetX
#define HIDC_EDIT_BACKIMG_OFFSET_Y 11428 //背景画像OffsetY
#define HIDC_EDIT_BACKIMG_TRANSPARENCY 11429 //背景画像透明度
#define HIDC_COMBO_SET_COLOR 11430 //強調キーワード1セット名
#define HIDC_COMBO_SET2_COLOR 11431 //強調キーワード2セット名
#define HIDC_EDIT_BLOCKCOMMENT_FROM 11440 //ブロックコメント1開始
Expand Down
5 changes: 4 additions & 1 deletion sakura_core/sakura_rc.h
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,9 @@
#define IDC_CHECK_BACKIMG_REP_Y 1608
#define IDC_EDIT_BACKIMG_OFFSET_X 1609
#define IDC_EDIT_BACKIMG_OFFSET_Y 1610
#define IDC_TRACKBAR_BACKIMG_TRANSPARENCY 1734
#define IDC_EDIT_BACKIMG_TRANSPARENCY 1735
#define IDC_UPDOWN_BACKIMG_TRANSPARENCY 1736
#define IDC_CHECK_CONVERTEOLPASTE 1611
#define IDC_CHECK_OpenNewWin 1612
#define IDC_BUTTON_TABFONT 1613
Expand Down Expand Up @@ -844,7 +847,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 230
#define _APS_NEXT_COMMAND_VALUE 4057
#define _APS_NEXT_CONTROL_VALUE 1734
#define _APS_NEXT_CONTROL_VALUE 1737
#define _APS_NEXT_SYMED_VALUE 104
#endif
#endif
6 changes: 5 additions & 1 deletion sakura_core/sakura_rc.rc
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,11 @@ BEGIN
LTEXT "Scroll", IDC_STATIC, 270, 150, 26, 8
CONTROL "", IDC_CHECK_BACKIMG_SCR_X, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 276, 164, 10, 10
CONTROL "", IDC_CHECK_BACKIMG_SCR_Y, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 276, 179, 10, 10
GROUPBOX "背景画像", IDC_STATIC, 153, 122, 145, 80
LTEXT "透明度", IDC_STATIC, 158, 194, 45, 8
CONTROL "",IDC_TRACKBAR_BACKIMG_TRANSPARENCY, "msctls_trackbar32", TBS_BOTH | TBS_NOTICKS | WS_TABSTOP, 205, 193, 60, 12
EDITTEXT IDC_EDIT_BACKIMG_TRANSPARENCY, 265, 193, 28, 12
CONTROL "Spin1", IDC_UPDOWN_BACKIMG_TRANSPARENCY, "msctls_updown32", UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS, 285, 193, 9, 12
GROUPBOX "背景画像", IDC_STATIC, 153, 122, 145, 90
END

IDD_DIALOG_KEYWORD_SELECT DIALOGEX 0, 0, 177, 197
Expand Down
44 changes: 44 additions & 0 deletions sakura_core/typeprop/CPropTypesWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ static const DWORD p_helpids2[] = { //11400
IDC_CHECK_BACKIMG_REP_Y, HIDC_CHECK_BACKIMG_REP_Y, //背景画像RepeatY
IDC_EDIT_BACKIMG_OFFSET_X, HIDC_EDIT_BACKIMG_OFFSET_X, //背景画像OffsetX
IDC_EDIT_BACKIMG_OFFSET_Y, HIDC_EDIT_BACKIMG_OFFSET_Y, //背景画像OffsetY
IDC_EDIT_BACKIMG_TRANSPARENCY, HIDC_EDIT_BACKIMG_TRANSPARENCY, //背景画像透明度
IDC_RADIO_LINENUM_LAYOUT, HIDC_RADIO_LINENUM_LAYOUT, //行番号の表示(折り返し単位)
IDC_RADIO_LINENUM_CRLF, HIDC_RADIO_LINENUM_CRLF, //行番号の表示(改行単位)
IDC_RADIO_LINETERMTYPE0, HIDC_RADIO_LINETERMTYPE0, //行番号区切り(なし)
Expand Down Expand Up @@ -162,6 +163,14 @@ INT_PTR CPropTypesWindow::DispatchEvent(
return TRUE;
}
break; /* BN_CLICKED */
case EN_KILLFOCUS:
if(wID == IDC_EDIT_BACKIMG_TRANSPARENCY){
int nVal = ::GetDlgItemInt( hwndDlg, IDC_EDIT_BACKIMG_TRANSPARENCY, NULL, FALSE );
if(nVal < 0) nVal = 0;
if(nVal > 255) nVal = 255;
TrackBarCtl_SetPos( ::GetDlgItem( hwndDlg, IDC_TRACKBAR_BACKIMG_TRANSPARENCY ), TRUE, nVal );
}
break;
}
break; /* WM_COMMAND */
case WM_NOTIFY:
Expand Down Expand Up @@ -205,6 +214,22 @@ INT_PTR CPropTypesWindow::DispatchEvent(
::SetDlgItemInt( hwndDlg, IDC_EDIT_LINENUMWIDTH, nVal, FALSE );
return TRUE;
}
switch( (int)wParam ) {
case IDC_UPDOWN_BACKIMG_TRANSPARENCY:
int nVal = ::GetDlgItemInt( hwndDlg, IDC_EDIT_BACKIMG_TRANSPARENCY, NULL, FALSE );
if( pMNUD->iDelta < 0 ){
if( nVal < 0xFF ){
++nVal;
}
}else if( pMNUD->iDelta > 0 ){
if( nVal > 0 ){
--nVal;
}
}
::SetDlgItemInt( hwndDlg, IDC_EDIT_BACKIMG_TRANSPARENCY, nVal, FALSE );
TrackBarCtl_SetPos( ::GetDlgItem( hwndDlg, IDC_TRACKBAR_BACKIMG_TRANSPARENCY ), TRUE, nVal );
return TRUE;
}

break; /* WM_NOTIFY */

Expand All @@ -226,6 +251,18 @@ INT_PTR CPropTypesWindow::DispatchEvent(
return TRUE;
//@@@ 2001.11.17 add end MIK

case WM_HSCROLL:
if( (HWND)lParam == ::GetDlgItem( hwndDlg, IDC_TRACKBAR_BACKIMG_TRANSPARENCY ) ){
WORD code = LOWORD(wParam);
WORD pos;
if(code == TB_THUMBPOSITION || code == TB_THUMBTRACK){
pos = HIWORD(wParam);
}else{
pos = (WORD)TrackBarCtl_GetPos((HWND)lParam);
}
::SetDlgItemInt( hwndDlg, IDC_EDIT_BACKIMG_TRANSPARENCY, pos, FALSE );
}
return TRUE;
}
return FALSE;
}
Expand Down Expand Up @@ -356,6 +393,7 @@ void CPropTypesWindow::SetData( HWND hwndDlg )
EditCtl_LimitText(GetDlgItem(hwndDlg, IDC_EDIT_BACKIMG_PATH), _countof2(m_Types.m_szBackImgPath));
EditCtl_LimitText(GetDlgItem(hwndDlg, IDC_EDIT_BACKIMG_OFFSET_X), 5);
EditCtl_LimitText(GetDlgItem(hwndDlg, IDC_EDIT_BACKIMG_OFFSET_Y), 5);
EditCtl_LimitText(GetDlgItem(hwndDlg, IDC_EDIT_BACKIMG_TRANSPARENCY), 3);

DlgItem_SetText( hwndDlg, IDC_EDIT_BACKIMG_PATH, m_Types.m_szBackImgPath );
{
Expand All @@ -380,6 +418,11 @@ void CPropTypesWindow::SetData( HWND hwndDlg )
CheckDlgButtonBool(hwndDlg, IDC_CHECK_BACKIMG_SCR_Y, m_Types.m_backImgScrollY);
SetDlgItemInt(hwndDlg, IDC_EDIT_BACKIMG_OFFSET_X, m_Types.m_backImgPosOffset.x, TRUE);
SetDlgItemInt(hwndDlg, IDC_EDIT_BACKIMG_OFFSET_Y, m_Types.m_backImgPosOffset.y, TRUE);
BYTE transparency = 255 - m_Types.m_backImgOpacity;
SetDlgItemInt(hwndDlg, IDC_EDIT_BACKIMG_TRANSPARENCY, transparency, FALSE);
HWND hWndTrackBar = ::GetDlgItem( hwndDlg, IDC_TRACKBAR_BACKIMG_TRANSPARENCY );
TrackBarCtl_SetRange( hWndTrackBar, FALSE, 0, 255 );
TrackBarCtl_SetPos( hWndTrackBar, TRUE, transparency );

/* 行番号区切り 0=なし 1=縦線 2=任意 */
if( 0 == m_Types.m_nLineTermType ){
Expand Down Expand Up @@ -483,6 +526,7 @@ int CPropTypesWindow::GetData( HWND hwndDlg )
m_Types.m_backImgScrollY = IsDlgButtonCheckedBool(hwndDlg, IDC_CHECK_BACKIMG_SCR_Y);
m_Types.m_backImgPosOffset.x = GetDlgItemInt(hwndDlg, IDC_EDIT_BACKIMG_OFFSET_X, NULL, TRUE);
m_Types.m_backImgPosOffset.y = GetDlgItemInt(hwndDlg, IDC_EDIT_BACKIMG_OFFSET_Y, NULL, TRUE);
m_Types.m_backImgOpacity = 255 - (BYTE)std::min(255U, GetDlgItemInt(hwndDlg, IDC_EDIT_BACKIMG_TRANSPARENCY, NULL, FALSE));

/* 行番号区切り 0=なし 1=縦線 2=任意 */
if( ::IsDlgButtonChecked( hwndDlg, IDC_RADIO_LINETERMTYPE0 ) ){
Expand Down
1 change: 1 addition & 0 deletions sakura_core/types/CType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ void _DefaultConfig(STypeConfig* pType)
POINT pt ={0,0};
pType->m_backImgPosOffset = pt;
}
pType->m_backImgOpacity = 0xFF;
pType->m_bLineNumIsCRLF = true; // 行番号の表示 false=折り返し単位/true=改行単位
pType->m_nLineTermType = 1; // 行番号区切り 0=なし 1=縦線 2=任意
pType->m_cLineTermChar = L':'; // 行番号区切り文字
Expand Down
1 change: 1 addition & 0 deletions sakura_core/types/CType.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ struct STypeConfig{
bool m_backImgScrollX; //!< 背景画像表示横方向スクロール
bool m_backImgScrollY; //!< 背景画像表示縦方向スクロール
POINT m_backImgPosOffset; //!< 背景画像表示オフセット
BYTE m_backImgOpacity; //!< 背景画像表示不透明度

bool m_bLineNumIsCRLF; //!< 行番号の表示 false=折り返し単位/true=改行単位
int m_nLineTermType; //!< 行番号区切り 0=なし 1=縦線 2=任意
Expand Down
5 changes: 4 additions & 1 deletion sakura_core/view/CEditView.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ class CEditView
public:
//! 背景にビットマップを使用するかどうか
//! 2010.10.03 背景実装
bool IsBkBitmap() const{ return NULL != m_pcEditDoc->m_hBackImg; }
bool IsBkBitmap() const{
return NULL != m_pcEditDoc->m_hBackImg
&& 0 != GetDocument()->m_cDocType.GetDocumentAttribute().m_backImgOpacity;
}

public:
CEditView* GetEditView()
Expand Down
4 changes: 2 additions & 2 deletions sakura_core/view/CEditView_Paint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ void CEditView::DrawBackImage(HDC hdc, RECT& rcPaint, HDC hdcBgImg)
}
rcImagePos.SetSize(doc.m_nBackImgWidth, doc.m_nBackImgHeight);


RECT rc = rcPaint;
// rc.left = t_max((int)rc.left, area.GetAreaLeft());
rc.top = t_max((int)rc.top, area.GetRulerHeight()); // ルーラーを除外
Expand All @@ -285,7 +285,7 @@ void CEditView::DrawBackImage(HDC hdc, RECT& rcPaint, HDC hdcBgImg)
BLENDFUNCTION bf;
bf.BlendOp = AC_SRC_OVER;
bf.BlendFlags = 0;
bf.SourceConstantAlpha = 0xFF;
bf.SourceConstantAlpha = typeConfig.m_backImgOpacity;
bf.AlphaFormat = AC_SRC_ALPHA;
for(; rcImagePos.top <= nYEnd; ){
for(; rcImagePos.left <= nXEnd; ){
Expand Down
6 changes: 5 additions & 1 deletion sakura_lang_en_US/sakura_lang_rc.rc
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,11 @@ BEGIN
LTEXT "Scroll", IDC_STATIC, 270, 150, 26, 8
CONTROL "", IDC_CHECK_BACKIMG_SCR_X, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 276, 164, 10, 10
CONTROL "", IDC_CHECK_BACKIMG_SCR_Y, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 276, 179, 10, 10
GROUPBOX "Background Image", IDC_STATIC, 153, 122, 145, 80
LTEXT "Transparency", IDC_STATIC, 158, 194, 45, 8
CONTROL "",IDC_TRACKBAR_BACKIMG_TRANSPARENCY, "msctls_trackbar32", TBS_BOTH | TBS_NOTICKS | WS_TABSTOP, 205, 193, 60, 12
EDITTEXT IDC_EDIT_BACKIMG_TRANSPARENCY, 265, 193, 28, 12
CONTROL "Spin1", IDC_UPDOWN_BACKIMG_TRANSPARENCY, "msctls_updown32", UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS, 285, 193, 9, 12
GROUPBOX "Background Image", IDC_STATIC, 153, 122, 145, 90
END

IDD_DIALOG_KEYWORD_SELECT DIALOGEX 0, 0, 177, 197
Expand Down

0 comments on commit 6b81742

Please sign in to comment.