Compare commits

...

2 Commits

Author SHA1 Message Date
Riccardo Elitropi 5d5a8bd01e Merge commit 'e31fcee3386361d8265e138accf2b6bf49858643' into ModelessDialog 2026-05-08 08:44:13 +02:00
Riccardo Elitropi 292361139a EgtExecutor (ModelessDialog) :
- primo commit.
2026-05-08 08:40:01 +02:00
10 changed files with 705 additions and 18 deletions
+90
View File
@@ -0,0 +1,90 @@
//----------------------------------------------------------------------------
// EgalTech 2026-2026
//----------------------------------------------------------------------------
// File : AuxDialogBox.cpp Data : 24.04.26 Versione : 3.1d4
// Contenuto : Funzioni DialogBox.
//
//
// Modifiche : 24.04.26 RE Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "EXE.h"
#include "EXE_Macro.h"
#include "AuxDialogBox.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EgtStringConverter.h"
using namespace std ;
#pragma comment( lib, "Comctl32.lib")
HWND phDlgModeless = nullptr ;
int nDlgModelessItem = -1 ;
//-----------------------------------------------------------------------------
bool
UpdateIdsModelessDialog( HWND phDlgModeless, int nDlgModelessItem)
{
// se DialogBox Modeless non inizializzato, esco
if ( phDlgModeless == nullptr)
return false ;
// se Id del controllo da aggiornare non valido, esco
if ( nDlgModelessItem == -1)
return false ;
// recupero tutti gli elementi selezionati
string sIds ;
int nId = ExeGetFirstSelectedObj() ;
while ( nId != GDB_ID_NULL) {
sIds.append( ToString( nId) + string{","}) ;
nId = ExeGetNextSelectedObj() ;
}
if ( ! sIds.empty())
sIds.pop_back() ;
// aggiorno il contenuto nel dialogo
return ( SetDlgItemText( phDlgModeless, nDlgModelessItem, stringtoW( sIds))) ;
}
//-----------------------------------------------------------------------------
LRESULT CALLBACK UpdateSelectionModelessDialog( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
{
if ( msg == WM_GETDLGCODE)
return DLGC_WANTALLKEYS ;
if ( msg == WM_KEYDOWN && wParam == VK_RETURN) {
// dwRefData contiene l'ID dell'EDIT
int nEditId = int( dwRefData) ;
HWND hwndDlg = GetParent(hwnd);
if ( hwndDlg == nullptr)
return FALSE ;
// recupero il testo dell'EDIT corretto
string sIds ;
AtoWEX<128> wsEdit( "") ;
if ( GetDlgItemText( hwndDlg, nEditId, LPWSTR( wsEdit), 128) > 0)
sIds = wstrztoA( wsEdit) ;
// deseleziono tutto
ExeDeselectAll() ;
// seleziono gli ID contenuti
if ( ! sIds.empty()) {
STRVECTOR vsIds;
Tokenize( sIds, ",", vsIds) ;
for ( auto& s : vsIds) {
int nId = GDB_ID_NULL ;
if ( FromString( s, nId) && nId != GDB_ID_NULL)
ExeSelectObj( nId) ;
}
}
// aggiorno la grafica ed esco
ExeDraw() ;
return TRUE ;
}
return ( DefSubclassProc(hwnd, msg, wParam, lParam)) ;
}
+31
View File
@@ -0,0 +1,31 @@
//----------------------------------------------------------------------------
// EgalTech 2026-2026
//----------------------------------------------------------------------------
// File : AuxDialogBox.h Data : 24.04.2026 Versione : 3.1d4
// Contenuto : Prototipi funzioni DialogBox.
//
//
//
// Modifiche : 22.04.26 RE Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "stdafx.h"
#include "resource.h"
#include "/EgtDev/Include/ExeExecutor.h"
#include "/EgtDev/Include/EGkLuaAux.h"
#include <shlobj.h>
//----------------------------------------------------------------------------
// Identificativo della finestra ModeLess corrente ( nullptr se non esiste)
extern HWND phDlgModeless ;
extern int nDlgModelessItem ;
// Funzione per passaggi di parametri tra Selezione DB e dialogo non modale
bool UpdateIdsModelessDialog( HWND phDlgModeless, int UpdateIdsModelessDialog) ;
//Funzione per selezionare gli Id presenti all'interno dei un EditText
LRESULT CALLBACK UpdateSelectionModelessDialog( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) ;
+19
View File
@@ -15,6 +15,7 @@
#include "stdafx.h"
#include "EXE.h"
#include "EXE_Macro.h"
#include "AuxDialogBox.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EgtStringConverter.h"
@@ -76,6 +77,9 @@ ExeSelectObj( int nId)
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// verifico se presente un dialogo modeless per aggiornare i valori
if ( bOk && phDlgModeless != nullptr && nDlgModelessItem != -1)
UpdateIdsModelessDialog( phDlgModeless, nDlgModelessItem) ;
// restituisco risultato
return bOk ;
}
@@ -100,6 +104,9 @@ ExeDeselectObj( int nId)
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// verifico se presente un dialogo modeless per aggiornare i valori
if ( bOk && phDlgModeless != nullptr && nDlgModelessItem != -1)
UpdateIdsModelessDialog( phDlgModeless, nDlgModelessItem) ;
// restituisco risultato
return bOk ;
}
@@ -139,6 +146,9 @@ ExeSelectAll( bool bOnlyIfVisible)
" -- bOk=1" ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// verifico se presente un dialogo modeless per aggiornare i valori
if ( phDlgModeless != nullptr && nDlgModelessItem != -1)
UpdateIdsModelessDialog( phDlgModeless, nDlgModelessItem) ;
// restituisco risultato
return true ;
}
@@ -160,6 +170,9 @@ ExeDeselectAll( void)
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// verifico se presente un dialogo modeless per aggiornare i valori
if ( bOk && phDlgModeless != nullptr && nDlgModelessItem != -1)
UpdateIdsModelessDialog( phDlgModeless, nDlgModelessItem) ;
// restituisco risultato
return bOk ;
}
@@ -186,6 +199,9 @@ ExeSelectGroupObjs( int nGroupId)
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// verifico se presente un dialogo modeless per aggiornare i valori
if ( bOk && phDlgModeless != nullptr && nDlgModelessItem != -1)
UpdateIdsModelessDialog( phDlgModeless, nDlgModelessItem) ;
// restituisco risultato
return bOk ;
}
@@ -209,6 +225,9 @@ ExeDeselectGroupObjs( int nGroupId)
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// verifico se presente un dialogo modeless per aggiornare i valori
if ( bOk && phDlgModeless != nullptr && nDlgModelessItem != -1)
UpdateIdsModelessDialog( phDlgModeless, nDlgModelessItem) ;
// restituisco risultato
return bOk ;
}
+2 -2
View File
@@ -869,7 +869,7 @@ ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, doubl
// ---------------------------------------------------------------------------
int
ExeRegolarizeSurfaceLocally( int nParentId, int nSurfId, int nSyncStartId, int nSyncEndId, double dLinTol, int nType)
ExeRegolarizeSurfaceLocally( int nParentId, int nSurfId, int nSyncStartId, int nSyncEndId, double dLinTol)
{
bool bOk = true ;
// Verifica database geometrico
@@ -889,7 +889,7 @@ ExeRegolarizeSurfaceLocally( int nParentId, int nSurfId, int nSyncStartId, int n
Point3d ptE2 ; pSyncEnd->GetEndPoint( ptE2) ;
BIPOINT bpIsoEnd( ptS2, ptE2) ;
PtrOwner<ISurfBezier> pNewSurf( RegolarizeBordersLocally( pSurfBez, bpIsoStart, bpIsoEnd, dLinTol, nType)) ;
PtrOwner<ISurfBezier> pNewSurf( RegolarizeBordersLocally( pSurfBez, bpIsoStart, bpIsoEnd, dLinTol)) ;
if ( IsNull( pNewSurf))
return GDB_ID_NULL ;
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pNewSurf)) ;
BIN
View File
Binary file not shown.
+2
View File
@@ -228,6 +228,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="..\Include\EXeConst.h" />
<ClInclude Include="..\Include\EXeDllMain.h" />
<ClInclude Include="..\Include\EXeExecutor.h" />
<ClInclude Include="AuxDialogBox.h" />
<ClInclude Include="DllExch3dm.h" />
<ClInclude Include="DllMain.h" />
<ClInclude Include="DllNesting.h" />
@@ -249,6 +250,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="stdafx.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="AuxDialogBox.cpp" />
<ClCompile Include="DllExch3dm.cpp" />
<ClCompile Include="DllNesting.cpp" />
<ClCompile Include="EXE_Base64.cpp" />
+6
View File
@@ -111,6 +111,9 @@
<ClInclude Include="DllExch3dm.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="AuxDialogBox.h">
<Filter>File di intestazione</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="LUA_Exchange.cpp">
@@ -431,6 +434,9 @@
<ClCompile Include="LUA_Base64.cpp">
<Filter>File di origine\LUA</Filter>
</ClCompile>
<ClCompile Include="AuxDialogBox.cpp">
<Filter>File di origine\Global</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="EgtExecutor.rc">
+494 -9
View File
@@ -18,6 +18,7 @@
#include "LUA.h"
#include "GenTools.h"
#include "resource.h"
#include "AuxDialogBox.h"
#include "/EgtDev/Include/ExeExecutor.h"
#include "/EgtDev/Include/EGkLuaAux.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
@@ -1212,22 +1213,39 @@ LuaReleaseMutex( lua_State* L)
}
//-------------------------------------------------------------------------------
const int MAX_CTRLS = IDC_TEXT8 -IDC_TEXT1 + 1 ;
// =================================== DIALOG ===================================
// Variabili Globali
const int OFFS_CTRLS = 40 ;
enum TYPE_CTRLS { CTRL_NONE = 0, CTRL_CHECK = 1, CTRL_COMBO = 2, CTRL_EDIT = 3, CTRL_COLOR = 4} ;
static int s_nCtrls = 0 ;
static string s_sCaption ;
static string s_sText[MAX_CTRLS] ;
static string s_sEdit[MAX_CTRLS] ;
static int s_nType[MAX_CTRLS] ;
enum TYPE_CTRLS { CTRL_NONE = 0, CTRL_CHECK = 1, CTRL_COMBO = 2, CTRL_EDIT = 3, CTRL_COLOR = 4, CTRL_BUTTON = 5} ;
static COLORREF s_CustomColors[16] = {12632256} ; // 16 colori GRAY
static bool s_bCustomColorsInit = false ; // flag di inizializzazione colori
const char* SEC_SCENE = "Scene" ;
const char* KEY_CUSTOMCOLORS = "CustomColors" ;
// Dialogo Modale
const int MAX_CTRLS = IDC_TEXT8 - IDC_TEXT1 + 1 ;
static int s_nCtrls = 0 ;
static string s_sCaption ;
static string s_sText[MAX_CTRLS] ;
static string s_sEdit[MAX_CTRLS] ;
static int s_nType[MAX_CTRLS] ;
// Dialogo non modale
const int MAX_CTRLS_ML = IDC_TEXT_ML_8 - IDC_TEXT_ML_1 + 1 ;
static int s_nCtrls_ML = 0 ;
static string s_sCaption_ML ;
static string s_sText_ML[MAX_CTRLS_ML] ;
static string s_sEdit_ML[MAX_CTRLS_ML] ;
static int s_nType_ML[MAX_CTRLS_ML] ;
struct DialogContext {
lua_State* L ; // stato Lua per Click bottone OK
int nCallBackFun ; // indice di funzione CallBack
} ;
static string s_sIdSel_ML ;
//-------------------------------------------------------------------------------
BOOL
CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
// variabili static locali per mantenere lo stato tra chiamate per selezione colori
static COLORREF selectedColor[MAX_CTRLS] = {0} ; // BLACK
@@ -1507,6 +1525,408 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam
return FALSE ;
}
//-------------------------------------------------------------------------------
BOOL
CALLBACK DialogBoxModelessProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
// variabili static locali per mantenere lo stato tra chiamate per selezione colori
static COLORREF selectedColor[MAX_CTRLS_ML] = {0} ; // BLACK
static HBRUSH hColorBrush[MAX_CTRLS_ML] = {NULL} ; // non definito
switch ( message) {
case WM_INITDIALOG :
{
// imposto il contesto per recuperalo in futuro ( per la funzione di CallBack Lua)
SetWindowLongPtr( hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam) ;
// colore di default
COLORREF defaultColor = RGB( 255, 0, 0) ;
// inizializzazione colori e brush
for ( int i = 0 ; i < MAX_CTRLS_ML ; ++ i) {
selectedColor[i] = defaultColor ;
if ( hColorBrush[i] != NULL)
DeleteObject( hColorBrush[i]) ;
hColorBrush[i] = CreateSolidBrush( selectedColor[i]) ;
}
// dati del dialogo
HWND hwndOwner = GetParent( hwndDlg) ;
if ( hwndOwner == nullptr)
hwndOwner = GetDesktopWindow() ;
RECT rcOwner, rcDlg ;
GetWindowRect( hwndOwner, &rcOwner) ;
GetWindowRect( hwndDlg, &rcDlg) ;
// determino la posizione dell'ultima riga di dati da visualizzare
HWND hwndLR = GetDlgItem( hwndDlg, IDC_TEXT_ML_1 + Clamp( s_nCtrls_ML, 1, MAX_CTRLS_ML) - 1) ;
RECT rcLR ;
GetWindowRect( hwndLR, &rcLR) ;
POINT ptLR{ rcLR.left, rcLR.top} ;
ScreenToClient( hwndDlg, &ptLR) ;
// centro e scalo il dialogo
int nNewH = rcLR.top - rcOwner.top + 2 * OFFS_CTRLS ; // non chiaro perchè va sottratto rcOwner.top ma funziona sempre
SetWindowPos( hwndDlg, HWND_TOP,
( rcOwner.left + rcOwner.right - ( rcDlg.right - rcDlg.left)) / 2,
( rcOwner.top + rcOwner.bottom - nNewH) / 2,
( rcDlg.right - rcDlg.left),
nNewH, 0) ;
// riposiziono il bottone Ok
HWND hwndOk = GetDlgItem( hwndDlg, IDOK_ML) ;
RECT rcOk ;
GetWindowRect( hwndOk, &rcOk) ;
POINT ptOk{ rcOk.left, rcOk.top} ;
ScreenToClient( hwndDlg, &ptOk) ;
SetWindowPos( hwndOk, hwndDlg, ptOk.x, ptLR.y + OFFS_CTRLS, 0, 0, SWP_NOSIZE | SWP_NOZORDER) ;
// riposiziono il bottone Cancel
HWND hwndCl = GetDlgItem( hwndDlg, IDCANCEL_ML) ;
RECT rcCl ;
GetWindowRect( hwndCl, &rcCl) ;
POINT ptCl{ rcCl.left, rcCl.top} ;
ScreenToClient( hwndDlg, &ptCl) ;
SetWindowPos( hwndCl, hwndDlg, ptCl.x, ptLR.y + OFFS_CTRLS, 0, 0, SWP_NOSIZE | SWP_NOZORDER) ;
// stile finestra
LONG style = GetWindowLong( hwndDlg, GWL_STYLE) ;
style |= WS_SYSMENU ;
SetWindowLong( hwndDlg, GWL_STYLE, style) ;
}
// assegno titolo del dialogo
SetWindowText( hwndDlg, stringtoW( s_sCaption_ML)) ;
// assegno testi e valori di default e nascondo linee dei controlli non usati
for ( int i = 0 ; i < MAX_CTRLS_ML ; ++ i) {
if ( i < s_nCtrls_ML) {
// imposto il testo nella riga corrente
SetDlgItemText( hwndDlg, IDC_TEXT_ML_1 + i, stringtoW( s_sText_ML[i])) ;
// --- se CheckBox
if ( s_sEdit_ML[i].find( "CK:") == 0) {
bool bChecked = false ;
FromString( s_sEdit_ML[i].substr( 3), bChecked) ;
CheckDlgButton( hwndDlg, IDC_CHECK_ML_1 + i, ( bChecked ? BST_CHECKED : BST_UNCHECKED)) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT_ML_1 + i), SW_HIDE) ; // nascondo Edit
ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO_ML_1 + i), SW_HIDE) ; // nascondo Combo
ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_ML_1 + i), SW_HIDE) ; // nascondo Button di selezione
s_nType_ML[i] = CTRL_CHECK ;
}
// --- se ComboBox
else if ( s_sEdit_ML[i].find( "CB:") == 0) {
string sList = s_sEdit_ML[i].substr( 3) ;
STRVECTOR vsVal ;
Tokenize( sList, ",", vsVal) ;
int nSel = 0 ;
HWND hwndCBox = GetDlgItem( hwndDlg, IDC_COMBO_ML_1 + i) ;
for ( int j = 0 ; j < ssize( vsVal) ; ++ j) {
string sItem ;
if ( vsVal[j][0] == '*') {
nSel = j ;
sItem = vsVal[j].substr( 1) ;
}
else
sItem = vsVal[j] ;
ComboBox_AddString( hwndCBox, stringtoW( sItem)) ;
}
ComboBox_SetCurSel( hwndCBox, nSel) ;
int nEditHeight = int( SendMessage( hwndCBox, CB_GETITEMHEIGHT, (WPARAM)-1, 0)) ;
int nItemHeight = int( SendMessage( hwndCBox, CB_GETITEMHEIGHT, 0, 0)) ;
int nTotalHeight = nEditHeight + nItemHeight * ( ssize( vsVal) + 1) ;
RECT rc ; GetWindowRect( hwndCBox, &rc) ;
HWND parent = GetParent(hwndCBox) ; MapWindowPoints( NULL, parent, (LPPOINT)&rc, 2) ;
SetWindowPos( hwndCBox, NULL, rc.left, rc.top, rc.right - rc.left, nTotalHeight, SWP_NOZORDER) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT_ML_1 + i), SW_HIDE) ; // nascondo Edit
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK_ML_1 + i), SW_HIDE) ; // nascondo CheckBox
ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_ML_1 + i), SW_HIDE) ; // nascondo Button di selezione
s_nType_ML[i] = CTRL_COMBO ;
}
// --- se ColorPicker
else if ( s_sEdit_ML[i].find( "CP:") == 0) {
string sVal = s_sEdit_ML[i].substr( 3) ;
Color CColor ;
if ( ! FromString( sVal, CColor))
CColor = INVISIBLE ;
selectedColor[i] = RGB( CColor.GetIntRed(), CColor.GetIntGreen(), CColor.GetIntBlue()) ;
if ( hColorBrush[i] != NULL)
DeleteObject( hColorBrush[i]) ;
hColorBrush[i] = CreateSolidBrush( selectedColor[i]) ;
// recupero i valori dei colori personalizzati dal file .ini
if ( ! s_bCustomColorsInit) {
// recupero il file Ini
string sIniFile = ExeGetIniFile() ;
if ( ! sIniFile.empty()) {
string sCustomVals = GetPrivateProfileStringUtf8( SEC_SCENE, KEY_CUSTOMCOLORS, "", sIniFile.c_str()) ;
STRVECTOR vsWinColors ; Tokenize( sCustomVals, ",", vsWinColors) ;
for ( int j = 0 ; j < ssize( vsWinColors) && j < 16 ; ++ j) {
unsigned int unVal ;
if ( FromString( vsWinColors[j], unVal)) {
unsigned int unR = unVal & 0xFF ;
unsigned int unG = ( unVal >> 8) & 0xFF ;
unsigned int unB = ( unVal >> 16) & 0xFF ;
s_CustomColors[j] = RGB( unR, unG, unB) ;
}
}
}
s_bCustomColorsInit = true ;
}
// nascondo qualsiasi tipo di componente
ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT_ML_1 + i), SW_HIDE) ; // nascondo Edit
ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO_ML_1 + i), SW_HIDE) ; // nascondo Combo
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK_ML_1 + i), SW_HIDE) ; // nascondo Check
ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_ML_1 + i), SW_HIDE) ; // nascondo Button di selezione
// margini per dimensione del rettangolo preview pickColor
const int MARGIN_RIGHT = 8 ; // spazio tra preview e bordo destro dialog
const int PREVIEW_HEIGHT = 20 ; // altezza del rettangolo
const int PREVIEW_MIN_WIDTH = 40 ; // larghezza minima
// creazione della static preview
HWND hwndPreview = NULL ;
HWND hwndEdit = GetDlgItem( hwndDlg, IDC_EDIT_ML_1 + i) ;
RECT rcEdit ; GetClientRect( hwndDlg, &rcEdit) ; // coordinate client del dialog
if ( hwndEdit != nullptr && GetWindowRect( hwndEdit, &rcEdit)) {
// converti rcLabel in coordinate client
POINT ptEdit = { rcEdit.left, rcEdit.top } ;
ScreenToClient( hwndDlg, &ptEdit) ;
int x = ptEdit.x ;
int y = ptEdit.y ;
int width = rcEdit.right - rcEdit.left ;
if ( width < PREVIEW_MIN_WIDTH)
width = PREVIEW_MIN_WIDTH ;
hwndPreview = CreateWindowEx( 0, L"STATIC", NULL,
WS_CHILD | WS_VISIBLE | SS_NOTIFY | SS_CENTERIMAGE | WS_BORDER,
x, y, width, PREVIEW_HEIGHT,
hwndDlg, ( HMENU)( IDC_COLOR1 + i),
GetModuleHandle( NULL), NULL) ;
}
// pulizia elementi testuali
if ( hwndPreview) {
SetWindowText( hwndPreview, L"") ;
SetWindowPos( hwndPreview, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE) ;
InvalidateRect( hwndPreview, NULL, TRUE) ;
UpdateWindow( hwndPreview) ;
}
s_nType_ML[i] = CTRL_COLOR ;
}
// --- se Button di selezione
else if ( s_sEdit_ML[i].find( "BT:") == 0) {
ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO_ML_1 + i), SW_HIDE) ; // nascondo la Combo
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK_ML_1 + i), SW_HIDE) ; // nascondo la Check
SetDlgItemText( hwndDlg, IDC_BUTTON_ML_1 + i, stringtoW( string{ "N"})) ; // modalità non Selezione
// associo alla casella di testo la funzione di KeyPress su Enter
HWND hEdit = GetDlgItem( hwndDlg, IDC_EDIT_ML_1 + i) ;
if ( hEdit != nullptr)
SetWindowSubclass( hEdit, UpdateSelectionModelessDialog, 1, (DWORD_PTR)( IDC_EDIT_ML_1 + i)) ;
s_nType_ML[i] = CTRL_BUTTON ;
}
// --- se Testo
else {
SetDlgItemText( hwndDlg, IDC_EDIT_ML_1 + i, stringtoW( s_sEdit_ML[i])) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO_ML_1 + i), SW_HIDE) ; // nascondo Combo
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK_ML_1 + i), SW_HIDE) ; // nascondo Check
ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_ML_1 + i), SW_HIDE) ; // nascondo Button di selezione
s_nType_ML[i] = CTRL_EDIT ;
}
}
// se numero di controllo superiore al massimo, non visualizzo nullo ( in questo caso aggiungere elementi a Dialog in .rc)
else {
// nascondo tutto
ShowWindow( GetDlgItem( hwndDlg, IDC_TEXT_ML_1 + i), SW_HIDE) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT_ML_1 + i), SW_HIDE) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO_ML_1 + i), SW_HIDE) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK_ML_1 + i), SW_HIDE) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_BUTTON_ML_1 + i), SW_HIDE) ;
s_nType[i] = CTRL_NONE ;
}
}
break ;
case WM_CTLCOLORSTATIC :
{
HDC hdcStatic = ( HDC)wParam ;
HWND hwndCtrl = ( HWND)lParam ;
int ctrlId = GetDlgCtrlID( hwndCtrl) ;
if ( ctrlId >= IDC_COLOR1 && ctrlId <= IDC_COLOR8) {
int idx = ctrlId - IDC_COLOR1 ;
if ( hColorBrush[idx] == NULL)
hColorBrush[idx] = CreateSolidBrush( selectedColor[idx]) ;
SetBkMode( hdcStatic, OPAQUE) ;
SetBkColor( hdcStatic, selectedColor[idx]) ;
return ( INT_PTR)hColorBrush[idx] ;
}
}
break ;
case WM_COMMAND : {
int id = LOWORD( wParam) ;
int code = HIWORD( wParam) ;
// --- se click di un Button di selezione
if ( id >= IDC_BUTTON_ML_1 && id < IDC_BUTTON_ML_1 + MAX_CTRLS_ML) {
int nBtnId = id ;
int nEditId = IDC_EDIT_ML_1 + ( id - IDC_BUTTON_ML_1) ;
// se il bottone premuto è lo stesso, allora termina le selezione degli Ids
if ( nDlgModelessItem == nEditId) {
SetDlgItemText( hwndDlg, nBtnId, stringtoW( string{ "N"})) ;
nDlgModelessItem = -1 ;
}
// se nuovo buttone premuto
else {
// se esisteva una selezione precedente, questa viene annullata
if ( nDlgModelessItem != -1) {
// recupero il Button di selezione precedente e modifico il suo testo
int nPrevBtnId = IDC_BUTTON_ML_1 + ( nDlgModelessItem - IDC_EDIT_ML_1) ;
SetDlgItemText( hwndDlg, nPrevBtnId, stringtoW( string{ "N"})) ;
}
// la selezione passa al comando corrente
nDlgModelessItem = nEditId ;
SetDlgItemText( hwndDlg, nBtnId, stringtoW( string{ "S"})) ;
}
// per semplicità, deseleziono tutto
ExeDeselectAll() ;
ExeDraw() ;
}
// --- se comando di Preview per brush di colori mediante click del mouse
else if ( code == STN_CLICKED && id >= IDC_COLOR1 && id <= IDC_COLOR8) {
int idx = id - IDC_COLOR1 ;
HWND hwndPreview = GetDlgItem( hwndDlg, IDC_COLOR1 + idx) ;
if ( ! hwndPreview)
return TRUE ;
// apertura ChooseColor (usa hwndDlg come owner)
CHOOSECOLOR cc = {} ;
cc.lStructSize = sizeof( cc) ;
cc.hwndOwner = hwndDlg ;
cc.lpCustColors = s_CustomColors ;
cc.rgbResult = selectedColor[idx] ;
cc.Flags = CC_FULLOPEN | CC_RGBINIT ;
if ( ChooseColor( &cc)) {
selectedColor[idx] = cc.rgbResult ;
// salvo nel file Ini i nuovi colori personalizzati
string sIniFile = ExeGetIniFile() ;
if ( ! sIniFile.empty()) {
string sOut = "" ;
for ( int j = 0 ; j < ssize( s_CustomColors) && j < 16 ; ++ j)
sOut += ToString( ( unsigned int)s_CustomColors[j]) + "," ;
sOut.pop_back() ;
WritePrivateProfileStringUtf8( SEC_SCENE, KEY_CUSTOMCOLORS, sOut.c_str(), sIniFile.c_str()) ;
}
if ( hColorBrush[idx] != NULL)
DeleteObject( hColorBrush[idx]) ;
hColorBrush[idx] = CreateSolidBrush( selectedColor[idx]) ;
InvalidateRect(hwndPreview, NULL, TRUE) ;
UpdateWindow( hwndPreview) ;
}
return TRUE ;
}
switch ( LOWORD( wParam)) {
case IDOK_ML : {
// recupero il contesto impostato alla creazione della finestra ( durante esecuzione WM_INITDIALOG)
DialogContext* ctx = (DialogContext*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA) ;
if ( ctx != nullptr && ctx->nCallBackFun != LUA_NOREF) {
// recupero la CallBack
lua_rawgeti( ctx->L, LUA_REGISTRYINDEX, ctx->nCallBackFun) ;
// definisco una tabella per tutti i valori Lua da restituire
lua_newtable( ctx->L) ;
// recupero i valori degli Item
for ( int i = 0 ; i < s_nCtrls_ML ; ++ i) {
AtoWEX<128> wsEdit( "") ;
s_sEdit_ML[i] = "" ;
switch ( s_nType_ML[i]) {
case CTRL_CHECK :
s_sEdit_ML[i] = ( IsDlgButtonChecked( hwndDlg, IDC_CHECK_ML_1 + i) == BST_CHECKED ? "1" : "0") ;
break ;
case CTRL_COMBO :
if ( GetDlgItemText( hwndDlg, IDC_COMBO_ML_1 + i, LPWSTR( wsEdit), 128) > 0)
s_sEdit_ML[i] = wstrztoA( wsEdit) ;
break ;
case CTRL_EDIT :
if ( GetDlgItemText( hwndDlg, IDC_EDIT_ML_1 + i, LPWSTR( wsEdit), 128) > 0)
s_sEdit_ML[i] = wstrztoA( wsEdit) ;
break ;
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_ML[i] = buf ;
}
break ;
case CTRL_BUTTON :
if ( GetDlgItemText( hwndDlg, IDC_EDIT_ML_1 + i, LPWSTR( wsEdit), 128) > 0)
s_sEdit_ML[i] = wstrztoA( wsEdit) ;
break ;
}
}
// Ogni valore letto viene inserito all'interno della Table creata in precedenza e passata alla CallBack di lua
int nIndex = 1 ;
for ( const string& sVal : s_sEdit_ML) {
lua_pushstring( ctx->L, sVal.c_str()) ;
lua_rawseti( ctx->L, -2, nIndex ++) ;
}
// chiamo la CallBack
lua_pcall( ctx->L, 1, 0, 0) ;
// libero la memoria
luaL_unref( ctx->L, LUA_REGISTRYINDEX, ctx->nCallBackFun) ;
delete ctx ;
ctx = nullptr ;
}
// rimuovo finestra e annullo il contesto
DestroyWindow( hwndDlg) ;
phDlgModeless = nullptr ;
nDlgModelessItem = -1 ;
return TRUE ;
}
[[fallthrough]] ;
case IDCANCEL_ML : {
// pulizia brush colori
for ( int i = 0 ; i < MAX_CTRLS_ML ; ++ i) {
if ( hColorBrush[i] != NULL) {
DeleteObject( hColorBrush[i]) ;
hColorBrush[i] = NULL ;
}
}
// recupero il contesto impostato alla creazione della finestra ( durante esecuzione WM_INITDIALOG) e se esiste lo rimuovo
DialogContext* ctx = (DialogContext*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA) ;
if ( ctx != nullptr && ctx->nCallBackFun != LUA_NOREF) {
luaL_unref( ctx->L, LUA_REGISTRYINDEX, ctx->nCallBackFun) ;
delete ctx ;
ctx = nullptr ;
}
// rimuovo finestra e annullo il contesto
DestroyWindow( hwndDlg) ;
phDlgModeless = nullptr ;
nDlgModelessItem = -1 ;
return TRUE ;
}
}
}
break ;
case WM_CLOSE : {
// recupero il contesto impostato alla creazione della finestra ( durante esecuzione WM_INITDIALOG) e se esiste lo rimuovo
DialogContext* ctx = (DialogContext*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA) ;
if ( ctx != nullptr && ctx->nCallBackFun != LUA_NOREF) {
luaL_unref( ctx->L, LUA_REGISTRYINDEX, ctx->nCallBackFun) ;
delete ctx ;
ctx = nullptr ;
}
// rimuovo finestra e annullo il contesto
DestroyWindow( hwndDlg) ;
phDlgModeless = nullptr ;
nDlgModelessItem = -1 ;
return TRUE ;
}
}
return FALSE ;
}
//-------------------------------------------------------------------------------
static int
LuaDialogBox( lua_State* L)
@@ -1546,6 +1966,71 @@ LuaDialogBox( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaDialogBoxModeless( lua_State* L)
{
// 1 .. 9 parametri : sCaption, { sText, sDefault}, ...
LuaCheckParam( L, 1, s_sCaption_ML)
s_nCtrls_ML = 0 ;
for ( int i = 0 ; i < MAX_CTRLS_ML ; ++ i) {
STRVECTOR vData ;
if ( LuaGetParam( L, 2 + i, vData) && ssize( vData) >= 2) {
s_sText_ML[i] = Trim( vData[0]) ;
s_sEdit_ML[i] = Trim( vData[1]) ;
++ s_nCtrls_ML ;
}
else
break ;
}
// se abilitata UI, lancio dialogo
if ( ExeGetEnableUI()) {
// se dialogo già presente, errore ( per ora una sola finestra non modale per volta)
if ( phDlgModeless != nullptr) {
LuaSetParam( L, false) ;
return 1 ;
}
// definisco il contesto per il dialogo
DialogContext* ctx = new DialogContext() ;
if ( ctx != nullptr) {
// recupero la funzione di CallBack per restituire i valori presenti nella DialogBoxModeless
// questa funzione deve essere l'ultimo parametro
int nCallBackRef = LUA_NOREF ;
int nLastPar = lua_gettop( L) ;
if ( lua_isfunction( L, nLastPar)) {
lua_pushvalue( L, nLastPar) ; // copio la funzione
ctx->nCallBackFun = luaL_ref( L, LUA_REGISTRYINDEX) ; // salvo nel registro
ctx->L = L ; // salvo lo State Lua
// lancio dialogo
HWND hTopWnd = ExeGetMainWindowHandle() ;
nDlgModelessItem = -1 ;
phDlgModeless = ( CreateDialogParam( GetModuleIstance(), MAKEINTRESOURCE( IDD_LUADLG_ML), hTopWnd,
(DLGPROC)DialogBoxModelessProc, (LPARAM)ctx)) ;
if ( phDlgModeless != nullptr) {
// se dialogo creato, porto la finestra in primo piano
ShowWindow( phDlgModeless, SW_SHOW) ;
SetForegroundWindow( phDlgModeless) ;
}
else {
delete ctx ;
LuaSetParam( L) ;
}
}
else {
delete ctx ;
LuaSetParam( L) ;
}
}
else
LuaSetParam( L) ;
}
else
LuaSetParam( L) ;
LuaClearStack( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
bool
LuaInstallGeneral( LuaMgr& luaMgr)
@@ -1607,6 +2092,6 @@ LuaInstallGeneral( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtCreateMutex", LuaCreateMutex) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtReleaseMutex", LuaReleaseMutex) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtDialogBox", LuaDialogBox) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtDialogBoxModeless", LuaDialogBoxModeless) ;
return bOk ;
}
+1 -3
View File
@@ -297,10 +297,8 @@ LuaRegolarizeSurfaceLocally( lua_State* L)
LuaCheckParam( L, 4, nSyncEndId)
double dLinTol ;
LuaCheckParam( L, 5, dLinTol)
int nType = 0 ;
LuaCheckParam( L, 6, nType)
int nId = ExeRegolarizeSurfaceLocally( nParentId, nSurfId, nSyncStartId, nSyncEndId, dLinTol, nType) ;
int nId = ExeRegolarizeSurfaceLocally( nParentId, nSurfId, nSyncStartId, nSyncEndId, dLinTol) ;
LuaSetParam( L, nId) ;
return 1 ;
}
+60 -4
View File
@@ -1,10 +1,13 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by EgtExecutor.rc
// File di inclusione generato con Microsoft Visual C++.
// Utilizzato da EgtExecutor.rc
//
#define VS_VERSION_INFO 1
#define IDD_LUADLG 101
#define IDD_LUASCENE 102
#define IDD_LUADLG_ML 103
#define IDC_TEXT1 1001
#define IDC_TEXT2 1002
#define IDC_TEXT3 1003
@@ -13,6 +16,7 @@
#define IDC_TEXT6 1006
#define IDC_TEXT7 1007
#define IDC_TEXT8 1008
#define IDC_EDIT1 1011
#define IDC_EDIT2 1012
#define IDC_EDIT3 1013
@@ -21,6 +25,7 @@
#define IDC_EDIT6 1016
#define IDC_EDIT7 1017
#define IDC_EDIT8 1018
#define IDC_COMBO1 1021
#define IDC_COMBO2 1022
#define IDC_COMBO3 1023
@@ -29,6 +34,7 @@
#define IDC_COMBO6 1026
#define IDC_COMBO7 1027
#define IDC_COMBO8 1028
#define IDC_CHECK1 1031
#define IDC_CHECK2 1032
#define IDC_CHECK3 1033
@@ -37,6 +43,7 @@
#define IDC_CHECK6 1036
#define IDC_CHECK7 1037
#define IDC_CHECK8 1038
#define IDC_COLOR1 1041
#define IDC_COLOR2 1042
#define IDC_COLOR3 1043
@@ -45,15 +52,64 @@
#define IDC_COLOR6 1046
#define IDC_COLOR7 1047
#define IDC_COLOR8 1048
#define IDC_PICTURE1 1101
#define IDC_TEXT_ML_1 2001
#define IDC_TEXT_ML_2 2002
#define IDC_TEXT_ML_3 2003
#define IDC_TEXT_ML_4 2004
#define IDC_TEXT_ML_5 2005
#define IDC_TEXT_ML_6 2006
#define IDC_TEXT_ML_7 2007
#define IDC_TEXT_ML_8 2008
#define IDC_EDIT_ML_1 2011
#define IDC_EDIT_ML_2 2012
#define IDC_EDIT_ML_3 2013
#define IDC_EDIT_ML_4 2014
#define IDC_EDIT_ML_5 2015
#define IDC_EDIT_ML_6 2016
#define IDC_EDIT_ML_7 2017
#define IDC_EDIT_ML_8 2018
#define IDC_COMBO_ML_1 2021
#define IDC_COMBO_ML_2 2022
#define IDC_COMBO_ML_3 2023
#define IDC_COMBO_ML_4 2024
#define IDC_COMBO_ML_5 2025
#define IDC_COMBO_ML_6 2026
#define IDC_COMBO_ML_7 2027
#define IDC_COMBO_ML_8 2028
#define IDC_CHECK_ML_1 2031
#define IDC_CHECK_ML_2 2032
#define IDC_CHECK_ML_3 2033
#define IDC_CHECK_ML_4 2034
#define IDC_CHECK_ML_5 2035
#define IDC_CHECK_ML_6 2036
#define IDC_CHECK_ML_7 2037
#define IDC_CHECK_ML_8 2038
#define IDC_BUTTON_ML_1 2041
#define IDC_BUTTON_ML_2 2042
#define IDC_BUTTON_ML_3 2043
#define IDC_BUTTON_ML_4 2044
#define IDC_BUTTON_ML_5 2045
#define IDC_BUTTON_ML_6 2046
#define IDC_BUTTON_ML_7 2047
#define IDC_BUTTON_ML_8 2048
#define IDOK_ML 2051
#define IDCANCEL_ML 2052
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_RESOURCE_VALUE 105
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1030
#define _APS_NEXT_CONTROL_VALUE 1072
#define _APS_NEXT_SYMED_VALUE 115
#endif
#endif