00001
00002
00003
00004
00005 #include "Transparency.h"
00006
00007 #ifndef WS_EX_LAYERED
00008 #define WS_EX_LAYERED 0x00080000
00009 #endif
00010
00011 #ifndef LWA_COLORKEY
00012 #define LWA_COLORKEY 0x00000001
00013 #endif
00014
00015 #ifndef LWA_ALPHA
00016 #define LWA_ALPHA 0x00000002
00017 #endif
00018
00019 static int CurrentAlphaLevel=255;
00020 static BOOL TransparencyON=FALSE;
00021
00022 extern LPTW GetTextWinScilab(void);
00023
00024 BOOL IsEnableTransparencyMode(void)
00025 {
00026 return TransparencyON;
00027 }
00028
00029 BOOL ActivateTransparencyMode(HWND hWnd)
00030 {
00031 BOOL bOK=FALSE;
00032 TransparencyON=TRUE;
00033 bOK=TRUE;
00034
00035 return bOK;
00036 }
00037
00038 BOOL DisableTransparencyMode(HWND hWnd)
00039 {
00040 BOOL bOK=FALSE;
00041
00042 SetWindowLong(hWnd, GWL_EXSTYLE,CS_HREDRAW | CS_VREDRAW);
00043 CurrentAlphaLevel=255;
00044 TransparencyON=FALSE;
00045 bOK=TRUE;
00046
00047 return bOK;
00048 }
00049
00050 void ScilabFxFadeOut(void)
00051 {
00052 LPTW lptw=GetTextWinScilab();
00053 int i=0;
00054 for (i=GetCurrentAlphaLevel();i>=0;i=i-16)
00055 {
00056 SetCurrentAlphaLevel(lptw->hWndParent ,i);
00057 SetCurrentAlphaLevel(lptw->hWndText ,i);
00058 }
00059 }
00060
00061 int GetCurrentAlphaLevel(void)
00062 {
00063 return CurrentAlphaLevel;
00064 }
00065
00066 void SetCurrentAlphaLevel(HWND hWnd ,int Alpha)
00067 {
00068 if ( (Alpha>=0) && (Alpha<=255) )
00069 {
00070 SetLayeredWindowAttributes(hWnd, (COLORREF)NULL,CurrentAlphaLevel, LWA_ALPHA);
00071 }
00072 CurrentAlphaLevel=Alpha;
00073 }
00074
00075 BOOL IncreaseAlphaLevel(void)
00076 {
00077 BOOL bOK=FALSE;
00078 LPTW lptw=GetTextWinScilab();
00079 int Alpha=GetCurrentAlphaLevel();
00080
00081 if (Alpha==255)
00082 {
00083 DisableTransparencyMode(lptw->hWndParent);
00084 DisableTransparencyMode(lptw->hWndText);
00085 DragAcceptFiles (lptw->hWndParent, TRUE);
00086 InvalidateRect(lptw->hWndParent,NULL,TRUE);
00087 InvalidateRect(lptw->hWndText,NULL,TRUE);
00088 }
00089 else
00090 {
00091 if (Alpha<255)
00092 {
00093 SetCurrentAlphaLevel(lptw->hWndParent ,Alpha++);
00094 SetCurrentAlphaLevel(lptw->hWndText ,Alpha++);
00095 if (Alpha>255) Alpha=255;
00096 }
00097 }
00098 return bOK;
00099 }
00100
00101 BOOL DecreaseAlphaLevel(void)
00102 {
00103 BOOL bOK=FALSE;
00104 LPTW lptw=GetTextWinScilab();
00105 int Alpha=GetCurrentAlphaLevel();
00106
00107 if (Alpha<0) Alpha=0;
00108 else
00109 {
00110 SetCurrentAlphaLevel(lptw->hWndParent ,Alpha--);
00111 SetCurrentAlphaLevel(lptw->hWndText ,Alpha--);
00112 }
00113 return bOK;
00114 }
00115
00116
00117