[NEW_FEATURE] Add restore button in fullscreen and postIt mode.

[BUG_FIXED] Fix auto-updater bug.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@590 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2009-12-13 23:54:02 +00:00
parent 2ec3cdea2f
commit b186f2a055
6 changed files with 167 additions and 4 deletions

View File

@ -8101,6 +8101,9 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
if (appDataNpp[0]) if (appDataNpp[0])
_pluginsManager.loadPlugins(appDataNpp); _pluginsManager.loadPlugins(appDataNpp);
_restoreButton.init(_hInst, _hSelf);
// ------------ // // ------------ //
// Menu Section // // Menu Section //
// ------------ // // ------------ //
@ -10236,7 +10239,12 @@ void Notepad_plus::fullScreenToggle()
} }
//Setup GUI //Setup GUI
if (!_beforeSpecialView.isPostIt) int bs = buttonStatus_fullscreen;
if (_beforeSpecialView.isPostIt)
{
bs |= buttonStatus_postit;
}
else
{ {
//only change the GUI if not already done by postit //only change the GUI if not already done by postit
_beforeSpecialView.isMenuShown = ::SendMessage(_hSelf, NPPM_ISMENUHIDDEN, 0, 0) != TRUE; _beforeSpecialView.isMenuShown = ::SendMessage(_hSelf, NPPM_ISMENUHIDDEN, 0, 0) != TRUE;
@ -10247,6 +10255,7 @@ void Notepad_plus::fullScreenToggle()
_rebarTop.display(false); _rebarTop.display(false);
_rebarBottom.display(false); _rebarBottom.display(false);
} }
_restoreButton.setButtonStatus(bs);
//Hide window so windows can properly update it //Hide window so windows can properly update it
::ShowWindow(_hSelf, SW_HIDE); ::ShowWindow(_hSelf, SW_HIDE);
@ -10264,12 +10273,31 @@ void Notepad_plus::fullScreenToggle()
::ShowWindow(_hSelf, SW_SHOW); ::ShowWindow(_hSelf, SW_SHOW);
::SetWindowPos(_hSelf, HWND_TOP, fullscreenArea.left, fullscreenArea.top, fullscreenArea.right, fullscreenArea.bottom, SWP_NOZORDER|SWP_DRAWFRAME|SWP_FRAMECHANGED); ::SetWindowPos(_hSelf, HWND_TOP, fullscreenArea.left, fullscreenArea.top, fullscreenArea.right, fullscreenArea.bottom, SWP_NOZORDER|SWP_DRAWFRAME|SWP_FRAMECHANGED);
::SetForegroundWindow(_hSelf); ::SetForegroundWindow(_hSelf);
// show restore button
_restoreButton.doDialog(_isRTL);
RECT rect;
GetWindowRect(_restoreButton.getHSelf(), &rect);
int w = rect.right - rect.left;
int h = rect.bottom - rect.top;
RECT nppRect;
GetWindowRect(_hSelf, &nppRect);
int x = nppRect.right - w;
int y = nppRect.top;
::MoveWindow(_restoreButton.getHSelf(), x, y, w, h, FALSE);
_pEditView->getFocus();
} }
else //toggle fullscreen off else //toggle fullscreen off
{ {
//Hide window for updating, restore style and menu then restore position and Z-Order //Hide window for updating, restore style and menu then restore position and Z-Order
::ShowWindow(_hSelf, SW_HIDE); ::ShowWindow(_hSelf, SW_HIDE);
_restoreButton.setButtonStatus(buttonStatus_fullscreen ^ _restoreButton.getButtonStatus());
_restoreButton.display(false);
//Setup GUI //Setup GUI
if (!_beforeSpecialView.isPostIt) if (!_beforeSpecialView.isPostIt)
{ {
@ -10333,7 +10361,12 @@ void Notepad_plus::postItToggle()
::SendMessage(_hSelf, WM_COMMAND, IDM_VIEW_ALWAYSONTOP, 0); ::SendMessage(_hSelf, WM_COMMAND, IDM_VIEW_ALWAYSONTOP, 0);
} }
//Only check these if not fullscreen //Only check these if not fullscreen
if (!_beforeSpecialView.isFullScreen) int bs = buttonStatus_postit;
if (_beforeSpecialView.isFullScreen)
{
bs |= buttonStatus_fullscreen;
}
else
{ {
_beforeSpecialView.isMenuShown = ::SendMessage(_hSelf, NPPM_ISMENUHIDDEN, 0, 0) != TRUE; _beforeSpecialView.isMenuShown = ::SendMessage(_hSelf, NPPM_ISMENUHIDDEN, 0, 0) != TRUE;
if (_beforeSpecialView.isMenuShown) if (_beforeSpecialView.isMenuShown)
@ -10343,6 +10376,7 @@ void Notepad_plus::postItToggle()
_rebarTop.display(false); _rebarTop.display(false);
_rebarBottom.display(false); _rebarBottom.display(false);
} }
_restoreButton.setButtonStatus(bs);
// PostIt! // PostIt!
@ -10359,9 +10393,28 @@ void Notepad_plus::postItToggle()
::SetWindowPos(_hSelf, HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_DRAWFRAME|SWP_FRAMECHANGED); ::SetWindowPos(_hSelf, HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_DRAWFRAME|SWP_FRAMECHANGED);
::ShowWindow(_hSelf, SW_SHOW); ::ShowWindow(_hSelf, SW_SHOW);
} }
// show restore button
_restoreButton.doDialog(_isRTL);
RECT rect;
GetWindowRect(_restoreButton.getHSelf(), &rect);
int w = rect.right - rect.left;
int h = rect.bottom - rect.top;
RECT nppRect;
GetWindowRect(_hSelf, &nppRect);
int x = nppRect.right - w;
int y = nppRect.top;
::MoveWindow(_restoreButton.getHSelf(), x, y, w, h, FALSE);
_pEditView->getFocus();
} }
else //PostIt enabled, disable it else //PostIt enabled, disable it
{ {
_restoreButton.setButtonStatus(buttonStatus_postit ^ _restoreButton.getButtonStatus());
_restoreButton.display(false);
//Setup GUI //Setup GUI
if (!_beforeSpecialView.isFullScreen) if (!_beforeSpecialView.isFullScreen)
{ {

View File

@ -106,6 +106,10 @@
#include "ScintillaCtrls.h" #include "ScintillaCtrls.h"
#endif //SCINTILLACTRLS_H #endif //SCINTILLACTRLS_H
#ifndef SIZE_DLG_H
#include "lesDlgs.h"
#endif //SIZE_DLG_H
#define MENU 0x01 #define MENU 0x01
#define TOOLBAR 0x02 #define TOOLBAR 0x02
@ -377,6 +381,7 @@ private:
ScintillaAccelerator _scintaccelerator; ScintillaAccelerator _scintaccelerator;
PluginsManager _pluginsManager; PluginsManager _pluginsManager;
ButtonDlg _restoreButton;
bool _isRTL; bool _isRTL;
winVer _winVersion; winVer _winVersion;

View File

@ -786,5 +786,12 @@ BEGIN
EDITTEXT IDC_VALUE_EDIT,49,2,18,14,ES_NUMBER,WS_EX_DLGMODALFRAME EDITTEXT IDC_VALUE_EDIT,49,2,18,14,ES_NUMBER,WS_EX_DLGMODALFRAME
END END
IDD_BUTTON_DLG DIALOGEX 0, 0, 51, 17
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
PUSHBUTTON "Restore",IDC_RESTORE_BUTTON,0,0,51,17
END
// xp style // xp style
1 RT_MANIFEST "notepad++.exe.manifest" 1 RT_MANIFEST "notepad++.exe.manifest"

View File

@ -18,6 +18,7 @@
#include "precompiledHeaders.h" #include "precompiledHeaders.h"
#include "lesDlgs.h" #include "lesDlgs.h"
#include "resource.h" #include "resource.h"
#include "menuCmdID.h"
void ValueDlg::init(HINSTANCE hInst, HWND parent, int valueToSet, const TCHAR *text) void ValueDlg::init(HINSTANCE hInst, HWND parent, int valueToSet, const TCHAR *text)
{ {
@ -108,3 +109,60 @@ BOOL CALLBACK ValueDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
} }
} }
BOOL CALLBACK ButtonDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
{
switch (Message)
{
case WM_INITDIALOG :
{
return TRUE;
}
case WM_COMMAND :
{
switch (wParam)
{
case IDC_RESTORE_BUTTON :
{
int bs = getButtonStatus();
bool isFullScreen = (bs & buttonStatus_fullscreen) != 0;
bool isPostIt = (bs & buttonStatus_postit) != 0;
int cmd = 0;
if (isFullScreen && isPostIt)
{
// remove postit firstly
cmd = IDM_VIEW_POSTIT;
}
else if (isFullScreen)
{
cmd = IDM_VIEW_FULLSCREENTOGGLE;
}
else if (isPostIt)
{
cmd = IDM_VIEW_POSTIT;
}
::SendMessage(_hParent, WM_COMMAND, cmd, 0);
display(false);
return TRUE;
}
default:
return FALSE;
}
}
default :
return FALSE;
}
}
void ButtonDlg::doDialog(bool isRTL)
{
if (!isCreated())
create(IDD_BUTTON_DLG, isRTL);
display();
}

View File

@ -40,7 +40,44 @@ private :
int _defaultValue; int _defaultValue;
generic_string _name; generic_string _name;
POINT _p; POINT _p;
}; };
// 0 : sans fullscreen
// 1 : fullscreen
// 2 : postit
const int buttonStatus_nada = 0;
const int buttonStatus_fullscreen = 1;
const int buttonStatus_postit = 2;
class ButtonDlg : public StaticDialog
{
public :
ButtonDlg() : StaticDialog(), _buttonStatus(buttonStatus_nada) {};
void init(HINSTANCE hInst, HWND parent){
Window::init(hInst, parent);
};
void doDialog(bool isRTL = false);
void destroy() {};
int getButtonStatus() const {
return _buttonStatus;
};
void setButtonStatus(int buttonStatus) {
_buttonStatus = buttonStatus;
};
void display(bool toShow = true) const {
int cmdToShow = toShow?SW_SHOW:SW_HIDE;
if (!toShow)
{
cmdToShow = (_buttonStatus != buttonStatus_nada)?SW_SHOW:SW_HIDE;
}
::ShowWindow(_hSelf, cmdToShow);
};
protected :
BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM);
int _buttonStatus;
};
#endif //TABSIZE_DLG_H #endif //TABSIZE_DLG_H

View File

@ -19,7 +19,7 @@
#define RESOURCE_H #define RESOURCE_H
#define NOTEPAD_PLUS_VERSION TEXT("Notepad++ v5.6.2") #define NOTEPAD_PLUS_VERSION TEXT("Notepad++ v5.6.2")
#define VERSION_VALUE TEXT("5.6.2\0") // should be X.Y : ie. if VERSION_DIGITALVALUE == 4, 7, 1, 0 , then X = 4, Y = 71 #define VERSION_VALUE TEXT("5.62\0") // should be X.Y : ie. if VERSION_DIGITALVALUE == 4, 7, 1, 0 , then X = 4, Y = 71
#define VERSION_DIGITALVALUE 5, 6, 2, 0 #define VERSION_DIGITALVALUE 5, 6, 2, 0
#ifdef UNICODE #ifdef UNICODE
@ -269,6 +269,9 @@
#define IDC_VALUE_STATIC 2401 #define IDC_VALUE_STATIC 2401
#define IDC_VALUE_EDIT 2402 #define IDC_VALUE_EDIT 2402
#define IDD_BUTTON_DLG 2410
#define IDC_RESTORE_BUTTON 2411
// see TaskListDlg_rc.h // see TaskListDlg_rc.h
//#define IDD_TASKLIST_DLG 2450 //#define IDD_TASKLIST_DLG 2450
#define IDD_SETTING_DLG 2500 #define IDD_SETTING_DLG 2500