EgtUILib :
- altre migliorie a DialogBox per lua.
This commit is contained in:
+62
-67
@@ -21,6 +21,7 @@
|
||||
#include "/EgtDev/Include/ExeExecutor.h"
|
||||
#include "/EgtDev/Include/EGkLuaAux.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGkSelection.h"
|
||||
#include "/EgtDev/Include/EgtIniFile.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include <Windowsx.h>
|
||||
@@ -48,40 +49,23 @@ static COLORREF s_CustomColors[16] = {12632256} ; // 16 colori GRAY
|
||||
static bool s_bSelectionMode = false ; // se true allora diventa dialogo "Modeless"
|
||||
static int s_nDlgItem = -1 ; // indice dell'Item di selezione
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// OnClosingDialog
|
||||
//
|
||||
// Scopo:
|
||||
// Gestisce la chiusura del dialogo modeless in modo centralizzato e sicuro.
|
||||
// Questa funzione viene chiamata quando l’utente chiude il dialogo tramite:
|
||||
// - OK
|
||||
// - Cancel
|
||||
// - pulsante X
|
||||
// - WM_CLOSE
|
||||
//
|
||||
// Comportamento:
|
||||
// - Riabilita la finestra principale (Main Window), che era stata disabilitata durante il funzionamento
|
||||
// modale del dialogo.
|
||||
// - Distrugge la finestra del dialogo.
|
||||
// - Riporta il focus alla finestra principale, garantendo continuità nell’interazione dell’utente.
|
||||
// - Deseleziona tutti gli oggetti nella scena e aggiorna la vista, in modo che nessuna selezione residua
|
||||
// rimanga attiva dopo la chiusura.
|
||||
//-------------------------------------------------------------------------------
|
||||
static void
|
||||
OnClosingDialog( HWND hwndDlg)
|
||||
//-----------------------------------------------------------------------------
|
||||
static string
|
||||
ValidateSelection( const string& sSel, bool bSelect)
|
||||
{
|
||||
// reset stato globale
|
||||
s_bSelectionMode = false ;
|
||||
s_nDlgItem = -1 ;
|
||||
// il controllo passa al Main
|
||||
HWND hMain = GetParent( hwndDlg) ;
|
||||
EnableWindow( hMain, TRUE) ;
|
||||
DestroyWindow( hwndDlg) ;
|
||||
s_hDlg = NULL ;
|
||||
SetFocus( hMain) ;
|
||||
// deseleziono tutto
|
||||
ExeDeselectAll() ;
|
||||
ExeDraw() ;
|
||||
string sVal = "" ;
|
||||
INTVECTOR vIds ;
|
||||
FromString( sSel, vIds) ;
|
||||
for ( int nId : vIds) {
|
||||
if ( ExeExistsObj( nId)) {
|
||||
sVal += ToString( nId) + "," ;
|
||||
if ( bSelect)
|
||||
ExeSelectObj( nId) ;
|
||||
}
|
||||
}
|
||||
if ( ! sVal.empty())
|
||||
sVal.pop_back() ;
|
||||
return sVal ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
@@ -115,18 +99,11 @@ StartSelectionMode( HWND hDlg, int nEditId)
|
||||
// seleziono solo gli elementi presenti nell'edit corrispondente
|
||||
s_nDlgItem = - 1 ;
|
||||
ExeDeselectAll() ; // !<-- NB. avendo messo s_nDlgItem = -1 il testo non viene rimosso
|
||||
s_bSelectionMode = true ;
|
||||
s_nDlgItem = nEditId ;
|
||||
AtoWEX<128> wsEdit( "") ;
|
||||
GetDlgItemText( hDlg, nEditId, LPWSTR( wsEdit), 128) ;
|
||||
string sIds = wstrztoA( wsEdit) ;
|
||||
STRVECTOR vsIds ;
|
||||
Tokenize( sIds, ",", vsIds) ;
|
||||
for ( const string& sId : vsIds) {
|
||||
int nId = GDB_ID_NULL ;
|
||||
if ( FromString( sId, nId) && nId != GDB_ID_NULL)
|
||||
ExeSelectObj( nId) ;
|
||||
}
|
||||
ValidateSelection( wstrztoA( wsEdit), true) ;
|
||||
s_bSelectionMode = true ;
|
||||
s_nDlgItem = nEditId ;
|
||||
ExeDraw() ;
|
||||
}
|
||||
|
||||
@@ -160,22 +137,6 @@ EndSelectionMode( HWND hDlg)
|
||||
ExeDraw() ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
static string
|
||||
ValidateSelection( const string& sSel)
|
||||
{
|
||||
string sVal = "" ;
|
||||
INTVECTOR vIds ;
|
||||
FromString( sSel, vIds) ;
|
||||
for ( int nId : vIds) {
|
||||
if ( ExeExistsObj( nId))
|
||||
sVal += ToString( nId) + "," ;
|
||||
}
|
||||
if ( ! sVal.empty())
|
||||
sVal.pop_back() ;
|
||||
return sVal ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
static LRESULT
|
||||
CALLBACK UpdateDialogSelection( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
|
||||
@@ -218,7 +179,43 @@ CALLBACK UpdateDialogSelection( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
// OnClosingDialog
|
||||
//
|
||||
// Scopo:
|
||||
// Gestisce la chiusura del dialogo modeless in modo centralizzato e sicuro.
|
||||
// Questa funzione viene chiamata quando l’utente chiude il dialogo tramite:
|
||||
// - OK
|
||||
// - Cancel
|
||||
// - pulsante X
|
||||
// - WM_CLOSE
|
||||
//
|
||||
// Comportamento:
|
||||
// - Riabilita la finestra principale (Main Window), che era stata disabilitata durante il funzionamento
|
||||
// modale del dialogo.
|
||||
// - Distrugge la finestra del dialogo.
|
||||
// - Riporta il focus alla finestra principale, garantendo continuità nell’interazione dell’utente.
|
||||
// - Deseleziona tutti gli oggetti nella scena e aggiorna la vista, in modo che nessuna selezione residua
|
||||
// rimanga attiva dopo la chiusura.
|
||||
//-------------------------------------------------------------------------------
|
||||
static void
|
||||
OnClosingDialog( HWND hwndDlg)
|
||||
{
|
||||
// reset stato globale
|
||||
s_bSelectionMode = false ;
|
||||
s_nDlgItem = -1 ;
|
||||
// il controllo passa al Main
|
||||
HWND hMain = GetParent( hwndDlg) ;
|
||||
EnableWindow( hMain, TRUE) ;
|
||||
DestroyWindow( hwndDlg) ;
|
||||
s_hDlg = NULL ;
|
||||
SetFocus( hMain) ;
|
||||
// deseleziono tutto
|
||||
ExeDeselectAll() ;
|
||||
ExeDraw() ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static BOOL
|
||||
CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// variabili static locali per mantenere lo stato tra chiamate per selezione colori
|
||||
@@ -404,7 +401,7 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam
|
||||
|
||||
// se Button di selezione
|
||||
else if ( s_sEdit[i].starts_with( "SB:")) {
|
||||
string sVal = ValidateSelection( s_sEdit[i].substr( 3)) ;
|
||||
string sVal = ValidateSelection( s_sEdit[i].substr( 3), false) ;
|
||||
SetDlgItemText( hwndDlg, IDC_EDIT1 + i, stringtoW( sVal)) ;
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO1 + i), SW_HIDE) ; // nascondo la Combo
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ; // nascondo la Check
|
||||
@@ -557,15 +554,13 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam
|
||||
case CTRL_COLOR :
|
||||
{
|
||||
COLORREF col = selectedColor[i] ;
|
||||
BYTE r = GetRValue( col), g = GetGValue( col), b = GetBValue( col) ;
|
||||
char buf[16] ;
|
||||
sprintf_s( buf, sizeof( buf), "%u,%u,%u", r, g, b) ;
|
||||
s_sEdit[i] = buf ;
|
||||
INTVECTOR vCol{ GetRValue( col), GetGValue( col), GetBValue( col)} ;
|
||||
s_sEdit[i] = ToString( vCol) ;
|
||||
}
|
||||
break ;
|
||||
case CTRL_BUTTON :
|
||||
if ( GetDlgItemText( hwndDlg, IDC_EDIT1 + i, LPWSTR( wsEdit), 128) > 0)
|
||||
s_sEdit[i] = ValidateSelection( wstrztoA( wsEdit)) ;
|
||||
s_sEdit[i] = ValidateSelection( wstrztoA( wsEdit), false) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
@@ -631,7 +626,7 @@ UpdateDialogIds( void)
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// LuaDialogBox (Modeless)
|
||||
// LuaDialogBox
|
||||
//
|
||||
// Scopo:
|
||||
// ------
|
||||
|
||||
+1
-1
@@ -20,5 +20,5 @@
|
||||
// Funzione implementazione DialogBox per lua
|
||||
int LuaDialogBox( lua_State* L) ;
|
||||
|
||||
// Funzione per passaggi di parametri tra Selezione DB e dialogo non modale
|
||||
// Funzione per passaggio di parametri tra Selezione DB e dialogo non modale
|
||||
bool UpdateDialogIds( void) ;
|
||||
|
||||
Reference in New Issue
Block a user