diff --git a/ChangeLog.txt b/ChangeLog.txt index 15ea8addc5..c843fb8adb 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,43 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2013-11-06 23:09 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * include/hbgtinfo.ch + + added new hb_gtInfo() switch: HB_GTI_CLOSEMODE + It controls close event (i.e. ALT+F4 and/or [x] button in MS-Windows) + behavior: + == 0 - terminate application + >= 1 - generate HB_K_CLOSE + == 2 - disable close button + + * contrib/gtqtc/gtqtc.h + * contrib/gtqtc/gtqtc1.cpp + % optimized setWindowFlags() and setWindowState() to not + execute show() when flags/state are not changed. + + added support for HB_GTI_CLOSEMODE + * changed HB_GTI_CLOSABLE to work line in GTXWC and GTWVT + + * src/rtl/gtxwc/gtxwc.c + ! fixed setting window position by HB_GTI_SETPOS_XY + + added support for HB_GTI_CLOSEMODE + ; note: in GTXWC we cannot easy disable close button so + HB_GTI_CLOSEMODE==2 will work like 1 until we + do not find some portable way to inform WM that + is should hide close button + + * src/rtl/gtwin/gtwin.c + * added type checking in few HB_GTI_* settings + + added support for HB_GTI_CLOSEMODE + ; note: in GTWIN we cannot catch close event so + HB_GTI_CLOSEMODE==1 works like 2 + In this GT HB_GTI_CLOSABLE also has to work like + HB_GTI_CLOSEMODE==2 + + * src/rtl/gtwvt/gtwvt.h + * src/rtl/gtwvt/gtwvt.c + * added range checking in HB_GTI_RESIZEMODE setting + + added support for HB_GTI_CLOSEMODE + 2013-11-06 15:26 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/common/hbdate.c + added support for decooding timestamp values with semicolon ";" used diff --git a/contrib/gtqtc/gtqtc.h b/contrib/gtqtc/gtqtc.h index 21f9ed4972..6c0c1b72eb 100644 --- a/contrib/gtqtc/gtqtc.h +++ b/contrib/gtqtc/gtqtc.h @@ -322,7 +322,6 @@ typedef struct QIcon * qIcon; /* application icon */ QString * wndTitle; /* window title */ - HB_BOOL fClosable; /* accept ALT+F4 and/or [x] button as CTRL+BREAK */ HB_BOOL fAltEnter; /* ALT+ENTER switch between fullscreen mode */ HB_BOOL fResizable; /* enable/disable window resizing */ HB_BOOL fResizeInc; /* enable/disable resize progression */ @@ -332,6 +331,7 @@ typedef struct HB_BOOL fRepaint; /* force internal image repainting */ int iResizeMode; /* Sets the resizing mode either to FONT or ROWS */ + HB_BOOL iCloseMode; /* ==0 accept ALT+F4 and/or [x] button as CTRL+BREAK, >=1 generate HB_K_CLOSE, ==2 disable [x] */ } HB_GTQTC, * PHB_GTQTC; diff --git a/contrib/gtqtc/gtqtc1.cpp b/contrib/gtqtc/gtqtc1.cpp index f467f52902..ace2c78729 100644 --- a/contrib/gtqtc/gtqtc1.cpp +++ b/contrib/gtqtc/gtqtc1.cpp @@ -1364,10 +1364,10 @@ static PHB_GTQTC hb_gt_qtc_new( PHB_GT pGT ) pQTC->fontName = new QString( QTC_DEFAULT_FONT_NAME ); pQTC->cellY = pQTC->fontHeight; pQTC->cellX = pQTC->fontWidth == 0 ? pQTC->cellY / 2: pQTC->fontWidth; + pQTC->iCloseMode = 0; pQTC->iResizeMode = HB_GTI_RESIZEMODE_FONT; pQTC->fResizable = HB_TRUE; pQTC->fResizeInc = HB_FALSE; - pQTC->fClosable = HB_TRUE; pQTC->fAltEnter = HB_FALSE; pQTC->fMaximized = HB_FALSE; pQTC->fFullScreen = HB_FALSE; @@ -1553,32 +1553,38 @@ static HB_BOOL hb_gt_qtc_setWindowSize( PHB_GTQTC pQTC, int iRows, int iCols ) static void hb_gt_qtc_setWindowFlags( PHB_GTQTC pQTC, Qt::WindowFlags flags, HB_BOOL fSet ) { - Qt::WindowFlags currFlags = pQTC->qWnd->windowFlags(); + Qt::WindowFlags currFlags = pQTC->qWnd->windowFlags(), newFlags; if( fSet ) - currFlags |= flags; + newFlags = currFlags | flags; else - currFlags &= ~flags; + newFlags = currFlags & ~flags; - pQTC->qWnd->setWindowFlags( currFlags ); - HB_QTC_LOCK(); - pQTC->qWnd->show(); - HB_QTC_UNLOCK(); + if( newFlags != currFlags ) + { + pQTC->qWnd->setWindowFlags( currFlags ); + HB_QTC_LOCK(); + pQTC->qWnd->show(); + HB_QTC_UNLOCK(); + } } static void hb_gt_qtc_setWindowState( PHB_GTQTC pQTC, Qt::WindowStates state, HB_BOOL fSet ) { - Qt::WindowStates currState = pQTC->qWnd->windowState(); + Qt::WindowStates currState = pQTC->qWnd->windowState(), newState; if( fSet ) - currState |= state; + newState = currState | state; else - currState &= ~state; + newState = currState & ~state; - pQTC->qWnd->setWindowState( currState ); - HB_QTC_LOCK(); - pQTC->qWnd->show(); - HB_QTC_UNLOCK(); + if( newState != currState ) + { + pQTC->qWnd->setWindowState( currState ); + HB_QTC_LOCK(); + pQTC->qWnd->show(); + HB_QTC_UNLOCK(); + } } static void hb_gt_qtc_initWindow( PHB_GTQTC pQTC, HB_BOOL fCenter ) @@ -2059,13 +2065,29 @@ static HB_BOOL hb_gt_qtc_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) break; case HB_GTI_CLOSABLE: - pInfo->pResult = hb_itemPutL( pInfo->pResult, pQTC->fClosable ); + pInfo->pResult = hb_itemPutL( pInfo->pResult, pQTC->iCloseMode == 0 ); if( pInfo->pNewVal && HB_IS_LOGICAL( pInfo->pNewVal ) && - ( hb_itemGetL( pInfo->pNewVal ) ? ! pQTC->fClosable : pQTC->fClosable ) ) + ( hb_itemGetL( pInfo->pNewVal ) ? ( pQTC->iCloseMode != 0 ) : + ( pQTC->iCloseMode == 0 ) ) ) { - pQTC->fClosable = ! pQTC->fClosable; + iVal = pQTC->iCloseMode; + pQTC->iCloseMode = iVal == 0 ? 1 : 0; if( pQTC->qWnd ) - hb_gt_qtc_setWindowFlags( pQTC, Qt::WindowCloseButtonHint, pQTC->fClosable ); + hb_gt_qtc_setWindowFlags( pQTC, Qt::WindowCloseButtonHint, pQTC->iCloseMode < 2 ); + } + break; + + case HB_GTI_CLOSEMODE: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, pQTC->iCloseMode ); + if( pInfo->pNewVal && HB_IS_NUMERIC( pInfo->pNewVal ) ) + { + iVal = hb_itemGetNI( pInfo->pNewVal ); + if( iVal >= 0 && iVal <= 2 ) + { + pQTC->iCloseMode = iVal; + if( pQTC->qWnd ) + hb_gt_qtc_setWindowFlags( pQTC, Qt::WindowCloseButtonHint, pQTC->iCloseMode < 2 ); + } } break; @@ -3386,7 +3408,7 @@ QTCWindow::QTCWindow( PHB_GTQTC pQTC ) Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::Window; - if( pQTC->fClosable ) + if( pQTC->iCloseMode < 2 ) flags |= Qt::WindowCloseButtonHint; if( pQTC->fResizable ) flags |= Qt::WindowMaximizeButtonHint; @@ -3424,7 +3446,7 @@ QTCWindow::~QTCWindow( void ) void QTCWindow::closeEvent( QCloseEvent * event ) { - if( qConsole->pQTC->fClosable ) + if( qConsole->pQTC->iCloseMode == 0 ) { PHB_ITEM pItem = hb_itemPutL( NULL, HB_TRUE ); hb_setSetItem( HB_SET_CANCEL, pItem ); diff --git a/include/hbgtinfo.ch b/include/hbgtinfo.ch index ccc821e18a..4f027f7049 100644 --- a/include/hbgtinfo.ch +++ b/include/hbgtinfo.ch @@ -151,6 +151,7 @@ #define HB_GTI_DISPIMAGE 71 /* Display image with given name */ #define HB_GTI_REDRAWMAX 72 /* Maximum number of unchanged neighboring chars in redrawn line */ #define HB_GTI_RESIZESTEP 73 /* Enable/Disable window resizing steps */ +#define HB_GTI_CLOSEMODE 74 /* Close event: 0 terminate application, >=1 generate HB_K_CLOSE, 2 disable close button */ /* Font weights */ #define HB_GTI_FONTW_THIN 1 diff --git a/src/rtl/gtwin/gtwin.c b/src/rtl/gtwin/gtwin.c index ddc49d822f..234379c7c4 100644 --- a/src/rtl/gtwin/gtwin.c +++ b/src/rtl/gtwin/gtwin.c @@ -1825,7 +1825,8 @@ static HB_BOOL hb_gt_win_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) UINT uiCodePage = GetConsoleCP(); UINT uiCodePageNew = hb_itemGetNI( pInfo->pNewVal ); pInfo->pResult = hb_itemPutNI( pInfo->pResult, uiCodePage ); - if( ( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) && uiCodePageNew != uiCodePage ) + if( ( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) && + uiCodePageNew != uiCodePage ) { SetConsoleCP( uiCodePageNew ); SetConsoleOutputCP( uiCodePageNew ); @@ -1851,7 +1852,7 @@ static HB_BOOL hb_gt_win_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) case HB_GTI_CLOSABLE: pInfo->pResult = hb_itemPutL( pInfo->pResult, s_bClosable ); - if( pInfo->pNewVal ) + if( hb_itemType( pInfo->pNewVal ) & HB_IT_LOGICAL ) { HB_BOOL bNewValue = hb_itemGetL( pInfo->pNewVal ); if( bNewValue != s_bClosable ) @@ -1862,6 +1863,20 @@ static HB_BOOL hb_gt_win_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) } break; + case HB_GTI_CLOSEMODE: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, s_bClosable ? 0 : 2 ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) + { + int iVal = hb_itemGetNI( pInfo->pNewVal ); + if( iVal >= 0 && iVal <= 2 && + ( s_bClosable ? ( iVal != 0 ) : ( iVal == 0 ) ) ) + { + s_bClosable = iVal == 0; + hb_gt_win_SetCloseButton( HB_TRUE, s_bClosable ); + } + } + break; + case HB_GTI_RESIZABLE: pInfo->pResult = hb_itemPutL( pInfo->pResult, HB_FALSE ); break; diff --git a/src/rtl/gtwvt/gtwvt.c b/src/rtl/gtwvt/gtwvt.c index 000a35f53f..95e7669803 100644 --- a/src/rtl/gtwvt/gtwvt.c +++ b/src/rtl/gtwvt/gtwvt.c @@ -384,10 +384,8 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT, HINSTANCE hInstance, int iCmdShow ) } pWVT->bResizable = HB_TRUE; - pWVT->bClosable = HB_TRUE; - + pWVT->CloseMode = 0; pWVT->ResizeMode = HB_GTI_RESIZEMODE_FONT; - pWVT->bResizing = HB_FALSE; pWVT->bAlreadySizing = HB_FALSE; @@ -2161,6 +2159,15 @@ static void hb_gt_wvt_Composited( PHB_GTWVT pWVT, HB_BOOL fEnable ) #endif } +static void hb_gt_wvt_SetCloseButton( PHB_GTWVT pWVT ) +{ + HMENU hSysMenu = GetSystemMenu( pWVT->hWnd, FALSE ); + + if( hSysMenu ) + EnableMenuItem( hSysMenu, SC_CLOSE, MF_BYCOMMAND | + ( pWVT->CloseMode < 2 ? MF_ENABLED : MF_GRAYED ) ); +} + static void hb_gt_wvt_MouseEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, LPARAM lParam ) { SHORT keyCode = 0; @@ -2895,7 +2902,7 @@ static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wPara return 0; case WM_CLOSE: /* Clicked 'X' on system menu */ - if( pWVT->bClosable ) + if( pWVT->CloseMode == 0 ) { PHB_ITEM pItem = hb_itemPutL( NULL, HB_TRUE ); hb_setSetItem( HB_SET_CANCEL, pItem ); @@ -3960,9 +3967,30 @@ static HB_BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) break; case HB_GTI_CLOSABLE: - pInfo->pResult = hb_itemPutL( pInfo->pResult, pWVT->bClosable ); - if( pInfo->pNewVal ) - pWVT->bClosable = hb_itemGetL( pInfo->pNewVal ); + pInfo->pResult = hb_itemPutL( pInfo->pResult, pWVT->CloseMode == 0 ); + if( ( hb_itemType( pInfo->pNewVal ) & HB_IT_LOGICAL ) && + ( hb_itemGetL( pInfo->pNewVal ) ? ( pWVT->CloseMode != 0 ) : + ( pWVT->CloseMode == 0 ) ) ) + { + iVal = pWVT->CloseMode; + pWVT->CloseMode = iVal == 0 ? 1 : 0; + if( pWVT->hWnd ) + hb_gt_wvt_SetCloseButton( pWVT ); + } + break; + + case HB_GTI_CLOSEMODE: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, pWVT->CloseMode ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) + { + iVal = hb_itemGetNI( pInfo->pNewVal ); + if( iVal >= 0 && iVal <= 2 && pWVT->CloseMode != iVal ) + { + pWVT->CloseMode = iVal; + if( pWVT->hWnd ) + hb_gt_wvt_SetCloseButton( pWVT ); + } + } break; case HB_GTI_PALETTE: @@ -4009,7 +4037,16 @@ static HB_BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) case HB_GTI_RESIZEMODE: pInfo->pResult = hb_itemPutNI( pInfo->pResult, pWVT->ResizeMode ); if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) - pWVT->ResizeMode = hb_itemGetNI( pInfo->pNewVal ); + { + iVal = hb_itemGetNI( pInfo->pNewVal ); + switch( iVal ) + { + case HB_GTI_RESIZEMODE_FONT: + case HB_GTI_RESIZEMODE_ROWS: + pWVT->ResizeMode = iVal; + break; + } + } break; case HB_GTI_SETPOS_XY: diff --git a/src/rtl/gtwvt/gtwvt.h b/src/rtl/gtwvt/gtwvt.h index 684ad5ec93..23a3bbcbc9 100644 --- a/src/rtl/gtwvt/gtwvt.h +++ b/src/rtl/gtwvt/gtwvt.h @@ -325,7 +325,7 @@ typedef struct HB_BOOL IgnoreWM_SYSCHAR; HB_BOOL bResizable; - HB_BOOL bClosable; + HB_BOOL bMaximized; /* Flag is set when window has been maximized */ HB_BOOL bFullScreen; HB_BOOL bAltEnter; /* Can use Alt+Enter to enter full screen mode */ int MarginTop; @@ -334,7 +334,6 @@ typedef struct int iNewPosX; int iNewPosY; - HB_BOOL bMaximized; /* Flag is set when window has been maximized */ HB_BOOL bBeingMarked; /* Flag to control DOS window like copy operation */ HB_BOOL bBeginMarked; @@ -345,6 +344,7 @@ typedef struct RECT sRectNew; RECT sRectOld; + int CloseMode; int ResizeMode; /* Sets the resizing mode either to FONT or ROWS */ HB_BOOL bResizing; diff --git a/src/rtl/gtxwc/gtxwc.c b/src/rtl/gtxwc/gtxwc.c index b66eb3abe7..a28f453b41 100644 --- a/src/rtl/gtxwc/gtxwc.c +++ b/src/rtl/gtxwc/gtxwc.c @@ -4367,7 +4367,7 @@ static void hb_gt_xwc_SetResizing( PXWND_DEF wnd ) /* xsize.flags = PWinGravity | PBaseSize | PResizeInc | PMinSize; */ xsize.flags = PWinGravity | PResizeInc | PMinSize | PMaxSize | PBaseSize; - xsize.win_gravity = CenterGravity; + xsize.win_gravity = StaticGravity; if( wnd->fResizable ) { xsize.width_inc = wnd->fontWidth; @@ -5046,6 +5046,16 @@ static HB_BOOL hb_gt_xwc_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) wnd->fClosable = hb_itemGetL( pInfo->pNewVal ); break; + case HB_GTI_CLOSEMODE: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, wnd->fClosable ? 0 : 1 ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) + { + iVal = hb_itemGetNI( pInfo->pNewVal ); + if( iVal >= 0 && iVal <= 2 ) + wnd->fClosable = iVal == 0; + } + break; + case HB_GTI_RESIZABLE: pInfo->pResult = hb_itemPutL( pInfo->pResult, wnd->fResizable ); if( hb_itemType( pInfo->pNewVal ) & HB_IT_LOGICAL )