26 Apr 2018
This commit is contained in:
parent
21a4165b4a
commit
f918245b2d
|
@ -30,5 +30,4 @@ mainui\legacy
|
|||
utils\
|
||||
utils\vgui\
|
||||
utils\vgui\include\
|
||||
utils\vgui\lib\
|
||||
utils\vgui\lib\win32_vc6\
|
91
change.log
91
change.log
|
@ -1,3 +1,94 @@
|
|||
LEGEND:
|
||||
|
||||
Client: - client.dll or client part of xash.dll
|
||||
Server: - hl.dll or server part of xash.dll
|
||||
Engine: - xash.dll
|
||||
Network: - a network part of xash.dll
|
||||
Render: - a render part of xash.dll
|
||||
FS: - a filesystem part of xash.dll
|
||||
GameUI - menu.dll
|
||||
Sound: - a sound part of xash.dll
|
||||
Input: - a input code of xash.dll
|
||||
ImageLib: - image loader in xash.dll
|
||||
SoundLib: - sound loader in xash.dll
|
||||
Console: - console code in xash.dll
|
||||
VGUI: - a VGUI implementation code in xash.dll
|
||||
Memory: - a memory manager in xash.dll
|
||||
Physic: - a server physics code in xash.dll
|
||||
|
||||
build 4097
|
||||
|
||||
Client: implement predictable laser spot for weapon RPG
|
||||
Server: fix bug with chat code that doesn't passed russian letters
|
||||
Engine: BSP31 now is obsolete and removed from the engine (please use bsp31migrate.exe tool for migration)
|
||||
Engine: new version of extended BSP30 map format (increase clipnode limits, tuneable lightmap resolution, per-vertex lighting etc)
|
||||
Render: mirrors are no longer support and has been removed from the engine (but leaved in the mods like XashXT or P2:Savior)
|
||||
Engine: mextrasurf_t was reorganized, please check your source code
|
||||
Engine: event API was reorganized, two functions was removed new one added
|
||||
Engine: engine feature ENGINE_FIXED_FRAMERATE are no longer supported
|
||||
Engine: RenderAPI was changed version to 37 and reorganized
|
||||
Server: "decalfrequency" is now stored into config.cfg
|
||||
Engine: some unused functions from undocumented part of game and client interface was replaced with stubs
|
||||
GameUI: import interface was updated with two new functions (save file and remove file)
|
||||
Console: rewrite debug messages system like in Quake (Con_Printf instead of MsgDev)
|
||||
Network: completely rewrite the network connection to allow downloading and uploading files (missing resources, player logos)
|
||||
Network: first implementation of player customization (logos)
|
||||
Network: protocol was changed to version 49
|
||||
Engine: demo protocol was changed to version 3
|
||||
Engine: implement timedemo command
|
||||
Network: implement a signon sequence
|
||||
Sound: fixup static sounds save\restore bug
|
||||
Network: user messages max size will be increased up to 2048 bytes
|
||||
Client: rewrite HudSprite manager allow to download missed HUD sprites
|
||||
Client: rewrite SPR_GetList to prevent memory leak (old Half-Life bug)
|
||||
Console: fix the ConsolePrint to allow to goes message only to notify buffer
|
||||
Engine: fix very old bug in CheckParm export function (internal version is not bugged)
|
||||
Client: getAppID was changed to 70
|
||||
Network: IPX protocol will no longer supported and has been removed
|
||||
Client: single export for client.dll was renamed to GetClientAPI
|
||||
VGUI: class CEngineApp was declared as static
|
||||
GameUI: fix old crash with playersetup and changelevel on a background map
|
||||
Engine: new queue system for change maps (not sticked with Cbuf_Execute)
|
||||
Engine: experimental function CL_ChangeGame was removed from the engine
|
||||
Engine: enable interpolation for addangle (fixangle = 2)
|
||||
Network: new experimenal system to get maximum pack size for UDP (official size 1200 bytes but in theory it can be larger up to 64000 bytes)
|
||||
Network: new generic resource system that included sounds, models, events, decals and all other types
|
||||
Client: add mp3 command like in GoldSrc (warn this is not tested)
|
||||
Server: implement instanced baselines (baselines that specified by user)
|
||||
Server: implement a consistency resource check (model CRC and bounds)
|
||||
Network: StudioDecal message is completely moved out from the engine
|
||||
Client: request cvar value now can detect mismatch between cvar.string and cvar.value for detect potential cheaters
|
||||
Render: allow remap colors on a alias player models (Quake1)
|
||||
Client: added built-in resource pathes to list of download resources
|
||||
Client: do revision of tempents code, fix some bugs
|
||||
Client: make work EF_MUZZLEFLASH for alias-models
|
||||
Render: tune intencity from dymanic lights (alias and studio models affected)
|
||||
Render: enable built-in MSAA feature (cvar gl_enable_msaa in opengl.cfg)
|
||||
Render: fix bug with 'sticky bind' while texture is uploaded
|
||||
Render: the most of internal procedural textures has been moved out from the engine (keep'd only textures that engine is used himself)
|
||||
Render: R_LightPoint has a contain VERY old bug from Quake1 with inaccurate samples from lightmap color and produce invalid results in some cases
|
||||
Render: new extension of BSP file format (lightmaps that based on luxel per units instead of luxel per texels). Also check P2:Savior compile tools
|
||||
Render: fix bug with sort STUDIO_NF_ADDITIVE meshes in studio models (old Half-Life bug)
|
||||
Render: fix water subdivision bug that kill the prefomance while water is rendering
|
||||
Render: r_drawentities 7 is now shows world position of luxel for lighting
|
||||
Render: removed all unused GL-extensions
|
||||
Render: fixed 16-bit color mode and NPOT textures case
|
||||
Render: throw a system error on failed initalization video sybsystem instead of fallthrough into dedicated mode
|
||||
Render: remove of rotational sky support (it's just was not used by nobody)
|
||||
Sound: some minor changes in DirectSound backend code
|
||||
VGUI: rewrite Font manager, enable vertex arrays support
|
||||
Network: fragmented packets it's can be compressed by LZSS algorhytm
|
||||
Console: mapinfo now shows information about editor and compiler
|
||||
Engine: handle exception in Q_vsnprintf to prevent crash engine from the mistake of formatted args
|
||||
Engine: new polymorphic BSP loader
|
||||
Memory: fix bug in Mem_CheckFilename
|
||||
Server: first implementation of server game log
|
||||
Server: cmd 'changelevel' was no longer provided (only internal cnhagelevel is possible)
|
||||
Server: cmd 'kill' moved from server to the client
|
||||
Server: new save\restore system that compatible sav. files from GoldSrc
|
||||
Server: implement server fps control that called a 'sv_fps' use with precaution
|
||||
Server: fix some bugs with unlag system
|
||||
|
||||
build 3886
|
||||
|
||||
Client: fixup processing russian leter 'ÿ' in READ_STRING()
|
||||
|
|
|
@ -14,9 +14,6 @@ if errorlevel 1 set BUILD_ERROR=1
|
|||
%MSDEV% mainui/mainui.dsp %CONFIG%"mainui - Win32 Debug" %build_target%
|
||||
if errorlevel 1 set BUILD_ERROR=1
|
||||
|
||||
%MSDEV% utils/vgui/lib/vgui.dsp %CONFIG%"vgui - Win32 Debug" %build_target%
|
||||
if errorlevel 1 set BUILD_ERROR=1
|
||||
|
||||
if "%BUILD_ERROR%"=="" goto build_ok
|
||||
|
||||
echo *********************
|
||||
|
@ -38,7 +35,6 @@ goto done
|
|||
rem //delete log files
|
||||
if exist engine\engine.plg del /f /q engine\engine.plg
|
||||
if exist mainui\mainui.plg del /f /q mainui\mainui.plg
|
||||
if exist utils/vgui/lib/vgui.plg del /f /q utils/vgui/lib/vgui.plg
|
||||
|
||||
echo
|
||||
echo Build succeeded!
|
||||
|
|
|
@ -237,7 +237,7 @@ void CL_InitCDAudio( const char *filename )
|
|||
|
||||
if( ++c > MAX_CDTRACKS - 1 )
|
||||
{
|
||||
MsgDev( D_WARN, "CD_Init: too many tracks %i in %s\n", filename, MAX_CDTRACKS );
|
||||
MsgDev( D_WARN, "CD_Init: too many tracks %i in %s\n", MAX_CDTRACKS, filename );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -985,6 +985,8 @@ static ui_enginefuncs_t gEngfuncs =
|
|||
GL_ProcessTexture,
|
||||
COM_CompareFileTime,
|
||||
VID_GetModeString,
|
||||
COM_SaveFile,
|
||||
FS_Delete,
|
||||
};
|
||||
|
||||
void UI_UnloadProgs( void )
|
||||
|
|
|
@ -195,7 +195,7 @@ int CL_GetFragmentSize( void *unused )
|
|||
if( Netchan_IsLocal( &cls.netchan ))
|
||||
return FRAGMENT_LOCAL_SIZE;
|
||||
|
||||
return bound( FRAGMENT_MIN_SIZE, cl_dlmax->value, FRAGMENT_MAX_SIZE );
|
||||
return FRAGMENT_MIN_SIZE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1091,7 +1091,7 @@ void CL_CheckForResend( void )
|
|||
if( cls.connect_retry == CL_TEST_RETRIES_NORESPONCE )
|
||||
{
|
||||
// too many fails use default connection method
|
||||
Msg( "hi-speed coonection is failed, use default method\n" );
|
||||
Con_Printf( "hi-speed connection is failed, use default method\n" );
|
||||
Netchan_OutOfBandPrint( NS_CLIENT, adr, "getchallenge\n" );
|
||||
Cvar_SetValue( "cl_dlmax", FRAGMENT_MIN_SIZE );
|
||||
cls.connect_time = host.realtime;
|
||||
|
@ -1801,7 +1801,7 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
|
|||
if( cls.connect_retry >= CL_TEST_RETRIES )
|
||||
{
|
||||
// too many fails use default connection method
|
||||
Msg( "hi-speed coonection is failed, use default method\n" );
|
||||
Con_Printf( "hi-speed connection is failed, use default method\n" );
|
||||
Netchan_OutOfBandPrint( NS_CLIENT, from, "getchallenge\n" );
|
||||
Cvar_SetValue( "cl_dlmax", FRAGMENT_MIN_SIZE );
|
||||
cls.connect_time = host.realtime;
|
||||
|
@ -1833,7 +1833,7 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
|
|||
if( cls.connect_retry >= CL_TEST_RETRIES )
|
||||
{
|
||||
// too many fails use default connection method
|
||||
Msg( "hi-speed coonection is failed, use default method\n" );
|
||||
Con_Printf( "hi-speed connection is failed, use default method\n" );
|
||||
Netchan_OutOfBandPrint( NS_CLIENT, from, "getchallenge\n" );
|
||||
Cvar_SetValue( "cl_dlmax", FRAGMENT_MIN_SIZE );
|
||||
cls.connect_time = host.realtime;
|
||||
|
@ -2216,7 +2216,8 @@ void CL_ProcessFile( qboolean successfully_received, const char *filename )
|
|||
}
|
||||
else
|
||||
{
|
||||
Con_Printf( "Downloaded %i bytes for purported %i byte file, ignoring download\n", p->nDownloadSize );
|
||||
Con_Printf( "Downloaded %i bytes for purported %i byte file, ignoring download\n",
|
||||
cls.netchan.tempbuffersize, p->nDownloadSize );
|
||||
}
|
||||
|
||||
if( cls.netchan.tempbuffer )
|
||||
|
|
|
@ -730,7 +730,7 @@ void CL_BatchResourceRequest( qboolean initialize )
|
|||
if( !COM_IsSafeFileToDownload( p->szFileName ))
|
||||
{
|
||||
CL_RemoveFromResourceList( p );
|
||||
MsgDev( D_WARN, "Invalid file type...skipping download of %s\n", p );
|
||||
MsgDev( D_WARN, "Invalid file type...skipping download of %s\n", p->szFileName );
|
||||
Mem_Free( p );
|
||||
break;
|
||||
}
|
||||
|
@ -1039,7 +1039,7 @@ void CL_CreateCustomizationList( void )
|
|||
pResource = &cl.resourcelist[i];
|
||||
|
||||
if( !COM_CreateCustomization( &pPlayer->customdata, pResource, cl.playernum, 0, NULL, NULL ))
|
||||
Con_Printf( "problem with client customization %i, ignoring...", pResource );
|
||||
Con_Printf( "problem with client customization %s, ignoring...", pResource->szFileName );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1220,6 +1220,7 @@ void CL_PredictMovement( qboolean repredicting )
|
|||
int i, stoppoint;
|
||||
qboolean runfuncs;
|
||||
double f = 1.0;
|
||||
cl_entity_t *ent;
|
||||
double time;
|
||||
|
||||
if( cls.state != ca_active || cls.spectator )
|
||||
|
@ -1349,8 +1350,7 @@ void CL_PredictMovement( qboolean repredicting )
|
|||
|
||||
if( FBitSet( to->client.flags, FL_ONGROUND ))
|
||||
{
|
||||
cl_entity_t *ent = CL_GetEntityByIndex( cl.local.lastground );
|
||||
|
||||
ent = CL_GetEntityByIndex( cl.local.lastground );
|
||||
cl.local.onground = cl.local.lastground;
|
||||
cl.local.moving = false;
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ void SCR_NetSpeeds( void )
|
|||
if( !host.allow_console )
|
||||
return;
|
||||
|
||||
if( !net_speeds->value || cls.demoplayback || cls.state != ca_active )
|
||||
if( !net_speeds->value || cls.state != ca_active )
|
||||
return;
|
||||
|
||||
// prevent to get too big values at max
|
||||
|
|
|
@ -311,9 +311,9 @@ void R_SetTextureParameters( void )
|
|||
if( GL_Support( GL_TEXTURE_LOD_BIAS ))
|
||||
{
|
||||
if( gl_texture_lodbias->value < -glConfig.max_texture_lod_bias )
|
||||
Cvar_SetValue( "gl_mipmap_bias", -glConfig.max_texture_lod_bias );
|
||||
Cvar_SetValue( "gl_texture_lodbias", -glConfig.max_texture_lod_bias );
|
||||
else if( gl_texture_lodbias->value > glConfig.max_texture_lod_bias )
|
||||
Cvar_SetValue( "gl_mipmap_bias", glConfig.max_texture_lod_bias );
|
||||
Cvar_SetValue( "gl_texture_lodbias", glConfig.max_texture_lod_bias );
|
||||
}
|
||||
|
||||
ClearBits( gl_texture_anisotropy->flags, FCVAR_CHANGED );
|
||||
|
|
|
@ -1119,10 +1119,7 @@ void R_EndFrame( void )
|
|||
R_Set2DMode( false );
|
||||
|
||||
if( !pwglSwapBuffers( glw_state.hDC ))
|
||||
{
|
||||
Con_Printf( S_ERROR "failed to swap buffers\n" );
|
||||
Host_NewInstance( va("#%s", GI->gamefolder ), "stopped" );
|
||||
}
|
||||
Sys_Error( "failed to swap buffers\nCheck your video driver and as possible of reinstall it" );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -361,7 +361,10 @@ static void CALLBACK GL_DebugOutput( GLuint source, GLuint type, GLuint id, GLui
|
|||
Con_Printf( S_OPENGL_NOTE "%s\n", message );
|
||||
break;
|
||||
case GL_DEBUG_TYPE_OTHER_ARB:
|
||||
default: Con_Printf( S_OPENGL_NOTE "%s\n", message );
|
||||
default:
|
||||
if( host_developer.value < DEV_EXTENDED )
|
||||
return;
|
||||
Con_Printf( S_OPENGL_NOTE "%s\n", message );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -904,7 +907,7 @@ void VID_CreateFakeWindow( void )
|
|||
pwglGetPixelFormatAttribiv = GL_GetProcAddress( "wglGetPixelFormatAttribivARB" );
|
||||
pwglChoosePixelFormat = GL_GetProcAddress( "wglChoosePixelFormatARB" );
|
||||
|
||||
// destory now it's no longer needed
|
||||
// destroy now it's no longer needed
|
||||
VID_DestroyFakeWindow();
|
||||
}
|
||||
|
||||
|
|
|
@ -328,7 +328,7 @@ void Cmd_Echo_f( void )
|
|||
int i;
|
||||
|
||||
for( i = 1; i < Cmd_Argc(); i++ )
|
||||
Con_Printf( Cmd_Argv( i ));
|
||||
Con_Printf( "%s", Cmd_Argv( i ));
|
||||
Con_Printf( "\n" );
|
||||
}
|
||||
|
||||
|
|
|
@ -1940,9 +1940,9 @@ void Con_DrawDebug( void )
|
|||
|
||||
if( scr_download->value != -1.0f )
|
||||
{
|
||||
Q_snprintf( dlstring, sizeof( dlstring ), "Downloading [%d remaining]: ^2%s^7 %5.1f%%",
|
||||
Q_snprintf( dlstring, sizeof( dlstring ), "Downloading [%d remaining]: ^2%s^7 %5.1f%% time %.f secs",
|
||||
host.downloadcount, host.downloadfile, scr_download->value, Sys_DoubleTime() - timeStart );
|
||||
x = glState.width - 400;
|
||||
x = glState.width - 500;
|
||||
y = con.curFont->charHeight * 1.05f;
|
||||
Con_DrawString( x, y, dlstring, g_color_table[7] );
|
||||
}
|
||||
|
|
|
@ -569,8 +569,9 @@ int Q_vsnprintf( char *buffer, size_t buffersize, const char *format, va_list ar
|
|||
// to prevent crash while output
|
||||
__except( EXCEPTION_EXECUTE_HANDLER )
|
||||
{
|
||||
memset( buffer, 0, buffersize );
|
||||
result = -1;
|
||||
Q_strncpy( buffer, "^1sprintf throw exception^7\n", buffersize );
|
||||
// memset( buffer, 0, buffersize );
|
||||
result = buffersize;
|
||||
}
|
||||
|
||||
if( result < 0 || result >= buffersize )
|
||||
|
|
|
@ -1502,7 +1502,7 @@ static file_t *FS_SysOpen( const char *filepath, const char *mode )
|
|||
opt |= O_BINARY;
|
||||
break;
|
||||
default:
|
||||
MsgDev( D_ERROR, "FS_SysOpen: %s: unknown char in mode (%c)\n", filepath, mode, mode[ind] );
|
||||
MsgDev( D_ERROR, "FS_SysOpen: %s: unknown char (%c) in mode (%s)\n", filepath, mode[ind], mode );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,10 +30,10 @@ host_parm_t host; // host parms
|
|||
sysinfo_t SI;
|
||||
|
||||
CVAR_DEFINE( host_developer, "developer", "0", 0, "engine is in development-mode" );
|
||||
CVAR_DEFINE_AUTO( sys_ticrate, "100", 0, "framerate in dedicated mode" );
|
||||
convar_t *host_gameloaded;
|
||||
convar_t *host_clientloaded;
|
||||
convar_t *host_limitlocal;
|
||||
convar_t host_developer;
|
||||
convar_t *host_maxfps;
|
||||
convar_t *host_framerate;
|
||||
convar_t *con_gamemaps;
|
||||
|
@ -130,7 +130,7 @@ void Host_CheckSleep( void )
|
|||
if( host.type == HOST_DEDICATED )
|
||||
{
|
||||
// let the dedicated server some sleep
|
||||
// Sys_Sleep( 1 );
|
||||
Sys_Sleep( 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -393,13 +393,20 @@ double Host_CalcFPS( void )
|
|||
|
||||
// NOTE: we should play demos with same fps as it was recorded
|
||||
if( CL_IsPlaybackDemo() || CL_IsRecordDemo( ))
|
||||
{
|
||||
fps = CL_GetDemoFramerate();
|
||||
}
|
||||
else if( Host_IsLocalGame( ))
|
||||
{
|
||||
fps = host_maxfps->value;
|
||||
}
|
||||
else if( host.type == HOST_DEDICATED )
|
||||
{
|
||||
fps = sys_ticrate.value;
|
||||
}
|
||||
else
|
||||
{
|
||||
fps = host_maxfps->value;
|
||||
if( fps == 0.0 ) fps = HOST_FPS; // default for multiplayer
|
||||
fps = bound( MIN_FPS, fps, MAX_FPS );
|
||||
}
|
||||
|
||||
|
@ -439,8 +446,16 @@ qboolean Host_FilterTime( float time )
|
|||
// limit fps to withing tolerable range
|
||||
fps = bound( MIN_FPS, fps, MAX_FPS );
|
||||
|
||||
if(( host.realtime - oldtime ) < ( 1.0 / fps ))
|
||||
return false;
|
||||
if( host.type == HOST_DEDICATED )
|
||||
{
|
||||
if(( host.realtime - oldtime ) < ( 1.0 / ( fps + 1.0 )))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(( host.realtime - oldtime ) < ( 1.0 / fps ))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
host.frametime = host.realtime - oldtime;
|
||||
|
@ -589,6 +604,7 @@ void Host_InitCommon( const char *hostname, qboolean bChangeGame )
|
|||
{
|
||||
MEMORYSTATUS lpBuffer;
|
||||
char dev_level[4];
|
||||
char ticrate[16];
|
||||
char progname[128];
|
||||
char cmdline[128];
|
||||
qboolean parse_cmdline = false;
|
||||
|
@ -596,6 +612,7 @@ void Host_InitCommon( const char *hostname, qboolean bChangeGame )
|
|||
int developer = 0;
|
||||
string szRootPath;
|
||||
char *in, *out;
|
||||
double fps;
|
||||
|
||||
lpBuffer.dwLength = sizeof( MEMORYSTATUS );
|
||||
GlobalMemoryStatus( &lpBuffer );
|
||||
|
@ -713,6 +730,8 @@ void Host_InitCommon( const char *hostname, qboolean bChangeGame )
|
|||
// member console allowing
|
||||
host.allow_console_init = host.allow_console;
|
||||
|
||||
timeBeginPeriod( 1 );
|
||||
|
||||
Con_CreateConsole(); // system console used by dedicated server or show fatal errors
|
||||
|
||||
// NOTE: this message couldn't be passed into game console but it doesn't matter
|
||||
|
@ -731,6 +750,13 @@ void Host_InitCommon( const char *hostname, qboolean bChangeGame )
|
|||
// share developer level across all dlls
|
||||
Q_snprintf( dev_level, sizeof( dev_level ), "%i", developer );
|
||||
Cvar_DirectSet( &host_developer, dev_level );
|
||||
Cvar_RegisterVariable( &sys_ticrate );
|
||||
|
||||
if( Sys_GetParmFromCmdLine( "-sys_ticrate", ticrate ))
|
||||
{
|
||||
fps = bound( MIN_FPS, atof( ticrate ), MAX_FPS );
|
||||
Cvar_SetValue( "sys_ticrate", fps );
|
||||
}
|
||||
|
||||
Con_Init(); // early console running to catch all the messages
|
||||
Cmd_AddCommand( "exec", Host_Exec_f, "execute a script file" );
|
||||
|
@ -787,7 +813,7 @@ int EXPORT Host_Main( const char *progname, int bChangeGame, pfnChangeGame func
|
|||
Cmd_AddCommand ( "crash", Host_Crash_f, "a way to force a bus error for development reasons");
|
||||
}
|
||||
|
||||
host_maxfps = Cvar_Get( "fps_max", "100", FCVAR_ARCHIVE, "host fps upper limit" );
|
||||
host_maxfps = Cvar_Get( "fps_max", "72", FCVAR_ARCHIVE, "host fps upper limit" );
|
||||
host_framerate = Cvar_Get( "host_framerate", "0", 0, "locks frame timing to this value in seconds" );
|
||||
host_gameloaded = Cvar_Get( "host_gameloaded", "0", FCVAR_READ_ONLY, "inidcates a loaded game.dll" );
|
||||
host_clientloaded = Cvar_Get( "host_clientloaded", "0", FCVAR_READ_ONLY, "inidcates a loaded client.dll" );
|
||||
|
|
|
@ -1023,7 +1023,7 @@ void HPAK_Extract_f( void )
|
|||
|
||||
if( entry->disksize <= 0 || entry->disksize >= HPAK_MAX_SIZE )
|
||||
{
|
||||
MsgDev( D_WARN, "Unable to extract data, size invalid: %s\n", nDataSize );
|
||||
MsgDev( D_WARN, "Unable to extract data, size invalid: %s\n", Q_memprint( entry->disksize ));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -1528,7 +1528,7 @@ static void Mod_LoadEntities( dbspmodel_t *bmod )
|
|||
{
|
||||
if( ft1 > ft2 )
|
||||
{
|
||||
Con_Printf( S_WARN "Entity patch is older than bsp. Ignored.\n", entfilename );
|
||||
Con_Printf( S_WARN "Entity patch is older than bsp. Ignored.\n" );
|
||||
}
|
||||
else if(( entpatch = FS_LoadFile( entfilename, &entpatchsize, true )) != NULL )
|
||||
{
|
||||
|
|
|
@ -114,7 +114,7 @@ freeze application for some time
|
|||
*/
|
||||
void Sys_Sleep( int msec )
|
||||
{
|
||||
msec = bound( 1, msec, 1000 );
|
||||
msec = bound( 0, msec, 1000 );
|
||||
Sleep( msec );
|
||||
}
|
||||
|
||||
|
|
|
@ -164,11 +164,16 @@ static const char *Mem_CheckFilename( const char *filename )
|
|||
const char *out = filename;
|
||||
int i;
|
||||
|
||||
if( !out ) return dummy;
|
||||
if( !COM_CheckString( out ))
|
||||
return dummy;
|
||||
|
||||
for( i = 0; i < 128; i++, out++ )
|
||||
if( out == '\0' ) break; // valid name
|
||||
if( i == 128 ) return dummy;
|
||||
return filename;
|
||||
{
|
||||
if( *out == '\0' )
|
||||
return filename; // valid name
|
||||
}
|
||||
|
||||
return dummy;
|
||||
}
|
||||
|
||||
static void Mem_FreeBlock( memheader_t *mem, const char *filename, int fileline )
|
||||
|
|
|
@ -162,6 +162,8 @@ typedef struct ui_enginefuncs_s
|
|||
int (*pfnCompareFileTime)( char *filename1, char *filename2, int *iCompare );
|
||||
|
||||
const char *(*pfnGetModeString)( int vid_mode );
|
||||
int (*COM_SaveFile)( const char *filename, const void *data, long len );
|
||||
int (*COM_RemoveFile)( const char *filepath );
|
||||
} ui_enginefuncs_t;
|
||||
|
||||
typedef struct
|
||||
|
|
|
@ -72,8 +72,11 @@ void SV_BroadcastPrintf( sv_client_t *ignore, char *fmt, ... )
|
|||
}
|
||||
}
|
||||
|
||||
// echo to console
|
||||
Con_DPrintf( string );
|
||||
if( host.type == HOST_DEDICATED )
|
||||
{
|
||||
// echo to console
|
||||
Con_DPrintf( string );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -60,8 +60,8 @@ static void SV_AddEntitiesToPacket( edict_t *pViewEnt, edict_t *pClient, client_
|
|||
byte *clientpvs;
|
||||
byte *clientphs;
|
||||
qboolean fullvis = false;
|
||||
sv_client_t *netclient;
|
||||
sv_client_t *cl = NULL;
|
||||
qboolean player;
|
||||
entity_state_t *state;
|
||||
int e;
|
||||
|
||||
|
@ -101,15 +101,29 @@ static void SV_AddEntitiesToPacket( edict_t *pViewEnt, edict_t *pClient, client_
|
|||
if( CHECKVISBIT( ents->sended, e ))
|
||||
continue;
|
||||
|
||||
if( e >= 1 && e <= svs.maxclients )
|
||||
player = 1;
|
||||
else player = 0;
|
||||
|
||||
if( player )
|
||||
{
|
||||
sv_client_t *cl = &svs.clients[e - 1];
|
||||
|
||||
if( cl->state != cs_spawned )
|
||||
continue;
|
||||
|
||||
if( FBitSet( cl->flags, FCL_HLTV_PROXY ))
|
||||
continue;
|
||||
}
|
||||
|
||||
if( FBitSet( ent->v.effects, EF_REQUEST_PHS ))
|
||||
pset = clientphs;
|
||||
else pset = clientpvs;
|
||||
|
||||
state = &ents->entities[ents->num_entities];
|
||||
netclient = SV_ClientFromEdict( ent, true );
|
||||
|
||||
// add entity to the net packet
|
||||
if( svgame.dllFuncs.pfnAddToFullPack( state, e, ent, pClient, sv.hostflags, ( netclient != NULL ), pset ))
|
||||
if( svgame.dllFuncs.pfnAddToFullPack( state, e, ent, pClient, sv.hostflags, player, pset ))
|
||||
{
|
||||
// to prevent adds it twice through portals
|
||||
SETVISBIT( ents->sended, e );
|
||||
|
@ -807,7 +821,7 @@ void SV_SendClientMessages( void )
|
|||
{
|
||||
cl = sv.current_client;
|
||||
|
||||
if( !cl->state || FBitSet( cl->flags, FCL_FAKECLIENT ))
|
||||
if( cl->state <= cs_zombie || FBitSet( cl->flags, FCL_FAKECLIENT ))
|
||||
continue;
|
||||
|
||||
if( FBitSet( cl->flags, FCL_SKIP_NET_MESSAGE ))
|
||||
|
|
|
@ -874,6 +874,10 @@ void SV_InitEdict( edict_t *pEdict )
|
|||
SV_FreePrivateData( pEdict );
|
||||
memset( &pEdict->v, 0, sizeof( entvars_t ));
|
||||
pEdict->v.pContainingEntity = pEdict;
|
||||
pEdict->v.controller[0] = 0x7F;
|
||||
pEdict->v.controller[1] = 0x7F;
|
||||
pEdict->v.controller[2] = 0x7F;
|
||||
pEdict->v.controller[3] = 0x7F;
|
||||
pEdict->free = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ GNU General Public License for more details.
|
|||
|
||||
#ifdef WIN32
|
||||
// enable NVIDIA High Performance Graphics while using Integrated Graphics.
|
||||
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
|
||||
__declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 1;
|
||||
extern "C" __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
|
||||
extern "C" __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 1;
|
||||
#endif
|
||||
|
||||
typedef void (*pfnChangeGame)( const char *progname );
|
||||
|
|
|
@ -14,9 +14,6 @@ if errorlevel 1 set BUILD_ERROR=1
|
|||
%MSDEV% mainui/mainui.dsp %CONFIG%"mainui - Win32 Release" %build_target%
|
||||
if errorlevel 1 set BUILD_ERROR=1
|
||||
|
||||
%MSDEV% utils/vgui/lib/vgui.dsp %CONFIG%"vgui - Win32 Release" %build_target%
|
||||
if errorlevel 1 set BUILD_ERROR=1
|
||||
|
||||
if "%BUILD_ERROR%"=="" goto build_ok
|
||||
|
||||
echo *********************
|
||||
|
@ -38,7 +35,6 @@ goto done
|
|||
rem //delete log files
|
||||
if exist engine\engine.plg del /f /q engine\engine.plg
|
||||
if exist mainui\mainui.plg del /f /q mainui\mainui.plg
|
||||
if exist utils\vgui\lib\vgui.plg del /f /q utils\vgui\lib\vgui.plg
|
||||
|
||||
echo
|
||||
echo Build succeeded!
|
||||
|
|
|
@ -1,693 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<stdio.h>
|
||||
#include<VGUI_App.h>
|
||||
#include<VGUI_SurfaceBase.h>
|
||||
#include<VGUI_Panel.h>
|
||||
#include<VGUI_TickSignal.h>
|
||||
#include<VGUI_Font.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
static char *staticKeyTrans[KEY_LAST];
|
||||
App *App::_instance=null;
|
||||
|
||||
App::App()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
App::App(bool externalMain)
|
||||
{
|
||||
init();
|
||||
_externalMain=externalMain;
|
||||
}
|
||||
|
||||
void App::init()
|
||||
{
|
||||
_instance=this;
|
||||
_externalMain=false;
|
||||
_running=false;
|
||||
_keyFocus=null;
|
||||
_oldMouseFocus=null;
|
||||
_mouseFocus=null;
|
||||
_mouseCapture=null;
|
||||
_wantedKeyFocus=null;
|
||||
_scheme=new Scheme();
|
||||
_buildMode=false;
|
||||
_wantedBuildMode=false;
|
||||
_mouseArenaPanel=null;
|
||||
_cursorOveride=null;
|
||||
_nextTickMillis=getTimeMillis();
|
||||
_minimumTickMillisInterval=50;
|
||||
|
||||
int i;
|
||||
for(i=0;i<MOUSE_LAST;i++)
|
||||
{
|
||||
_mousePressed[i]=false;
|
||||
_mouseDoublePressed[i]=false;
|
||||
_mouseDown[i]=false;
|
||||
_mouseReleased[i]=false;
|
||||
}
|
||||
|
||||
for(i=0;i<KEY_LAST;i++)
|
||||
{
|
||||
_keyPressed[i]=false;
|
||||
_keyTyped[i]=false;
|
||||
_keyDown[i]=false;
|
||||
_keyReleased[i]=false;
|
||||
}
|
||||
|
||||
// build key to text translation table
|
||||
// first byte unshifted key
|
||||
// second byte shifted key
|
||||
// the rest is the name of the key
|
||||
#if defined ( WIN32 )
|
||||
staticKeyTrans[KEY_0] ="0)KEY_0";
|
||||
staticKeyTrans[KEY_1] ="1!KEY_1";
|
||||
staticKeyTrans[KEY_2] ="2@KEY_2";
|
||||
staticKeyTrans[KEY_3] ="3#KEY_3";
|
||||
staticKeyTrans[KEY_4] ="4$KEY_4";
|
||||
staticKeyTrans[KEY_5] ="5%KEY_5";
|
||||
staticKeyTrans[KEY_6] ="6^KEY_6";
|
||||
staticKeyTrans[KEY_7] ="7&KEY_7";
|
||||
staticKeyTrans[KEY_8] ="8*KEY_8";
|
||||
staticKeyTrans[KEY_9] ="9(KEY_9";
|
||||
staticKeyTrans[KEY_A] ="aAKEY_A";
|
||||
staticKeyTrans[KEY_B] ="bBKEY_B";
|
||||
staticKeyTrans[KEY_C] ="cCKEY_C";
|
||||
staticKeyTrans[KEY_D] ="dDKEY_D";
|
||||
staticKeyTrans[KEY_E] ="eEKEY_E";
|
||||
staticKeyTrans[KEY_F] ="fFKEY_F";
|
||||
staticKeyTrans[KEY_G] ="gGKEY_G";
|
||||
staticKeyTrans[KEY_H] ="hHKEY_H";
|
||||
staticKeyTrans[KEY_I] ="iIKEY_I";
|
||||
staticKeyTrans[KEY_J] ="jJKEY_J";
|
||||
staticKeyTrans[KEY_K] ="kKKEY_K";
|
||||
staticKeyTrans[KEY_L] ="lLKEY_L";
|
||||
staticKeyTrans[KEY_M] ="mMKEY_M";
|
||||
staticKeyTrans[KEY_N] ="nNKEY_N";
|
||||
staticKeyTrans[KEY_O] ="oOKEY_O";
|
||||
staticKeyTrans[KEY_P] ="pPKEY_P";
|
||||
staticKeyTrans[KEY_Q] ="qQKEY_Q";
|
||||
staticKeyTrans[KEY_R] ="rRKEY_R";
|
||||
staticKeyTrans[KEY_S] ="sSKEY_S";
|
||||
staticKeyTrans[KEY_T] ="tTKEY_T";
|
||||
staticKeyTrans[KEY_U] ="uUKEY_U";
|
||||
staticKeyTrans[KEY_V] ="vVKEY_V";
|
||||
staticKeyTrans[KEY_W] ="wWKEY_W";
|
||||
staticKeyTrans[KEY_X] ="xXKEY_X";
|
||||
staticKeyTrans[KEY_Y] ="yYKEY_Y";
|
||||
staticKeyTrans[KEY_Z] ="zZKEY_Z";
|
||||
staticKeyTrans[KEY_PAD_0] ="0\0KEY_PAD_0";
|
||||
staticKeyTrans[KEY_PAD_1] ="1\0KEY_PAD_1";
|
||||
staticKeyTrans[KEY_PAD_2] ="2\0KEY_PAD_2";
|
||||
staticKeyTrans[KEY_PAD_3] ="3\0KEY_PAD_3";
|
||||
staticKeyTrans[KEY_PAD_4] ="4\0KEY_PAD_4";
|
||||
staticKeyTrans[KEY_PAD_5] ="5\0KEY_PAD_5";
|
||||
staticKeyTrans[KEY_PAD_6] ="6\0KEY_PAD_6";
|
||||
staticKeyTrans[KEY_PAD_7] ="7\0KEY_PAD_7";
|
||||
staticKeyTrans[KEY_PAD_8] ="8\0KEY_PAD_8";
|
||||
staticKeyTrans[KEY_PAD_9] ="9\0KEY_PAD_9";
|
||||
staticKeyTrans[KEY_PAD_DIVIDE] ="//KEY_PAD_DIVIDE";
|
||||
staticKeyTrans[KEY_PAD_MULTIPLY] ="**KEY_PAD_MULTIPLY";
|
||||
staticKeyTrans[KEY_PAD_MINUS] ="--KEY_PAD_MINUS";
|
||||
staticKeyTrans[KEY_PAD_PLUS] ="++KEY_PAD_PLUS";
|
||||
staticKeyTrans[KEY_PAD_ENTER] ="\0\0KEY_PAD_ENTER";
|
||||
staticKeyTrans[KEY_PAD_DECIMAL] =".\0KEY_PAD_DECIMAL";
|
||||
staticKeyTrans[KEY_LBRACKET] ="[{KEY_LBRACKET";
|
||||
staticKeyTrans[KEY_RBRACKET] ="]}KEY_RBRACKET";
|
||||
staticKeyTrans[KEY_SEMICOLON] =";:KEY_SEMICOLON";
|
||||
staticKeyTrans[KEY_APOSTROPHE] ="'\"KEY_APOSTROPHE";
|
||||
staticKeyTrans[KEY_BACKQUOTE] ="`~KEY_BACKQUOTE";
|
||||
staticKeyTrans[KEY_COMMA] =",<KEY_COMMA";
|
||||
staticKeyTrans[KEY_PERIOD] =".>KEY_PERIOD";
|
||||
staticKeyTrans[KEY_SLASH] ="/?KEY_SLASH";
|
||||
staticKeyTrans[KEY_BACKSLASH] ="\\|KEY_BACKSLASH";
|
||||
staticKeyTrans[KEY_MINUS] ="-_KEY_MINUS";
|
||||
staticKeyTrans[KEY_EQUAL] ="=+KEY_EQUAL";
|
||||
staticKeyTrans[KEY_ENTER] ="\0\0KEY_ENTER";
|
||||
staticKeyTrans[KEY_SPACE] =" KEY_SPACE";
|
||||
staticKeyTrans[KEY_BACKSPACE] ="\0\0KEY_BACKSPACE";
|
||||
staticKeyTrans[KEY_TAB] ="\0\0KEY_TAB";
|
||||
staticKeyTrans[KEY_CAPSLOCK] ="\0\0KEY_CAPSLOCK";
|
||||
staticKeyTrans[KEY_NUMLOCK] ="\0\0KEY_NUMLOCK";
|
||||
staticKeyTrans[KEY_ESCAPE] ="\0\0KEY_ESCAPE";
|
||||
staticKeyTrans[KEY_SCROLLLOCK] ="\0\0KEY_SCROLLLOCK";
|
||||
staticKeyTrans[KEY_INSERT] ="\0\0KEY_INSERT";
|
||||
staticKeyTrans[KEY_DELETE] ="\0\0KEY_DELETE";
|
||||
staticKeyTrans[KEY_HOME] ="\0\0KEY_HOME";
|
||||
staticKeyTrans[KEY_END] ="\0\0KEY_END";
|
||||
staticKeyTrans[KEY_PAGEUP] ="\0\0KEY_PAGEUP";
|
||||
staticKeyTrans[KEY_PAGEDOWN] ="\0\0KEY_PAGEDOWN";
|
||||
staticKeyTrans[KEY_BREAK] ="\0\0KEY_BREAK";
|
||||
staticKeyTrans[KEY_LSHIFT] ="\0\0KEY_LSHIFT";
|
||||
staticKeyTrans[KEY_RSHIFT] ="\0\0KEY_RSHIFT";
|
||||
staticKeyTrans[KEY_LALT] ="\0\0KEY_LALT";
|
||||
staticKeyTrans[KEY_RALT] ="\0\0KEY_RALT";
|
||||
staticKeyTrans[KEY_LCONTROL] ="\0\0KEY_LCONTROL";
|
||||
staticKeyTrans[KEY_RCONTROL] ="\0\0KEY_RCONTROL";
|
||||
staticKeyTrans[KEY_LWIN] ="\0\0KEY_LWIN";
|
||||
staticKeyTrans[KEY_RWIN] ="\0\0KEY_RWIN";
|
||||
staticKeyTrans[KEY_APP] ="\0\0KEY_APP";
|
||||
staticKeyTrans[KEY_UP] ="\0\0KEY_UP";
|
||||
staticKeyTrans[KEY_LEFT] ="\0\0KEY_LEFT";
|
||||
staticKeyTrans[KEY_DOWN] ="\0\0KEY_DOWN";
|
||||
staticKeyTrans[KEY_RIGHT] ="\0\0KEY_RIGHT";
|
||||
staticKeyTrans[KEY_F1] ="\0\0KEY_F1";
|
||||
staticKeyTrans[KEY_F2] ="\0\0KEY_F2";
|
||||
staticKeyTrans[KEY_F3] ="\0\0KEY_F3";
|
||||
staticKeyTrans[KEY_F4] ="\0\0KEY_F4";
|
||||
staticKeyTrans[KEY_F5] ="\0\0KEY_F5";
|
||||
staticKeyTrans[KEY_F6] ="\0\0KEY_F6";
|
||||
staticKeyTrans[KEY_F7] ="\0\0KEY_F7";
|
||||
staticKeyTrans[KEY_F8] ="\0\0KEY_F8";
|
||||
staticKeyTrans[KEY_F9] ="\0\0KEY_F9";
|
||||
staticKeyTrans[KEY_F10] ="\0\0KEY_F10";
|
||||
staticKeyTrans[KEY_F11] ="\0\0KEY_F11";
|
||||
staticKeyTrans[KEY_F12] ="\0\0KEY_F12";
|
||||
#endif
|
||||
}
|
||||
|
||||
void App::externalTick()
|
||||
{
|
||||
internalTick();
|
||||
}
|
||||
|
||||
void App::run()
|
||||
{
|
||||
_running=true;
|
||||
|
||||
while(_running)
|
||||
{
|
||||
internalTick();
|
||||
}
|
||||
|
||||
setMouseArena(0,0,0,0,false);
|
||||
}
|
||||
|
||||
void App::start()
|
||||
{
|
||||
#if defined ( WIN32 )
|
||||
// main(__argc,__argv);
|
||||
#endif
|
||||
if(_externalMain)
|
||||
{
|
||||
return;
|
||||
}
|
||||
run();
|
||||
|
||||
for(int i=0;i<_surfaceBaseDar.getCount();i++)
|
||||
{
|
||||
_surfaceBaseDar[i]->setWindowedMode();
|
||||
}
|
||||
}
|
||||
|
||||
void App::stop()
|
||||
{
|
||||
_running=false;
|
||||
}
|
||||
|
||||
void App::surfaceBaseCreated(SurfaceBase* surfaceBase)
|
||||
{
|
||||
_surfaceBaseDar.putElement(surfaceBase);
|
||||
}
|
||||
|
||||
void App::surfaceBaseDeleted(SurfaceBase* surfaceBase)
|
||||
{
|
||||
_surfaceBaseDar.removeElement(surfaceBase);
|
||||
_mouseFocus=null;
|
||||
_mouseCapture=null;
|
||||
_keyFocus=null;
|
||||
}
|
||||
|
||||
void App::updateMouseFocus(int x,int y,SurfaceBase* surfaceBase)
|
||||
{
|
||||
if(_mouseCapture!=null)
|
||||
{
|
||||
setMouseFocus(_mouseCapture);
|
||||
return;
|
||||
}
|
||||
|
||||
if(surfaceBase->isWithin(x,y))
|
||||
{
|
||||
Panel* focus=surfaceBase->getPanel()->isWithinTraverse(x,y);
|
||||
|
||||
if(focus!=null)
|
||||
{
|
||||
setMouseFocus(focus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void App::internalCursorMoved(int x,int y,SurfaceBase* surfaceBase)
|
||||
{
|
||||
surfaceBase->getPanel()->localToScreen(x,y);
|
||||
|
||||
if(!_buildMode)
|
||||
{
|
||||
//cursor has moved, so make sure the mouseFocus is current
|
||||
updateMouseFocus(x,y,surfaceBase);
|
||||
|
||||
//UpdateMouseFocus would have set _mouseFocus current, so tell the panel with the mouseFocus the mouse has moved
|
||||
if(_mouseFocus!=null)
|
||||
{
|
||||
_mouseFocus->internalCursorMoved(x,y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void App::internalMousePressed(MouseCode code,SurfaceBase* surfaceBzase)
|
||||
{
|
||||
//set mouse state
|
||||
_mousePressed[code]=1;
|
||||
_mouseDown[code]=1;
|
||||
|
||||
if(!_buildMode)
|
||||
{
|
||||
if(_mouseFocus!=null)
|
||||
{
|
||||
_mouseFocus->internalMousePressed(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void App::internalMouseDoublePressed(MouseCode code,SurfaceBase* surfaceBase)
|
||||
{
|
||||
//set mouse state
|
||||
_mouseDoublePressed[code]=1;
|
||||
|
||||
if(!_buildMode)
|
||||
{
|
||||
if(_mouseFocus!=null)
|
||||
{
|
||||
_mouseFocus->internalMouseDoublePressed(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void App::internalMouseReleased(MouseCode code,SurfaceBase* surfaceBase)
|
||||
{
|
||||
//set mouse state
|
||||
_mouseReleased[code]=1;
|
||||
_mouseDown[code]=0;
|
||||
|
||||
if(!_buildMode)
|
||||
{
|
||||
if(_mouseFocus!=null)
|
||||
{
|
||||
_mouseFocus->internalMouseReleased(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void App::internalMouseWheeled(int delta,SurfaceBase* surfaceBase)
|
||||
{
|
||||
if(!_buildMode)
|
||||
{
|
||||
if(_keyFocus!=null)
|
||||
{
|
||||
_keyFocus->internalMouseWheeled(delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void App::internalKeyPressed(KeyCode code,SurfaceBase* surfaceBase)
|
||||
{
|
||||
if((code < 0)||(code >= KEY_LAST))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//set key state
|
||||
_keyPressed[code]=1;
|
||||
_keyDown[code]=1;
|
||||
|
||||
if(!_buildMode)
|
||||
{
|
||||
if(_keyFocus!=null)
|
||||
{
|
||||
_keyFocus->internalKeyPressed(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void App::internalKeyTyped(KeyCode code,SurfaceBase* surfaceBase)
|
||||
{
|
||||
if((code < 0)||(code >= KEY_LAST))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//set key state
|
||||
_keyTyped[code]=1;
|
||||
|
||||
if(!_buildMode)
|
||||
{
|
||||
if(_keyFocus!=null)
|
||||
{
|
||||
_keyFocus->internalKeyTyped(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void App::internalKeyReleased(KeyCode code,SurfaceBase* surfaceBase)
|
||||
{
|
||||
if((code < 0)||(code >= KEY_LAST))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//set key state
|
||||
_keyReleased[code]=1;
|
||||
_keyDown[code]=0;
|
||||
|
||||
if(!_buildMode)
|
||||
{
|
||||
if(_keyFocus!=null)
|
||||
{
|
||||
_keyFocus->internalKeyReleased(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool App::wasMousePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
return _mousePressed[code];
|
||||
}
|
||||
|
||||
bool App::wasMouseDoublePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
return _mouseDoublePressed[code];
|
||||
}
|
||||
|
||||
bool App::isMouseDown(MouseCode code,Panel* panel)
|
||||
{
|
||||
return _mouseDown[code];
|
||||
}
|
||||
|
||||
bool App::wasMouseReleased(MouseCode code,Panel* panel)
|
||||
{
|
||||
return _mouseReleased[code];
|
||||
}
|
||||
|
||||
bool App::wasKeyPressed(KeyCode code,Panel* panel)
|
||||
{
|
||||
if((panel!=null)&&(panel!=_keyFocus))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _keyPressed[code];
|
||||
}
|
||||
|
||||
bool App::isKeyDown(KeyCode code,Panel* panel)
|
||||
{
|
||||
if((panel!=null)&&(panel!=_keyFocus))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _keyDown[code];
|
||||
}
|
||||
|
||||
bool App::wasKeyTyped(KeyCode code,Panel* panel)
|
||||
{
|
||||
if((panel!=null)&&(panel!=_keyFocus))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _keyTyped[code];
|
||||
}
|
||||
|
||||
bool App::wasKeyReleased(KeyCode code,Panel* panel)
|
||||
{
|
||||
if((panel!=null)&&(panel!=_keyFocus))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _keyReleased[code];
|
||||
}
|
||||
|
||||
void App::addTickSignal(TickSignal* s)
|
||||
{
|
||||
_tickSignalDar.putElement(s);
|
||||
}
|
||||
|
||||
void App::internalTick()
|
||||
{
|
||||
int i;
|
||||
|
||||
if(getTimeMillis()<_nextTickMillis)
|
||||
{
|
||||
return;
|
||||
}
|
||||
platTick();
|
||||
|
||||
int cursorX,cursorY;
|
||||
getCursorPos(cursorX,cursorY);
|
||||
|
||||
bool mouseOverAnySurface=false;
|
||||
for(i=0;i<_surfaceBaseDar.getCount();i++)
|
||||
{
|
||||
updateMouseFocus(cursorX,cursorY,_surfaceBaseDar[i]);
|
||||
|
||||
if(_surfaceBaseDar[i]->isWithin(cursorX,cursorY))
|
||||
{
|
||||
mouseOverAnySurface=true;
|
||||
}
|
||||
|
||||
_surfaceBaseDar[i]->setEmulatedCursorPos(cursorX,cursorY);
|
||||
}
|
||||
if(!mouseOverAnySurface)
|
||||
{
|
||||
setMouseFocus(null);
|
||||
}
|
||||
|
||||
if(_mouseFocus!=null)
|
||||
{
|
||||
_mouseFocus->internalSetCursor();
|
||||
}
|
||||
|
||||
for(i=0;i<_tickSignalDar.getCount();i++)
|
||||
{
|
||||
_tickSignalDar[i]->ticked();
|
||||
}
|
||||
|
||||
if(_keyFocus!=null)
|
||||
{
|
||||
_keyFocus->internalKeyFocusTicked();
|
||||
}
|
||||
|
||||
//clear mouse and key states
|
||||
for(i=0;i<MOUSE_LAST;i++)
|
||||
{
|
||||
_mousePressed[i]=false;
|
||||
_mouseDoublePressed[i]=false;
|
||||
_mouseReleased[i]=false;
|
||||
}
|
||||
for(i=0;i<KEY_LAST;i++)
|
||||
{
|
||||
_keyPressed[i]=false;
|
||||
_keyTyped[i]=false;
|
||||
_keyReleased[i]=false;
|
||||
}
|
||||
|
||||
for(i=0;i<_surfaceBaseDar.getCount();i++)
|
||||
{
|
||||
if(_surfaceBaseDar[i]->hasFocus())
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i==_surfaceBaseDar.getCount())
|
||||
{
|
||||
_wantedKeyFocus=null;
|
||||
}
|
||||
|
||||
if(_keyFocus!=_wantedKeyFocus)
|
||||
{
|
||||
if(_keyFocus!=null)
|
||||
{
|
||||
_keyFocus->internalFocusChanged(true);
|
||||
_keyFocus->repaint();
|
||||
}
|
||||
if(_wantedKeyFocus!=null)
|
||||
{
|
||||
_wantedKeyFocus->internalFocusChanged(false);
|
||||
_wantedKeyFocus->repaint();
|
||||
}
|
||||
}
|
||||
|
||||
_keyFocus=_wantedKeyFocus;
|
||||
_buildMode=_wantedBuildMode;
|
||||
|
||||
for(i=0;i<_surfaceBaseDar.getCount();i++)
|
||||
{
|
||||
_surfaceBaseDar[i]->getPanel()->solveTraverse();
|
||||
_surfaceBaseDar[i]->applyChanges();
|
||||
}
|
||||
|
||||
if(_mouseArenaPanel!=null)
|
||||
{
|
||||
SurfaceBase* sur=_mouseArenaPanel->getSurfaceBase();
|
||||
if(sur!=null)
|
||||
{
|
||||
int x,y,extents[4];
|
||||
sur->getPanel()->getPos(x,y);
|
||||
_mouseArenaPanel->getAbsExtents(extents[0],extents[1],extents[2],extents[3]);
|
||||
internalSetMouseArena(x+extents[0],y+extents[1],x+extents[2],y+extents[3],true);
|
||||
}
|
||||
}
|
||||
|
||||
_nextTickMillis=getTimeMillis()+_minimumTickMillisInterval;
|
||||
}
|
||||
|
||||
void App::setMouseCapture(Panel* panel)
|
||||
{
|
||||
if(panel==null)
|
||||
{
|
||||
if(_mouseCapture!=null)
|
||||
{
|
||||
_mouseCapture->_surfaceBase->enableMouseCapture(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
panel->_surfaceBase->enableMouseCapture(true);
|
||||
}
|
||||
|
||||
_mouseCapture = panel;
|
||||
}
|
||||
|
||||
void App::requestFocus(Panel* panel)
|
||||
{
|
||||
_wantedKeyFocus=panel;
|
||||
}
|
||||
|
||||
Panel* App::getFocus()
|
||||
{
|
||||
return _keyFocus;
|
||||
}
|
||||
|
||||
void App::repaintAll()
|
||||
{
|
||||
for(int i=0;i<_surfaceBaseDar.getCount();i++)
|
||||
{
|
||||
_surfaceBaseDar[i]->getPanel()->repaintAll();
|
||||
_surfaceBaseDar[i]->invalidate(_surfaceBaseDar[i]->getPanel());
|
||||
}
|
||||
}
|
||||
|
||||
void App::setScheme(Scheme* scheme)
|
||||
{
|
||||
if(scheme!=null)
|
||||
{
|
||||
_scheme=scheme;
|
||||
repaintAll();
|
||||
}
|
||||
}
|
||||
|
||||
Scheme* App::getScheme()
|
||||
{
|
||||
return _scheme;
|
||||
}
|
||||
|
||||
void App::enableBuildMode()
|
||||
{
|
||||
_wantedBuildMode=true;
|
||||
}
|
||||
|
||||
char App::getKeyCodeChar(KeyCode code,bool shifted)
|
||||
{
|
||||
if(shifted)
|
||||
{
|
||||
return staticKeyTrans[code][1];
|
||||
}
|
||||
else
|
||||
{
|
||||
return staticKeyTrans[code][0];
|
||||
}
|
||||
}
|
||||
|
||||
void App::getKeyCodeText(KeyCode code,char* buf,int buflen)
|
||||
{
|
||||
if (!buf)
|
||||
return;
|
||||
|
||||
// copy text into buf up to buflen in length
|
||||
// skip 2 in staticKeyTrans because the first two are for getKeyCodeChar
|
||||
for (int i = 0; i < buflen; i++)
|
||||
{
|
||||
char ch = staticKeyTrans[code][i+2];
|
||||
buf[i] = ch;
|
||||
if (ch == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void App::reset()
|
||||
{
|
||||
_keyFocus=null;
|
||||
_mouseFocus=null;
|
||||
_mouseCapture=null;
|
||||
_wantedKeyFocus=null;
|
||||
_buildMode=false;
|
||||
_wantedBuildMode=false;
|
||||
_mouseArenaPanel=null;
|
||||
_tickSignalDar.removeAll();
|
||||
Font_Reset();
|
||||
setScheme(new Scheme());
|
||||
}
|
||||
|
||||
void App::setMouseArena(Panel* panel)
|
||||
{
|
||||
_mouseArenaPanel=panel;
|
||||
}
|
||||
|
||||
void App::setMouseArena(int x0,int y0,int x1,int y1,bool enabled)
|
||||
{
|
||||
setMouseArena(false);
|
||||
internalSetMouseArena(x0,y0,x1,y1,enabled);
|
||||
}
|
||||
|
||||
void App::setCursorOveride(Cursor* cursor)
|
||||
{
|
||||
_cursorOveride=cursor;
|
||||
}
|
||||
|
||||
Cursor* App::getCursorOveride()
|
||||
{
|
||||
return _cursorOveride;
|
||||
}
|
||||
|
||||
void App::setMinimumTickMillisInterval(int interval)
|
||||
{
|
||||
_minimumTickMillisInterval=interval;
|
||||
}
|
||||
|
||||
void App::setMouseFocus(Panel* newMouseFocus)
|
||||
{
|
||||
if(_mouseFocus!=newMouseFocus)
|
||||
{
|
||||
_oldMouseFocus=_mouseFocus;
|
||||
_mouseFocus=newMouseFocus;
|
||||
|
||||
if(_oldMouseFocus!=null)
|
||||
{
|
||||
_oldMouseFocus->internalCursorExited();
|
||||
}
|
||||
|
||||
if(_mouseFocus!=null)
|
||||
{
|
||||
_mouseFocus->internalCursorEntered();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_Bitmap.h>
|
||||
#include<VGUI_Panel.h>
|
||||
#include<VGUI_SurfaceBase.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
Bitmap::Bitmap() : Image()
|
||||
{
|
||||
_rgba=null;
|
||||
_id=0;
|
||||
_uploaded=false;
|
||||
}
|
||||
|
||||
void Bitmap::setSize(int wide,int tall)
|
||||
{
|
||||
Image::setSize(wide,tall);
|
||||
|
||||
if(_rgba!=null)
|
||||
{
|
||||
delete[] _rgba;
|
||||
}
|
||||
|
||||
_rgba=new uchar[wide*tall*4];
|
||||
}
|
||||
|
||||
void Bitmap::setRGBA(int x,int y,uchar r,uchar g,uchar b,uchar a)
|
||||
{
|
||||
if(_rgba==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int wide,tall;
|
||||
getSize(wide,tall);
|
||||
|
||||
if ((x>=0)&&(x<wide)&&(y>=0)&&(y<tall))
|
||||
{
|
||||
_rgba[((y*wide)+x)*4]=r;
|
||||
_rgba[((y*wide)+x)*4+1]=g;
|
||||
_rgba[((y*wide)+x)*4+2]=b;
|
||||
_rgba[((y*wide)+x)*4+3]=a;
|
||||
}
|
||||
}
|
||||
|
||||
void Bitmap::paint(Panel* panel)
|
||||
{
|
||||
if(_rgba==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int wide,tall;
|
||||
getSize(wide,tall);
|
||||
|
||||
if(_id==0)
|
||||
{
|
||||
if(panel->getSurfaceBase()==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_id=panel->getSurfaceBase()->createNewTextureID();
|
||||
}
|
||||
|
||||
if(!_uploaded)
|
||||
{
|
||||
drawSetTextureRGBA(_id,(const char*)_rgba,wide,tall);
|
||||
_uploaded=true;
|
||||
}
|
||||
|
||||
Color color;
|
||||
getColor(color);
|
||||
|
||||
int r,g,b,a;
|
||||
color.getColor(r,g,b,a);
|
||||
drawSetTexture(_id);
|
||||
drawSetColor(r,g,b,a);
|
||||
|
||||
int x,y;
|
||||
getPos(x,y);
|
||||
drawTexturedRect(x,y,x+wide,y+tall);
|
||||
}
|
|
@ -1,334 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_BitmapTGA.h>
|
||||
#include<VGUI_DataInputStream.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
BitmapTGA::BitmapTGA(InputStream* is,bool invertAlpha) : Bitmap()
|
||||
{
|
||||
loadTGA(is,invertAlpha);
|
||||
}
|
||||
|
||||
bool BitmapTGA::loadTGA(InputStream* is,bool invertAlpha)
|
||||
{
|
||||
if(is==null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DataInputStream dis(is);
|
||||
|
||||
bool success=false;
|
||||
|
||||
uchar id_length=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
uchar colormap_type=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
uchar image_type=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ushort colormap_index=dis.readUShort(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ushort colormap_length=dis.readUShort(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
uchar colormap_size=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ushort x_origin=dis.readUShort(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ushort y_origin=dis.readUShort(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int wide=dis.readUShort(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int tall=dis.readUShort(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
uchar pixel_size=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
uchar attributes=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (image_type!=2
|
||||
&& image_type!=10)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (colormap_type !=0
|
||||
|| (pixel_size!=32 && pixel_size!=24))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
setSize(wide,tall);
|
||||
|
||||
if(_rgba==null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (id_length != 0)
|
||||
dis.seekRelative(id_length,success); // skip TARGA image comment
|
||||
|
||||
int column, row;
|
||||
uchar* ptr;
|
||||
if (image_type==2) { // Uncompressed, RGB images
|
||||
for(row=tall-1; row>=0; row--) {
|
||||
ptr = _rgba + row*wide*4;
|
||||
for(column=0; column<wide; column++) {
|
||||
switch (pixel_size) {
|
||||
case 24:
|
||||
ptr[2]=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ptr[1]=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ptr[0]=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ptr[3]=255;
|
||||
if(invertAlpha)
|
||||
{
|
||||
ptr[3]=0;
|
||||
}
|
||||
ptr+=4;
|
||||
break;
|
||||
case 32:
|
||||
ptr[2]=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ptr[1]=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ptr[0]=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ptr[3]=255-dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(invertAlpha)
|
||||
{
|
||||
ptr[3]=255-ptr[3];
|
||||
}
|
||||
ptr+=4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else/* if (image_type==10)*/ { // Runlength encoded RGB images
|
||||
uchar packetHeader,packetSize,j,color[4];
|
||||
for(row=tall-1; row>=0; row--) {
|
||||
ptr = _rgba + row*wide*4;
|
||||
for(column=0; column<wide; ) {
|
||||
packetHeader=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
packetSize = 1 + (packetHeader & 0x7f);
|
||||
if (packetHeader & 0x80) { // run-length packet
|
||||
switch (pixel_size) {
|
||||
case 24:
|
||||
color[2]=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
color[1]=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
color[0]=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
color[3]=255;
|
||||
if(invertAlpha)
|
||||
{
|
||||
color[3]=0;
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
color[2]=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
color[1]=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
color[0]=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
color[3]=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(invertAlpha)
|
||||
{
|
||||
color[3]=255-color[3];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for(j=0;j<packetSize;j++) {
|
||||
*ptr++=color[0];
|
||||
*ptr++=color[1];
|
||||
*ptr++=color[2];
|
||||
*ptr++=color[3];
|
||||
column++;
|
||||
if (column==wide) { // run spans across tall
|
||||
column=0;
|
||||
if (row>0)
|
||||
row--;
|
||||
else
|
||||
goto breakOut;
|
||||
ptr = _rgba + row*wide*4;
|
||||
}
|
||||
}
|
||||
}
|
||||
else { // non run-length packet
|
||||
for(j=0;j<packetSize;j++) {
|
||||
switch (pixel_size) {
|
||||
case 24:
|
||||
ptr[2]=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ptr[1]=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ptr[0]=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ptr[0]=255;
|
||||
if(invertAlpha)
|
||||
{
|
||||
color[3]=0;
|
||||
}
|
||||
ptr+=4;
|
||||
break;
|
||||
case 32:
|
||||
ptr[2]=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ptr[1]=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ptr[0]=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ptr[3]=dis.readUChar(success);
|
||||
if(!success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(invertAlpha)
|
||||
{
|
||||
ptr[3]=255-ptr[3];
|
||||
}
|
||||
ptr+=4;
|
||||
break;
|
||||
}
|
||||
column++;
|
||||
if (column==wide) { // pixel packet run spans across tall
|
||||
column=0;
|
||||
if (row>0)
|
||||
row--;
|
||||
else
|
||||
goto breakOut;
|
||||
ptr = _rgba + row*wide*4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
breakOut:;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_Border.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
Border::Border() : Image()
|
||||
{
|
||||
_inset[0]=0;
|
||||
_inset[1]=0;
|
||||
_inset[2]=0;
|
||||
_inset[3]=0;
|
||||
_panel=null;
|
||||
}
|
||||
|
||||
Border::Border(int left,int top,int right,int bottom) : Image()
|
||||
{
|
||||
_inset[0]=0;
|
||||
_inset[1]=0;
|
||||
_inset[2]=0;
|
||||
_inset[3]=0;
|
||||
_panel=null;
|
||||
setInset(left,top,right,bottom);
|
||||
}
|
||||
|
||||
void Border::setInset(int left,int top,int right,int bottom)
|
||||
{
|
||||
_inset[0]=left;
|
||||
_inset[1]=top;
|
||||
_inset[2]=right;
|
||||
_inset[3]=bottom;
|
||||
}
|
||||
|
||||
void Border::getInset(int& left,int& top,int& right,int& bottom)
|
||||
{
|
||||
left=_inset[0];
|
||||
top=_inset[1];
|
||||
right=_inset[2];
|
||||
bottom=_inset[3];
|
||||
}
|
||||
|
||||
void Border::drawFilledRect(int x0,int y0,int x1,int y1)
|
||||
{
|
||||
Image::drawFilledRect(x0-_inset[0],y0-_inset[1],x1-_inset[0],y1-_inset[1]);
|
||||
}
|
||||
|
||||
void Border::drawOutlinedRect(int x0,int y0,int x1,int y1)
|
||||
{
|
||||
Image::drawOutlinedRect(x0-_inset[0],y0-_inset[1],x1-_inset[0],y1-_inset[1]);
|
||||
}
|
||||
|
||||
void Border::drawSetTextPos(int x,int y)
|
||||
{
|
||||
Image::drawSetTextPos(x-_inset[0],y-_inset[1]);
|
||||
}
|
||||
|
||||
void Border::drawPrintText(int x,int y,const char* str,int strlen)
|
||||
{
|
||||
Image::drawPrintText(x-_inset[0],y-_inset[1],str,strlen);
|
||||
}
|
||||
|
||||
void Border::drawPrintChar(int x,int y,char ch)
|
||||
{
|
||||
Image::drawPrintChar(x-_inset[0],y-_inset[1],ch);
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_BorderLayout.h>
|
||||
#include<VGUI_LayoutInfo.h>
|
||||
#include<VGUI_Panel.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
class BorderLayoutInfo : public LayoutInfo
|
||||
{
|
||||
public:
|
||||
BorderLayout::Alignment _alignment;
|
||||
public:
|
||||
BorderLayoutInfo(BorderLayout::Alignment alignment)
|
||||
{
|
||||
_alignment=alignment;
|
||||
}
|
||||
virtual LayoutInfo* getThis()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
BorderLayout::BorderLayout(int inset) : Layout()
|
||||
{
|
||||
_inset=inset;
|
||||
}
|
||||
|
||||
LayoutInfo* BorderLayout::createLayoutInfo(Alignment alignment)
|
||||
{
|
||||
return new BorderLayoutInfo(alignment);
|
||||
}
|
||||
|
||||
void BorderLayout::performLayout(Panel* panel)
|
||||
{
|
||||
int wide,tall;
|
||||
panel->getSize(wide,tall);
|
||||
|
||||
int maxNorth=0;
|
||||
int maxSouth=0;
|
||||
int maxEast=0;
|
||||
int maxWest=0;
|
||||
|
||||
int i;
|
||||
|
||||
for(i=0;i<panel->getChildCount();i++)
|
||||
{
|
||||
BorderLayoutInfo* info=dynamic_cast<BorderLayoutInfo*>(panel->getChild(i)->getLayoutInfo());
|
||||
if(info!=null)
|
||||
{
|
||||
Panel* child=panel->getChild(i);
|
||||
|
||||
switch(info->_alignment)
|
||||
{
|
||||
case a_north:
|
||||
{
|
||||
if(child->getTall()>maxNorth)
|
||||
{
|
||||
maxNorth=child->getTall();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case a_south:
|
||||
{
|
||||
if(child->getTall()>maxSouth)
|
||||
{
|
||||
maxSouth=child->getTall();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case a_west:
|
||||
{
|
||||
if(child->getWide()>maxWest)
|
||||
{
|
||||
maxWest=child->getWide();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case a_east:
|
||||
{
|
||||
if(child->getTall()>maxEast) // getWide?
|
||||
{
|
||||
maxEast=child->getWide();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int x0=_inset+maxWest;
|
||||
int y0=_inset+maxNorth;
|
||||
int x1=wide-_inset-maxEast;
|
||||
int y1=tall-_inset-maxSouth;
|
||||
|
||||
for(i=0;i<panel->getChildCount();i++)
|
||||
{
|
||||
BorderLayoutInfo* info=dynamic_cast<BorderLayoutInfo*>(panel->getChild(i)->getLayoutInfo());if(info==null){continue;}
|
||||
Alignment alignment=info->_alignment;
|
||||
|
||||
Panel* child=panel->getChild(i);
|
||||
|
||||
switch(alignment)
|
||||
{
|
||||
case a_north:
|
||||
{
|
||||
child->setBounds(0,0,wide,y0);
|
||||
break;
|
||||
}
|
||||
case a_south:
|
||||
{
|
||||
child->setBounds(0,y1,wide,tall-y1);
|
||||
break;
|
||||
}
|
||||
case a_west:
|
||||
{
|
||||
child->setBounds(0,y0,x0,y1-y0);
|
||||
break;
|
||||
}
|
||||
case a_east:
|
||||
{
|
||||
child->setBounds(x1,y0,wide-x1,y1-y0);
|
||||
break;
|
||||
}
|
||||
case a_center:
|
||||
{
|
||||
child->setBounds(x0,y0,x1-x0,y1-y0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_BorderPair.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
BorderPair::BorderPair(Border* border0,Border* border1)
|
||||
{
|
||||
_border[0]=border0;
|
||||
_border[1]=border1;
|
||||
}
|
||||
|
||||
void BorderPair::doPaint(Panel* panel)
|
||||
{
|
||||
if(_border[0]!=null)
|
||||
{
|
||||
_border[0]->doPaint(panel);
|
||||
}
|
||||
|
||||
if(_border[1]!=null)
|
||||
{
|
||||
_border[1]->doPaint(panel);
|
||||
}
|
||||
}
|
||||
|
||||
void BorderPair::paint(Panel* panel)
|
||||
{
|
||||
if(_border[0]!=null)
|
||||
{
|
||||
_border[0]->paint(panel);
|
||||
}
|
||||
|
||||
if(_border[1]!=null)
|
||||
{
|
||||
_border[1]->paint(panel);
|
||||
}
|
||||
}
|
|
@ -1,287 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<assert.h>
|
||||
#include<VGUI_BuildGroup.h>
|
||||
#include<VGUI_ChangeSignal.h>
|
||||
#include<VGUI_App.h>
|
||||
#include<VGUI_Label.h>
|
||||
#include<VGUI_LineBorder.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
BuildGroup::BuildGroup()
|
||||
{
|
||||
_enabled=false;
|
||||
_snapX=4;
|
||||
_snapY=4;
|
||||
_cursor_sizenwse=new Cursor(Cursor::dc_sizenwse);
|
||||
_cursor_sizenesw=new Cursor(Cursor::dc_sizenesw);
|
||||
_cursor_sizewe=new Cursor(Cursor::dc_sizewe);
|
||||
_cursor_sizens=new Cursor(Cursor::dc_sizens);
|
||||
_cursor_sizeall=new Cursor(Cursor::dc_sizeall);
|
||||
_currentPanel=null;
|
||||
_dragging=false;
|
||||
}
|
||||
|
||||
void BuildGroup::setEnabled(bool state)
|
||||
{
|
||||
if(_enabled!=state)
|
||||
{
|
||||
if(_currentPanel!=null)
|
||||
{
|
||||
_currentPanel=null;
|
||||
fireCurrentPanelChangeSignal();
|
||||
}
|
||||
|
||||
_currentPanel=null;
|
||||
}
|
||||
|
||||
_enabled=state;
|
||||
}
|
||||
|
||||
bool BuildGroup::isEnabled()
|
||||
{
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
void BuildGroup::cursorMoved(int x,int y,Panel* panel)
|
||||
{
|
||||
assert(panel);
|
||||
|
||||
if(_dragging)
|
||||
{
|
||||
panel->getApp()->getCursorPos(x,y);
|
||||
|
||||
if(_dragMouseCode==MOUSE_RIGHT)
|
||||
{
|
||||
panel->setSize(x-_dragStartCursorPos[0],y-_dragStartCursorPos[1]);
|
||||
applySnap(panel);
|
||||
}
|
||||
else
|
||||
{
|
||||
panel->setSize(_dragStartPanelPos[0]+(x-_dragStartCursorPos[0]),_dragStartPanelPos[1]+(y-_dragStartCursorPos[1]));
|
||||
applySnap(panel);
|
||||
}
|
||||
|
||||
panel->repaintParent();
|
||||
}
|
||||
}
|
||||
|
||||
void BuildGroup::mousePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
assert(panel);
|
||||
|
||||
if(code==MOUSE_RIGHT)
|
||||
{
|
||||
int lx,ly;
|
||||
panel->getApp()->getCursorPos(lx,ly);
|
||||
panel->screenToLocal(lx,ly);
|
||||
|
||||
Panel *newPanel=new Label("Label",lx,ly,0,0);
|
||||
newPanel->setBorder(new LineBorder());
|
||||
newPanel->setParent(panel);
|
||||
newPanel->setBuildGroup(this, "Label");
|
||||
panel=newPanel;
|
||||
}
|
||||
|
||||
_dragging=true;
|
||||
_dragMouseCode=code;
|
||||
panel->requestFocus();
|
||||
|
||||
int x,y;
|
||||
panel->getApp()->getCursorPos(x,y);
|
||||
_dragStartCursorPos[0]=x;
|
||||
_dragStartCursorPos[1]=y;
|
||||
|
||||
panel->getPos(x,y);
|
||||
_dragStartPanelPos[0]=x;
|
||||
_dragStartPanelPos[1]=y;
|
||||
|
||||
panel->getApp()->setMouseCapture(panel);
|
||||
|
||||
if(_currentPanel!=panel)
|
||||
{
|
||||
_currentPanel=panel;
|
||||
fireCurrentPanelChangeSignal();
|
||||
}
|
||||
}
|
||||
|
||||
void BuildGroup::mouseReleased(MouseCode code,Panel* panel)
|
||||
{
|
||||
assert(panel);
|
||||
|
||||
_dragging=false;
|
||||
panel->getApp()->setMouseCapture(null);
|
||||
}
|
||||
|
||||
void BuildGroup::mouseDoublePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
assert(panel);
|
||||
}
|
||||
|
||||
void BuildGroup::keyTyped(KeyCode code,Panel* panel)
|
||||
{
|
||||
assert(panel);
|
||||
|
||||
int dx=0;
|
||||
int dy=0;
|
||||
|
||||
bool shift=(panel->isKeyDown(KEY_LSHIFT)||panel->isKeyDown(KEY_RSHIFT));
|
||||
bool ctrl=(panel->isKeyDown(KEY_LCONTROL)||panel->isKeyDown(KEY_RCONTROL));
|
||||
|
||||
switch(code)
|
||||
{
|
||||
case KEY_LEFT:
|
||||
{
|
||||
dx-=_snapX;
|
||||
break;
|
||||
}
|
||||
case KEY_RIGHT:
|
||||
{
|
||||
dx+=_snapX;
|
||||
break;
|
||||
}
|
||||
case KEY_UP:
|
||||
{
|
||||
dy-=_snapY;
|
||||
break;
|
||||
}
|
||||
case KEY_DOWN:
|
||||
{
|
||||
dy+=_snapY;
|
||||
break;
|
||||
}
|
||||
case KEY_C:
|
||||
{
|
||||
if(ctrl)
|
||||
{
|
||||
copyPropertiesToClipboard();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(dx||dy)
|
||||
{
|
||||
//TODO: make this stuff actually snap
|
||||
|
||||
int x,y,wide,tall;
|
||||
|
||||
panel->getBounds(x,y,wide,tall);
|
||||
|
||||
if(shift)
|
||||
{
|
||||
panel->setSize(wide+dx,tall+dy);
|
||||
}
|
||||
else
|
||||
{
|
||||
panel->setPos(x+dx,y+dy);
|
||||
}
|
||||
|
||||
applySnap(panel);
|
||||
|
||||
panel->repaint();
|
||||
if(panel->getParent()!=null)
|
||||
{
|
||||
panel->getParent()->repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Cursor* BuildGroup::getCursor(Panel* panel)
|
||||
{
|
||||
assert(panel);
|
||||
|
||||
int x,y,wide,tall;
|
||||
panel->getApp()->getCursorPos(x,y);
|
||||
panel->screenToLocal(x,y);
|
||||
panel->getSize(wide,tall);
|
||||
|
||||
if(x < 2)
|
||||
{
|
||||
if(y < 4)
|
||||
{
|
||||
return _cursor_sizenwse;
|
||||
}
|
||||
else
|
||||
if(y<(tall-4))
|
||||
{
|
||||
return _cursor_sizewe;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _cursor_sizenesw;
|
||||
}
|
||||
}
|
||||
|
||||
return _cursor_sizeall;
|
||||
}
|
||||
|
||||
void BuildGroup::applySnap(Panel* panel)
|
||||
{
|
||||
assert(panel);
|
||||
|
||||
int x,y,wide,tall;
|
||||
panel->getBounds(x,y,wide,tall);
|
||||
|
||||
x=(x/_snapX)*_snapX;
|
||||
y=(y/_snapY)*_snapY;
|
||||
panel->setPos(x,y);
|
||||
|
||||
int xx,yy;
|
||||
xx=x+wide;
|
||||
yy=y+tall;
|
||||
|
||||
xx=(xx/_snapX)*_snapX;
|
||||
yy=(yy/_snapY)*_snapY;
|
||||
panel->setSize(xx-x,yy-y);
|
||||
}
|
||||
|
||||
void BuildGroup::addCurrentPanelChangeSignal(ChangeSignal* s)
|
||||
{
|
||||
_currentPanelChangeSignalDar.putElement(s);
|
||||
}
|
||||
|
||||
void BuildGroup::fireCurrentPanelChangeSignal()
|
||||
{
|
||||
for(int i=0;i<_currentPanelChangeSignalDar.getCount();i++)
|
||||
{
|
||||
_currentPanelChangeSignalDar[i]->valueChanged(null);
|
||||
}
|
||||
}
|
||||
|
||||
Panel* BuildGroup::getCurrentPanel()
|
||||
{
|
||||
return _currentPanel;
|
||||
}
|
||||
|
||||
void BuildGroup::panelAdded(Panel* panel,const char* panelName)
|
||||
{
|
||||
assert(panel);
|
||||
|
||||
_panelDar.addElement(panel);
|
||||
_panelNameDar.addElement(vgui_strdup(panelName));
|
||||
}
|
||||
|
||||
void BuildGroup::copyPropertiesToClipboard()
|
||||
{
|
||||
char text[32768];
|
||||
text[0]=0;
|
||||
|
||||
for(int i=0;i<_panelDar.getCount();i++)
|
||||
{
|
||||
char buf[512];
|
||||
_panelDar[i]->getPersistanceText(buf,sizeof(buf));
|
||||
strcat(text,_panelNameDar[i]);
|
||||
strcat(text,buf);
|
||||
}
|
||||
|
||||
App::getInstance()->setClipboardText(text,strlen(text));
|
||||
|
||||
vgui_printf("Copied to clipboard\n");
|
||||
}
|
|
@ -1,273 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_Button.h>
|
||||
#include<VGUI_ButtonController.h>
|
||||
#include<VGUI_InputSignal.h>
|
||||
#include<VGUI_ButtonGroup.h>
|
||||
#include<VGUI_TreeFolder.h>
|
||||
#include<VGUI_ActionSignal.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class FooDefaultButtonController : public ButtonController, public InputSignal
|
||||
{
|
||||
public:
|
||||
FooDefaultButtonController(Button* button)
|
||||
{
|
||||
_button=button;
|
||||
}
|
||||
public:
|
||||
virtual void addSignals(Button* button)
|
||||
{
|
||||
button->addInputSignal(this);
|
||||
}
|
||||
virtual void removeSignals(Button* button)
|
||||
{
|
||||
button->removeInputSignal(this);
|
||||
}
|
||||
public:
|
||||
virtual void cursorMoved(int x,int y,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void cursorEntered(Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void cursorExited(Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void mousePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
if(_button->isEnabled())
|
||||
{
|
||||
if(_button->isMouseClickEnabled(code))
|
||||
{
|
||||
_button->setSelected(true);
|
||||
_button->repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void mouseDoublePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void mouseReleased(MouseCode code,Panel* panel)
|
||||
{
|
||||
if(_button->isEnabled())
|
||||
{
|
||||
if(_button->isMouseClickEnabled(code))
|
||||
{
|
||||
_button->setSelected(false);
|
||||
_button->fireActionSignal();
|
||||
_button->repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void mouseWheeled(int delta,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyPressed(KeyCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyTyped(KeyCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyReleased(KeyCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyFocusTicked(Panel* panel)
|
||||
{
|
||||
}
|
||||
protected:
|
||||
Button* _button;
|
||||
};
|
||||
}
|
||||
|
||||
void Button::init()
|
||||
{
|
||||
_armed=false;
|
||||
_selected=false;
|
||||
_buttonBorderEnabled=true;
|
||||
_mouseClickMask=0;
|
||||
_buttonController=null;
|
||||
_buttonGroup=null;
|
||||
setMouseClickEnabled(MOUSE_LEFT,true);
|
||||
setButtonController(new FooDefaultButtonController(this));
|
||||
}
|
||||
|
||||
Button::Button(const char* text,int x,int y,int wide,int tall) : Label(text,x,y,wide,tall)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
Button::Button(const char* text,int x,int y) : Label(text,x,y)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
void Button::setButtonBorderEnabled(bool state)
|
||||
{
|
||||
_buttonBorderEnabled=state;
|
||||
repaint();
|
||||
}
|
||||
|
||||
void Button::setSelected(bool state)
|
||||
{
|
||||
if(_buttonGroup!=null)
|
||||
{
|
||||
_buttonGroup->setSelected(this);
|
||||
return;
|
||||
}
|
||||
|
||||
setSelectedDirect(state);
|
||||
}
|
||||
|
||||
void Button::setSelectedDirect(bool state)
|
||||
{
|
||||
_selected=state;
|
||||
repaint();
|
||||
}
|
||||
|
||||
void Button::setArmed(bool state)
|
||||
{
|
||||
_armed=state;
|
||||
repaint();
|
||||
}
|
||||
|
||||
bool Button::isArmed()
|
||||
{
|
||||
return _armed;
|
||||
}
|
||||
|
||||
void Button::doClick()
|
||||
{
|
||||
setSelected(true);
|
||||
fireActionSignal();
|
||||
setSelected(false);
|
||||
}
|
||||
|
||||
bool Button::isSelected()
|
||||
{
|
||||
return _selected;
|
||||
}
|
||||
|
||||
void Button::paintBackground()
|
||||
{
|
||||
int wide,tall;
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
if(isSelected())
|
||||
{
|
||||
drawSetColor(Scheme::sc_secondary2);
|
||||
drawFilledRect(0,0,wide,tall);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawSetColor(Scheme::sc_secondary3);
|
||||
drawFilledRect(0,0,wide,tall);
|
||||
|
||||
if(_buttonBorderEnabled)
|
||||
{
|
||||
drawSetColor(Scheme::sc_secondary1);
|
||||
drawFilledRect(0,0,_size[0]-1,1); // top
|
||||
drawFilledRect(2,_size[1]-2,_size[0]-1,_size[1]-1); // bottom
|
||||
drawFilledRect(0,1,1,_size[1]-1); // left
|
||||
drawFilledRect(_size[0]-2,2,_size[0]-1,_size[1]-2); // right
|
||||
|
||||
drawSetColor(Scheme::sc_white);
|
||||
drawFilledRect(1,1,_size[0]-2,2); // top
|
||||
drawFilledRect(1,_size[1]-1,_size[0],_size[1]); // bottom
|
||||
drawFilledRect(1,2,2,_size[1]-2); // left
|
||||
drawFilledRect(_size[0]-1,1,_size[0],_size[1]-1); // right
|
||||
}
|
||||
}
|
||||
|
||||
if(isArmed())
|
||||
{
|
||||
drawSetColor(Scheme::sc_white);
|
||||
drawFilledRect(0,0,wide,2);
|
||||
drawFilledRect(0,2,2,tall);
|
||||
|
||||
drawSetColor(Scheme::sc_secondary2);
|
||||
drawFilledRect(2,tall-2,wide,tall);
|
||||
drawFilledRect(wide-2,2,wide,tall-1);
|
||||
|
||||
drawSetColor(Scheme::sc_secondary1);
|
||||
drawFilledRect(1,tall-1,wide,tall);
|
||||
drawFilledRect(wide-1,1,wide,tall-1);
|
||||
}
|
||||
}
|
||||
|
||||
void Button::setButtonGroup(ButtonGroup* buttonGroup)
|
||||
{
|
||||
_buttonGroup=buttonGroup;
|
||||
|
||||
if(_buttonGroup!=null)
|
||||
{
|
||||
_buttonGroup->addButton(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Button::setMouseClickEnabled(MouseCode code,bool state)
|
||||
{
|
||||
if(state)
|
||||
{
|
||||
//set bit to 1
|
||||
_mouseClickMask|=1<<((int)(code+1));
|
||||
}
|
||||
else
|
||||
{
|
||||
//set bit to 0
|
||||
_mouseClickMask&=~(1<<((int)(code+1)));
|
||||
}
|
||||
}
|
||||
|
||||
bool Button::isMouseClickEnabled(MouseCode code)
|
||||
{
|
||||
if(_mouseClickMask&(1<<((int)(code+1))))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Button::addActionSignal(ActionSignal* s)
|
||||
{
|
||||
_actionSignalDar.putElement(s);
|
||||
}
|
||||
|
||||
void Button::fireActionSignal()
|
||||
{
|
||||
for(int i=0;i<_actionSignalDar.getCount();i++)
|
||||
{
|
||||
_actionSignalDar[i]->actionPerformed(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Button::setButtonController(ButtonController* buttonController)
|
||||
{
|
||||
if(_buttonController!=null)
|
||||
{
|
||||
_buttonController->removeSignals(this);
|
||||
}
|
||||
|
||||
_buttonController=buttonController;
|
||||
_buttonController->addSignals(this);
|
||||
}
|
||||
|
||||
Panel* Button::createPropertyPanel()
|
||||
{
|
||||
Panel* parentPropertyPanel=Label::createPropertyPanel();
|
||||
|
||||
TreeFolder* folder=new TreeFolder("Button");
|
||||
parentPropertyPanel->addChild(folder);
|
||||
folder->addChild(new Label("setSelected"));
|
||||
folder->addChild(new Label("setArmed"));
|
||||
|
||||
return parentPropertyPanel;
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_ButtonGroup.h>
|
||||
#include<VGUI_Button.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
void ButtonGroup::addButton(Button* button)
|
||||
{
|
||||
_buttonDar.putElement(button);
|
||||
}
|
||||
|
||||
void ButtonGroup::setSelected(Button* button)
|
||||
{
|
||||
for(int i=0;i<_buttonDar.getCount();i++)
|
||||
{
|
||||
if(_buttonDar[i]!=button)
|
||||
{
|
||||
_buttonDar[i]->setSelectedDirect(false);
|
||||
}
|
||||
}
|
||||
|
||||
button->setSelectedDirect(true);
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_CheckButton.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class FooCheckImage : public Image
|
||||
{
|
||||
public:
|
||||
FooCheckImage(CheckButton* checkButton) : Image()
|
||||
{
|
||||
_checkButton=checkButton;
|
||||
setSize(20,20);
|
||||
}
|
||||
public:
|
||||
virtual void paint()
|
||||
{
|
||||
drawSetTextFont(Scheme::sf_secondary1);
|
||||
drawSetTextColor(Scheme::sc_white);
|
||||
drawPrintChar(0,0,'g');
|
||||
drawSetTextColor(Scheme::sc_secondary2);
|
||||
drawPrintChar(0,0,'c');
|
||||
drawSetTextColor(Scheme::sc_white);
|
||||
drawPrintChar(0,0,'d');
|
||||
drawSetTextColor(Scheme::sc_black);
|
||||
drawPrintChar(0,0,'e');
|
||||
drawSetTextColor(Scheme::sc_secondary3);
|
||||
drawPrintChar(0,0,'f');
|
||||
drawSetTextColor(Scheme::sc_black);
|
||||
if(_checkButton->isSelected())
|
||||
{
|
||||
drawSetTextColor(Scheme::sc_black);
|
||||
drawPrintChar(0,0,'a');
|
||||
}
|
||||
}
|
||||
protected:
|
||||
CheckButton* _checkButton;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
CheckButton::CheckButton(const char* text,int x,int y,int wide,int tall) : ToggleButton(text,x,y,wide,tall)
|
||||
{
|
||||
setTextAlignment(Label::a_east);
|
||||
setImage(new FooCheckImage(this));
|
||||
}
|
||||
|
||||
CheckButton::CheckButton(const char* text,int x,int y) : ToggleButton(text,x,y)
|
||||
{
|
||||
setTextAlignment(Label::a_east);
|
||||
setImage(new FooCheckImage(this));
|
||||
|
||||
int wide,tall;
|
||||
getContentSize(wide,tall);
|
||||
setSize(wide,tall);
|
||||
}
|
||||
|
||||
void CheckButton::paintBackground()
|
||||
{
|
||||
int wide,tall;
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
drawSetColor(Scheme::sc_secondary3);
|
||||
drawFilledRect(0,0,wide,tall);
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_Color.h>
|
||||
#include<VGUI_App.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
void Color::init()
|
||||
{
|
||||
_color[0]=0;
|
||||
_color[1]=0;
|
||||
_color[2]=0;
|
||||
_color[3]=0;
|
||||
_schemeColor=Scheme::sc_user;
|
||||
}
|
||||
|
||||
Color::Color()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
Color::Color(int r,int g,int b,int a)
|
||||
{
|
||||
init();
|
||||
setColor(r,g,b,a);
|
||||
}
|
||||
|
||||
Color::Color(Scheme::SchemeColor sc)
|
||||
{
|
||||
init();
|
||||
setColor(sc);
|
||||
}
|
||||
|
||||
void Color::setColor(int r,int g,int b,int a)
|
||||
{
|
||||
_color[0]=r;
|
||||
_color[1]=g;
|
||||
_color[2]=b;
|
||||
_color[3]=a;
|
||||
_schemeColor=Scheme::sc_user;
|
||||
}
|
||||
|
||||
void Color::setColor(Scheme::SchemeColor sc)
|
||||
{
|
||||
_schemeColor=sc;
|
||||
}
|
||||
|
||||
void Color::getColor(int& r,int& g,int& b,int& a)
|
||||
{
|
||||
if(_schemeColor==Scheme::sc_user)
|
||||
{
|
||||
r=_color[0];
|
||||
g=_color[1];
|
||||
b=_color[2];
|
||||
a=_color[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
App::getInstance()->getScheme()->getColor(_schemeColor,r,g,b,a);
|
||||
}
|
||||
}
|
||||
|
||||
void Color::getColor(Scheme::SchemeColor& sc)
|
||||
{
|
||||
sc=_schemeColor;
|
||||
}
|
||||
|
||||
int Color::operator[](int index)
|
||||
{
|
||||
int co[4];
|
||||
getColor(co[0],co[1],co[2],co[3]);
|
||||
return co[index];
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_ConfigWizard.h>
|
||||
#include<VGUI_TreeFolder.h>
|
||||
#include<VGUI_LineBorder.h>
|
||||
#include<VGUI_LoweredBorder.h>
|
||||
#include<VGUI_Button.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
ConfigWizard::ConfigWizard(int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
||||
{
|
||||
setBorder(new LineBorder());
|
||||
|
||||
_treeFolder=new TreeFolder("DonkeyFoo");
|
||||
_treeFolder->setParent(this);
|
||||
_treeFolder->setBorder(new LoweredBorder());
|
||||
|
||||
_client=new Panel(80,30,64,64);
|
||||
_client->setParent(this);
|
||||
_treeFolder->setBorder(new LineBorder());
|
||||
|
||||
_okButton=new Button("Ok",80,80,60,20);
|
||||
_okButton->setParent(this);
|
||||
|
||||
_cancelButton=new Button("Cancel",120,80);
|
||||
_cancelButton->setParent(this);
|
||||
|
||||
_applyButton=new Button("Apply",160,80);
|
||||
_applyButton->setParent(this);
|
||||
|
||||
_helpButton=new Button("Help",200,80);
|
||||
_helpButton->setParent(this);
|
||||
}
|
||||
|
||||
Panel* ConfigWizard::getClient()
|
||||
{
|
||||
return _client;
|
||||
}
|
||||
|
||||
TreeFolder* ConfigWizard::getFolder()
|
||||
{
|
||||
return _treeFolder;
|
||||
}
|
||||
|
||||
void ConfigWizard::setSize(int wide,int tall)
|
||||
{
|
||||
setSize(wide,tall);
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
_treeFolder->setBounds(10,10,160,tall-60);
|
||||
_client->setBounds(180,10,wide-190,tall-60);
|
||||
_helpButton->setPos(wide-80,tall-25);
|
||||
_applyButton->setPos(wide-150,tall-25);
|
||||
_cancelButton->setPos(wide-220,tall-25);
|
||||
_okButton->setPos(wide-290,tall-25);
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_Cursor.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
Cursor::Cursor(Bitmap* bitmap,int hotspotX,int hotspotY)
|
||||
{
|
||||
_dc=dc_user;
|
||||
privateInit(bitmap,hotspotX,hotspotY);
|
||||
}
|
||||
|
||||
void Cursor::privateInit(Bitmap* bitmap,int hotspotX,int hotspotY)
|
||||
{
|
||||
_hotspot[0]=hotspotX;
|
||||
_hotspot[1]=hotspotY;
|
||||
}
|
||||
|
||||
Bitmap* Cursor::getBitmap()
|
||||
{
|
||||
return _bitmap;
|
||||
}
|
||||
|
||||
Cursor::DefaultCursor Cursor::getDefaultCursor()
|
||||
{
|
||||
return _dc;
|
||||
}
|
||||
|
||||
void Cursor::getHotspot(int& x,int& y)
|
||||
{
|
||||
x=_hotspot[0];
|
||||
x=_hotspot[1];
|
||||
}
|
|
@ -1,235 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_DataInputStream.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
DataInputStream::DataInputStream(InputStream* is)
|
||||
{
|
||||
_is=is;
|
||||
}
|
||||
|
||||
void DataInputStream::seekStart(bool& success)
|
||||
{
|
||||
if(_is==null)
|
||||
{
|
||||
success=false;
|
||||
return;
|
||||
}
|
||||
|
||||
_is->seekStart(success);
|
||||
}
|
||||
|
||||
void DataInputStream::seekRelative(int count,bool& success)
|
||||
{
|
||||
if(_is==null)
|
||||
{
|
||||
success=false;
|
||||
return;
|
||||
}
|
||||
|
||||
_is->seekRelative(count,success);
|
||||
}
|
||||
|
||||
void DataInputStream::seekEnd(bool& success)
|
||||
{
|
||||
if(_is==null)
|
||||
{
|
||||
success=false;
|
||||
return;
|
||||
}
|
||||
|
||||
_is->seekEnd(success);
|
||||
}
|
||||
|
||||
int DataInputStream::getAvailable(bool& success)
|
||||
{
|
||||
if(_is==null)
|
||||
{
|
||||
success=false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return _is->getAvailable(success);
|
||||
}
|
||||
|
||||
void DataInputStream::readUChar(uchar* buf,int count,bool& success)
|
||||
{
|
||||
if(_is==null)
|
||||
{
|
||||
success=false;
|
||||
return;
|
||||
}
|
||||
|
||||
_is->readUChar(buf,count,success);
|
||||
}
|
||||
|
||||
void DataInputStream::close(bool& success)
|
||||
{
|
||||
if(_is==null)
|
||||
{
|
||||
success=false;
|
||||
return;
|
||||
}
|
||||
|
||||
_is->close(success);
|
||||
}
|
||||
|
||||
void DataInputStream::close()
|
||||
{
|
||||
bool success;
|
||||
_is->close(success);
|
||||
}
|
||||
|
||||
bool DataInputStream::readBool(bool& success)
|
||||
{
|
||||
if(_is==null)
|
||||
{
|
||||
success=false;
|
||||
return false;
|
||||
}
|
||||
|
||||
return _is->readUChar(success)!=0;
|
||||
}
|
||||
|
||||
char DataInputStream::readChar(bool& success)
|
||||
{
|
||||
if(_is==null)
|
||||
{
|
||||
success=false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return _is->readUChar(success);
|
||||
}
|
||||
|
||||
uchar DataInputStream::readUChar(bool& success)
|
||||
{
|
||||
if(_is==null)
|
||||
{
|
||||
success=false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return _is->readUChar(success);
|
||||
}
|
||||
|
||||
short DataInputStream::readShort(bool& success)
|
||||
{
|
||||
if(_is==null)
|
||||
{
|
||||
success=false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
short ret;
|
||||
_is->readUChar((uchar*)&ret,sizeof(ret),success);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ushort DataInputStream::readUShort(bool& success)
|
||||
{
|
||||
if(_is==null)
|
||||
{
|
||||
success=false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ushort ret;
|
||||
_is->readUChar((uchar*)&ret,sizeof(ret),success);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int DataInputStream::readInt(bool& success)
|
||||
{
|
||||
if(_is==null)
|
||||
{
|
||||
success=false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ret;
|
||||
_is->readUChar((uchar*)&ret,sizeof(ret),success);
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint DataInputStream::readUInt(bool& success)
|
||||
{
|
||||
if(_is==null)
|
||||
{
|
||||
success=false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint ret;
|
||||
_is->readUChar((uchar*)&ret,sizeof(ret),success);
|
||||
return ret;
|
||||
}
|
||||
|
||||
long DataInputStream::readLong(bool& success)
|
||||
{
|
||||
if(_is==null)
|
||||
{
|
||||
success=false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
long ret;
|
||||
_is->readUChar((uchar*)&ret,sizeof(ret),success);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ulong DataInputStream::readULong(bool& success)
|
||||
{
|
||||
if(_is==null)
|
||||
{
|
||||
success=false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ulong ret;
|
||||
_is->readUChar((uchar*)&ret,sizeof(ret),success);
|
||||
return ret;
|
||||
}
|
||||
|
||||
float DataInputStream::readFloat(bool& success)
|
||||
{
|
||||
if(_is==null)
|
||||
{
|
||||
success=false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
float ret;
|
||||
_is->readUChar((uchar*)&ret,sizeof(ret),success);
|
||||
return ret;
|
||||
}
|
||||
|
||||
double DataInputStream::readDouble(bool& success)
|
||||
{
|
||||
if(_is==null)
|
||||
{
|
||||
success=false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
double ret;
|
||||
_is->readUChar((uchar*)&ret,sizeof(ret),success);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void DataInputStream::readLine(char* buf,int bufLen,bool& success)
|
||||
{
|
||||
if(_is==null)
|
||||
{
|
||||
success=false;
|
||||
return;
|
||||
}
|
||||
|
||||
_is->readUChar((uchar*)buf,bufLen,success);
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_Desktop.h>
|
||||
#include<VGUI_TaskBar.h>
|
||||
#include<VGUI_DesktopIcon.h>
|
||||
#include<VGUI_MiniApp.h>
|
||||
#include<VGUI_Frame.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
Desktop::Desktop(int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
||||
{
|
||||
setBgColor(0,128,128,0);
|
||||
setPaintBorderEnabled(false);
|
||||
setPaintBackgroundEnabled(false);
|
||||
setPaintEnabled(false);
|
||||
|
||||
_background=new Panel(0,0,wide,tall-36);
|
||||
_background->setParent(this);
|
||||
_background->setBgColor(0,128,128,0);
|
||||
_foreground=new Panel(0,0,wide,tall-36);
|
||||
_foreground->setPaintBorderEnabled(false);
|
||||
_foreground->setPaintBackgroundEnabled(false);
|
||||
_foreground->setPaintEnabled(false);
|
||||
_foreground->setParent(this);
|
||||
|
||||
_taskBar=new TaskBar(0,tall-36,wide,36);
|
||||
_taskBar->setParent(this);
|
||||
|
||||
_cascade[0]=50;
|
||||
_cascade[1]=50;
|
||||
}
|
||||
|
||||
void Desktop::setSize(int wide,int tall)
|
||||
{
|
||||
Panel::setSize(wide,tall);
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
_background->setBounds(0,0,wide,tall-36);
|
||||
_foreground->setBounds(0,0,wide,tall-36);
|
||||
_taskBar->setBounds(0,tall-36,wide,36);
|
||||
}
|
||||
|
||||
Panel* Desktop::getBackground()
|
||||
{
|
||||
return _background;
|
||||
}
|
||||
|
||||
Panel* Desktop::getForeground()
|
||||
{
|
||||
return _foreground;
|
||||
}
|
||||
|
||||
void Desktop::addIcon(DesktopIcon* icon)
|
||||
{
|
||||
icon->setDesktop(this);
|
||||
icon->setParent(_foreground);
|
||||
icon->setPos(10,10);
|
||||
_desktopIconDar.addElement(icon);
|
||||
}
|
||||
|
||||
void Desktop::iconActivated(DesktopIcon* icon)
|
||||
{
|
||||
MiniApp* miniApp=icon->getMiniApp();
|
||||
Frame* frame=miniApp->createInstance();
|
||||
|
||||
if(frame!=null)
|
||||
{
|
||||
frame->setPos(_cascade[0],_cascade[1]);
|
||||
frame->setParent(_foreground);
|
||||
_taskBar->addFrame(frame);
|
||||
frame->requestFocus();
|
||||
|
||||
_cascade[0]+=25;
|
||||
_cascade[1]+=50;
|
||||
|
||||
if(_cascade[1]>400)
|
||||
{
|
||||
_cascade[0]=50;
|
||||
_cascade[1]=50;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Desktop::arrangeIcons()
|
||||
{
|
||||
int x=15;
|
||||
int y=10;
|
||||
for(int i=0;i<_desktopIconDar.getCount();i++)
|
||||
{
|
||||
_desktopIconDar[i]->setPos(x,y);
|
||||
y+=60;
|
||||
|
||||
if(y>340)
|
||||
{
|
||||
x+=50;
|
||||
y=10;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,165 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_DesktopIcon.h>
|
||||
#include<VGUI_Image.h>
|
||||
#include<VGUI_InputSignal.h>
|
||||
#include<VGUI_App.h>
|
||||
#include<VGUI_Desktop.h>
|
||||
#include<VGUI_Font.h>
|
||||
#include<VGUI_MiniApp.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class FooHandler : public InputSignal
|
||||
{
|
||||
public:
|
||||
FooHandler(DesktopIcon* desktopIcon)
|
||||
{
|
||||
_desktopIcon=desktopIcon;
|
||||
_dragging=false;
|
||||
}
|
||||
public:
|
||||
virtual void cursorMoved(int x,int y,Panel* panel)
|
||||
{
|
||||
if(_dragging)
|
||||
{
|
||||
panel->getApp()->getCursorPos(x,y);
|
||||
_desktopIcon->setPos(x+_dragOrgPos[0]-_dragStart[0],y+_dragOrgPos[1]-_dragStart[1]);
|
||||
|
||||
if(_desktopIcon->getParent()!=null)
|
||||
{
|
||||
_desktopIcon->getParent()->repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void cursorEntered(Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void cursorExited(Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void mousePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
int x,y;
|
||||
panel->getApp()->getCursorPos(x,y);
|
||||
_dragging=true;
|
||||
_dragStart[0]=x;
|
||||
_dragStart[1]=y;
|
||||
_desktopIcon->getPos(_dragOrgPos[0],_dragOrgPos[1]);
|
||||
|
||||
panel->getApp()->setMouseCapture(panel);
|
||||
_desktopIcon->requestFocus();
|
||||
}
|
||||
virtual void mouseDoublePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
_desktopIcon->doActivate();
|
||||
}
|
||||
virtual void mouseReleased(MouseCode code,Panel* panel)
|
||||
{
|
||||
_dragging=false;
|
||||
panel->getApp()->setMouseCapture(null);
|
||||
}
|
||||
virtual void mouseWheeled(int delta,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyPressed(KeyCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyTyped(KeyCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyReleased(KeyCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyFocusTicked(Panel* panel)
|
||||
{
|
||||
}
|
||||
protected:
|
||||
DesktopIcon* _desktopIcon;
|
||||
bool _dragging;
|
||||
int _dragOrgPos[2];
|
||||
int _dragStart[2];
|
||||
};
|
||||
}
|
||||
|
||||
DesktopIcon::DesktopIcon(MiniApp* miniApp,Image* image) : Panel(0,0,32,50)
|
||||
{
|
||||
_desktop=null;
|
||||
_miniApp=miniApp;
|
||||
setImage(image);
|
||||
|
||||
if(image!=null)
|
||||
{
|
||||
int wide,tall;
|
||||
image->getSize(wide,tall);
|
||||
setSize(wide,tall);
|
||||
}
|
||||
|
||||
addInputSignal(new FooHandler(this));
|
||||
}
|
||||
|
||||
void DesktopIcon::paintBackground()
|
||||
{
|
||||
Panel::paintBackground();
|
||||
|
||||
int wide,tall;
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
if(_image!=null)
|
||||
{
|
||||
_image->doPaint(this);
|
||||
}
|
||||
|
||||
Font* font=getApp()->getScheme()->getFont(Scheme::sf_primary2);
|
||||
|
||||
drawSetTextFont(Scheme::sf_primary1);
|
||||
drawSetTextColor(Scheme::sc_black);
|
||||
|
||||
if(_miniApp!=null)
|
||||
{
|
||||
char buf[256];
|
||||
_miniApp->getName(buf,sizeof(buf));
|
||||
int tWide,tTall;
|
||||
font->getTextSize(buf,tWide,tTall);
|
||||
drawSetTextColor(255,255,255,0);
|
||||
drawSetTextPos(wide/2-(tWide/2),tall-20);
|
||||
drawPrintText(buf,strlen(buf));
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopIcon::setDesktop(Desktop* desktop)
|
||||
{
|
||||
_desktop=desktop;
|
||||
}
|
||||
|
||||
void DesktopIcon::doActivate()
|
||||
{
|
||||
if(_desktop!=null)
|
||||
{
|
||||
_desktop->iconActivated(this);
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopIcon::setImage(Image* image)
|
||||
{
|
||||
_image=image;
|
||||
|
||||
if(_image!=null)
|
||||
{
|
||||
int wide,tall;
|
||||
_image->getSize(wide,tall);
|
||||
setSize(wide,tall);
|
||||
}
|
||||
}
|
||||
|
||||
MiniApp* DesktopIcon::getMiniApp()
|
||||
{
|
||||
return _miniApp;
|
||||
}
|
|
@ -1,602 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<stdio.h>
|
||||
#include<stdarg.h>
|
||||
#include<VGUI_EditPanel.h>
|
||||
#include<VGUI_InputSignal.h>
|
||||
#include<VGUI_App.h>
|
||||
#include<VGUI_Font.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class FooDefaultEditPanelSignal : public InputSignal
|
||||
{
|
||||
public:
|
||||
FooDefaultEditPanelSignal(EditPanel* editPanel)
|
||||
{
|
||||
_editPanel=editPanel;
|
||||
}
|
||||
public:
|
||||
virtual void cursorMoved(int x,int y,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void cursorEntered(Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void cursorExited(Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void mousePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
_editPanel->requestFocus();
|
||||
_editPanel->repaint();
|
||||
}
|
||||
virtual void mouseDoublePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void mouseReleased(MouseCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void mouseWheeled(int delta,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyPressed(KeyCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyTyped(KeyCode code,Panel* panel)
|
||||
{
|
||||
bool shift=(_editPanel->isKeyDown(KEY_LSHIFT)||_editPanel->isKeyDown(KEY_RSHIFT));
|
||||
|
||||
switch(code)
|
||||
{
|
||||
case KEY_UP:
|
||||
{
|
||||
_editPanel->doCursorUp();
|
||||
break;
|
||||
}
|
||||
case KEY_DOWN:
|
||||
{
|
||||
_editPanel->doCursorDown();
|
||||
break;
|
||||
}
|
||||
case KEY_LEFT:
|
||||
{
|
||||
_editPanel->doCursorLeft();
|
||||
break;
|
||||
}
|
||||
case KEY_RIGHT:
|
||||
{
|
||||
_editPanel->doCursorRight();
|
||||
break;
|
||||
}
|
||||
case KEY_HOME:
|
||||
{
|
||||
_editPanel->doCursorToStartOfLine();
|
||||
break;
|
||||
}
|
||||
case KEY_END:
|
||||
{
|
||||
_editPanel->doCursorToEndOfLine();
|
||||
break;
|
||||
}
|
||||
case KEY_BACKSPACE:
|
||||
{
|
||||
_editPanel->doCursorBackspace();
|
||||
break;
|
||||
}
|
||||
case KEY_DELETE:
|
||||
{
|
||||
_editPanel->doCursorDelete();
|
||||
break;
|
||||
}
|
||||
case KEY_ENTER:
|
||||
{
|
||||
_editPanel->doCursorNewLine();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
_editPanel->doCursorInsertChar(_editPanel->getApp()->getKeyCodeChar(code,shift));
|
||||
break;
|
||||
}
|
||||
case KEY_LSHIFT:
|
||||
case KEY_RSHIFT:
|
||||
case KEY_LALT:
|
||||
case KEY_RALT:
|
||||
case KEY_LCONTROL:
|
||||
case KEY_RCONTROL:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void keyReleased(KeyCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyFocusTicked(Panel* panel)
|
||||
{
|
||||
bool blink;
|
||||
int nextBlinkTime;
|
||||
_editPanel->getCursorBlink(blink,nextBlinkTime);
|
||||
|
||||
int time=_editPanel->getApp()->getTimeMillis();
|
||||
if(time>nextBlinkTime)
|
||||
{
|
||||
_editPanel->setCursorBlink(!blink);
|
||||
}
|
||||
}
|
||||
private:
|
||||
EditPanel* _editPanel;
|
||||
};
|
||||
}
|
||||
|
||||
EditPanel::EditPanel(int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
||||
{
|
||||
_cursor[0]=0;
|
||||
_cursor[1]=0;
|
||||
_font=null;
|
||||
setCursorBlink(true);
|
||||
addInputSignal(new FooDefaultEditPanelSignal(this));
|
||||
getLine(0);
|
||||
}
|
||||
|
||||
void EditPanel::paintBackground()
|
||||
{
|
||||
int wide,tall;
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
drawSetColor(Scheme::sc_white);
|
||||
drawFilledRect(0,0,wide,tall);
|
||||
}
|
||||
|
||||
void EditPanel::addLine()
|
||||
{
|
||||
}
|
||||
|
||||
Dar<char>* EditPanel::getLine(int lineIndex)
|
||||
{
|
||||
if(lineIndex<0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if((lineIndex==0)&&(_lineDarDar.getCount()==0))
|
||||
{
|
||||
Dar<char>* lineDar=new Dar<char>;
|
||||
_lineDarDar.addElement(lineDar);
|
||||
return lineDar;
|
||||
}
|
||||
|
||||
if(lineIndex>=_lineDarDar.getCount())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return _lineDarDar[lineIndex];
|
||||
}
|
||||
|
||||
void EditPanel::getText(int lineIndex, int offset,char* buf,int bufLen)
|
||||
{
|
||||
if((lineIndex>=0)&&(lineIndex<_lineDarDar.getCount()))
|
||||
{
|
||||
Dar<char>* dataStr=_lineDarDar[lineIndex];
|
||||
|
||||
int j=0;
|
||||
for(int i=offset;i<dataStr->getCount()&&(j<bufLen-1);i++,j++)
|
||||
{
|
||||
buf[i-offset]=(*dataStr)[i];
|
||||
}
|
||||
buf[j]=0;
|
||||
}
|
||||
}
|
||||
|
||||
void EditPanel::setChar(Dar<char>* lineDar,int x,char ch,char fill)
|
||||
{
|
||||
if((lineDar==null)||(x<0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int count=lineDar->getCount();
|
||||
if(x>=count)
|
||||
{
|
||||
lineDar->ensureCapacity(x+1);
|
||||
lineDar->setCount(x+1);
|
||||
for(int i=count;i<x;i++)
|
||||
{
|
||||
lineDar->setElementAt(fill,i);
|
||||
}
|
||||
}
|
||||
lineDar->setElementAt(ch,x);
|
||||
}
|
||||
|
||||
void EditPanel::setChar(Dar<char>* lineDar,int x,char ch)
|
||||
{
|
||||
setChar(lineDar,x,ch,' ');
|
||||
}
|
||||
|
||||
int EditPanel::getLineCount()
|
||||
{
|
||||
return _lineDarDar.getCount();
|
||||
}
|
||||
|
||||
int EditPanel::getVisibleLineCount()
|
||||
{
|
||||
int wide,tall;
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
Font* font=_font;
|
||||
if(font==null)
|
||||
{
|
||||
font=getApp()->getScheme()->getFont(Scheme::sf_primary1);
|
||||
}
|
||||
|
||||
return tall/font->getTall();
|
||||
}
|
||||
|
||||
void EditPanel::setCursorBlink(bool state)
|
||||
{
|
||||
_cursorBlink=state;
|
||||
_cursorNextBlinkTime=getApp()->getTimeMillis()+400;
|
||||
repaint();
|
||||
}
|
||||
|
||||
void EditPanel::getCursorBlink(bool& blink,int& nextBlinkTime)
|
||||
{
|
||||
blink=_cursorBlink;
|
||||
nextBlinkTime=_cursorNextBlinkTime;
|
||||
}
|
||||
|
||||
void EditPanel::shiftLineLeft(Dar<char>* lineDar,int x,int count)
|
||||
{
|
||||
if((x<0)||(x>lineDar->getCount()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(count<0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i=x;i<lineDar->getCount();i++)
|
||||
{
|
||||
int xx=x-count;
|
||||
if(xx>=0)
|
||||
{
|
||||
setChar(lineDar,xx,(*lineDar)[i]);
|
||||
}
|
||||
}
|
||||
lineDar->setCount(lineDar->getCount()-count);
|
||||
}
|
||||
|
||||
void EditPanel::shiftLineRight(Dar<char>* lineDar,int x,int count)
|
||||
{
|
||||
if(x<0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(count<0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i=lineDar->getCount()-1;i>=x;i--)
|
||||
{
|
||||
setChar(lineDar,i-count,(*lineDar)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int EditPanel::spatialCharOffsetBetweenTwoLines(Dar<char>* srcDar,Dar<char>* dstDar,int x)
|
||||
{
|
||||
if((srcDar==null)||(dstDar==null))
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
Font* font=_font;
|
||||
if(font==null)
|
||||
{
|
||||
font=getApp()->getScheme()->getFont(Scheme::sf_primary1);
|
||||
}
|
||||
|
||||
int i;
|
||||
|
||||
int x0=0;
|
||||
for(i=0;i<x;i++)
|
||||
{
|
||||
char ch=' ';
|
||||
if(i<srcDar->getCount())
|
||||
{
|
||||
ch=(*srcDar)[i];
|
||||
}
|
||||
|
||||
int a,b,c;
|
||||
font->getCharABCwide(ch,a,b,c);
|
||||
x0+=a+b+c;
|
||||
}
|
||||
|
||||
int x1=0;
|
||||
for(i=0;;i++)
|
||||
{
|
||||
char ch=' ';
|
||||
if(i<dstDar->getCount())
|
||||
{
|
||||
ch=(*dstDar)[i];
|
||||
}
|
||||
|
||||
int a,b,c;
|
||||
font->getCharABCwide(ch,a,b,c);
|
||||
|
||||
int mid=x1+(a+b+c)/2;
|
||||
if (x1>x0)
|
||||
{
|
||||
if(mid>x0)
|
||||
{
|
||||
}
|
||||
else if (x1+(a+b+c)>x0)
|
||||
{
|
||||
return i+1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(mid>x0)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
else if(x1+(a+b+c)>x0)
|
||||
{
|
||||
return i+1;
|
||||
}
|
||||
}
|
||||
x1+=a+b+c;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void EditPanel::paint()
|
||||
{
|
||||
Font* font=_font;
|
||||
if(font==null)
|
||||
{
|
||||
font=getApp()->getScheme()->getFont(Scheme::sf_primary1);
|
||||
}
|
||||
|
||||
drawSetTextFont(font);
|
||||
drawSetTextColor(Scheme::sc_black);
|
||||
|
||||
int yy=0;
|
||||
for(int j=0;j<_lineDarDar.getCount();j++)
|
||||
{
|
||||
int cx=0;
|
||||
int xx=0;
|
||||
Dar<char>* lineDar=_lineDarDar[j];
|
||||
for(int i=0;i<lineDar->getCount();i++)
|
||||
{
|
||||
char ch=(*lineDar)[i];
|
||||
drawPrintChar(xx,yy,ch);
|
||||
|
||||
if((_cursor[0]==i)&&(_cursor[1]==j))
|
||||
{
|
||||
cx=xx;
|
||||
}
|
||||
|
||||
int a,b,c;
|
||||
font->getCharABCwide(ch,a,b,c);
|
||||
xx+=a+b+c;
|
||||
}
|
||||
|
||||
if((_cursor[1]==j)&&_cursorBlink)
|
||||
{
|
||||
if(_cursor[0]>=lineDar->getCount())
|
||||
{
|
||||
int a,b,c;
|
||||
font->getCharABCwide(' ',a,b,c);
|
||||
cx=xx+(_cursor[0]-lineDar->getCount())*(a+b+c);
|
||||
}
|
||||
drawSetColor(255,0,0,0);
|
||||
drawFilledRect(cx-1,yy,cx+1,yy+font->getTall());
|
||||
}
|
||||
yy+=font->getTall();
|
||||
}
|
||||
}
|
||||
|
||||
void EditPanel::doCursorUp()
|
||||
{
|
||||
_cursor[0]=spatialCharOffsetBetweenTwoLines(getLine(_cursor[1]),getLine(_cursor[1]-1),_cursor[0]);
|
||||
_cursor[1]--;
|
||||
|
||||
if(_cursor[1]<0)
|
||||
{
|
||||
_cursor[1]=0;
|
||||
}
|
||||
|
||||
setCursorBlink(true);
|
||||
repaint();
|
||||
}
|
||||
|
||||
void EditPanel::doCursorDown()
|
||||
{
|
||||
int lCount=getVisibleLineCount();
|
||||
_cursor[0]=spatialCharOffsetBetweenTwoLines(getLine(_cursor[1]),getLine(_cursor[1]+1),_cursor[0]);
|
||||
|
||||
if(lCount>getLineCount())
|
||||
{
|
||||
lCount=getLineCount();
|
||||
}
|
||||
|
||||
if(_cursor[1]+1>=lCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_cursor[1]++;
|
||||
setCursorBlink(true);
|
||||
repaint();
|
||||
}
|
||||
|
||||
void EditPanel::doCursorLeft()
|
||||
{
|
||||
_cursor[0]--;
|
||||
|
||||
if(_cursor[0]<0)
|
||||
{
|
||||
_cursor[0]=0;
|
||||
}
|
||||
|
||||
setCursorBlink(true);
|
||||
repaint();
|
||||
}
|
||||
|
||||
void EditPanel::doCursorRight()
|
||||
{
|
||||
_cursor[0]++;
|
||||
setCursorBlink(true);
|
||||
repaint();
|
||||
}
|
||||
|
||||
void EditPanel::doCursorToStartOfLine()
|
||||
{
|
||||
_cursor[0]=0;
|
||||
setCursorBlink(true);
|
||||
repaint();
|
||||
}
|
||||
|
||||
void EditPanel::doCursorToEndOfLine()
|
||||
{
|
||||
Dar<char>* lineDar=getLine(_cursor[1]);
|
||||
if(lineDar==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_cursor[0]=lineDar->getCount();
|
||||
setCursorBlink(true);
|
||||
repaint();
|
||||
}
|
||||
|
||||
void EditPanel::doCursorInsertChar(char ch)
|
||||
{
|
||||
Dar<char>* lineDar=getLine(_cursor[1]);
|
||||
if(lineDar==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
shiftLineRight(lineDar,_cursor[0],1);
|
||||
setChar(lineDar,_cursor[0],ch);
|
||||
doCursorRight();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void EditPanel::doCursorBackspace()
|
||||
{
|
||||
Dar<char>* lineDar=getLine(_cursor[1]);
|
||||
if(lineDar==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(_cursor[0]==0)
|
||||
{
|
||||
Dar<char>* prevLineDar=getLine(_cursor[1]-1);
|
||||
if(prevLineDar==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int len=prevLineDar->getCount();
|
||||
for(int i=0;i<lineDar->getCount();i++)
|
||||
{
|
||||
setChar(prevLineDar,len+i,(*lineDar)[i]);
|
||||
}
|
||||
|
||||
if(_cursor[1]>=0)
|
||||
{
|
||||
_lineDarDar.removeElementAt(_cursor[1]);
|
||||
doCursorUp();
|
||||
_cursor[0]=prevLineDar->getCount();
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
else
|
||||
{
|
||||
shiftLineLeft(lineDar,_cursor[0],1);
|
||||
doCursorLeft();
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
void EditPanel::doCursorNewLine()
|
||||
{
|
||||
Dar<char>* lineDar=getLine(_cursor[1]);
|
||||
if(lineDar==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Dar<char>* newLineDar=new Dar<char>;
|
||||
_lineDarDar.insertElementAt(newLineDar,_cursor[1]+1);
|
||||
|
||||
for(int i=_cursor[0];i<lineDar->getCount();i++)
|
||||
{
|
||||
setChar(newLineDar,i-_cursor[0],(*lineDar)[i]);
|
||||
}
|
||||
lineDar->setCount(_cursor[0]);
|
||||
|
||||
_cursor[0]=0;
|
||||
doCursorDown();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void EditPanel::doCursorDelete()
|
||||
{
|
||||
Dar<char>* lineDar=getLine(_cursor[1]);
|
||||
if(lineDar==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
doCursorRight();
|
||||
shiftLineRight(lineDar,_cursor[0],1);
|
||||
doCursorLeft();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void EditPanel::doCursorPrintf(char* format,...)
|
||||
{
|
||||
va_list argList;
|
||||
va_start(argList,format);
|
||||
char buf[8192];
|
||||
vsprintf(buf,format,argList);
|
||||
va_end(argList);
|
||||
|
||||
for(int i=0;i<sizeof(buf);i++)
|
||||
{
|
||||
if(buf[i]==0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(buf[i]=='\n')
|
||||
{
|
||||
doCursorNewLine();
|
||||
continue;
|
||||
}
|
||||
doCursorInsertChar(buf[i]);
|
||||
}
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
void EditPanel::setFont(Font* font)
|
||||
{
|
||||
_font=font;
|
||||
repaint();
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_EtchedBorder.h>
|
||||
#include<VGUI_Panel.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
EtchedBorder::EtchedBorder() : Border()
|
||||
{
|
||||
setInset(2,2,2,2);
|
||||
}
|
||||
|
||||
void EtchedBorder::paint(Panel* panel)
|
||||
{
|
||||
int wide,tall;
|
||||
panel->getSize(wide,tall);
|
||||
|
||||
drawSetColor(Scheme::sc_white);
|
||||
drawFilledRect(0,0,wide,2);
|
||||
drawFilledRect(0,tall-2,wide,tall);
|
||||
drawFilledRect(0,2,2,tall-2);
|
||||
drawFilledRect(wide-2,2,wide,tall-2);
|
||||
|
||||
drawSetColor(Scheme::sc_secondary2);
|
||||
drawFilledRect(0,0,wide-1,1);
|
||||
drawFilledRect(0,tall-2,wide-1,tall-1);
|
||||
drawFilledRect(0,1,1,tall-2);
|
||||
drawFilledRect(wide-2,1,wide-1,tall-2);
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_FileInputStream.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
FileInputStream::FileInputStream(const char* fileName,bool textMode)
|
||||
{
|
||||
_fp=fopen(fileName,textMode?"rt":"rb");
|
||||
}
|
||||
|
||||
void FileInputStream::seekStart(bool& success)
|
||||
{
|
||||
if(_fp==null)
|
||||
{
|
||||
success=false;
|
||||
return;
|
||||
}
|
||||
|
||||
success=(fseek(_fp,0,SEEK_SET)!=0);
|
||||
}
|
||||
|
||||
void FileInputStream::seekRelative(int count,bool& success)
|
||||
{
|
||||
if(_fp==null)
|
||||
{
|
||||
success=false;
|
||||
return;
|
||||
}
|
||||
|
||||
success=(fseek(_fp,SEEK_CUR,count)!=0);
|
||||
}
|
||||
|
||||
void FileInputStream::seekEnd(bool& success)
|
||||
{
|
||||
if(_fp==null)
|
||||
{
|
||||
success=false;
|
||||
return;
|
||||
}
|
||||
|
||||
success=(fseek(_fp,SEEK_END,0)!=0);
|
||||
}
|
||||
|
||||
int FileInputStream::getAvailable(bool& success)
|
||||
{
|
||||
if(_fp==null)
|
||||
{
|
||||
success=false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
success=false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uchar FileInputStream::readUChar(bool& success)
|
||||
{
|
||||
if(_fp==null)
|
||||
{
|
||||
success=false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uchar ret;
|
||||
success=(fread(&ret,sizeof(ret),1,_fp)==1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void FileInputStream::readUChar(uchar* buf,int count,bool& success)
|
||||
{
|
||||
if(_fp==null)
|
||||
{
|
||||
success=false;
|
||||
return;
|
||||
}
|
||||
|
||||
success=(fread(buf,count,1,_fp)==1);
|
||||
}
|
||||
|
||||
void FileInputStream::close(bool& success)
|
||||
{
|
||||
if(_fp==null)
|
||||
{
|
||||
success=false;
|
||||
return;
|
||||
}
|
||||
|
||||
success=(fclose(_fp)==0);
|
||||
}
|
||||
|
||||
void FileInputStream::close()
|
||||
{
|
||||
bool success;
|
||||
close(success);
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_FlowLayout.h>
|
||||
#include<VGUI_Panel.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
FlowLayout::FlowLayout(int hgap) : Layout()
|
||||
{
|
||||
_hgap=hgap;
|
||||
}
|
||||
|
||||
void FlowLayout::performLayout(Panel* panel)
|
||||
{
|
||||
int xx=0;
|
||||
for(int i=0;i<panel->getChildCount();i++)
|
||||
{
|
||||
int x,y,wide,tall;
|
||||
Panel* child=panel->getChild(i);
|
||||
child->getBounds(x,y,wide,tall);
|
||||
child->setPos(xx,y);
|
||||
xx+=wide+_hgap;
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_FocusNavGroup.h>
|
||||
#include<VGUI_Panel.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
FocusNavGroup::FocusNavGroup()
|
||||
{
|
||||
_currentIndex=0;
|
||||
}
|
||||
|
||||
void FocusNavGroup::addPanel(Panel* panel)
|
||||
{
|
||||
_panelDar.putElement(panel);
|
||||
}
|
||||
|
||||
void FocusNavGroup::requestFocusPrev()
|
||||
{
|
||||
if(_panelDar.getCount()==0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_currentIndex--;
|
||||
if(_currentIndex<0)
|
||||
{
|
||||
_currentIndex=_panelDar.getCount()-1;
|
||||
}
|
||||
_panelDar[_currentIndex]->requestFocus();
|
||||
}
|
||||
|
||||
void FocusNavGroup::requestFocusNext()
|
||||
{
|
||||
if(_panelDar.getCount()==0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_currentIndex++;
|
||||
if(_currentIndex>=_panelDar.getCount())
|
||||
{
|
||||
_currentIndex=0;
|
||||
}
|
||||
_panelDar[_currentIndex]->requestFocus();
|
||||
}
|
||||
|
||||
void FocusNavGroup::setCurrentPanel(Panel* panel)
|
||||
{
|
||||
for(int i=0;i<_panelDar.getCount();i++)
|
||||
{
|
||||
if(_panelDar[i]==panel)
|
||||
{
|
||||
_currentIndex=i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_Font.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
void Font::getTextSize(const char* text,int& wide,int& tall)
|
||||
{
|
||||
wide=0;
|
||||
tall=0;
|
||||
|
||||
if(text==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
tall=getTall();
|
||||
|
||||
int xx=0;
|
||||
for(int i=0;;i++)
|
||||
{
|
||||
char ch=text[i];
|
||||
|
||||
if(ch==0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(ch=='\n')
|
||||
{
|
||||
tall+=getTall();
|
||||
xx=0;
|
||||
continue;
|
||||
}
|
||||
|
||||
int a,b,c;
|
||||
getCharABCwide(ch,a,b,c);
|
||||
xx+=a+b+c;
|
||||
if(xx>wide)
|
||||
{
|
||||
wide=xx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int Font::getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
BaseFontPlat* Font::getPlat()
|
||||
{
|
||||
return _plat;
|
||||
}
|
|
@ -1,699 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_Frame.h>
|
||||
#include<VGUI_InputSignal.h>
|
||||
#include<VGUI_App.h>
|
||||
#include<VGUI_Button.h>
|
||||
#include<VGUI_FrameSignal.h>
|
||||
#include<VGUI_ActionSignal.h>
|
||||
#include<VGUI_SurfaceBase.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class FooDraggerSignal : public InputSignal
|
||||
{
|
||||
protected:
|
||||
Frame* _frame;
|
||||
|
||||
public:
|
||||
FooDraggerSignal(Frame* frame)
|
||||
{
|
||||
_frame=frame;
|
||||
_dragging=false;
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void moved(int dx,int dy,bool internal,Panel* panel,Panel* parent)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void cursorMoved(int x,int y,Panel* panel)
|
||||
{
|
||||
if(!_dragging)
|
||||
return;
|
||||
|
||||
panel=panel->getParent();
|
||||
if(panel==null)
|
||||
return;
|
||||
|
||||
panel->getApp()->getCursorPos(x,y);
|
||||
Frame* frame=dynamic_cast<Frame*>(panel);
|
||||
if(frame==null)
|
||||
return;
|
||||
|
||||
if(frame->isInternal())
|
||||
{
|
||||
moved(x-_dragStart[0],y-_dragStart[1],true,panel,panel->getParent());
|
||||
if(panel->getParent()!=null)
|
||||
panel->getParent()->repaint();
|
||||
panel->repaint();
|
||||
}
|
||||
else
|
||||
{
|
||||
Panel* parent=panel->getParent();
|
||||
if(parent!=null)
|
||||
{
|
||||
moved(x-_dragStart[0],y-_dragStart[1],false,panel,parent);
|
||||
if(parent->getParent()!=null)
|
||||
parent->getParent()->repaint();
|
||||
parent->repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void cursorEntered(Panel* panel)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void cursorExited(Panel* panel)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void mouseDoublePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void mousePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
Panel* opanel=panel->getParent();
|
||||
if(opanel==null)
|
||||
return;
|
||||
|
||||
Frame* frame=dynamic_cast<Frame*>(opanel);
|
||||
if(frame==null)
|
||||
return;
|
||||
|
||||
if(code==MOUSE_LEFT)
|
||||
{
|
||||
_dragging=true;
|
||||
|
||||
int x,y;
|
||||
opanel->getApp()->getCursorPos(x,y);
|
||||
_dragStart[0]=x;
|
||||
_dragStart[1]=y;
|
||||
opanel->getPos(_dragOrgPos[0],_dragOrgPos[1]);
|
||||
opanel->getSize(_dragOrgSize[0],_dragOrgSize[1]);
|
||||
if(opanel->getParent()!=null)
|
||||
{
|
||||
opanel->getParent()->getPos(_dragOrgPos2[0],_dragOrgPos2[1]);
|
||||
opanel->getParent()->getSize(_dragOrgSize2[0],_dragOrgSize2[1]);
|
||||
|
||||
int x0,y0,x1,y1;
|
||||
opanel->getParent()->getAbsExtents(x0,y0,x1,y1);
|
||||
opanel->getApp()->setMouseArena(x0,y0,x1,y1,true);
|
||||
|
||||
Panel* parent=opanel->getParent();
|
||||
parent->removeChild(opanel);
|
||||
parent->addChild(opanel);
|
||||
}
|
||||
|
||||
opanel->getApp()->setMouseCapture(panel);
|
||||
opanel->requestFocus();
|
||||
opanel->repaintAll();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void mouseReleased(MouseCode code,Panel* panel)
|
||||
{
|
||||
_dragging=false;
|
||||
panel->getApp()->setMouseArena(0,0,0,0,false);
|
||||
panel->getApp()->setMouseCapture(null);
|
||||
}
|
||||
|
||||
virtual void mouseWheeled(int delta,Panel* panel){}
|
||||
virtual void keyPressed(KeyCode code,Panel* panel){}
|
||||
virtual void keyTyped(KeyCode code,Panel* panel){}
|
||||
virtual void keyReleased(KeyCode code,Panel* panel){}
|
||||
virtual void keyFocusTicked(Panel* panel){}
|
||||
|
||||
protected:
|
||||
bool _dragging;
|
||||
int _dragOrgPos[2];
|
||||
int _dragOrgPos2[2];
|
||||
int _dragOrgSize[2];
|
||||
int _dragOrgSize2[2];
|
||||
int _dragStart[2];
|
||||
};
|
||||
|
||||
class FooTopGripSignal : public FooDraggerSignal
|
||||
{
|
||||
public:
|
||||
FooTopGripSignal(Frame* frame) : FooDraggerSignal(frame)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void moved(int dx,int dy,bool internal,Panel* panel,Panel* parent)
|
||||
{
|
||||
if(!_frame->isSizeable())
|
||||
return;
|
||||
|
||||
if(internal)
|
||||
{
|
||||
panel->setPos(_dragOrgPos[0],_dragOrgPos[1]+dy);
|
||||
panel->setSize(_dragOrgSize[0],_dragOrgSize[1]-dy);
|
||||
}
|
||||
else
|
||||
{
|
||||
parent->setPos(_dragOrgPos2[0],_dragOrgPos2[1]+dy);
|
||||
parent->setSize(_dragOrgSize2[0],_dragOrgSize2[1]-dy);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class FooBottomGripSignal : public FooDraggerSignal
|
||||
{
|
||||
public:
|
||||
FooBottomGripSignal(Frame* frame) : FooDraggerSignal(frame)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void moved(int dx,int dy,bool internal,Panel* panel,Panel* parent)
|
||||
{
|
||||
if(!_frame->isSizeable())
|
||||
return;
|
||||
|
||||
if(internal)
|
||||
{
|
||||
panel->setSize(_dragOrgSize[0],_dragOrgSize[1]+dy);
|
||||
}
|
||||
else
|
||||
{
|
||||
parent->setSize(_dragOrgSize2[0],_dragOrgSize2[1]+dy);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class FooLeftGripSignal : public FooDraggerSignal
|
||||
{
|
||||
public:
|
||||
FooLeftGripSignal(Frame* frame) : FooDraggerSignal(frame)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void moved(int dx,int dy,bool internal,Panel* panel,Panel* parent)
|
||||
{
|
||||
if(!_frame->isSizeable())
|
||||
return;
|
||||
|
||||
if(internal)
|
||||
{
|
||||
panel->setPos(_dragOrgPos[0]+dx,_dragOrgPos[1]);
|
||||
panel->setSize(_dragOrgSize[0]-dx,_dragOrgSize[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
parent->setPos(_dragOrgPos2[0]+dx,_dragOrgPos2[1]);
|
||||
parent->setSize(_dragOrgSize2[0]-dx,_dragOrgSize2[1]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class FooRightGripSignal : public FooDraggerSignal
|
||||
{
|
||||
public:
|
||||
FooRightGripSignal(Frame* frame) : FooDraggerSignal(frame)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void moved(int dx,int dy,bool internal,Panel* panel,Panel* parent)
|
||||
{
|
||||
if(!_frame->isSizeable())
|
||||
return;
|
||||
|
||||
if(internal)
|
||||
{
|
||||
panel->setSize(_dragOrgSize[0]+dx,_dragOrgSize[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
parent->setSize(_dragOrgSize2[0]+dx,_dragOrgSize2[1]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class FooTopLeftGripSignal : public FooDraggerSignal
|
||||
{
|
||||
public:
|
||||
FooTopLeftGripSignal(Frame* frame) : FooDraggerSignal(frame)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void moved(int dx,int dy,bool internal,Panel* panel,Panel* parent)
|
||||
{
|
||||
if(!_frame->isSizeable())
|
||||
return;
|
||||
|
||||
if(internal)
|
||||
{
|
||||
panel->setPos(_dragOrgPos[0]+dx,_dragOrgPos[1]+dy);
|
||||
panel->setSize(_dragOrgSize[0]-dx,_dragOrgSize[1]-dy);
|
||||
}
|
||||
else
|
||||
{
|
||||
parent->setPos(_dragOrgPos2[0]+dx,_dragOrgPos2[1]+dy);
|
||||
parent->setSize(_dragOrgSize2[0]-dx,_dragOrgSize2[1]-dy);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class FooTopRightGripSignal : public FooDraggerSignal
|
||||
{
|
||||
public:
|
||||
FooTopRightGripSignal(Frame* frame) : FooDraggerSignal(frame)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void moved(int dx,int dy,bool internal,Panel* panel,Panel* parent)
|
||||
{
|
||||
if(!_frame->isSizeable())
|
||||
return;
|
||||
|
||||
if(internal)
|
||||
{
|
||||
panel->setPos(_dragOrgPos[0],_dragOrgPos[1]+dy);
|
||||
panel->setSize(_dragOrgSize[0]+dx,_dragOrgSize[1]-dy);
|
||||
}
|
||||
else
|
||||
{
|
||||
parent->setPos(_dragOrgPos2[0],_dragOrgPos2[1]+dy);
|
||||
parent->setSize(_dragOrgSize2[0]+dx,_dragOrgSize2[1]-dy);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class FooBottomLeftGripSignal : public FooDraggerSignal
|
||||
{
|
||||
public:
|
||||
FooBottomLeftGripSignal(Frame* frame) : FooDraggerSignal(frame)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void moved(int dx,int dy,bool internal,Panel* panel,Panel* parent)
|
||||
{
|
||||
if(!_frame->isSizeable())
|
||||
return;
|
||||
|
||||
if(internal)
|
||||
{
|
||||
panel->setPos(_dragOrgPos[0]+dx,_dragOrgPos[1]);
|
||||
panel->setSize(_dragOrgSize[0]-dx,_dragOrgSize[1]+dy);
|
||||
}
|
||||
else
|
||||
{
|
||||
parent->setPos(_dragOrgPos2[0]+dx,_dragOrgPos2[1]);
|
||||
parent->setSize(_dragOrgSize2[0]-dx,_dragOrgSize2[1]+dy);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class FooBottomRightGripSignal : public FooDraggerSignal
|
||||
{
|
||||
public:
|
||||
FooBottomRightGripSignal(Frame* frame) : FooDraggerSignal(frame)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void moved(int dx,int dy,bool internal,Panel* panel,Panel* parent)
|
||||
{
|
||||
if(!_frame->isSizeable())
|
||||
return;
|
||||
|
||||
if(internal)
|
||||
{
|
||||
panel->setSize(_dragOrgSize[0]+dx,_dragOrgSize[1]+dy);
|
||||
}
|
||||
else
|
||||
{
|
||||
parent->setSize(_dragOrgSize2[0]+dx,_dragOrgSize2[1]+dy);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class FooCaptionGripSignal : public FooDraggerSignal
|
||||
{
|
||||
public:
|
||||
FooCaptionGripSignal(Frame* frame) : FooDraggerSignal(frame)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void moved(int dx,int dy,bool internal,Panel* panel,Panel* parent)
|
||||
{
|
||||
if(!_frame->isSizeable())
|
||||
return;
|
||||
|
||||
if(internal)
|
||||
{
|
||||
panel->setPos(_dragOrgPos[0]+dx,_dragOrgPos[1]+dy);
|
||||
}
|
||||
else
|
||||
{
|
||||
parent->setPos(_dragOrgPos2[0]+dx,_dragOrgPos2[1]+dy);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class FooCloseButtonHandler : public ActionSignal
|
||||
{
|
||||
public:
|
||||
FooCloseButtonHandler(Frame* frame)
|
||||
{
|
||||
_frame=frame;
|
||||
}
|
||||
public:
|
||||
virtual void actionPerformed(Panel* panel)
|
||||
{
|
||||
_frame->fireClosingSignal();
|
||||
}
|
||||
protected:
|
||||
Frame* _frame;
|
||||
};
|
||||
|
||||
class FooMinimizeButtonHandler : public ActionSignal
|
||||
{
|
||||
public:
|
||||
FooMinimizeButtonHandler(Frame* frame)
|
||||
{
|
||||
_frame=frame;
|
||||
}
|
||||
public:
|
||||
virtual void actionPerformed(Panel* panel)
|
||||
{
|
||||
_frame->fireMinimizingSignal();
|
||||
}
|
||||
protected:
|
||||
Frame* _frame;
|
||||
};
|
||||
}
|
||||
|
||||
Frame::Frame(int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
||||
{
|
||||
_title=null;
|
||||
_internal=true;
|
||||
_moveable=true;
|
||||
_sizeable=true;
|
||||
_title=vgui_strdup("Untitled");
|
||||
setMinimumSize(64,33);
|
||||
|
||||
bool showGrip=false;
|
||||
|
||||
_topGrip=new Panel(15,0,wide-30,5);
|
||||
_topGrip->setParent(this);
|
||||
_topGrip->setCursor(new Cursor(Cursor::dc_sizens));
|
||||
_topGrip->addInputSignal(new FooTopGripSignal(this));
|
||||
_topGrip->setPaintBorderEnabled(false);
|
||||
_topGrip->setPaintBackgroundEnabled(false);
|
||||
_topGrip->setPaintEnabled(false);
|
||||
|
||||
_bottomGrip=new Panel(15,tall-5,wide-30,5);
|
||||
_bottomGrip->setParent(this);
|
||||
_bottomGrip->setCursor(new Cursor(Cursor::dc_sizens));
|
||||
_bottomGrip->addInputSignal(new FooBottomGripSignal(this));
|
||||
_bottomGrip->setPaintBorderEnabled(false);
|
||||
_bottomGrip->setPaintBackgroundEnabled(false);
|
||||
_bottomGrip->setPaintEnabled(false);
|
||||
|
||||
_leftGrip=new Panel(0,15,5,tall-30);
|
||||
_leftGrip->setParent(this);
|
||||
_leftGrip->setCursor(new Cursor(Cursor::dc_sizewe));
|
||||
_leftGrip->addInputSignal(new FooLeftGripSignal(this));
|
||||
_leftGrip->setPaintBorderEnabled(false);
|
||||
_leftGrip->setPaintBackgroundEnabled(false);
|
||||
_leftGrip->setPaintEnabled(false);
|
||||
|
||||
_rightGrip=new Panel(wide-5,15,5,tall-30);
|
||||
_rightGrip->setParent(this);
|
||||
_rightGrip->setCursor(new Cursor(Cursor::dc_sizewe));
|
||||
_rightGrip->addInputSignal(new FooRightGripSignal(this));
|
||||
_rightGrip->setPaintBorderEnabled(false);
|
||||
_rightGrip->setPaintBackgroundEnabled(false);
|
||||
_rightGrip->setPaintEnabled(false);
|
||||
|
||||
_topLeftGrip=new Panel(0,0,15,15);
|
||||
_topLeftGrip->setParent(this);
|
||||
_topLeftGrip->setCursor(new Cursor(Cursor::dc_sizenwse));
|
||||
_topLeftGrip->addInputSignal(new FooTopLeftGripSignal(this));
|
||||
_topLeftGrip->setPaintBorderEnabled(false);
|
||||
_topLeftGrip->setPaintBackgroundEnabled(false);
|
||||
_topLeftGrip->setPaintEnabled(false);
|
||||
|
||||
_topRightGrip=new Panel(wide-15,0,15,15);
|
||||
_topRightGrip->setParent(this);
|
||||
_topRightGrip->setCursor(new Cursor(Cursor::dc_sizenesw));
|
||||
_topRightGrip->addInputSignal(new FooTopRightGripSignal(this));
|
||||
_topRightGrip->setPaintBorderEnabled(false);
|
||||
_topRightGrip->setPaintBackgroundEnabled(false);
|
||||
_topRightGrip->setPaintEnabled(false);
|
||||
|
||||
_bottomLeftGrip=new Panel(0,tall-15,15,15);
|
||||
_bottomLeftGrip->setParent(this);
|
||||
_bottomLeftGrip->setCursor(new Cursor(Cursor::dc_sizenesw));
|
||||
_bottomLeftGrip->addInputSignal(new FooBottomLeftGripSignal(this));
|
||||
_bottomLeftGrip->setPaintBorderEnabled(false);
|
||||
_bottomLeftGrip->setPaintBackgroundEnabled(false);
|
||||
_bottomLeftGrip->setPaintEnabled(false);
|
||||
|
||||
_bottomRightGrip=new Panel(wide-15,tall-15,15,15);
|
||||
_bottomRightGrip->setParent(this);
|
||||
_bottomRightGrip->setCursor(new Cursor(Cursor::dc_sizenwse));
|
||||
_bottomRightGrip->addInputSignal(new FooBottomRightGripSignal(this));
|
||||
_bottomRightGrip->setPaintBorderEnabled(false);
|
||||
_bottomRightGrip->setPaintBackgroundEnabled(false);
|
||||
_bottomRightGrip->setPaintEnabled(false);
|
||||
|
||||
_captionGrip=new Panel(5,5,wide-10,23);
|
||||
_captionGrip->setParent(this);
|
||||
_captionGrip->setCursor(new Cursor(Cursor::dc_sizeall));
|
||||
_captionGrip->addInputSignal(new FooCaptionGripSignal(this));
|
||||
_captionGrip->setPaintBorderEnabled(false);
|
||||
_captionGrip->setPaintBackgroundEnabled(false);
|
||||
_captionGrip->setPaintEnabled(false);
|
||||
|
||||
_client=new Panel(5,29,wide-10,tall-34);
|
||||
_client->setParent(this);
|
||||
_client->addInputSignal(new FooDraggerSignal(this));
|
||||
|
||||
_trayButton=new Button(".",wide-85,8,18,18);
|
||||
_trayButton->setParent(this);
|
||||
|
||||
_minimizeButton=new Button("2",wide-65,8,18,18);
|
||||
_minimizeButton->setFont(Scheme::sf_secondary1);
|
||||
_minimizeButton->setParent(this);
|
||||
_minimizeButton->addActionSignal(new FooMinimizeButtonHandler(this));
|
||||
|
||||
_maximizeButton=new Button("1",wide-45,8,18,18);
|
||||
_maximizeButton->setFont(Scheme::sf_secondary1);
|
||||
_maximizeButton->setParent(this);
|
||||
|
||||
_closeButton=new Button("r",wide-25,8,18,18);
|
||||
_closeButton->setFont(Scheme::sf_secondary1);
|
||||
_closeButton->setParent(this);
|
||||
_closeButton->addActionSignal(new FooCloseButtonHandler(this));
|
||||
|
||||
_menuButton=new Button("s",7,8,18,18);
|
||||
_menuButton->setFont(Scheme::sf_secondary1);
|
||||
_menuButton->setParent(this);
|
||||
}
|
||||
|
||||
void Frame::setSize(int wide,int tall)
|
||||
{
|
||||
if((getWide()==wide)&&(getTall()==tall))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Panel::setSize(wide,tall);
|
||||
|
||||
_topGrip->setBounds(15,0,_size[0]-30,5);
|
||||
_bottomGrip->setBounds(15,_size[1]-5,_size[0]-30,5);
|
||||
_leftGrip->setBounds(0,15,5,_size[1]-30);
|
||||
_rightGrip->setBounds(_size[0]-5,15,5,_size[1]-30);
|
||||
_topLeftGrip->setBounds(0,0,15,15);
|
||||
_topRightGrip->setBounds(_size[0]-15,0,15,15);
|
||||
_bottomLeftGrip->setBounds(0,_size[1]-15,15,15);
|
||||
_bottomRightGrip->setBounds(_size[0]-15,_size[1]-15,15,15);
|
||||
_captionGrip->setSize(_size[0]-10,23);
|
||||
_client->setSize(_size[0]-10,_size[1]-34);
|
||||
_trayButton->setPos(_size[0]-85,8);
|
||||
_minimizeButton->setPos(_size[0]-65,8);
|
||||
_maximizeButton->setPos(_size[0]-45,8);
|
||||
_closeButton->setPos(_size[0]-25,8);
|
||||
_client->invalidateLayout(false);
|
||||
}
|
||||
|
||||
void Frame::setInternal(bool state)
|
||||
{
|
||||
_internal=state;
|
||||
}
|
||||
|
||||
bool Frame::isInternal()
|
||||
{
|
||||
return _internal;
|
||||
}
|
||||
|
||||
Panel* Frame::getClient()
|
||||
{
|
||||
return _client;
|
||||
}
|
||||
|
||||
void Frame::setTitle(const char* title)
|
||||
{
|
||||
delete[] _title;
|
||||
_title=vgui_strdup(title);
|
||||
repaint();
|
||||
}
|
||||
|
||||
void Frame::getTitle(char* buf,int bufLen)
|
||||
{
|
||||
vgui_strcpy(buf,bufLen,_title);
|
||||
}
|
||||
|
||||
void Frame::setMoveable(bool state)
|
||||
{
|
||||
_moveable=state;
|
||||
}
|
||||
|
||||
void Frame::setSizeable(bool state)
|
||||
{
|
||||
_sizeable=state;
|
||||
}
|
||||
|
||||
bool Frame::isMoveable()
|
||||
{
|
||||
return _moveable;
|
||||
}
|
||||
|
||||
bool Frame::isSizeable()
|
||||
{
|
||||
return _sizeable;
|
||||
}
|
||||
|
||||
void Frame::paintBackground()
|
||||
{
|
||||
int wide=_size[0];
|
||||
int tall=_size[1];
|
||||
|
||||
const int captionTall=23;
|
||||
|
||||
Scheme::SchemeColor color1=Scheme::sc_secondary1;
|
||||
Scheme::SchemeColor color2=Scheme::sc_secondary2;
|
||||
Scheme::SchemeColor color3=Scheme::sc_secondary3;
|
||||
|
||||
if(getSurfaceBase()->hasFocus())
|
||||
{
|
||||
Panel* trav=getApp()->getFocus();
|
||||
while(trav!=null)
|
||||
{
|
||||
if(trav==this)
|
||||
{
|
||||
color1=Scheme::sc_primary1;
|
||||
color2=Scheme::sc_primary2;
|
||||
color3=Scheme::sc_primary3;
|
||||
}
|
||||
trav=trav->getParent();
|
||||
}
|
||||
}
|
||||
|
||||
drawSetColor(color3);
|
||||
drawFilledRect(5,5,wide-5,28);
|
||||
|
||||
drawSetColor(Scheme::sc_white);
|
||||
drawFilledRect(120,10,wide-70,11);
|
||||
drawFilledRect(120,15,wide-70,16);
|
||||
drawFilledRect(120,20,wide-70,21);
|
||||
|
||||
drawSetColor(color1);
|
||||
drawFilledRect(120,12,wide-70,13);
|
||||
drawFilledRect(120,17,wide-70,18);
|
||||
drawFilledRect(120,22,wide-70,23);
|
||||
|
||||
drawSetColor(color1);
|
||||
drawFilledRect(1,0,wide-1,5);
|
||||
drawFilledRect(1,tall-5,wide-1,tall);
|
||||
drawFilledRect(0,1,5,tall-1);
|
||||
drawFilledRect(wide-5,1,wide,tall-1);
|
||||
drawFilledRect(5,5,6,6);
|
||||
drawFilledRect(wide-6,5,wide-5,6);
|
||||
drawFilledRect(5,28,wide-5,29);
|
||||
|
||||
drawSetColor(Scheme::sc_black);
|
||||
drawFilledRect(13,2,wide-13,3);
|
||||
drawFilledRect(13,tall-3,wide-13,tall-2);
|
||||
drawFilledRect(2,13,3,tall-13);
|
||||
drawFilledRect(wide-3,13,wide-2,tall-13);
|
||||
|
||||
drawSetColor(color2);
|
||||
drawFilledRect(14,3,wide-12,4);
|
||||
drawFilledRect(14,tall-2,wide-12,tall-1);
|
||||
drawFilledRect(3,14,4,tall-12);
|
||||
drawFilledRect(wide-2,14,wide-1,tall-12);
|
||||
|
||||
if(_title!=null)
|
||||
{
|
||||
drawSetTextFont(Scheme::sf_primary1);
|
||||
drawSetTextColor(Scheme::sc_black);
|
||||
drawPrintText(28,7,_title,strlen(_title));
|
||||
}
|
||||
}
|
||||
|
||||
void Frame::addFrameSignal(FrameSignal* s)
|
||||
{
|
||||
_frameSignalDar.putElement(s);
|
||||
}
|
||||
|
||||
void Frame::fireClosingSignal()
|
||||
{
|
||||
for(int i=0;i<_frameSignalDar.getCount();i++)
|
||||
{
|
||||
_frameSignalDar[i]->closing(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Frame::fireMinimizingSignal()
|
||||
{
|
||||
for(int i=0;i<_frameSignalDar.getCount();i++)
|
||||
{
|
||||
_frameSignalDar[i]->minimizing(this,false);
|
||||
}
|
||||
}
|
||||
|
||||
void Frame::setVisible(bool state)
|
||||
{
|
||||
Panel::setVisible(state);
|
||||
|
||||
if(getParent()!=null)
|
||||
{
|
||||
getParent()->repaint();
|
||||
}
|
||||
}
|
||||
|
||||
void Frame::setMenuButtonVisible(bool state)
|
||||
{
|
||||
_menuButton->setVisible(state);
|
||||
}
|
||||
|
||||
void Frame::setTrayButtonVisible(bool state)
|
||||
{
|
||||
_trayButton->setVisible(state);
|
||||
}
|
||||
|
||||
void Frame::setMinimizeButtonVisible(bool state)
|
||||
{
|
||||
_minimizeButton->setVisible(state);
|
||||
}
|
||||
|
||||
void Frame::setMaximizeButtonVisible(bool state)
|
||||
{
|
||||
_maximizeButton->setVisible(state);
|
||||
}
|
||||
|
||||
void Frame::setCloseButtonVisible(bool state)
|
||||
{
|
||||
_closeButton->setVisible(state);
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_GridLayout.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
/*GridLayout::GridLayout(int rows,int cols,int hgap,int vgap) : Layout()
|
||||
{
|
||||
}*/
|
|
@ -1,208 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_HeaderPanel.h>
|
||||
#include<VGUI_App.h>
|
||||
#include<VGUI_InputSignal.h>
|
||||
#include<VGUI_ChangeSignal.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class HeaderPanelSignal : public InputSignal
|
||||
{
|
||||
private:
|
||||
HeaderPanel* _headerPanel;
|
||||
public:
|
||||
HeaderPanelSignal(HeaderPanel* headerPanel)
|
||||
{
|
||||
_headerPanel=headerPanel;
|
||||
}
|
||||
public:
|
||||
virtual void cursorMoved(int x,int y,Panel* panel)
|
||||
{
|
||||
_headerPanel->privateCursorMoved(x,y,panel);
|
||||
}
|
||||
virtual void cursorEntered(Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void cursorExited(Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void mouseDoublePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void mousePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
_headerPanel->privateMousePressed(code,panel);
|
||||
}
|
||||
virtual void mouseReleased(MouseCode code,Panel* panel)
|
||||
{
|
||||
_headerPanel->privateMouseReleased(code,panel);
|
||||
}
|
||||
virtual void mouseWheeled(int delta,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyPressed(KeyCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyTyped(KeyCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyReleased(KeyCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyFocusTicked(Panel* panel)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
HeaderPanel::HeaderPanel(int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
||||
{
|
||||
_sliderWide=11;
|
||||
_dragging=false;
|
||||
_sectionLayer=new Panel(0,0,wide,tall);
|
||||
_sectionLayer->setPaintBorderEnabled(false);
|
||||
_sectionLayer->setPaintBackgroundEnabled(false);
|
||||
_sectionLayer->setPaintEnabled(false);
|
||||
_sectionLayer->setParent(this);
|
||||
}
|
||||
|
||||
void HeaderPanel::addSectionPanel(Panel* panel)
|
||||
{
|
||||
invalidateLayout(true);
|
||||
|
||||
int x=0;
|
||||
int y=999999999,wide=999999999,tall=999999999; // uninitialize
|
||||
for(int i=0;i<_sectionPanelDar.getCount();i++)
|
||||
{
|
||||
_sectionPanelDar[i]->getBounds(x,y,wide,tall);
|
||||
x+=wide+_sliderWide;
|
||||
}
|
||||
_sectionPanelDar.addElement(panel);
|
||||
|
||||
panel->setPos(x,0);
|
||||
panel->setParent(_sectionLayer);
|
||||
panel->setBounds(x,y,wide,tall);
|
||||
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
Panel* slider=new Panel(0,0,_sliderWide,tall);
|
||||
slider->setPaintBorderEnabled(false);
|
||||
slider->setPaintBackgroundEnabled(false);
|
||||
slider->setPaintEnabled(false);
|
||||
slider->setPos(x+wide,0);
|
||||
slider->addInputSignal(new HeaderPanelSignal(this));
|
||||
slider->setCursor(getApp()->getScheme()->getCursor(Scheme::scu_sizewe));
|
||||
slider->setParent(this);
|
||||
_sliderPanelDar.addElement(slider);
|
||||
|
||||
invalidateLayout(false);
|
||||
fireChangeSignal();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void HeaderPanel::setSliderPos(int sliderIndex,int pos)
|
||||
{
|
||||
_sliderPanelDar[sliderIndex]->setPos(pos-_sliderWide/2,0);
|
||||
|
||||
invalidateLayout(false);
|
||||
fireChangeSignal();
|
||||
repaint();
|
||||
}
|
||||
|
||||
int HeaderPanel::getSectionCount()
|
||||
{
|
||||
return _sectionPanelDar.getCount();
|
||||
}
|
||||
|
||||
void HeaderPanel::getSectionExtents(int sectionIndex,int& x0,int& x1)
|
||||
{
|
||||
int x,y,wide,tall;
|
||||
_sectionPanelDar[sectionIndex]->getBounds(x,y,wide,tall);
|
||||
x0=x;
|
||||
x1=x+wide;
|
||||
}
|
||||
|
||||
void HeaderPanel::addChangeSignal(ChangeSignal* s)
|
||||
{
|
||||
_changeSignalDar.putElement(s);
|
||||
}
|
||||
|
||||
void HeaderPanel::fireChangeSignal()
|
||||
{
|
||||
invalidateLayout(true);
|
||||
|
||||
for(int i=0;i<_changeSignalDar.getCount();i++)
|
||||
{
|
||||
_changeSignalDar[i]->valueChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
void HeaderPanel::performLayout()
|
||||
{
|
||||
int x0=0;
|
||||
int x1;
|
||||
int x,y,wide,tall;
|
||||
getPaintSize(wide,tall);
|
||||
_sectionLayer->setBounds(0,0,wide,tall);
|
||||
|
||||
for(int i=0;i<_sectionPanelDar.getCount();i++)
|
||||
{
|
||||
Panel* slider=_sliderPanelDar[i];
|
||||
slider->getPos(x,y);
|
||||
x1=x+(_sliderWide/2);
|
||||
|
||||
Panel* panel=_sectionPanelDar[i];
|
||||
panel->setBounds(x0,0,x1-x0,tall);
|
||||
x0=x1;
|
||||
}
|
||||
}
|
||||
|
||||
void HeaderPanel::privateCursorMoved(int x,int y,Panel* panel)
|
||||
{
|
||||
if(!_dragging)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
getApp()->getCursorPos(x,y);
|
||||
screenToLocal(x,y);
|
||||
|
||||
setSliderPos(_dragSliderIndex,x+_dragSliderStartPos-_dragSliderStartX);
|
||||
invalidateLayout(false);
|
||||
repaint();
|
||||
}
|
||||
|
||||
void HeaderPanel::privateMousePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
int mx,my;
|
||||
getApp()->getCursorPos(mx,my);
|
||||
screenToLocal(mx,my);
|
||||
|
||||
for(int i=0;i<_sliderPanelDar.getCount();i++)
|
||||
{
|
||||
Panel* slider=_sliderPanelDar[i];
|
||||
if(slider==panel)
|
||||
{
|
||||
int x,y;
|
||||
panel->getPos(x,y);
|
||||
_dragging=true;
|
||||
_dragSliderIndex=i;
|
||||
_dragSliderStartPos=x+(_sliderWide/2);
|
||||
_dragSliderStartX=mx;
|
||||
panel->setAsMouseCapture(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HeaderPanel::privateMouseReleased(MouseCode code,Panel* panel)
|
||||
{
|
||||
}
|
|
@ -1,158 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_Image.h>
|
||||
#include<VGUI_Panel.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
Image::Image()
|
||||
{
|
||||
_panel=null;
|
||||
setPos(0,0);
|
||||
setSize(0,0);
|
||||
setColor(Color(255,255,255,0));
|
||||
}
|
||||
|
||||
void Image::setPos(int x,int y)
|
||||
{
|
||||
_pos[0]=x;
|
||||
_pos[1]=y;
|
||||
}
|
||||
|
||||
void Image::getPos(int& x,int& y)
|
||||
{
|
||||
x=_pos[0];
|
||||
y=_pos[1];
|
||||
}
|
||||
|
||||
void Image::getSize(int& wide,int& tall)
|
||||
{
|
||||
wide=_size[0];
|
||||
tall=_size[1];
|
||||
}
|
||||
|
||||
void Image::setColor(Color color)
|
||||
{
|
||||
_color=color;
|
||||
}
|
||||
|
||||
void Image::getColor(Color& color)
|
||||
{
|
||||
color=_color;
|
||||
}
|
||||
|
||||
void Image::setSize(int wide,int tall)
|
||||
{
|
||||
_size[0]=wide;
|
||||
_size[1]=tall;
|
||||
}
|
||||
|
||||
void Image::drawSetColor(Scheme::SchemeColor sc)
|
||||
{
|
||||
_panel->drawSetColor(sc);
|
||||
}
|
||||
|
||||
void Image::drawSetColor(int r,int g,int b,int a)
|
||||
{
|
||||
_panel->drawSetColor(r,g,b,a);
|
||||
}
|
||||
|
||||
void Image::drawFilledRect(int x0,int y0,int x1,int y1)
|
||||
{
|
||||
x0+=_pos[0];
|
||||
y0+=_pos[1];
|
||||
x1+=_pos[0];
|
||||
y1+=_pos[1];
|
||||
_panel->drawFilledRect(x0,y0,x1,y1);
|
||||
}
|
||||
|
||||
void Image::drawOutlinedRect(int x0,int y0,int x1,int y1)
|
||||
{
|
||||
x0+=_pos[0];
|
||||
y0+=_pos[1];
|
||||
x1+=_pos[0];
|
||||
y1+=_pos[1];
|
||||
_panel->drawOutlinedRect(x0,y0,x1,y1);
|
||||
}
|
||||
|
||||
void Image::drawSetTextFont(Scheme::SchemeFont sf)
|
||||
{
|
||||
_panel->drawSetTextFont(sf);
|
||||
}
|
||||
|
||||
void Image::drawSetTextFont(Font* font)
|
||||
{
|
||||
_panel->drawSetTextFont(font);
|
||||
}
|
||||
|
||||
void Image::drawSetTextColor(Scheme::SchemeColor sc)
|
||||
{
|
||||
_panel->drawSetTextColor(sc);
|
||||
}
|
||||
|
||||
void Image::drawSetTextColor(int r,int g,int b,int a)
|
||||
{
|
||||
_panel->drawSetTextColor(r,g,b,a);
|
||||
}
|
||||
|
||||
void Image::drawSetTextPos(int x,int y)
|
||||
{
|
||||
x+=_pos[0];
|
||||
y+=_pos[1];
|
||||
_panel->drawSetTextPos(x,y);
|
||||
}
|
||||
|
||||
void Image::drawPrintText(const char* str,int strlen)
|
||||
{
|
||||
_panel->drawPrintText(str,strlen);
|
||||
}
|
||||
|
||||
void Image::drawPrintText(int x,int y,const char* str,int strlen)
|
||||
{
|
||||
x+=_pos[0];
|
||||
y+=_pos[1];
|
||||
_panel->drawPrintText(x,y,str,strlen);
|
||||
}
|
||||
|
||||
void Image::drawPrintChar(char ch)
|
||||
{
|
||||
_panel->drawPrintChar(ch);
|
||||
}
|
||||
|
||||
void Image::drawPrintChar(int x,int y,char ch)
|
||||
{
|
||||
x+=_pos[0];
|
||||
y+=_pos[1];
|
||||
_panel->drawPrintChar(x,y,ch);
|
||||
}
|
||||
|
||||
void Image::drawSetTextureRGBA(int id,const char* rgba,int wide,int tall)
|
||||
{
|
||||
_panel->drawSetTextureRGBA(id,rgba,wide,tall);
|
||||
}
|
||||
|
||||
void Image::drawSetTexture(int id)
|
||||
{
|
||||
_panel->drawSetTexture(id);
|
||||
}
|
||||
|
||||
void Image::drawTexturedRect(int x0,int y0,int x1,int y1)
|
||||
{
|
||||
_panel->drawTexturedRect(x0,y0,x1,y1);
|
||||
}
|
||||
|
||||
void Image::paint(Panel* panel)
|
||||
{
|
||||
}
|
||||
|
||||
void Image::doPaint(Panel* panel)
|
||||
{
|
||||
_panel=panel;
|
||||
paint(panel);
|
||||
_panel=null;
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_ImagePanel.h>
|
||||
#include<VGUI_Image.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
ImagePanel::ImagePanel(Image* image) : Panel(0,0,64,64)
|
||||
{
|
||||
_image=null;
|
||||
setImage(image);
|
||||
}
|
||||
|
||||
void ImagePanel::setImage(Image* image)
|
||||
{
|
||||
_image=image;
|
||||
|
||||
if(_image!=null)
|
||||
{
|
||||
int wide,tall;
|
||||
_image->getSize(wide,tall);
|
||||
setSize(wide,tall);
|
||||
}
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
void ImagePanel::paintBackground()
|
||||
{
|
||||
if(_image!=null)
|
||||
{
|
||||
drawSetColor(Scheme::sc_white);
|
||||
_image->doPaint(this);
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<stdio.h>
|
||||
#include<VGUI_IntLabel.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
IntLabel::IntLabel(int value,int x,int y,int wide,int tall) : Label(null,x,y,wide,tall)
|
||||
{
|
||||
_value=0;
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
void IntLabel::setValue(int value)
|
||||
{
|
||||
if(_value!=value)
|
||||
{
|
||||
_value=value;
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
void IntLabel::intChanged(int value,Panel* panel)
|
||||
{
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
void IntLabel::paintBackground()
|
||||
{
|
||||
char buf[50];
|
||||
sprintf(buf,"%d",_value);
|
||||
Panel::paintBackground();
|
||||
drawSetTextFont(Scheme::sf_primary1);
|
||||
drawSetTextColor(Scheme::sc_black);
|
||||
drawPrintText(0,0,buf,strlen(buf));
|
||||
}
|
|
@ -1,425 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<stdarg.h>
|
||||
#include<stdio.h>
|
||||
#include<VGUI_Label.h>
|
||||
#include<VGUI_TextImage.h>
|
||||
#include<VGUI_TreeFolder.h>
|
||||
#include<VGUI_FlowLayout.h>
|
||||
#include<VGUI_TextEntry.h>
|
||||
#include<VGUI_ActionSignal.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class FooDumb : public Panel, public ActionSignal
|
||||
{
|
||||
private:
|
||||
Label* _label;
|
||||
TextEntry*_textEntry;
|
||||
public:
|
||||
FooDumb(Label* label) : Panel(0,0,200,20)
|
||||
{
|
||||
_label=label;
|
||||
|
||||
setLayout(new FlowLayout(2));
|
||||
|
||||
Label* lll=new Label("setText");
|
||||
lll->setParent(this);
|
||||
|
||||
_textEntry=new TextEntry("",0,0,80,20);
|
||||
_textEntry->setParent(this);
|
||||
_textEntry->addActionSignal(this);
|
||||
}
|
||||
public:
|
||||
void actionPerformed(Panel* panel)
|
||||
{
|
||||
char buf[256];
|
||||
_textEntry->getText(0,buf,sizeof(buf));
|
||||
_label->setText(buf);
|
||||
_label->repaint();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void Label::init(int textBufferLen,const char* text,bool textFitted)
|
||||
{
|
||||
_contentFitted=textFitted;
|
||||
_textAlignment=a_center;
|
||||
_contentAlignment=a_center;
|
||||
_textImage=new TextImage(textBufferLen,text);
|
||||
_textImage->setColor(Color(Scheme::sc_black));
|
||||
_image=null;
|
||||
setText(textBufferLen,text);
|
||||
}
|
||||
|
||||
Label::Label(int textBufferLen,const char* text,int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
||||
{
|
||||
init(textBufferLen,text,false);
|
||||
}
|
||||
|
||||
Label::Label(const char* text,int x,int y,int wide,int tall): Panel(x,y,wide,tall)
|
||||
{
|
||||
init(strlen(text)+1,text,false);
|
||||
}
|
||||
|
||||
Label::Label(const char* text,int x,int y) : Panel(x,y,10,10)
|
||||
{
|
||||
init(strlen(text)+1,text,true);
|
||||
}
|
||||
|
||||
Label::Label(const char* text) : Panel(0,0,10,10)
|
||||
{
|
||||
init(strlen(text)+1,text,true);
|
||||
}
|
||||
|
||||
void Label::getTextSize(int& wide,int& tall)
|
||||
{
|
||||
_textImage->getTextSize(wide,tall);
|
||||
}
|
||||
|
||||
void Label::getContentSize(int& wide,int& tall)
|
||||
{
|
||||
int tx0,ty0,tx1,ty1,ix0,iy0,ix1,iy1,minX,minY,maxX,maxY;
|
||||
computeAlignment(tx0,ty0,tx1,ty1,ix0,iy0,ix1,iy1,minX,minY,maxX,maxY);
|
||||
wide=maxX-minX;
|
||||
tall=maxY-minY;
|
||||
}
|
||||
|
||||
void Label::setFont(Scheme::SchemeFont schemeFont)
|
||||
{
|
||||
_textImage->setFont(schemeFont);
|
||||
recomputeMinimumSize();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void Label::setImage(Image* image)
|
||||
{
|
||||
_image=image;
|
||||
recomputeMinimumSize();
|
||||
|
||||
if(_image!=null)
|
||||
{
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
void Label::setText(int textBufferLen,const char* text)
|
||||
{
|
||||
_textImage->setText(textBufferLen,text);
|
||||
recomputeMinimumSize();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void Label::setText(const char* format,...)
|
||||
{
|
||||
char buf[4096];
|
||||
va_list argList;
|
||||
|
||||
va_start(argList,format);
|
||||
int ret=_vsnprintf(buf,sizeof(buf),format,argList);
|
||||
buf[sizeof(buf)-1]=0;
|
||||
va_end(argList);
|
||||
|
||||
setText(strlen(buf)+1,buf);
|
||||
}
|
||||
|
||||
void Label::computeAlignment(int& tx0,int& ty0,int& tx1,int& ty1,int& ix0,int& iy0,int& ix1,int& iy1,int& minX,int& minY,int& maxX,int& maxY)
|
||||
{
|
||||
int wide,tall;
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
int tWide,tTall;
|
||||
getTextSize(tWide,tTall);
|
||||
|
||||
int iWide=0;
|
||||
int iTall=0;
|
||||
|
||||
if(_image!=null)
|
||||
{
|
||||
_image->getSize(iWide,iTall);
|
||||
}
|
||||
|
||||
ix0=0;
|
||||
iy0=0;
|
||||
ix1=iWide;
|
||||
iy1=iTall;
|
||||
|
||||
tx0=0;
|
||||
ty0=0;
|
||||
tx1=tWide;
|
||||
ty1=tTall;
|
||||
|
||||
switch(_textAlignment)
|
||||
{
|
||||
// left
|
||||
case Label::a_northwest:
|
||||
case Label::a_west:
|
||||
case Label::a_southwest:
|
||||
{
|
||||
tx0=ix0-tWide;
|
||||
break;
|
||||
}
|
||||
// center
|
||||
case Label::a_north:
|
||||
case Label::a_center:
|
||||
case Label::a_south:
|
||||
{
|
||||
tx0=((ix1-ix0)/2)-((tx1-tx0)/2);
|
||||
break;
|
||||
}
|
||||
// right
|
||||
case Label::a_northeast:
|
||||
case Label::a_east:
|
||||
case Label::a_southeast:
|
||||
{
|
||||
tx0=ix1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch(_textAlignment)
|
||||
{
|
||||
// top
|
||||
case Label::a_northwest:
|
||||
case Label::a_north:
|
||||
case Label::a_northeast:
|
||||
{
|
||||
ty0=iy0-tTall;
|
||||
break;
|
||||
}
|
||||
// center
|
||||
case Label::a_west:
|
||||
case Label::a_center:
|
||||
case Label::a_east:
|
||||
{
|
||||
ty0=((iy1-iy0)/2)-((ty1-ty0)/2);
|
||||
break;
|
||||
}
|
||||
// south
|
||||
case Label::a_southwest:
|
||||
case Label::a_south:
|
||||
case Label::a_southeast:
|
||||
{
|
||||
ty0=iy1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
tx1=tx0+tWide;
|
||||
ty1=ty0+tTall;
|
||||
|
||||
minX=tx0;
|
||||
minY=ty0;
|
||||
|
||||
if(ix0<minX)
|
||||
{
|
||||
minX=ix0;
|
||||
}
|
||||
if(iy0<minY)
|
||||
{
|
||||
minY=iy0;
|
||||
}
|
||||
|
||||
maxX=tx1;
|
||||
maxY=ty1;
|
||||
|
||||
if(ix1>maxX)
|
||||
{
|
||||
maxX=ix1;
|
||||
}
|
||||
if(iy1>maxY)
|
||||
{
|
||||
maxY=iy1;
|
||||
}
|
||||
|
||||
tx0-=minX;
|
||||
ty0-=minY;
|
||||
tx1-=minX;
|
||||
ty1-=minY;
|
||||
|
||||
ix0-=minX;
|
||||
iy0-=minY;
|
||||
ix1-=minX;
|
||||
iy1-=minY;
|
||||
|
||||
maxX-=minX;
|
||||
maxY-=minY;
|
||||
minX=0;
|
||||
minY=0;
|
||||
|
||||
int offX,offY;
|
||||
switch(_contentAlignment)
|
||||
{
|
||||
// left
|
||||
case Label::a_northwest:
|
||||
case Label::a_west:
|
||||
case Label::a_southwest:
|
||||
{
|
||||
offX=0;
|
||||
break;
|
||||
}
|
||||
// center
|
||||
case Label::a_north:
|
||||
case Label::a_center:
|
||||
case Label::a_south:
|
||||
{
|
||||
offX=(wide/2)-((maxX-minX)/2);
|
||||
break;
|
||||
}
|
||||
// right
|
||||
case Label::a_northeast:
|
||||
case Label::a_east:
|
||||
case Label::a_southeast:
|
||||
{
|
||||
offX=minX+wide-maxX;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch(_contentAlignment)
|
||||
{
|
||||
// top
|
||||
case Label::a_northwest:
|
||||
case Label::a_north:
|
||||
case Label::a_northeast:
|
||||
{
|
||||
offY=0;
|
||||
break;
|
||||
}
|
||||
// center
|
||||
case Label::a_west:
|
||||
case Label::a_center:
|
||||
case Label::a_east:
|
||||
{
|
||||
offY=(tall/2)-(maxY/2);
|
||||
break;
|
||||
}
|
||||
// south
|
||||
case Label::a_southwest:
|
||||
case Label::a_south:
|
||||
case Label::a_southeast:
|
||||
{
|
||||
offY=tall-maxY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
tx0+=offX;
|
||||
ty0+=offY;
|
||||
tx1+=offX;
|
||||
ty1+=offY;
|
||||
|
||||
ix0+=offX;
|
||||
iy0+=offY;
|
||||
ix1+=offX;
|
||||
iy1+=offY;
|
||||
|
||||
minX+=offX;
|
||||
minY+=offY;
|
||||
maxX+=offX;
|
||||
maxY+=offY;
|
||||
|
||||
int pad=4;
|
||||
minX-=pad;
|
||||
minY-=pad;
|
||||
maxX+=pad;
|
||||
maxY+=pad;
|
||||
}
|
||||
|
||||
void Label::paint()
|
||||
{
|
||||
int tx0,ty0,tx1,ty1,ix0,iy0,ix1,iy1,minX,minY,maxX,maxY;
|
||||
computeAlignment(tx0,ty0,tx1,ty1,ix0,iy0,ix1,iy1,minX,minY,maxX,maxY);
|
||||
|
||||
if(_image!=null)
|
||||
{
|
||||
_image->setPos(ix0,iy0);
|
||||
_image->doPaint(this);
|
||||
}
|
||||
|
||||
if(_textImage!=null)
|
||||
{
|
||||
_textImage->setPos(tx0,ty0);
|
||||
_textImage->doPaint(this);
|
||||
}
|
||||
|
||||
if(hasFocus())
|
||||
{
|
||||
drawSetColor(Scheme::sc_primary2);
|
||||
drawOutlinedRect(tx0,ty0,tx1,ty1);
|
||||
}
|
||||
}
|
||||
|
||||
void Label::setTextAlignment(Alignment alignment)
|
||||
{
|
||||
_textAlignment=alignment;
|
||||
recomputeMinimumSize();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void Label::setContentAlignment(Alignment alignment)
|
||||
{
|
||||
_contentAlignment=alignment;
|
||||
recomputeMinimumSize();
|
||||
repaint();
|
||||
}
|
||||
|
||||
Panel* Label::createPropertyPanel()
|
||||
{
|
||||
Panel* parentPropertyPanel=Panel::createPropertyPanel();
|
||||
|
||||
TreeFolder* folder=new TreeFolder("Label");
|
||||
parentPropertyPanel->addChild(folder);
|
||||
folder->addChild(new FooDumb(this));
|
||||
folder->addChild(new Label("setContentAlignment"));
|
||||
|
||||
return parentPropertyPanel;
|
||||
}
|
||||
|
||||
void Label::recomputeMinimumSize()
|
||||
{
|
||||
int wide,tall;
|
||||
getContentSize(wide,tall);
|
||||
setPreferredSize(wide,tall);
|
||||
|
||||
if(_contentFitted)
|
||||
{
|
||||
setSize(wide,tall);
|
||||
}
|
||||
}
|
||||
|
||||
void Label::setFont(Font* font)
|
||||
{
|
||||
_textImage->setFont(font);
|
||||
recomputeMinimumSize();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void Label::setFgColor(int r,int g,int b,int a)
|
||||
{
|
||||
Panel::setFgColor(r,g,b,a);
|
||||
Color color=Color(r,g,b,a);
|
||||
_textImage->setColor(color);
|
||||
repaint();
|
||||
}
|
||||
|
||||
void Label::setFgColor(vgui::Scheme::SchemeColor sc)
|
||||
{
|
||||
Panel::setFgColor(sc);
|
||||
_textImage->setColor(sc);
|
||||
repaint();
|
||||
}
|
||||
|
||||
void Label::setContentFitted(bool state)
|
||||
{
|
||||
_contentFitted=state;
|
||||
recomputeMinimumSize();
|
||||
repaint();
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_Layout.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
Layout::Layout()
|
||||
{
|
||||
}
|
||||
|
||||
/*void Layout::setPanel(Panel* panel)
|
||||
{
|
||||
}*/
|
||||
|
||||
void Layout::performLayout(Panel* panel)
|
||||
{
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_LineBorder.h>
|
||||
#include<VGUI_Panel.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
LineBorder::LineBorder() : Border()
|
||||
{
|
||||
init(1,Color(0,0,0,0));
|
||||
}
|
||||
|
||||
LineBorder::LineBorder(int thickness) : Border()
|
||||
{
|
||||
init(thickness,Color(0,0,0,0));
|
||||
}
|
||||
|
||||
LineBorder::LineBorder(Color color) : Border()
|
||||
{
|
||||
init(1,color);
|
||||
}
|
||||
|
||||
LineBorder::LineBorder(int thickness,Color color) : Border()
|
||||
{
|
||||
init(thickness,color);
|
||||
}
|
||||
|
||||
void LineBorder::init(int thickness,Color color)
|
||||
{
|
||||
setInset(thickness,thickness,thickness,thickness);
|
||||
_color=color;
|
||||
}
|
||||
|
||||
void LineBorder::paint(Panel* panel)
|
||||
{
|
||||
int wide,tall;
|
||||
panel->getSize(wide,tall);
|
||||
|
||||
int r,g,b,a;
|
||||
_color.getColor(r,g,b,a);
|
||||
drawSetColor(r,g,b,a);
|
||||
|
||||
drawFilledRect(0,0,wide,_inset[1]);
|
||||
drawFilledRect(0,tall-_inset[3],wide,tall);
|
||||
drawFilledRect(0,_inset[1],_inset[0],tall-_inset[3]);
|
||||
drawFilledRect(wide-_inset[2],_inset[1],wide,tall-_inset[3]);
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_ListPanel.h>
|
||||
#include<VGUI_StackLayout.h>
|
||||
#include<VGUI_ScrollBar.h>
|
||||
#include<VGUI_IntChangeSignal.h>
|
||||
#include<VGUI_Label.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class FooDefaultListPanelSignal : public IntChangeSignal
|
||||
{
|
||||
public:
|
||||
FooDefaultListPanelSignal(ListPanel* listPanel)
|
||||
{
|
||||
_listPanel=listPanel;
|
||||
}
|
||||
virtual void intChanged(int value,Panel* panel)
|
||||
{
|
||||
_listPanel->setPixelScroll(-value);
|
||||
}
|
||||
protected:
|
||||
ListPanel* _listPanel;
|
||||
};
|
||||
}
|
||||
|
||||
ListPanel::ListPanel(int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
||||
{
|
||||
_vpanel=new Panel(0,0,wide-15,tall*2);
|
||||
_vpanel->setParent(this);
|
||||
|
||||
setLayout(new StackLayout(1,false));
|
||||
setBgColor(0,0,100,0);
|
||||
|
||||
_scroll=new ScrollBar(wide-15,0,15,tall,true);
|
||||
_scroll->setParent(this);
|
||||
_scroll->addIntChangeSignal(new FooDefaultListPanelSignal(this));
|
||||
}
|
||||
|
||||
void ListPanel::paintBackground()
|
||||
{
|
||||
Panel::paintBackground();
|
||||
}
|
||||
|
||||
void ListPanel::addString(const char* str)
|
||||
{
|
||||
addItem(new Label(str,0,0,80,20));
|
||||
}
|
||||
|
||||
void ListPanel::addItem(Panel* panel)
|
||||
{
|
||||
panel->setParent(_vpanel);
|
||||
_vpanel->invalidateLayout(true);
|
||||
Panel* last=_vpanel->getChild(_vpanel->getChildCount()-1);
|
||||
int x,y,wide,tall,vwide,vtall;
|
||||
last->getBounds(x,y,wide,tall);
|
||||
_vpanel->getSize(vwide,vtall);
|
||||
_vpanel->setSize(vwide,y+tall);
|
||||
_scroll->setRange(0,y+tall-_size[1]);
|
||||
}
|
||||
|
||||
void ListPanel::setSize(int wide,int tall)
|
||||
{
|
||||
Panel::setSize(wide,tall);
|
||||
invalidateLayout(false);
|
||||
}
|
||||
|
||||
void ListPanel::performLayout()
|
||||
{
|
||||
Panel* last=_vpanel->getChild(_vpanel->getChildCount()-1);
|
||||
if(last==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int x,y,wide,tall;
|
||||
last->getBounds(x,y,wide,tall);
|
||||
|
||||
int vwide,vtall;
|
||||
_vpanel->getSize(vwide,vtall);
|
||||
_vpanel->setSize(_size[0]-15,tall);
|
||||
_scroll->setBounds(_size[0]-15,0,15,_size[1]);
|
||||
_scroll->setRange(0,y+tall-_size[1]);
|
||||
}
|
||||
|
||||
void ListPanel::setPixelScroll(int value)
|
||||
{
|
||||
_vpanel->setPos(0,value);
|
||||
repaint();
|
||||
_vpanel->repaint();
|
||||
}
|
||||
|
||||
void ListPanel::translatePixelScroll(int delta)
|
||||
{
|
||||
int x,y;
|
||||
_vpanel->getPos(x,y);
|
||||
_vpanel->setPos(0,y+delta);
|
||||
repaint();
|
||||
_vpanel->repaint();
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_LoweredBorder.h>
|
||||
#include<VGUI_Panel.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
LoweredBorder::LoweredBorder() : Border()
|
||||
{
|
||||
setInset(2,2,2,2);
|
||||
}
|
||||
|
||||
void LoweredBorder::paint(Panel* panel)
|
||||
{
|
||||
int wide,tall;
|
||||
panel->getSize(wide,tall);
|
||||
|
||||
drawSetColor(Scheme::sc_secondary2);
|
||||
drawFilledRect(0,0,wide,2);
|
||||
drawFilledRect(0,2,2,tall);
|
||||
|
||||
drawSetColor(Scheme::sc_white);
|
||||
drawFilledRect(1,tall-2,wide,tall);
|
||||
drawFilledRect(wide-2,1,wide,tall-1);
|
||||
|
||||
drawSetColor(Scheme::sc_secondary1);
|
||||
drawFilledRect(1,1,wide-1,2);
|
||||
drawFilledRect(1,2,2,tall-1);
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_Menu.h>
|
||||
#include<VGUI_RaisedBorder.h>
|
||||
#include<VGUI_StackLayout.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
Menu::Menu(int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
||||
{
|
||||
setBorder(new RaisedBorder());
|
||||
setLayout(new StackLayout(1,true));
|
||||
}
|
||||
|
||||
Menu::Menu(int wide,int tall) : Panel(0,0,wide,tall)
|
||||
{
|
||||
setBorder(new RaisedBorder());
|
||||
setLayout(new StackLayout(1,true));
|
||||
}
|
||||
|
||||
void Menu::addMenuItem(Panel* panel)
|
||||
{
|
||||
addChild(panel);
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_MenuItem.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
MenuItem::MenuItem(const char* text) : Button(text,0,0)
|
||||
{
|
||||
setButtonBorderEnabled(false);
|
||||
_subMenu=null;
|
||||
}
|
||||
|
||||
MenuItem::MenuItem(const char* text,Menu* subMenu) : Button(text,0,0)
|
||||
{
|
||||
setButtonBorderEnabled(false);
|
||||
_subMenu=subMenu;
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_MenuSeparator.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
MenuSeparator::MenuSeparator(const char* text) : Label(text)
|
||||
{
|
||||
setFont(Scheme::sf_primary3);
|
||||
}
|
||||
|
||||
void MenuSeparator::paintBackground()
|
||||
{
|
||||
int wide,tall;
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
drawSetColor(Scheme::sc_secondary3);
|
||||
drawFilledRect(0,0,wide,tall);
|
||||
|
||||
int textWide,textTall;
|
||||
int gap=2;
|
||||
int tgap=2;
|
||||
|
||||
getTextSize(textWide,textTall);
|
||||
|
||||
if(textWide>0)
|
||||
{
|
||||
textWide+=(gap*2);
|
||||
}
|
||||
|
||||
int wide2=(textWide/2);
|
||||
int tall2=(textTall/2)-(tgap/2);
|
||||
int x0=(wide/2)-wide2;
|
||||
int x1=(wide/2)+wide2;
|
||||
|
||||
drawSetColor(Scheme::sc_secondary1);
|
||||
drawFilledRect(gap,tall2,x0,tall2+(tgap/2));
|
||||
drawFilledRect(x1,tall2,wide-gap,tall2+(tgap/2));
|
||||
|
||||
drawSetColor(Scheme::sc_white);
|
||||
drawFilledRect(gap,tall2+(tgap/2),x0,tall2+tgap);
|
||||
drawFilledRect(x1,tall2+(tgap/2),wide-gap,tall2+tgap);
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_MessageBox.h>
|
||||
#include<VGUI_ActionSignal.h>
|
||||
#include<VGUI_Label.h>
|
||||
#include<VGUI_Button.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class FooButtonHandler : public ActionSignal
|
||||
{
|
||||
private:
|
||||
MessageBox* _messageBox;
|
||||
public:
|
||||
FooButtonHandler(MessageBox* messageBox)
|
||||
{
|
||||
_messageBox=messageBox;
|
||||
}
|
||||
public:
|
||||
virtual void actionPerformed(Panel* panel)
|
||||
{
|
||||
_messageBox->fireActionSignal();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
MessageBox::MessageBox(const char* title,const char* text,int x,int y) : Frame(x,y,64,64)
|
||||
{
|
||||
setTitle(title);
|
||||
setMenuButtonVisible(false);
|
||||
setTrayButtonVisible(false);
|
||||
setMinimizeButtonVisible(false);
|
||||
setMaximizeButtonVisible(false);
|
||||
setCloseButtonVisible(false);
|
||||
setSizeable(false);
|
||||
|
||||
_messageLabel=new Label(text);
|
||||
_messageLabel->setParent(getClient());
|
||||
|
||||
_okButton=new Button("Ok",10,10);
|
||||
_okButton->setParent(getClient());
|
||||
_okButton->addActionSignal(new FooButtonHandler(this));
|
||||
|
||||
int wide,tall;
|
||||
_messageLabel->getSize(wide,tall);
|
||||
setSize(wide+100,tall+100);
|
||||
}
|
||||
|
||||
void MessageBox::addActionSignal(ActionSignal* s)
|
||||
{
|
||||
_actionSignalDar.putElement(s);
|
||||
}
|
||||
|
||||
void MessageBox::fireActionSignal()
|
||||
{
|
||||
for(int i=0;i<_actionSignalDar.getCount();i++)
|
||||
{
|
||||
_actionSignalDar[i]->actionPerformed(this);
|
||||
}
|
||||
}
|
||||
|
||||
void MessageBox::performLayout()
|
||||
{
|
||||
int wide,tall;
|
||||
getClient()->getSize(wide,tall);
|
||||
|
||||
_messageLabel->setPos((wide/2)-(_messageLabel->getWide()/2),(tall/2)-(_messageLabel->getTall()/2));
|
||||
_okButton->setPos((wide/2)-(_okButton->getWide()/2),(tall/2)-(_okButton->getTall()/2));
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<string.h>
|
||||
#include<VGUI_MiniApp.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
MiniApp::MiniApp()
|
||||
{
|
||||
_name=null;
|
||||
}
|
||||
|
||||
void MiniApp::getName(char* buf,int bufLen)
|
||||
{
|
||||
if(buf==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int len=strlen(_name)+1;
|
||||
if(len>bufLen)
|
||||
{
|
||||
len=bufLen;
|
||||
}
|
||||
|
||||
memcpy(buf,_name,len-1);
|
||||
buf[len-1]=0;
|
||||
}
|
||||
|
||||
void MiniApp::setName(const char* name)
|
||||
{
|
||||
_name=strdup(_name);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,24 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_PopupMenu.h>
|
||||
#include<VGUI_SurfaceBase.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
PopupMenu::PopupMenu(int x,int y,int wide,int tall) : Menu(x,y,wide,tall)
|
||||
{
|
||||
}
|
||||
|
||||
PopupMenu::PopupMenu(int wide,int tall) : Menu(wide,tall)
|
||||
{
|
||||
}
|
||||
|
||||
void PopupMenu::showModal(Panel* panel)
|
||||
{
|
||||
panel->getSurfaceBase()->createPopup(this);
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<math.h>
|
||||
#include<VGUI_ProgressBar.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
ProgressBar::ProgressBar(int segmentCount)
|
||||
{
|
||||
_segmentCount=segmentCount;
|
||||
_progress=0;
|
||||
}
|
||||
|
||||
void ProgressBar::paintBackground()
|
||||
{
|
||||
int wide,tall;
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
drawSetColor(Scheme::sc_secondary2);
|
||||
drawFilledRect(0,0,wide,tall);
|
||||
|
||||
const int segmentGap=2;
|
||||
int segmentWide=wide/_segmentCount-segmentGap;
|
||||
|
||||
const float rr=0;
|
||||
const float gg=0;
|
||||
const float bb=100;
|
||||
|
||||
int x=0;
|
||||
|
||||
int litSeg=(int)floor(_progress);
|
||||
for(int i=litSeg;i>0;i--)
|
||||
{
|
||||
drawSetColor((int)rr,(int)gg,(int)bb,0);
|
||||
drawFilledRect(x,0,x+segmentWide,tall);
|
||||
x+=segmentWide+segmentGap;
|
||||
}
|
||||
|
||||
if(_segmentCount>_progress)
|
||||
{
|
||||
float frac=_progress-(float)floor(_progress);
|
||||
float r=0;
|
||||
float g=255-(frac*155);
|
||||
float b=0;
|
||||
|
||||
drawSetColor((int)r,(int)g,(int)b,0);
|
||||
drawFilledRect(x,0,x+segmentWide,tall);
|
||||
}
|
||||
}
|
||||
|
||||
void ProgressBar::setProgress(float progress)
|
||||
{
|
||||
if(_progress!=progress)
|
||||
{
|
||||
_progress=progress;
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
int ProgressBar::getSegmentCount()
|
||||
{
|
||||
return _segmentCount;
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_RadioButton.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class FooRadioImage : public Image
|
||||
{
|
||||
public:
|
||||
FooRadioImage(RadioButton* radioButton) : Image()
|
||||
{
|
||||
_radioButton=radioButton;
|
||||
setSize(20,20);
|
||||
}
|
||||
public:
|
||||
virtual void paint()
|
||||
{
|
||||
drawSetTextFont(Scheme::sf_secondary1);
|
||||
drawSetTextColor(Scheme::sc_white);
|
||||
drawPrintChar(0,0,'n');
|
||||
drawSetTextColor(Scheme::sc_secondary2);
|
||||
drawPrintChar(0,0,'j');
|
||||
drawSetTextColor(Scheme::sc_white);
|
||||
drawPrintChar(0,0,'k');
|
||||
drawSetTextColor(Scheme::sc_black);
|
||||
drawPrintChar(0,0,'l');
|
||||
drawSetTextColor(Scheme::sc_secondary3);
|
||||
drawPrintChar(0,0,'m');
|
||||
if(_radioButton->isSelected())
|
||||
{
|
||||
drawSetTextColor(Scheme::sc_black);
|
||||
drawPrintChar(0,0,'h');
|
||||
}
|
||||
}
|
||||
protected:
|
||||
RadioButton* _radioButton;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
RadioButton::RadioButton(const char* text,int x,int y,int wide,int tall) : ToggleButton(text,x,y,wide,tall)
|
||||
{
|
||||
setTextAlignment(Label::a_east);
|
||||
setImage(new FooRadioImage(this));
|
||||
}
|
||||
|
||||
RadioButton::RadioButton(const char* text,int x,int y) : ToggleButton(text,x,y)
|
||||
{
|
||||
setTextAlignment(Label::a_east);
|
||||
setImage(new FooRadioImage(this));
|
||||
|
||||
int wide,tall;
|
||||
getContentSize(wide,tall);
|
||||
setSize(wide,tall);
|
||||
}
|
||||
|
||||
void RadioButton::paintBackground()
|
||||
{
|
||||
int wide,tall;
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
drawSetColor(Scheme::sc_secondary3);
|
||||
drawFilledRect(0,0,wide,tall);
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_RaisedBorder.h>
|
||||
#include<VGUI_Panel.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
RaisedBorder::RaisedBorder() : Border()
|
||||
{
|
||||
setInset(2,2,2,2);
|
||||
}
|
||||
|
||||
void RaisedBorder::paint(Panel* panel)
|
||||
{
|
||||
int wide,tall;
|
||||
panel->getSize(wide,tall);
|
||||
|
||||
drawSetColor(Scheme::sc_white);
|
||||
drawFilledRect(0,0,wide,2);
|
||||
drawFilledRect(0,2,2,tall);
|
||||
|
||||
drawSetColor(Scheme::sc_secondary2);
|
||||
drawFilledRect(2,tall-2,wide,tall);
|
||||
drawFilledRect(wide-2,2,wide,tall-1);
|
||||
|
||||
drawSetColor(Scheme::sc_secondary1);
|
||||
drawFilledRect(1,tall-1,wide,tall);
|
||||
drawFilledRect(wide-1,1,wide,tall-1);
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_Scheme.h>
|
||||
#include<VGUI_Font.h>
|
||||
#include<VGUI_Cursor.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
Scheme::Scheme()
|
||||
{
|
||||
setColor(sc_black,0,0,0,0);
|
||||
setColor(sc_white,255,255,255,0);
|
||||
setColor(sc_primary1,102,102,153,0);
|
||||
setColor(sc_primary2,153,153,204,0);
|
||||
setColor(sc_primary3,204,204,255,0);
|
||||
setColor(sc_secondary1,102,102,102,0);
|
||||
setColor(sc_secondary2,153,153,153,0);
|
||||
setColor(sc_secondary3,204,204,204,0);
|
||||
setColor(sc_user,0,0,0,0);
|
||||
setFont(sf_primary1,new Font("Arial",0,0,20,0,0,400,false,false,false,false));
|
||||
setFont(sf_primary2,new Font("FixedSys",0,0,18,0,0,400,false,false,false,false));
|
||||
setFont(sf_primary3,new Font("Arial",0,0,12,0,0,400,false,false,false,false));
|
||||
setFont(sf_secondary1,new Font("Marlett",0,0,16,0,0,0,false,false,false,true));
|
||||
setCursor(scu_none,new Cursor(Cursor::dc_none));
|
||||
setCursor(scu_arrow,new Cursor(Cursor::dc_arrow));
|
||||
setCursor(scu_ibeam,new Cursor(Cursor::dc_ibeam));
|
||||
setCursor(scu_hourglass,new Cursor(Cursor::dc_hourglass));
|
||||
setCursor(scu_crosshair,new Cursor(Cursor::dc_crosshair));
|
||||
setCursor(scu_up,new Cursor(Cursor::dc_up));
|
||||
setCursor(scu_sizenwse,new Cursor(Cursor::dc_sizenwse));
|
||||
setCursor(scu_sizenesw,new Cursor(Cursor::dc_sizenesw));
|
||||
setCursor(scu_sizewe,new Cursor(Cursor::dc_sizewe));
|
||||
setCursor(scu_sizens,new Cursor(Cursor::dc_sizens));
|
||||
setCursor(scu_sizeall,new Cursor(Cursor::dc_sizeall));
|
||||
setCursor(scu_no,new Cursor(Cursor::dc_no));
|
||||
setCursor(scu_hand,new Cursor(Cursor::dc_hand));
|
||||
}
|
||||
|
||||
void Scheme::setColor(SchemeColor sc,int r,int g,int b,int a)
|
||||
{
|
||||
_color[sc][0]=r;
|
||||
_color[sc][1]=g;
|
||||
_color[sc][2]=b;
|
||||
_color[sc][3]=a;
|
||||
}
|
||||
|
||||
void Scheme::getColor(SchemeColor sc,int& r,int& g,int& b,int& a)
|
||||
{
|
||||
r=_color[sc][0];
|
||||
g=_color[sc][1];
|
||||
b=_color[sc][2];
|
||||
a=_color[sc][3];
|
||||
}
|
||||
|
||||
void Scheme::setFont(SchemeFont sf,Font* font)
|
||||
{
|
||||
_font[sf]=font;
|
||||
}
|
||||
|
||||
Font* Scheme::getFont(SchemeFont sf)
|
||||
{
|
||||
return _font[sf];
|
||||
}
|
||||
|
||||
void Scheme::setCursor(SchemeCursor scu,Cursor* cursor)
|
||||
{
|
||||
_cursor[scu]=cursor;
|
||||
}
|
||||
|
||||
Cursor* Scheme::getCursor(SchemeCursor scu)
|
||||
{
|
||||
return _cursor[scu];
|
||||
}
|
|
@ -1,262 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_ScrollBar.h>
|
||||
#include<VGUI_Slider.h>
|
||||
#include<VGUI_IntChangeSignal.h>
|
||||
#include<VGUI_Button.h>
|
||||
#include<VGUI_ActionSignal.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
class FooDefaultScrollBarIntChangeSignal : public IntChangeSignal
|
||||
{
|
||||
public:
|
||||
FooDefaultScrollBarIntChangeSignal(ScrollBar* scrollBar)
|
||||
{
|
||||
_scrollBar=scrollBar;
|
||||
}
|
||||
virtual void intChanged(int value,Panel* panel)
|
||||
{
|
||||
_scrollBar->fireIntChangeSignal();
|
||||
}
|
||||
protected:
|
||||
ScrollBar* _scrollBar;
|
||||
};
|
||||
|
||||
class FooDefaultButtonSignal : public ActionSignal
|
||||
{
|
||||
public:
|
||||
ScrollBar* _scrollBar;
|
||||
int _buttonIndex;
|
||||
public:
|
||||
FooDefaultButtonSignal(ScrollBar* scrollBar,int buttonIndex)
|
||||
{
|
||||
_scrollBar=scrollBar;
|
||||
_buttonIndex=buttonIndex;
|
||||
}
|
||||
public:
|
||||
virtual void actionPerformed(Panel* panel)
|
||||
{
|
||||
_scrollBar->doButtonPressed(_buttonIndex);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
ScrollBar::ScrollBar(int x,int y,int wide,int tall,bool vertical) : Panel(x,y,wide,tall)
|
||||
{
|
||||
_slider=null;
|
||||
_button[0]=null;
|
||||
_button[1]=null;
|
||||
|
||||
if(vertical)
|
||||
{
|
||||
setSlider(new Slider(0,wide-1,wide,(tall-(wide*2))+2,true));
|
||||
setButton(new Button("",0,0,wide,wide),0);
|
||||
setButton(new Button("",0,tall-wide,wide,wide),1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// untested code
|
||||
setSlider(new Slider(tall,0,wide-(tall*2),tall,false));
|
||||
setButton(new Button("",0,0,tall+1,tall+1),0);
|
||||
setButton(new Button("",wide-tall,0,tall+1,tall+1),1);
|
||||
}
|
||||
|
||||
setPaintBorderEnabled(true);
|
||||
setPaintBackgroundEnabled(true);
|
||||
setPaintEnabled(true);
|
||||
setButtonPressedScrollValue(15);
|
||||
|
||||
validate();
|
||||
}
|
||||
|
||||
void ScrollBar::setSize(int wide,int tall)
|
||||
{
|
||||
Panel::setSize(wide,tall);
|
||||
|
||||
if(_slider==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(_button[0]==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(_button[1]==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
if(_slider->isVertical())
|
||||
{
|
||||
_slider->setBounds(0,wide,wide,tall-(wide*2));
|
||||
//_slider->setBounds(0,0,wide,tall);
|
||||
_button[0]->setBounds(0,0,wide,wide);
|
||||
_button[1]->setBounds(0,tall-wide,wide,wide);
|
||||
}
|
||||
else
|
||||
{
|
||||
_slider->setBounds(tall,0,wide-(tall*2),tall);
|
||||
//_slider->setBounds(0,0,wide,tall);
|
||||
_button[0]->setBounds(0,0,tall,tall);
|
||||
_button[1]->setBounds((wide-tall),0,tall,tall);
|
||||
}
|
||||
}
|
||||
|
||||
void ScrollBar::performLayout()
|
||||
{
|
||||
}
|
||||
|
||||
void ScrollBar::setValue(int value)
|
||||
{
|
||||
_slider->setValue(value);
|
||||
}
|
||||
|
||||
int ScrollBar::getValue()
|
||||
{
|
||||
return _slider->getValue();
|
||||
}
|
||||
|
||||
void ScrollBar::addIntChangeSignal(IntChangeSignal* s)
|
||||
{
|
||||
_intChangeSignalDar.putElement(s);
|
||||
_slider->addIntChangeSignal(new FooDefaultScrollBarIntChangeSignal(this));
|
||||
}
|
||||
|
||||
void ScrollBar::setRange(int min,int max)
|
||||
{
|
||||
_slider->setRange(min,max);
|
||||
}
|
||||
|
||||
void ScrollBar::fireIntChangeSignal()
|
||||
{
|
||||
for(int i=0;i<_intChangeSignalDar.getCount();i++)
|
||||
{
|
||||
_intChangeSignalDar[i]->intChanged(_slider->getValue(),this);
|
||||
}
|
||||
}
|
||||
|
||||
bool ScrollBar::isVertical()
|
||||
{
|
||||
return _slider->isVertical();
|
||||
}
|
||||
|
||||
bool ScrollBar::hasFullRange()
|
||||
{
|
||||
return _slider->hasFullRange();
|
||||
}
|
||||
|
||||
//LEAK: new and old slider will leak
|
||||
void ScrollBar::setButton(Button* button,int index)
|
||||
{
|
||||
if(_button[index]!=null)
|
||||
{
|
||||
removeChild(_button[index]);
|
||||
}
|
||||
_button[index]=button;
|
||||
addChild(_button[index]);
|
||||
|
||||
_button[index]->addActionSignal(new FooDefaultButtonSignal(this,index));
|
||||
|
||||
validate();
|
||||
|
||||
//_button[index]->setVisible(false);
|
||||
}
|
||||
|
||||
Button* ScrollBar::getButton(int index)
|
||||
{
|
||||
return _button[index];
|
||||
}
|
||||
|
||||
//LEAK: new and old slider will leak
|
||||
void ScrollBar::setSlider(Slider *slider)
|
||||
{
|
||||
if(_slider!=null)
|
||||
{
|
||||
removeChild(_slider);
|
||||
}
|
||||
_slider=slider;
|
||||
addChild(_slider);
|
||||
|
||||
_slider->addIntChangeSignal(new FooDefaultScrollBarIntChangeSignal(this));
|
||||
|
||||
validate();
|
||||
}
|
||||
|
||||
Slider *ScrollBar::getSlider()
|
||||
{
|
||||
return _slider;
|
||||
}
|
||||
|
||||
void ScrollBar::doButtonPressed(int buttonIndex)
|
||||
{
|
||||
if(buttonIndex==0)
|
||||
{
|
||||
_slider->setValue(_slider->getValue()-_buttonPressedScrollValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
_slider->setValue(_slider->getValue()+_buttonPressedScrollValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ScrollBar::setButtonPressedScrollValue(int value)
|
||||
{
|
||||
_buttonPressedScrollValue=value;
|
||||
}
|
||||
|
||||
void ScrollBar::setRangeWindow(int rangeWindow)
|
||||
{
|
||||
_slider->setRangeWindow(rangeWindow);
|
||||
}
|
||||
|
||||
void ScrollBar::setRangeWindowEnabled(bool state)
|
||||
{
|
||||
_slider->setRangeWindowEnabled(state);
|
||||
}
|
||||
|
||||
void ScrollBar::validate()
|
||||
{
|
||||
if(_slider!=null)
|
||||
{
|
||||
int buttonOffset=0;
|
||||
|
||||
for(int i=0;i<2;i++)
|
||||
{
|
||||
if(_button[i]!=null)
|
||||
{
|
||||
if(_button[i]->isVisible())
|
||||
{
|
||||
if(_slider->isVertical())
|
||||
{
|
||||
buttonOffset+=_button[i]->getTall();
|
||||
}
|
||||
else
|
||||
{
|
||||
buttonOffset+=_button[i]->getWide();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_slider->setButtonOffset(buttonOffset);
|
||||
}
|
||||
|
||||
int wide,tall;
|
||||
getSize(wide,tall);
|
||||
setSize(wide,tall);
|
||||
}
|
|
@ -1,204 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_ScrollPanel.h>
|
||||
#include<VGUI_ScrollBar.h>
|
||||
#include<VGUI_IntChangeSignal.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class ChangeHandler : public IntChangeSignal
|
||||
{
|
||||
private:
|
||||
ScrollPanel* _scrollPanel;
|
||||
public:
|
||||
ChangeHandler(ScrollPanel* scrollPanel)
|
||||
{
|
||||
_scrollPanel=scrollPanel;
|
||||
}
|
||||
public:
|
||||
virtual void intChanged(int value,Panel* panel)
|
||||
{
|
||||
_scrollPanel->recomputeScroll();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ScrollPanel::ScrollPanel(int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
||||
{
|
||||
setPaintBorderEnabled(true);
|
||||
setPaintBackgroundEnabled(false);
|
||||
setPaintEnabled(false);
|
||||
|
||||
_clientClip=new Panel(0,0,wide-16,tall-16);
|
||||
_clientClip->setParent(this);
|
||||
_clientClip->setBgColor(Color(0,128,0,0));
|
||||
_clientClip->setPaintBorderEnabled(true);
|
||||
_clientClip->setPaintBackgroundEnabled(false);
|
||||
_clientClip->setPaintEnabled(false);
|
||||
|
||||
_client=new Panel(0,0,wide*2,tall*2);
|
||||
_client->setParent(_clientClip);
|
||||
_client->setPaintBorderEnabled(true);
|
||||
_client->setPaintBackgroundEnabled(false);
|
||||
_client->setPaintEnabled(false);
|
||||
|
||||
_horizontalScrollBar=new ScrollBar(0,tall-16,wide-16,16,false);
|
||||
_horizontalScrollBar->setParent(this);
|
||||
_horizontalScrollBar->addIntChangeSignal(new ChangeHandler(this));
|
||||
_horizontalScrollBar->setVisible(false);
|
||||
|
||||
_verticalScrollBar=new ScrollBar(wide-16,0,16,tall-16,true);
|
||||
_verticalScrollBar->setParent(this);
|
||||
_verticalScrollBar->addIntChangeSignal(new ChangeHandler(this));
|
||||
_verticalScrollBar->setVisible(false);
|
||||
|
||||
_autoVisible[0]=true;
|
||||
_autoVisible[1]=true;
|
||||
|
||||
validate();
|
||||
}
|
||||
|
||||
void ScrollPanel::setSize(int wide,int tall)
|
||||
{
|
||||
Panel::setSize(wide,tall);
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
if(_autoVisible[0])
|
||||
{
|
||||
_horizontalScrollBar->setVisible(!_horizontalScrollBar->hasFullRange());
|
||||
}
|
||||
|
||||
if(_autoVisible[1])
|
||||
{
|
||||
_verticalScrollBar->setVisible(!_verticalScrollBar->hasFullRange());
|
||||
}
|
||||
|
||||
if(_verticalScrollBar->isVisible())
|
||||
{
|
||||
wide-=_verticalScrollBar->getWide();
|
||||
}
|
||||
|
||||
if(_horizontalScrollBar->isVisible())
|
||||
{
|
||||
tall-=_horizontalScrollBar->getTall();
|
||||
}
|
||||
|
||||
_verticalScrollBar->setBounds(wide,0,_verticalScrollBar->getWide(),tall);
|
||||
_horizontalScrollBar->setBounds(0,tall,wide,_horizontalScrollBar->getTall());
|
||||
_clientClip->setSize(wide,tall);
|
||||
recomputeClientSize();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void ScrollPanel::setScrollBarVisible(bool horizontal,bool vertical)
|
||||
{
|
||||
_horizontalScrollBar->setVisible(horizontal);
|
||||
_verticalScrollBar->setVisible(horizontal);
|
||||
|
||||
validate();
|
||||
}
|
||||
|
||||
Panel* ScrollPanel::getClient()
|
||||
{
|
||||
return _client;
|
||||
}
|
||||
|
||||
Panel* ScrollPanel::getClientClip()
|
||||
{
|
||||
return _clientClip;
|
||||
}
|
||||
|
||||
void ScrollPanel::setScrollValue(int horizontal,int vertical)
|
||||
{
|
||||
_horizontalScrollBar->setValue(horizontal);
|
||||
_verticalScrollBar->setValue(horizontal);
|
||||
recomputeScroll();
|
||||
}
|
||||
|
||||
void ScrollPanel::getScrollValue(int& horizontal,int& vertical)
|
||||
{
|
||||
horizontal=_horizontalScrollBar->getValue();
|
||||
vertical=_verticalScrollBar->getValue();
|
||||
}
|
||||
|
||||
void ScrollPanel::recomputeScroll()
|
||||
{
|
||||
int x,y;
|
||||
getScrollValue(x,y);
|
||||
_client->setPos(-x,-y);
|
||||
_clientClip->repaint();
|
||||
}
|
||||
|
||||
void ScrollPanel::setScrollBarAutoVisible(bool horizontal,bool vertical)
|
||||
{
|
||||
_autoVisible[0]=horizontal;
|
||||
_autoVisible[1]=vertical;
|
||||
|
||||
validate();
|
||||
}
|
||||
|
||||
void ScrollPanel::recomputeClientSize()
|
||||
{
|
||||
int wide=0;
|
||||
int tall=0;
|
||||
|
||||
for(int i=0;i<_client->getChildCount();i++)
|
||||
{
|
||||
Panel* child=_client->getChild(i);
|
||||
if(child->isVisible())
|
||||
{
|
||||
int x,y,w,t;
|
||||
child->getPos(x,y);
|
||||
child->getVirtualSize(w,t);
|
||||
x+=w;
|
||||
y+=t;
|
||||
|
||||
if(x>wide)
|
||||
{
|
||||
wide=x;
|
||||
}
|
||||
if(t>tall)
|
||||
{
|
||||
tall=t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_client->setSize(wide,tall);
|
||||
|
||||
_horizontalScrollBar->setRange(0,_client->getWide()-_clientClip->getWide());
|
||||
_horizontalScrollBar->setRangeWindow(_client->getWide());
|
||||
|
||||
_verticalScrollBar->setRange(0,_client->getTall()-_clientClip->getTall());
|
||||
_verticalScrollBar->setRangeWindow(_client->getTall());
|
||||
}
|
||||
|
||||
ScrollBar* ScrollPanel::getHorizontalScrollBar()
|
||||
{
|
||||
return _horizontalScrollBar;
|
||||
}
|
||||
|
||||
ScrollBar* ScrollPanel::getVerticalScrollBar()
|
||||
{
|
||||
return _verticalScrollBar;
|
||||
}
|
||||
|
||||
void ScrollPanel::validate()
|
||||
{
|
||||
_horizontalScrollBar->setRangeWindowEnabled(true);
|
||||
_verticalScrollBar->setRangeWindowEnabled(true);
|
||||
|
||||
int wide,tall;
|
||||
getSize(wide,tall);
|
||||
setSize(wide,tall);
|
||||
setSize(wide,tall);
|
||||
setSize(wide,tall);
|
||||
setSize(wide,tall);
|
||||
}
|
|
@ -1,449 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_Slider.h>
|
||||
#include<VGUI_InputSignal.h>
|
||||
#include<VGUI_App.h>
|
||||
#include<VGUI_IntChangeSignal.h>
|
||||
#include<VGUI_MouseCode.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class FooDefaultSliderSignal : public InputSignal
|
||||
{
|
||||
private:
|
||||
Slider* _slider;
|
||||
public:
|
||||
FooDefaultSliderSignal(Slider* slider)
|
||||
{
|
||||
_slider=slider;
|
||||
}
|
||||
public:
|
||||
void cursorMoved(int x,int y,Panel* panel)
|
||||
{
|
||||
_slider->privateCursorMoved(x,y,panel);
|
||||
}
|
||||
void cursorEntered(Panel* panel){}
|
||||
void cursorExited(Panel* panel){}
|
||||
void mouseDoublePressed(MouseCode code,Panel* panel){}
|
||||
void mousePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
_slider->privateMousePressed(code,panel);
|
||||
}
|
||||
void mouseReleased(MouseCode code,Panel* panel)
|
||||
{
|
||||
_slider->privateMouseReleased(code,panel);
|
||||
}
|
||||
void mouseWheeled(int delta,Panel* panel){}
|
||||
void keyPressed(KeyCode code,Panel* panel){}
|
||||
void keyTyped(KeyCode code,Panel* panel){}
|
||||
void keyReleased(KeyCode code,Panel* panel){}
|
||||
void keyFocusTicked(Panel* panel){}
|
||||
};
|
||||
}
|
||||
|
||||
Slider::Slider(int x,int y,int wide,int tall,bool vertical) : Panel(x,y,wide,tall)
|
||||
{
|
||||
_vertical=vertical;
|
||||
_dragging=false;
|
||||
_value=0;
|
||||
_range[0]=0;
|
||||
_range[1]=299;
|
||||
_rangeWindow=0;
|
||||
_rangeWindowEnabled=false;
|
||||
_buttonOffset=0;
|
||||
recomputeNobPosFromValue();
|
||||
addInputSignal(new FooDefaultSliderSignal(this));
|
||||
}
|
||||
|
||||
void Slider::setSize(int wide,int tall)
|
||||
{
|
||||
Panel::setSize(wide,tall);
|
||||
recomputeNobPosFromValue();
|
||||
}
|
||||
|
||||
bool Slider::isVertical()
|
||||
{
|
||||
return _vertical;
|
||||
}
|
||||
|
||||
void Slider::setValue(int value)
|
||||
{
|
||||
int oldValue=_value;
|
||||
|
||||
if(value<_range[0])
|
||||
{
|
||||
value=_range[0];
|
||||
}
|
||||
|
||||
if(value>_range[1])
|
||||
{
|
||||
value=_range[1];
|
||||
}
|
||||
|
||||
_value=value;
|
||||
recomputeNobPosFromValue();
|
||||
|
||||
if(_value!=oldValue)
|
||||
{
|
||||
fireIntChangeSignal();
|
||||
}
|
||||
}
|
||||
|
||||
int Slider::getValue()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
void Slider::recomputeNobPosFromValue()
|
||||
{
|
||||
int wide,tall;
|
||||
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
float fwide=(float)wide;
|
||||
float ftall=(float)tall;
|
||||
float frange=(float)(_range[1]-_range[0]);
|
||||
float fvalue=(float)(_value-_range[0]);
|
||||
float fper=fvalue/frange;
|
||||
float frangewindow=(float)(_rangeWindow);
|
||||
|
||||
if(frangewindow<0)
|
||||
{
|
||||
frangewindow=0;
|
||||
}
|
||||
|
||||
if(!_rangeWindowEnabled)
|
||||
{
|
||||
frangewindow=frange;
|
||||
}
|
||||
|
||||
if ( frangewindow > 0 )
|
||||
{
|
||||
if(_vertical)
|
||||
{
|
||||
float fnobsize=ftall/frangewindow*ftall;
|
||||
float freepixels = ftall - fnobsize;
|
||||
|
||||
float firstpixel = freepixels * fper;
|
||||
|
||||
_nobPos[0]=(int)( firstpixel );
|
||||
_nobPos[1]=(int)( firstpixel + fnobsize );
|
||||
|
||||
if(_nobPos[1]>tall)
|
||||
{
|
||||
_nobPos[0]=tall-((int)fnobsize);
|
||||
_nobPos[1]=tall;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float fnobsize=fwide/frangewindow*fwide;
|
||||
float freepixels = fwide - fnobsize;
|
||||
|
||||
float firstpixel = freepixels * fper;
|
||||
|
||||
_nobPos[0]=(int)( firstpixel );
|
||||
_nobPos[1]=(int)( firstpixel + fnobsize );
|
||||
|
||||
if(_nobPos[1]>wide)
|
||||
{
|
||||
_nobPos[0]=wide-((int)fnobsize);
|
||||
_nobPos[1]=wide;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
void Slider::recomputeValueFromNobPos()
|
||||
{
|
||||
int wide,tall;
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
float fwide=(float)wide;
|
||||
float ftall=(float)tall;
|
||||
float frange=(float)(_range[1]-_range[0]);
|
||||
float fvalue=(float)(_value-_range[0]);
|
||||
float fnob=(float)_nobPos[0];
|
||||
float frangewindow=(float)(_rangeWindow);
|
||||
|
||||
if(frangewindow<0)
|
||||
{
|
||||
frangewindow=0;
|
||||
}
|
||||
|
||||
if(!_rangeWindowEnabled)
|
||||
{
|
||||
frangewindow=frange;
|
||||
}
|
||||
|
||||
if ( frangewindow > 0 )
|
||||
{
|
||||
float fnobsize;
|
||||
|
||||
if(_vertical)
|
||||
{
|
||||
fnobsize=ftall/frangewindow*ftall;
|
||||
fvalue=frange*(fnob/(ftall-fnobsize));
|
||||
}
|
||||
else
|
||||
{
|
||||
fnobsize=fwide/frangewindow*fwide;
|
||||
fvalue=frange*(fnob/(fwide-fnobsize));
|
||||
}
|
||||
}
|
||||
// Take care of rounding issues.
|
||||
_value=(int)(fvalue+_range[0]+0.5);
|
||||
|
||||
// Clamp final result
|
||||
_value = ( _value < _range[1] ) ? _value : _range[1];
|
||||
}
|
||||
|
||||
bool Slider::hasFullRange()
|
||||
{
|
||||
int wide,tall;
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
float fwide=(float)wide;
|
||||
float ftall=(float)tall;
|
||||
float frange=(float)(_range[1]-_range[0]);
|
||||
float frangewindow=(float)(_rangeWindow);
|
||||
|
||||
if(frangewindow<0)
|
||||
{
|
||||
frangewindow=0;
|
||||
}
|
||||
|
||||
if(!_rangeWindowEnabled)
|
||||
{
|
||||
frangewindow=frange;
|
||||
}
|
||||
|
||||
if ( frangewindow > 0 )
|
||||
{
|
||||
if(_vertical)
|
||||
{
|
||||
if( frangewindow <= ( ftall + _buttonOffset ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( frangewindow <= ( fwide + _buttonOffset ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Slider::addIntChangeSignal(IntChangeSignal* s)
|
||||
{
|
||||
_intChangeSignalDar.putElement(s);
|
||||
}
|
||||
|
||||
void Slider::fireIntChangeSignal()
|
||||
{
|
||||
for(int i=0;i<_intChangeSignalDar.getCount();i++)
|
||||
{
|
||||
_intChangeSignalDar[i]->intChanged(getValue(),this);
|
||||
}
|
||||
}
|
||||
|
||||
void Slider::paintBackground()
|
||||
{
|
||||
int wide,tall;
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
if (_vertical)
|
||||
{
|
||||
drawSetColor(Scheme::sc_secondary1);
|
||||
drawFilledRect(0,0,wide,1); // top
|
||||
drawFilledRect(0,tall-1,wide,tall); // bottom
|
||||
drawFilledRect(0,1,1,tall-1); // left
|
||||
drawFilledRect(wide-1,1,wide,tall-1); // right
|
||||
|
||||
drawSetColor(Scheme::sc_secondary2);
|
||||
drawFilledRect(1,1,wide-1,2);
|
||||
drawFilledRect(1,2,3,tall-1);
|
||||
drawFilledRect(2,_nobPos[1],wide-1,_nobPos[1]+1);
|
||||
|
||||
drawSetColor(Scheme::sc_secondary3);
|
||||
drawFilledRect(2,2,wide-1,tall-1);
|
||||
|
||||
drawSetColor(Scheme::sc_primary1);
|
||||
drawFilledRect(0,_nobPos[0],wide,_nobPos[0]+1); // top
|
||||
drawFilledRect(0,_nobPos[1],wide,_nobPos[1]+1); // bottom
|
||||
drawFilledRect(0,_nobPos[0]+1,1,_nobPos[1]); // left
|
||||
drawFilledRect(wide-1,_nobPos[0]+1,wide,_nobPos[1]); // right
|
||||
|
||||
drawSetColor(Scheme::sc_primary3);
|
||||
drawFilledRect(1,_nobPos[0]+1,wide-1,_nobPos[0]+2);
|
||||
drawFilledRect(1,_nobPos[0]+2,2,_nobPos[1]);
|
||||
|
||||
drawSetColor(Scheme::sc_primary2);
|
||||
drawFilledRect(2,_nobPos[0]+2,wide-1,_nobPos[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
//!! doesn't work
|
||||
|
||||
drawSetColor(Scheme::sc_secondary3);
|
||||
drawFilledRect(0,0,wide,tall);
|
||||
|
||||
drawSetColor(Scheme::sc_black);
|
||||
drawOutlinedRect(0,0,wide,tall);
|
||||
|
||||
drawSetColor(Scheme::sc_primary2);
|
||||
drawFilledRect(_nobPos[0],0,_nobPos[1],tall);
|
||||
|
||||
drawSetColor(Scheme::sc_black);
|
||||
drawOutlinedRect(_nobPos[0],0,_nobPos[1],tall);
|
||||
}
|
||||
}
|
||||
|
||||
void Slider::setRange(int min,int max)
|
||||
{
|
||||
if(max<min)
|
||||
{
|
||||
max=min;
|
||||
}
|
||||
|
||||
if(min>max)
|
||||
{
|
||||
min=max;
|
||||
}
|
||||
|
||||
_range[0]=min;
|
||||
_range[1]=max;
|
||||
}
|
||||
|
||||
void Slider::getRange(int& min,int& max)
|
||||
{
|
||||
min=_range[0];
|
||||
max=_range[1];
|
||||
}
|
||||
|
||||
void Slider::privateCursorMoved(int x,int y,Panel* panel)
|
||||
{
|
||||
if(!_dragging)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
getApp()->getCursorPos(x,y);
|
||||
screenToLocal(x,y);
|
||||
|
||||
int wide,tall;
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
if(_vertical)
|
||||
{
|
||||
_nobPos[0]=_nobDragStartPos[0]+(y-_dragStartPos[1]);
|
||||
_nobPos[1]=_nobDragStartPos[1]+(y-_dragStartPos[1]);
|
||||
|
||||
if(_nobPos[1]>tall)
|
||||
{
|
||||
_nobPos[0]=tall-(_nobPos[1]-_nobPos[0]);
|
||||
_nobPos[1]=tall;
|
||||
}
|
||||
|
||||
if(_nobPos[0]<0)
|
||||
{
|
||||
_nobPos[1]=_nobPos[1]-_nobPos[0];
|
||||
_nobPos[0]=0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_nobPos[0]=_nobDragStartPos[0]+(x-_dragStartPos[0]);
|
||||
_nobPos[1]=_nobDragStartPos[1]+(x-_dragStartPos[0]);
|
||||
|
||||
if(_nobPos[1]>wide)
|
||||
{
|
||||
_nobPos[0]=wide-(_nobPos[1]-_nobPos[0]);
|
||||
_nobPos[1]=wide;
|
||||
}
|
||||
|
||||
if(_nobPos[0]<0)
|
||||
{
|
||||
_nobPos[1]=_nobPos[1]-_nobPos[0];
|
||||
_nobPos[0]=0;
|
||||
}
|
||||
}
|
||||
|
||||
recomputeValueFromNobPos();
|
||||
repaint();
|
||||
fireIntChangeSignal();
|
||||
}
|
||||
|
||||
void Slider::privateMousePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
int x,y;
|
||||
getApp()->getCursorPos(x,y);
|
||||
screenToLocal(x,y);
|
||||
|
||||
if(_vertical)
|
||||
{
|
||||
if((y>=_nobPos[0])&&(y<_nobPos[1]))
|
||||
{
|
||||
_dragging=true;
|
||||
getApp()->setMouseCapture(this);
|
||||
_nobDragStartPos[0]=_nobPos[0];
|
||||
_nobDragStartPos[1]=_nobPos[1];
|
||||
_dragStartPos[0]=x;
|
||||
_dragStartPos[1]=y;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if((x>=_nobPos[0])&&(x<_nobPos[1]))
|
||||
{
|
||||
_dragging=true;
|
||||
getApp()->setMouseCapture(this);
|
||||
_nobDragStartPos[0]=_nobPos[0];
|
||||
_nobDragStartPos[1]=_nobPos[1];
|
||||
_dragStartPos[0]=x;
|
||||
_dragStartPos[1]=y;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Slider::privateMouseReleased(MouseCode code,Panel* panel)
|
||||
{
|
||||
_dragging=false;
|
||||
getApp()->setMouseCapture(null);
|
||||
}
|
||||
|
||||
void Slider::getNobPos(int& min, int& max)
|
||||
{
|
||||
min=_nobPos[0];
|
||||
max=_nobPos[1];
|
||||
}
|
||||
|
||||
void Slider::setRangeWindow(int rangeWindow)
|
||||
{
|
||||
_rangeWindow=rangeWindow;
|
||||
}
|
||||
|
||||
void Slider::setRangeWindowEnabled(bool state)
|
||||
{
|
||||
_rangeWindowEnabled=state;
|
||||
}
|
||||
|
||||
void Slider::setButtonOffset(int buttonOffset)
|
||||
{
|
||||
_buttonOffset=buttonOffset;
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_StackLayout.h>
|
||||
#include<VGUI_Panel.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
StackLayout::StackLayout(int vgap,bool fitWide) : Layout()
|
||||
{
|
||||
_vgap=vgap;
|
||||
_fitWide=fitWide;
|
||||
}
|
||||
|
||||
void StackLayout::performLayout(Panel* panel)
|
||||
{
|
||||
int yy=0;
|
||||
for(int i=0;i<panel->getChildCount();i++)
|
||||
{
|
||||
int x,y,wide,tall;
|
||||
Panel* child=panel->getChild(i);
|
||||
child->getBounds(x,y,wide,tall);
|
||||
child->setPos(x,yy);
|
||||
|
||||
if(_fitWide)
|
||||
{
|
||||
int pwide,ptall;
|
||||
panel->getPaintSize(pwide,ptall);
|
||||
child->setSize(pwide,tall);
|
||||
}
|
||||
y+=tall+_vgap;
|
||||
}
|
||||
}
|
|
@ -1,146 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<string.h>
|
||||
#include<stdio.h>
|
||||
#include<VGUI_String.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
String::String()
|
||||
{
|
||||
_text="";
|
||||
}
|
||||
|
||||
String::String(const char* text)
|
||||
{
|
||||
int len=getCount(text);
|
||||
_text=new char[len+1];
|
||||
memcpy(_text,text,len);
|
||||
_text[len]=0;
|
||||
}
|
||||
|
||||
String::String(const String& src)
|
||||
{
|
||||
_text=src._text;
|
||||
}
|
||||
|
||||
String::~String()
|
||||
{
|
||||
_text=null;
|
||||
}
|
||||
|
||||
int String::getCount(const char* text)
|
||||
{
|
||||
int ctr;
|
||||
for(ctr=0;;ctr++)
|
||||
{
|
||||
if(text[ctr]==0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ctr;
|
||||
}
|
||||
|
||||
int String::getCount()
|
||||
{
|
||||
return getCount(_text);
|
||||
}
|
||||
|
||||
String String::operator+(String text)
|
||||
{
|
||||
int len0=getCount();
|
||||
int len1=text.getCount();
|
||||
|
||||
String* newString=new String();
|
||||
newString->_text=new char[len0+len1+1];
|
||||
memcpy(newString->_text,_text,len0);
|
||||
memcpy(newString->_text+len0,text._text,len1);
|
||||
newString->_text[len0+len1]=0;
|
||||
|
||||
return String(*newString);
|
||||
}
|
||||
|
||||
String String::operator+(const char* text)
|
||||
{
|
||||
int len0=getCount();
|
||||
int len1=getCount(text);
|
||||
|
||||
String* newString=new String();
|
||||
newString->_text=new char[len0+len1+1];
|
||||
memcpy(newString->_text,_text,len0);
|
||||
memcpy(newString->_text+len0,text,len1);
|
||||
newString->_text[len0+len1]=0;
|
||||
|
||||
return String(*newString);
|
||||
}
|
||||
|
||||
bool String::operator==(String text)
|
||||
{
|
||||
char *text2=text._text;
|
||||
|
||||
int ctr;
|
||||
for(ctr=0;;ctr++)
|
||||
{
|
||||
if(_text[ctr]!=text2[ctr])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(_text[ctr]==0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool String::operator==(const char* text)
|
||||
{
|
||||
int ctr;
|
||||
for(ctr=0;;ctr++)
|
||||
{
|
||||
if(_text[ctr]!=text[ctr])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(_text[ctr]==0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
char String::operator[](int index)
|
||||
{
|
||||
return _text[index];
|
||||
}
|
||||
|
||||
const char* String::getChars()
|
||||
{
|
||||
return _text;
|
||||
}
|
||||
|
||||
void String::test()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
printf("{\n");
|
||||
String aa("aa");
|
||||
printf("aa [%s]\n",aa);
|
||||
String bb("bb");
|
||||
printf("bb [%s]\n",bb);
|
||||
String cc("cc");
|
||||
printf("cc [%s]\n",cc);
|
||||
String dd("dd");
|
||||
printf("dd [%s]\n",dd);
|
||||
String aacc=aa+cc;
|
||||
printf("aacc [%s]\n",aacc);
|
||||
String aabb("aa");
|
||||
printf("}\n");
|
||||
#endif
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_Surface.h>
|
||||
#include<VGUI_Panel.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
Surface::Surface(Panel* embeddedPanel) : SurfaceBase(embeddedPanel)
|
||||
{
|
||||
createPlat();
|
||||
recreateContext();
|
||||
}
|
||||
|
||||
void Surface::createPopup(Panel* embeddedPanel)
|
||||
{
|
||||
embeddedPanel->setParent(null);
|
||||
new Surface(embeddedPanel);
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<stdio.h>
|
||||
#include<VGUI_SurfaceBase.h>
|
||||
#include<VGUI_ImagePanel.h>
|
||||
#include<VGUI_App.h>
|
||||
#include<VGUI_Cursor.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
SurfaceBase::SurfaceBase(Panel* embeddedPanel)
|
||||
{
|
||||
_embeddedPanel=embeddedPanel;
|
||||
_needsSwap=true;
|
||||
_emulatedCursor=new ImagePanel(null);
|
||||
_emulatedCursor->setVisible(false);
|
||||
_currentCursor=null;
|
||||
_embeddedPanel->setSurfaceBaseTraverse(this);
|
||||
getApp()->surfaceBaseCreated(this);
|
||||
_emulatedCursor->setParent(getPanel());
|
||||
}
|
||||
|
||||
SurfaceBase::~SurfaceBase()
|
||||
{
|
||||
getApp()->surfaceBaseDeleted(this);
|
||||
}
|
||||
|
||||
Panel* SurfaceBase::getPanel()
|
||||
{
|
||||
return _embeddedPanel;
|
||||
}
|
||||
|
||||
void SurfaceBase::requestSwap()
|
||||
{
|
||||
_needsSwap=true;
|
||||
}
|
||||
|
||||
void SurfaceBase::resetModeInfo()
|
||||
{
|
||||
_modeInfoDar.removeAll();
|
||||
}
|
||||
|
||||
int SurfaceBase::getModeInfoCount()
|
||||
{
|
||||
return _modeInfoDar.getCount();
|
||||
}
|
||||
|
||||
bool SurfaceBase::getModeInfo(int index,int& wide,int& tall,int& bpp)
|
||||
{
|
||||
if((index<0)||(index>=_modeInfoDar.getCount()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
sscanf(_modeInfoDar[index],"%dx%dx%d",&wide,&tall,&bpp);
|
||||
return true;
|
||||
}
|
||||
|
||||
void SurfaceBase::addModeInfo(int wide,int tall,int bpp)
|
||||
{
|
||||
char buf[256];
|
||||
sprintf(buf,"%dx%dx%d",wide,tall,bpp);
|
||||
_modeInfoDar.putElement(vgui_strdup(buf));
|
||||
}
|
||||
|
||||
App* SurfaceBase::getApp()
|
||||
{
|
||||
return App::getInstance();
|
||||
}
|
||||
|
||||
void SurfaceBase::setEmulatedCursorVisible(bool state)
|
||||
{
|
||||
_emulatedCursor->setVisible(state);
|
||||
}
|
||||
|
||||
void SurfaceBase::setEmulatedCursorPos(int x,int y)
|
||||
{
|
||||
getPanel()->removeChild(_emulatedCursor);
|
||||
getPanel()->addChild(_emulatedCursor);
|
||||
getPanel()->screenToLocal(x,y);
|
||||
|
||||
if((_currentCursor!=null)&&(!_emulatedCursor->isVisible()))
|
||||
{
|
||||
int hx,hy;
|
||||
_currentCursor->getHotspot(hx,hy);
|
||||
x-=hx;
|
||||
y-=hy;
|
||||
}
|
||||
|
||||
_emulatedCursor->setPos(x,y);
|
||||
}
|
|
@ -1,266 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_TabPanel.h>
|
||||
#include<VGUI_ButtonGroup.h>
|
||||
#include<VGUI_Border.h>
|
||||
#include<VGUI_ActionSignal.h>
|
||||
#include<VGUI_ToggleButton.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class FooTabPanelTab : public ToggleButton, public ActionSignal
|
||||
{
|
||||
public:
|
||||
FooTabPanelTab(TabPanel* tabPanel,const char* text,int x,int y) : ToggleButton(text,x,y)
|
||||
{
|
||||
_tabPanel=tabPanel;
|
||||
addActionSignal(this);
|
||||
}
|
||||
public:
|
||||
virtual bool isWithin(int x,int y)
|
||||
{
|
||||
return Panel::isWithin(x,y);
|
||||
}
|
||||
virtual void actionPerformed(Panel* panel)
|
||||
{
|
||||
_tabPanel->setSelectedTab(this);
|
||||
}
|
||||
protected:
|
||||
virtual void paintBackground()
|
||||
{
|
||||
int wide,tall;
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
if(isSelected())
|
||||
{
|
||||
drawSetColor(Scheme::sc_secondary3);
|
||||
drawFilledRect(0,0,wide,tall);
|
||||
|
||||
drawSetColor(Scheme::sc_secondary1);
|
||||
drawFilledRect(0,0,wide,1);
|
||||
drawFilledRect(0,1,1,tall-1);
|
||||
drawFilledRect(wide-1,1,wide,tall-1);
|
||||
|
||||
drawSetColor(Scheme::sc_white);
|
||||
drawFilledRect(1,1,wide-1,2);
|
||||
drawFilledRect(1,2,2,tall);
|
||||
drawFilledRect(0,tall-1,1,tall);
|
||||
drawFilledRect(wide-1,tall-1,wide,tall);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawSetColor(Scheme::sc_secondary2);
|
||||
drawFilledRect(0,0,wide,tall);
|
||||
|
||||
drawSetColor(Scheme::sc_secondary1);
|
||||
drawFilledRect(0,0,wide,1);
|
||||
drawFilledRect(0,1,1,tall-1);
|
||||
drawFilledRect(wide-1,1,wide,tall-1);
|
||||
|
||||
drawSetColor(Scheme::sc_secondary3);
|
||||
drawFilledRect(1,1,wide-1,2);
|
||||
drawFilledRect(1,2,2,tall);
|
||||
drawFilledRect(0,tall-1,1,tall);
|
||||
drawFilledRect(wide-1,tall-1,wide,tall);
|
||||
|
||||
drawSetColor(Scheme::sc_white);
|
||||
drawFilledRect(0,tall-1,wide,tall);
|
||||
}
|
||||
}
|
||||
protected:
|
||||
TabPanel* _tabPanel;
|
||||
};
|
||||
|
||||
class FooClientBorder : public Border
|
||||
{
|
||||
protected:
|
||||
virtual void paintBorder(Panel* panel)
|
||||
{
|
||||
int wide,tall;
|
||||
panel->getSize(wide,tall);
|
||||
|
||||
drawSetColor(Scheme::sc_black);
|
||||
drawFilledRect(0,0,wide-1,1);
|
||||
drawFilledRect(0,1,1,tall-1);
|
||||
|
||||
drawSetColor(Scheme::sc_secondary1);
|
||||
drawFilledRect(0,tall-1,wide,tall);
|
||||
drawFilledRect(wide-1,0,wide,tall-1);
|
||||
}
|
||||
};
|
||||
|
||||
class FooTabAreaBorder : public Border
|
||||
{
|
||||
protected:
|
||||
virtual void paintBorder(Panel* panel)
|
||||
{
|
||||
int wide,tall;
|
||||
panel->getSize(wide,tall);
|
||||
|
||||
drawSetColor(Scheme::sc_white);
|
||||
drawFilledRect(0,tall-1,wide,tall);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
TabPanel::TabPanel(int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
||||
{
|
||||
_tabPlacement=tp_top;
|
||||
|
||||
_clientArea=new Panel(5,5,wide-10,tall-10);
|
||||
_clientArea->setParent(this);
|
||||
_clientArea->setBorder(new FooClientBorder());
|
||||
|
||||
_tabArea=new Panel(5,5,wide,5);
|
||||
_tabArea->setParent(this);
|
||||
_tabArea->setBorder(new FooTabAreaBorder());
|
||||
|
||||
_selectedTab=null;
|
||||
_selectedPanel=null;
|
||||
_buttonGroup=new ButtonGroup();
|
||||
}
|
||||
|
||||
Panel* TabPanel::addTab(const char* text)
|
||||
{
|
||||
FooTabPanelTab* tab=new FooTabPanelTab(this,text,0,0);
|
||||
_tabArea->insertChildAt(tab,0);
|
||||
tab->setButtonGroup(_buttonGroup);
|
||||
|
||||
Panel* panel=new Panel(0,0,20,20);
|
||||
_clientArea->insertChildAt(panel,0);
|
||||
panel->setVisible(false);
|
||||
|
||||
if(_selectedTab==null)
|
||||
{
|
||||
_selectedTab=tab;
|
||||
_selectedPanel=panel;
|
||||
panel->setVisible(true);
|
||||
tab->setSelected(true);
|
||||
}
|
||||
|
||||
recomputeLayout();
|
||||
return panel;
|
||||
}
|
||||
|
||||
void TabPanel::setSelectedTab(Panel* tab)
|
||||
{
|
||||
if(tab==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(tab==_selectedTab)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i=0;i<_tabArea->getChildCount();i++)
|
||||
{
|
||||
if(_tabArea->getChild(i)==tab)
|
||||
{
|
||||
_selectedPanel->setVisible(false);
|
||||
_selectedPanel=_clientArea->getChild(i);
|
||||
_selectedPanel->setVisible(true);
|
||||
_selectedTab=tab;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
recomputeLayout();
|
||||
}
|
||||
|
||||
void TabPanel::recomputeLayoutTop()
|
||||
{
|
||||
int x=0;
|
||||
int y=0;
|
||||
int i,wide,tall;
|
||||
|
||||
int paintWide,paintTall;
|
||||
getPaintSize(paintWide,paintTall);
|
||||
|
||||
const int minx=5;
|
||||
int maxx=paintWide-minx;
|
||||
int inRowCount=0;
|
||||
|
||||
x=minx;
|
||||
for(i=_tabArea->getChildCount()-1;i>=0;i--)
|
||||
{
|
||||
_tabArea->getChild(i)->getPreferredSize(wide,tall);
|
||||
_tabArea->getChild(i)->setSize(wide,tall);
|
||||
if(x+wide>maxx)
|
||||
{
|
||||
if(inRowCount!=0)
|
||||
{
|
||||
int extra=(maxx-x)/inRowCount;
|
||||
int error=maxx-(inRowCount*extra)-x;
|
||||
int extraAccum=0;
|
||||
for(int j=i+inRowCount;j>i;j--)
|
||||
{
|
||||
int ww,tt,xx,yy;
|
||||
int extra2=extra;
|
||||
if(j==i+inRowCount)
|
||||
{
|
||||
extra2+=error;
|
||||
}
|
||||
_tabArea->getChild(j)->getPreferredSize(ww,tt);
|
||||
_tabArea->getChild(j)->getPos(xx,yy);
|
||||
_tabArea->getChild(j)->setBounds(xx+extraAccum,yy,ww+extra2,tt);
|
||||
extraAccum+=extra2;
|
||||
}
|
||||
}
|
||||
maxx-=minx;
|
||||
x=minx;
|
||||
y-=tall-4;
|
||||
inRowCount=0;
|
||||
}
|
||||
_tabArea->getChild(i)->setPos(x,y);
|
||||
inRowCount++;
|
||||
x+=wide-1;
|
||||
}
|
||||
|
||||
int miny;
|
||||
_tabArea->getChild(0)->getPos(x,miny);
|
||||
for(i=0;i<_tabArea->getChildCount();i++)
|
||||
{
|
||||
_tabArea->getChild(i)->getPos(x,y);
|
||||
_tabArea->getChild(i)->setPos(x,y-miny);
|
||||
}
|
||||
|
||||
_tabArea->getChild(0)->getSize(wide,tall);
|
||||
_tabArea->setBounds(0,5,paintWide,tall-miny);
|
||||
_tabArea->getSize(wide,tall);
|
||||
_clientArea->setBounds(0,tall+4,paintWide,paintTall-tall-5);
|
||||
_clientArea->getSize(wide,tall);
|
||||
|
||||
for(i=0;i<_clientArea->getChildCount();i++)
|
||||
{
|
||||
_clientArea->getChild(i)->setBounds(5,5,wide-10,tall-10);
|
||||
_clientArea->getChild(i)->invalidateLayout(false);
|
||||
}
|
||||
}
|
||||
|
||||
void TabPanel::recomputeLayout()
|
||||
{
|
||||
if(_tabArea->getChildCount()!=0)
|
||||
{
|
||||
if(_tabPlacement==0)
|
||||
{
|
||||
recomputeLayoutTop();
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
void TabPanel::setSize(int wide,int tall)
|
||||
{
|
||||
Panel::setSize(wide,tall);
|
||||
|
||||
recomputeLayout();
|
||||
}
|
|
@ -1,440 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_TablePanel.h>
|
||||
#include<VGUI_HeaderPanel.h>
|
||||
#include<VGUI_ChangeSignal.h>
|
||||
#include<VGUI_InputSignal.h>
|
||||
#include<VGUI_RepaintSignal.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace vgui
|
||||
{
|
||||
class FooVGuiTablePanelHandler : public ChangeSignal, public InputSignal, public RepaintSignal
|
||||
{
|
||||
private:
|
||||
TablePanel* _table;
|
||||
public:
|
||||
FooVGuiTablePanelHandler(TablePanel* table)
|
||||
{
|
||||
_table=table;
|
||||
}
|
||||
public:
|
||||
virtual void valueChanged(Panel* panel)
|
||||
{
|
||||
HeaderPanel* header=dynamic_cast<HeaderPanel*>(panel);
|
||||
|
||||
int cols=_table->getColumnCount();
|
||||
|
||||
for(int i=0;i<header->getSectionCount()&&(i<cols);i++)
|
||||
{
|
||||
int x0,x1;
|
||||
header->getSectionExtents(i,x0,x1);
|
||||
_table->setColumnExtents(i,x0,x1);
|
||||
}
|
||||
}
|
||||
virtual void cursorMoved(int x,int y,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void cursorEntered(Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void cursorExited(Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void mousePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
_table->privateMousePressed(code,panel);
|
||||
}
|
||||
virtual void mouseDoublePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
_table->privateMouseDoublePressed(code,panel);
|
||||
}
|
||||
virtual void mouseReleased(MouseCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void mouseWheeled(int delta,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyPressed(KeyCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyTyped(KeyCode code,Panel* panel)
|
||||
{
|
||||
_table->privateKeyTyped(code,panel);
|
||||
}
|
||||
virtual void keyReleased(KeyCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyFocusTicked(Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void panelRepainted(Panel* panel)
|
||||
{
|
||||
_table->repaint();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
TablePanel::TablePanel(int x,int y,int wide,int tall,int columnCount) : Panel(x,y,wide,tall)
|
||||
{
|
||||
setGridSize(2,2);
|
||||
setGridVisible(false,false);
|
||||
setColumnCount(columnCount);
|
||||
setFgColor(Color(Scheme::sc_black));
|
||||
_selectedCell[0]=-1;
|
||||
_selectedCell[1]=-1;
|
||||
_fakeInputPanel=new Panel();
|
||||
_columnSelectionEnabled=false;
|
||||
_rowSelectionEnabled=true;
|
||||
_cellSelectionEnabled=true;
|
||||
_mouseOverCell[0]=0;
|
||||
_mouseOverCell[1]=0;
|
||||
_editableCell[0]=-1;
|
||||
_editableCell[1]=-1;
|
||||
_editableCellPanel=null;
|
||||
_virtualSize[0]=wide;
|
||||
_virtualSize[1]=tall;
|
||||
_cellEditingEnabled=true;
|
||||
addInputSignal(new FooVGuiTablePanelHandler(this));
|
||||
}
|
||||
|
||||
void TablePanel::setCellEditingEnabled(bool state)
|
||||
{
|
||||
_cellEditingEnabled=state;
|
||||
}
|
||||
|
||||
void TablePanel::setGridSize(int wide,int tall)
|
||||
{
|
||||
_gridWide=wide;
|
||||
_gridTall=tall;
|
||||
}
|
||||
|
||||
void TablePanel::setGridVisible(bool horizontal,bool vertical)
|
||||
{
|
||||
_gridVisible[0]=horizontal;
|
||||
_gridVisible[1]=horizontal; // vertical?
|
||||
}
|
||||
|
||||
void TablePanel::setColumnCount(int columnCount)
|
||||
{
|
||||
_columnDar.ensureCapacity(columnCount);
|
||||
_columnDar.setCount(columnCount);
|
||||
}
|
||||
|
||||
int TablePanel::getColumnCount()
|
||||
{
|
||||
return _columnDar.getCount();
|
||||
}
|
||||
|
||||
void TablePanel::setColumnExtents(int column,int x0,int x1)
|
||||
{
|
||||
_columnDar.setElementAt((x0<<12)+x1,column);
|
||||
repaint();
|
||||
}
|
||||
|
||||
void TablePanel::setSelectedCell(int column,int row)
|
||||
{
|
||||
if((_selectedCell[0]!=column)||(_selectedCell[1]!=row))
|
||||
{
|
||||
repaint();
|
||||
stopCellEditing();
|
||||
}
|
||||
_selectedCell[0]=column;
|
||||
_selectedCell[1]=row;
|
||||
}
|
||||
|
||||
void TablePanel::getSelectedCell(int& column,int& row)
|
||||
{
|
||||
column=_selectedCell[0];
|
||||
row=_selectedCell[1];
|
||||
}
|
||||
|
||||
void TablePanel::setColumnSelectionEnabled(bool state)
|
||||
{
|
||||
_columnSelectionEnabled=state;
|
||||
repaint();
|
||||
}
|
||||
|
||||
void TablePanel::setRowSelectionEnabled(bool state)
|
||||
{
|
||||
_rowSelectionEnabled=state;
|
||||
repaint();
|
||||
}
|
||||
|
||||
void TablePanel::setCellSectionEnabled(bool state)
|
||||
{
|
||||
_cellSelectionEnabled=state;
|
||||
repaint();
|
||||
}
|
||||
|
||||
void TablePanel::setEditableCell(int column,int row)
|
||||
{
|
||||
if((_editableCell[0]!=column)||(_editableCell[1]!=row))
|
||||
{
|
||||
stopCellEditing();
|
||||
_editableCellPanel=startCellEditing(column,row);
|
||||
if(_editableCellPanel!=null)
|
||||
{
|
||||
_editableCellPanel->setParent(this);
|
||||
}
|
||||
}
|
||||
_editableCell[0]=column;
|
||||
_editableCell[1]=row;
|
||||
}
|
||||
|
||||
void TablePanel::stopCellEditing()
|
||||
{
|
||||
if(_editableCellPanel!=null)
|
||||
{
|
||||
_editableCellPanel->setParent(null);
|
||||
_editableCellPanel=null;
|
||||
_editableCell[0]=-1;
|
||||
_editableCell[1]=-1;
|
||||
}
|
||||
}
|
||||
|
||||
void TablePanel::setHeaderPanel(HeaderPanel* header)
|
||||
{
|
||||
header->addChangeSignal(new FooVGuiTablePanelHandler(this));
|
||||
header->fireChangeSignal();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void TablePanel::privateMousePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
if(!_cellEditingEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
setSelectedCell(_mouseOverCell[0],_mouseOverCell[1]);
|
||||
requestFocus();
|
||||
}
|
||||
|
||||
void TablePanel::privateMouseDoublePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
if(!_cellEditingEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
setSelectedCell(_mouseOverCell[0],_mouseOverCell[1]);
|
||||
int column,row;
|
||||
getSelectedCell(column,row);
|
||||
setEditableCell(_mouseOverCell[0],_mouseOverCell[1]);
|
||||
}
|
||||
|
||||
void TablePanel::privateKeyTyped(KeyCode code,Panel* panel)
|
||||
{
|
||||
if(!_cellEditingEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int column,row;
|
||||
getSelectedCell(column,row);
|
||||
|
||||
switch(code)
|
||||
{
|
||||
case KEY_UP:
|
||||
{
|
||||
row--;
|
||||
if(row<0)
|
||||
{
|
||||
row=0;
|
||||
}
|
||||
setSelectedCell(column,row);
|
||||
break;
|
||||
}
|
||||
case KEY_DOWN:
|
||||
{
|
||||
row++;
|
||||
setSelectedCell(column,row);
|
||||
break;
|
||||
}
|
||||
case KEY_LEFT:
|
||||
{
|
||||
column--;
|
||||
if(column<0)
|
||||
{
|
||||
column=0;
|
||||
}
|
||||
setSelectedCell(column,row);
|
||||
break;
|
||||
}
|
||||
case KEY_RIGHT:
|
||||
{
|
||||
column++;
|
||||
setSelectedCell(column,row);
|
||||
break;
|
||||
}
|
||||
case KEY_ENTER:
|
||||
{
|
||||
setEditableCell(column,row);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TablePanel::paint()
|
||||
{
|
||||
int x0gap=(_gridWide/2)-1;
|
||||
int x1gap=_gridWide-x0gap;
|
||||
|
||||
int i,wide,tall,maxX;
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
Color fgColor;
|
||||
getFgColor(fgColor);
|
||||
int r,g,b,a;
|
||||
fgColor.getColor(r,g,b,a);
|
||||
|
||||
if(_gridVisible[1])
|
||||
{
|
||||
maxX=0;
|
||||
for(i=0;i<_columnDar.getCount();i++)
|
||||
{
|
||||
maxX=(_columnDar[i]&0xFFF);
|
||||
int x0=maxX+x0gap;
|
||||
int x1=maxX-x1gap;
|
||||
drawSetColor(r,g,b,a);
|
||||
drawFilledRect(x1,0,x0,tall);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
maxX=wide;
|
||||
}
|
||||
if(_gridVisible[0])
|
||||
{
|
||||
int y0=0;
|
||||
for(int j=0;j<getRowCount();j++)
|
||||
{
|
||||
drawSetColor(r,g,b,a);
|
||||
drawFilledRect(0,y0,maxX,y0+_gridTall);
|
||||
y0+=_gridTall+getCellTall(j);
|
||||
}
|
||||
}
|
||||
|
||||
_virtualSize[0]=0;
|
||||
_virtualSize[1]=0;
|
||||
|
||||
for(i=0;i<_columnDar.getCount();i++)
|
||||
{
|
||||
int x0=(_columnDar[i]>>12)&0xFFF;
|
||||
int x1=(_columnDar[i])&0xFFF;
|
||||
|
||||
x0+=x0gap;
|
||||
x1-=x1gap;
|
||||
|
||||
if(x1>_virtualSize[0])
|
||||
{
|
||||
_virtualSize[0]=x1;
|
||||
}
|
||||
|
||||
int y0=_gridTall;
|
||||
for(int j=0;j<getRowCount();j++)
|
||||
{
|
||||
bool columnSelected=false;
|
||||
if(_columnSelectionEnabled&&(_selectedCell[0]==i))
|
||||
{
|
||||
columnSelected=true;
|
||||
}
|
||||
|
||||
bool rowSelected=false;
|
||||
if(_rowSelectionEnabled&&(_selectedCell[1]==j))
|
||||
{
|
||||
rowSelected=true;
|
||||
}
|
||||
|
||||
bool cellSelected=false;
|
||||
if(_cellSelectionEnabled&&(_selectedCell[0]==i)&&(_selectedCell[1]==j))
|
||||
{
|
||||
cellSelected=true;
|
||||
}
|
||||
|
||||
if((_editableCell[0]==i)&&(_editableCell[1]==j))
|
||||
{
|
||||
if(_editableCellPanel!=null)
|
||||
{
|
||||
_editableCellPanel->setBounds(x0,y0,x1-x0,getCellTall(j));
|
||||
_editableCellPanel->repaint();
|
||||
_editableCellPanel->solveTraverse();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Panel* panel=getCellRenderer(i,j,columnSelected,rowSelected,cellSelected);
|
||||
if(panel)
|
||||
{
|
||||
panel->setParent(this);
|
||||
panel->setBounds(x0,y0,x1-x0,getCellTall(j));
|
||||
panel->repaint();
|
||||
panel->solveTraverse();
|
||||
panel->paintTraverse();
|
||||
panel->setParent(null);
|
||||
}
|
||||
}
|
||||
|
||||
y0+=_gridTall+getCellTall(j);
|
||||
if(y0>_virtualSize[1])
|
||||
{
|
||||
_virtualSize[1]=x1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Panel* TablePanel::isWithinTraverse(int x,int y)
|
||||
{
|
||||
Panel* panel=Panel::isWithinTraverse(x,y);
|
||||
if(panel!=this)
|
||||
{
|
||||
return panel;
|
||||
}
|
||||
|
||||
int x0gap=(_gridWide/2)-1;
|
||||
int x1gap=_gridWide-x0gap;
|
||||
|
||||
for(int i=0;i<_columnDar.getCount();i++)
|
||||
{
|
||||
int x0=(_columnDar[i]>>12)&0xFFF;
|
||||
int x1=(_columnDar[i])&0xFFF;
|
||||
|
||||
x0+=x0gap;
|
||||
x1-=x1gap;
|
||||
|
||||
int y0=_gridTall;
|
||||
for(int j=0;j<getRowCount();j++)
|
||||
{
|
||||
_fakeInputPanel->setParent(this);
|
||||
_fakeInputPanel->setBounds(x0,y0,x1-x0,getCellTall(j));
|
||||
_fakeInputPanel->solveTraverse();
|
||||
panel=_fakeInputPanel->isWithinTraverse(x,y);
|
||||
_fakeInputPanel->setParent(null);
|
||||
|
||||
if(panel==_fakeInputPanel)
|
||||
{
|
||||
_mouseOverCell[0]=i;
|
||||
_mouseOverCell[1]=j;
|
||||
return this;
|
||||
}
|
||||
|
||||
y0+=_gridTall+getCellTall(j);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
void TablePanel::getVirtualSize(int& wide,int& tall)
|
||||
{
|
||||
wide=_virtualSize[0];
|
||||
tall=_virtualSize[1];
|
||||
}
|
|
@ -1,157 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<stdio.h>
|
||||
#include<time.h>
|
||||
#include<VGUI_TaskBar.h>
|
||||
#include<VGUI_FocusChangeSignal.h>
|
||||
#include<VGUI_FrameSignal.h>
|
||||
#include<VGUI_ActionSignal.h>
|
||||
#include<VGUI_TickSignal.h>
|
||||
#include<VGUI_RaisedBorder.h>
|
||||
#include<VGUI_LoweredBorder.h>
|
||||
#include<VGUI_App.h>
|
||||
#include<VGUI_Button.h>
|
||||
#include<VGUI_Frame.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class FooClock : public Panel, public TickSignal
|
||||
{
|
||||
public:
|
||||
FooClock(int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
||||
{
|
||||
_hour=0;
|
||||
_minute=0;
|
||||
_second=0;
|
||||
getApp()->addTickSignal(this);
|
||||
}
|
||||
virtual void paintBackground()
|
||||
{
|
||||
char buf[50];
|
||||
if(_hour>12)
|
||||
{
|
||||
sprintf(buf,"%d:%.2d:%.2d PM",_hour-12,_minute,_second);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(buf,"%d:%.2d:%.2d AM",_hour,_minute,_second);
|
||||
}
|
||||
|
||||
Panel::paintBackground();
|
||||
drawSetTextFont(Scheme::sf_primary1);
|
||||
drawSetTextColor(Scheme::sc_black);
|
||||
drawPrintText(buf,strlen(buf));
|
||||
}
|
||||
virtual void ticked()
|
||||
{
|
||||
struct tm* newtime;
|
||||
time_t aclock;
|
||||
time(&aclock);
|
||||
newtime=localtime(&aclock);
|
||||
|
||||
int hour=newtime->tm_hour;
|
||||
int minute=newtime->tm_min;
|
||||
int second=newtime->tm_sec;
|
||||
if((_hour!=hour)||(_minute!=minute)||(_second!=second))
|
||||
{
|
||||
_hour=hour;
|
||||
_minute=minute;
|
||||
_second=second;
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
protected:
|
||||
int _hour;
|
||||
int _minute;
|
||||
int _second;
|
||||
};
|
||||
|
||||
class FooTaskBarButtonHandler : public ActionSignal, public FrameSignal, public FocusChangeSignal
|
||||
{
|
||||
public:
|
||||
FooTaskBarButtonHandler(Button* button,Frame* frame)
|
||||
{
|
||||
_button=button;
|
||||
_frame=frame;
|
||||
}
|
||||
public:
|
||||
virtual void actionPerformed(Panel* panel)
|
||||
{
|
||||
_frame->setVisible(true);
|
||||
_frame->requestFocus();
|
||||
}
|
||||
virtual void closing(Frame* frame)
|
||||
{
|
||||
}
|
||||
virtual void minimizing(Frame* frame,bool toTray)
|
||||
{
|
||||
_frame->setVisible(false);
|
||||
_frame->getApp()->requestFocus(null);
|
||||
}
|
||||
virtual void focusChanged(bool lost,Panel* panel)
|
||||
{
|
||||
_button->setSelected(!lost);
|
||||
}
|
||||
protected:
|
||||
Button* _button;
|
||||
Frame* _frame;
|
||||
};
|
||||
}
|
||||
|
||||
TaskBar::TaskBar(int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
||||
{
|
||||
setBorder(new RaisedBorder());
|
||||
|
||||
_tray=new Panel(100,0,120,26);
|
||||
_tray->setBorder(new LoweredBorder());
|
||||
_tray->setParent(this);
|
||||
|
||||
FooClock* clock=new FooClock(25,2,85,20);
|
||||
clock->setParent(_tray);
|
||||
}
|
||||
|
||||
void TaskBar::addFrame(Frame* frame)
|
||||
{
|
||||
_frameDar.addElement(frame);
|
||||
|
||||
char buf[256];
|
||||
frame->getTitle(buf,sizeof(buf));
|
||||
|
||||
Button* button=new Button(buf,2,2);
|
||||
FooTaskBarButtonHandler* handler=new FooTaskBarButtonHandler(button,frame);
|
||||
button->setParent(this);
|
||||
button->addActionSignal(handler);
|
||||
frame->addFrameSignal(handler);
|
||||
frame->addFocusChangeSignal(handler);
|
||||
_taskButtonDar.addElement(button);
|
||||
|
||||
invalidateLayout(false);
|
||||
}
|
||||
|
||||
void TaskBar::performLayout()
|
||||
{
|
||||
int wide,tall;
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
int twide,ttall;
|
||||
_tray->getSize(twide,ttall);
|
||||
_tray->setBounds(wide-twide-3,2,twide,tall-4);
|
||||
|
||||
int xx=3;
|
||||
for(int i=0;i<_taskButtonDar.getCount();i++)
|
||||
{
|
||||
Button* button=_taskButtonDar[i];
|
||||
|
||||
int x,y;
|
||||
button->getBounds(x,y,wide,tall);
|
||||
button->setPos(xx,y);
|
||||
xx+=wide+3;
|
||||
}
|
||||
}
|
|
@ -1,552 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_TextEntry.h>
|
||||
#include<VGUI_App.h>
|
||||
#include<VGUI_ActionSignal.h>
|
||||
#include<VGUI_Font.h>
|
||||
#include<VGUI_FocusChangeSignal.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class FooDefaultTextEntrySignal : public FocusChangeSignal
|
||||
{
|
||||
public:
|
||||
FooDefaultTextEntrySignal(TextEntry* textEntry)
|
||||
{
|
||||
_textEntry=textEntry;
|
||||
}
|
||||
public:
|
||||
virtual void focusChanged(bool lost,Panel* panel)
|
||||
{
|
||||
_textEntry->resetCursorBlink();
|
||||
_textEntry->doSelectNone();
|
||||
}
|
||||
protected:
|
||||
TextEntry* _textEntry;
|
||||
};
|
||||
}
|
||||
|
||||
TextEntry::TextEntry(const char* text,int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
||||
{
|
||||
_font=null;
|
||||
_hideText=false;
|
||||
_cursorPos=0;
|
||||
_cursorBlinkRate=400;
|
||||
_select[0]=-1;
|
||||
_select[1]=-1;
|
||||
|
||||
resetCursorBlink();
|
||||
setText(text,strlen(text));
|
||||
doGotoEndOfLine();
|
||||
addInputSignal(this);
|
||||
addFocusChangeSignal(new FooDefaultTextEntrySignal(this));
|
||||
}
|
||||
|
||||
void TextEntry::setText(const char* text,int textLen)
|
||||
{
|
||||
_lineDar.removeAll();
|
||||
_lineDar.ensureCapacity(textLen);
|
||||
|
||||
for(int i=0;i<textLen;i++)
|
||||
{
|
||||
_lineDar.addElement(text[i]);
|
||||
setCharAt(text[i],i);
|
||||
}
|
||||
|
||||
doGotoEndOfLine();
|
||||
}
|
||||
|
||||
void TextEntry::setCharAt(char ch,int index)
|
||||
{
|
||||
if(index<0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_lineDar.ensureCapacity(index+1);
|
||||
_lineDar.setElementAt(ch,index);
|
||||
}
|
||||
|
||||
void TextEntry::resetCursorBlink()
|
||||
{
|
||||
_cursorBlink=false;
|
||||
_cursorNextBlinkTime=getApp()->getTimeMillis()+_cursorBlinkRate;
|
||||
}
|
||||
|
||||
void TextEntry::setTextHidden(bool bHideText)
|
||||
{
|
||||
_hideText=bHideText;
|
||||
repaint();
|
||||
}
|
||||
|
||||
int TextEntry::cursorToPixelSpace(int cursorPos)
|
||||
{
|
||||
Font* font=_font;
|
||||
if(font==null)
|
||||
{
|
||||
font=getApp()->getScheme()->getFont(Scheme::sf_primary1);
|
||||
}
|
||||
|
||||
int cx=0;
|
||||
for(int i=0;i<_lineDar.getCount();i++)
|
||||
{
|
||||
if(i==cursorPos)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
int a,b,c;
|
||||
if(_hideText)
|
||||
{
|
||||
font->getCharABCwide('*',a,b,c);
|
||||
}
|
||||
else
|
||||
{
|
||||
font->getCharABCwide(_lineDar[i],a,b,c);
|
||||
}
|
||||
cx+=a+b+c;
|
||||
}
|
||||
|
||||
return cx;
|
||||
}
|
||||
|
||||
void TextEntry::paintBackground()
|
||||
{
|
||||
Font* font=_font;
|
||||
if(font==null)
|
||||
{
|
||||
font=getApp()->getScheme()->getFont(Scheme::sf_primary1);
|
||||
}
|
||||
|
||||
int fTall=font->getTall();
|
||||
|
||||
int x0,x1;
|
||||
if(getSelectedPixelRange(x0,x1))
|
||||
{
|
||||
drawSetColor(Scheme::sc_white);
|
||||
drawFilledRect(0,0,x0,fTall+1);
|
||||
drawFilledRect(x1,0,_size[0],fTall+1);
|
||||
drawSetColor(0,0,200,0);
|
||||
drawFilledRect(x0,0,x1,fTall+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawSetColor(Scheme::sc_white);
|
||||
drawFilledRect(0,0,_size[0],_size[1]);
|
||||
}
|
||||
|
||||
drawSetTextFont(font);
|
||||
drawSetColor(Scheme::sc_black);
|
||||
drawSetTextPos(3,0);
|
||||
|
||||
for(int i=0;i<_lineDar.getCount();i++)
|
||||
{
|
||||
if(_hideText)
|
||||
{
|
||||
drawPrintChar('*');
|
||||
}
|
||||
else
|
||||
{
|
||||
drawPrintChar(_lineDar[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(hasFocus())
|
||||
{
|
||||
drawSetColor(Scheme::sc_black);
|
||||
drawFilledRect(0,0,_size[0],1);
|
||||
drawFilledRect(0,_size[1]-1,_size[0],_size[1]);
|
||||
drawFilledRect(0,1,1,_size[1]-1);
|
||||
drawFilledRect(_size[0]-1,1,_size[0],_size[1]-1);
|
||||
|
||||
if(!_cursorBlink)
|
||||
{
|
||||
int cx=cursorToPixelSpace(_cursorPos);
|
||||
drawSetColor(Scheme::sc_black);
|
||||
drawFilledRect(cx+3,2,cx+4,fTall-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TextEntry::cursorMoved(int x,int y,Panel* panel)
|
||||
{
|
||||
}
|
||||
|
||||
void TextEntry::cursorEntered(Panel* panel)
|
||||
{
|
||||
}
|
||||
|
||||
void TextEntry::cursorExited(Panel* panel)
|
||||
{
|
||||
}
|
||||
|
||||
void TextEntry::mousePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
resetCursorBlink();
|
||||
requestFocus();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void TextEntry::mouseDoublePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
|
||||
void TextEntry::mouseReleased(MouseCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
|
||||
void TextEntry::mouseWheeled(int delta,Panel* panel)
|
||||
{
|
||||
}
|
||||
|
||||
void TextEntry::keyPressed(KeyCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
|
||||
void TextEntry::keyTyped(KeyCode code,Panel* panel)
|
||||
{
|
||||
bool shift=(panel->isKeyDown(KEY_LSHIFT)||panel->isKeyDown(KEY_RSHIFT));
|
||||
bool ctrl=(panel->isKeyDown(KEY_LCONTROL)||panel->isKeyDown(KEY_RCONTROL));
|
||||
|
||||
if(ctrl)
|
||||
{
|
||||
switch(code)
|
||||
{
|
||||
case KEY_C:
|
||||
{
|
||||
doCopySelected();
|
||||
break;
|
||||
}
|
||||
case KEY_V:
|
||||
{
|
||||
doPaste();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char ch;
|
||||
switch(code)
|
||||
{
|
||||
case KEY_ENTER:
|
||||
case KEY_TAB:
|
||||
case KEY_LSHIFT:
|
||||
case KEY_RSHIFT:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case KEY_INSERT:
|
||||
{
|
||||
if(shift)
|
||||
{
|
||||
doPaste();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KEY_DELETE:
|
||||
{
|
||||
if(shift)
|
||||
{
|
||||
doDeleteSelected();
|
||||
}
|
||||
else
|
||||
{
|
||||
doDelete();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KEY_LEFT:
|
||||
{
|
||||
doGotoLeft();
|
||||
break;
|
||||
}
|
||||
case KEY_RIGHT:
|
||||
{
|
||||
doGotoRight();
|
||||
break;
|
||||
}
|
||||
case KEY_HOME:
|
||||
{
|
||||
doGotoFirstOfLine();
|
||||
break;
|
||||
}
|
||||
case KEY_END:
|
||||
{
|
||||
doGotoEndOfLine();
|
||||
break;
|
||||
}
|
||||
case KEY_BACKSPACE:
|
||||
{
|
||||
doBackspace();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
ch=getApp()->getKeyCodeChar(code,(panel->isKeyDown(KEY_LSHIFT)||panel->isKeyDown(KEY_RSHIFT)));
|
||||
if(ch!=0)
|
||||
{
|
||||
doInsertChar(ch);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_select[1]=_cursorPos;
|
||||
|
||||
if(code==KEY_ENTER)
|
||||
{
|
||||
fireActionSignal();
|
||||
}
|
||||
}
|
||||
|
||||
void TextEntry::keyReleased(KeyCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
|
||||
void TextEntry::keyFocusTicked(Panel* panel)
|
||||
{
|
||||
int time=getApp()->getTimeMillis();
|
||||
if(time>_cursorNextBlinkTime)
|
||||
{
|
||||
_cursorBlink=!_cursorBlink;
|
||||
_cursorNextBlinkTime=time+_cursorBlinkRate;
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
void TextEntry::selectCheck()
|
||||
{
|
||||
if (!(isKeyDown(KEY_LSHIFT) || isKeyDown(KEY_RSHIFT)))
|
||||
{
|
||||
_select[0] = -1;
|
||||
}
|
||||
else if (_select[0] == -1)
|
||||
{
|
||||
_select[0] = _cursorPos;
|
||||
}
|
||||
}
|
||||
|
||||
void TextEntry::doGotoLeft()
|
||||
{
|
||||
selectCheck();
|
||||
_cursorPos--;
|
||||
|
||||
if(_cursorPos<0)
|
||||
{
|
||||
_cursorPos=0;
|
||||
}
|
||||
|
||||
resetCursorBlink();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void TextEntry::doGotoRight()
|
||||
{
|
||||
selectCheck();
|
||||
_cursorPos++;
|
||||
|
||||
if(_cursorPos>_lineDar.getCount())
|
||||
{
|
||||
_cursorPos=_lineDar.getCount();
|
||||
}
|
||||
|
||||
resetCursorBlink();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void TextEntry::doGotoFirstOfLine()
|
||||
{
|
||||
selectCheck();
|
||||
_cursorPos=0;
|
||||
|
||||
resetCursorBlink();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void TextEntry::doGotoEndOfLine()
|
||||
{
|
||||
selectCheck();
|
||||
_cursorPos=_lineDar.getCount();
|
||||
|
||||
resetCursorBlink();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void TextEntry::doInsertChar(char ch)
|
||||
{
|
||||
_lineDar.setCount(_lineDar.getCount()+1);
|
||||
for(int i=_lineDar.getCount()-1;i>=_cursorPos;i--)
|
||||
{
|
||||
setCharAt(_lineDar[i],i+1);
|
||||
}
|
||||
setCharAt(ch,_cursorPos);
|
||||
_cursorPos++;
|
||||
|
||||
resetCursorBlink();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void TextEntry::doBackspace()
|
||||
{
|
||||
if(_cursorPos==0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(_lineDar.getCount()==0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i=_cursorPos;i<_lineDar.getCount();i++)
|
||||
{
|
||||
setCharAt(_lineDar[i],i-1);
|
||||
}
|
||||
_lineDar.setCount(_lineDar.getCount()-1);
|
||||
_cursorPos--;
|
||||
|
||||
resetCursorBlink();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void TextEntry::doDelete()
|
||||
{
|
||||
if(_lineDar.getCount()==0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(_cursorPos!=_lineDar.getCount())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i=_cursorPos+1;i<_lineDar.getCount();i++)
|
||||
{
|
||||
setCharAt(_lineDar[i],i-1);
|
||||
}
|
||||
_lineDar.setCount(_lineDar.getCount()-1);
|
||||
_cursorPos--;
|
||||
|
||||
resetCursorBlink();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void TextEntry::doSelectNone()
|
||||
{
|
||||
_select[0]=-1;
|
||||
repaint();
|
||||
}
|
||||
|
||||
bool TextEntry::getSelectedRange(int& cx0,int& cx1)
|
||||
{
|
||||
if(_select[0]==-1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
cx0=_select[0];
|
||||
cx1=_select[1];
|
||||
int temp;
|
||||
if(cx1<cx0){temp=cx0;cx0=cx1;cx1=temp;}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TextEntry::getSelectedPixelRange(int& cx0,int& cx1)
|
||||
{
|
||||
if(!getSelectedRange(cx0,cx1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
cx0=cursorToPixelSpace(cx0);
|
||||
cx1=cursorToPixelSpace(cx1);
|
||||
return true;
|
||||
}
|
||||
|
||||
void TextEntry::doCopySelected()
|
||||
{
|
||||
int x0,x1;
|
||||
if(getSelectedRange(x0,x1))
|
||||
{
|
||||
char buf[256];
|
||||
int i=0;
|
||||
for(;i<199;i++)
|
||||
{
|
||||
if(x0+i>=x1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
buf[i]=_lineDar[x0+i];
|
||||
}
|
||||
buf[i]=0;
|
||||
getApp()->setClipboardText(buf,i);
|
||||
}
|
||||
}
|
||||
|
||||
void TextEntry::doPaste()
|
||||
{
|
||||
char buf[256];
|
||||
int c=getApp()->getClipboardText(0,buf,sizeof(buf));
|
||||
for(int i=0;i<c-1;i++)
|
||||
{
|
||||
doInsertChar(buf[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void TextEntry::doPasteSelected()
|
||||
{
|
||||
doDeleteSelected();
|
||||
doPaste();
|
||||
}
|
||||
|
||||
void TextEntry::doDeleteSelected()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TextEntry::getText(int offset,char* buf,int bufLen)
|
||||
{
|
||||
if(buf==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i=offset;i<bufLen-1;i++)
|
||||
{
|
||||
buf[i-offset]=0;
|
||||
if(i>=_lineDar.getCount())
|
||||
{
|
||||
break;
|
||||
}
|
||||
buf[i-offset]=_lineDar[i];
|
||||
}
|
||||
buf[bufLen-1]=0;
|
||||
}
|
||||
|
||||
void TextEntry::addActionSignal(ActionSignal* s)
|
||||
{
|
||||
_actionSignalDar.putElement(s);
|
||||
}
|
||||
|
||||
void TextEntry::fireActionSignal()
|
||||
{
|
||||
for(int i=0;i<_actionSignalDar.getCount();i++)
|
||||
{
|
||||
_actionSignalDar[i]->actionPerformed(this);
|
||||
}
|
||||
}
|
||||
|
||||
void TextEntry::setFont(Font* font)
|
||||
{
|
||||
_font=font;
|
||||
}
|
|
@ -1,132 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<stdio.h>
|
||||
#include<VGUI_TextGrid.h>
|
||||
#include<VGUI_App.h>
|
||||
#include<VGUI_Font.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
TextGrid::TextGrid(int gridWide,int gridTall,int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
||||
{
|
||||
_grid=null;
|
||||
_gridSize[0]=0;
|
||||
_gridSize[1]=0;
|
||||
setXY(0,0);
|
||||
setBgColor(255,255,255,0);
|
||||
setFgColor(0,0,0,0);
|
||||
setGridSize(gridWide,gridTall);
|
||||
}
|
||||
|
||||
void TextGrid::setGridSize(int wide,int tall)
|
||||
{
|
||||
if((wide<=0)||(tall<=0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
delete[] _grid;
|
||||
_grid=new char[wide*tall*7];
|
||||
memset(_grid,0,wide*tall*7);
|
||||
|
||||
_gridSize[0]=wide;
|
||||
_gridSize[1]=tall;
|
||||
}
|
||||
|
||||
void TextGrid::newLine()
|
||||
{
|
||||
if(_xy[1]==(_gridSize[1]-1))
|
||||
{
|
||||
if(_gridSize[1]>1)
|
||||
{
|
||||
memset(&_grid[((_xy[1]*_gridSize[0])+_xy[0])*7],0,_gridSize[0]-_xy[0]);
|
||||
for(int j=1;j<_gridSize[1];j++)
|
||||
{
|
||||
memcpy(&_grid[((j-1)*_gridSize[0])*7],&_grid[(j*_gridSize[0])*7],_gridSize[0]*7);
|
||||
}
|
||||
memset(&_grid[(_xy[1]*_gridSize[0])*7],0,_gridSize[0]*7);
|
||||
}
|
||||
|
||||
_xy[0]=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_xy[0]=0;
|
||||
_xy[1]++;
|
||||
}
|
||||
}
|
||||
|
||||
void TextGrid::setXY(int x,int y)
|
||||
{
|
||||
_xy[0]=x;
|
||||
_xy[1]=y;
|
||||
}
|
||||
|
||||
int TextGrid::vprintf(const char* format,va_list argList)
|
||||
{
|
||||
char buf[2048];
|
||||
int ret=vsprintf(buf,format,argList);
|
||||
for(int i=0;i<2048;i++)
|
||||
{
|
||||
if(buf[i]==0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(buf[i]=='\n')
|
||||
{
|
||||
newLine();
|
||||
continue;
|
||||
}
|
||||
if((_xy[0]>=0)&&(_xy[0]<_gridSize[0]))
|
||||
{
|
||||
if((_xy[1]>=0)&&(_xy[1]<_gridSize[1]))
|
||||
{
|
||||
_grid[((_xy[1]*_gridSize[0])+_xy[0])*7]=buf[i];
|
||||
_xy[0]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repaint();
|
||||
return ret;
|
||||
}
|
||||
|
||||
int TextGrid::printf(const char* format,...)
|
||||
{
|
||||
va_list argList;
|
||||
va_start(argList,format);
|
||||
return vprintf(format,argList);
|
||||
}
|
||||
|
||||
void TextGrid::paintBackground()
|
||||
{
|
||||
Panel::paintBackground();
|
||||
|
||||
Font* font=getApp()->getScheme()->getFont(Scheme::sf_primary2);
|
||||
int abc[3];
|
||||
font->getCharABCwide('W',abc[0],abc[1],abc[2]);
|
||||
int fwide=abc[0]+abc[1]+abc[2];
|
||||
int ftall=font->getTall();
|
||||
drawSetTextFont(Scheme::sf_primary2);
|
||||
|
||||
int r,g,b,a;
|
||||
|
||||
for(int j=0;j<_gridSize[1];j++)
|
||||
{
|
||||
for(int i=0;i<_gridSize[0];i++)
|
||||
{
|
||||
char ch=_grid[((j*_gridSize[0])+i)*7];
|
||||
if(ch!=0)
|
||||
{
|
||||
getFgColor(r,g,b,a);
|
||||
drawSetTextColor(r,g,b,a);
|
||||
drawPrintChar(fwide*i,ftall*j,ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,312 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_TextImage.h>
|
||||
#include<VGUI_App.h>
|
||||
#include<VGUI_Scheme.h>
|
||||
#include<VGUI_Font.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
void TextImage::init(int textBufferLen,const char* text)
|
||||
{
|
||||
_text=null;
|
||||
_font=null;
|
||||
_textBufferLen=0;
|
||||
_schemeFont=Scheme::sf_primary1;
|
||||
int wide,tall;
|
||||
setText(textBufferLen,text);
|
||||
getTextSize(wide,tall);
|
||||
setSize(wide,tall);
|
||||
}
|
||||
|
||||
TextImage::TextImage(int textBufferLen,const char* text) : Image()
|
||||
{
|
||||
init(textBufferLen,text);
|
||||
}
|
||||
|
||||
TextImage::TextImage(const char* text) : Image()
|
||||
{
|
||||
init(strlen(text)+1,text);
|
||||
}
|
||||
|
||||
void TextImage::setText(int textBufferLen,const char* text)
|
||||
{
|
||||
if(textBufferLen>_textBufferLen)
|
||||
{
|
||||
delete[] _text;
|
||||
_textBufferLen=textBufferLen;
|
||||
_text=new char[textBufferLen];
|
||||
if(_text==null)
|
||||
{
|
||||
_textBufferLen=0;
|
||||
}
|
||||
}
|
||||
if(_text!=null)
|
||||
{
|
||||
vgui_strcpy(_text,_textBufferLen,text);
|
||||
}
|
||||
|
||||
int wide,tall;
|
||||
getTextSize(wide,tall);
|
||||
Image::setSize(wide,tall);
|
||||
}
|
||||
|
||||
void TextImage::setText(const char* text)
|
||||
{
|
||||
setText(strlen(text)+1,text);
|
||||
}
|
||||
|
||||
void TextImage::setFont(vgui::Scheme::SchemeFont schemeFont)
|
||||
{
|
||||
_schemeFont=schemeFont;
|
||||
}
|
||||
|
||||
void TextImage::setFont(vgui::Font* font)
|
||||
{
|
||||
_font=font;
|
||||
}
|
||||
|
||||
Font* TextImage::getFont()
|
||||
{
|
||||
if(_font==null)
|
||||
{
|
||||
return App::getInstance()->getScheme()->getFont(_schemeFont);
|
||||
}
|
||||
return _font;
|
||||
}
|
||||
|
||||
void TextImage::setSize(int wide,int tall)
|
||||
{
|
||||
Image::setSize(wide,tall);
|
||||
}
|
||||
|
||||
void TextImage::paint(Panel* panel)
|
||||
{
|
||||
int wide,tall;
|
||||
getSize(wide,tall);
|
||||
|
||||
if(_text==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Color color;
|
||||
getColor(color);
|
||||
|
||||
int r,g,b,a;
|
||||
color.getColor(r,g,b,a);
|
||||
drawSetTextColor(r,g,b,a);
|
||||
|
||||
Font* font=getFont();
|
||||
drawSetTextFont(font);
|
||||
|
||||
int yAdd=font->getTall();
|
||||
int x=0,y=0;
|
||||
|
||||
for(int i=0;;i++)
|
||||
{
|
||||
int ch=_text[i];
|
||||
|
||||
int a,b,c;
|
||||
|
||||
font->getCharABCwide(ch,a,b,c);
|
||||
int len=a+b+c;
|
||||
|
||||
if(ch==0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
if(ch=='\r')
|
||||
{
|
||||
}
|
||||
else
|
||||
if(ch=='\n')
|
||||
{
|
||||
x=0;
|
||||
y+=yAdd;
|
||||
}
|
||||
else
|
||||
if(ch==' ')
|
||||
{
|
||||
char nextch;
|
||||
nextch = _text[i+1];
|
||||
|
||||
font->getCharABCwide(' ',a,b,c);
|
||||
|
||||
if ( !(nextch==0) && !(nextch=='\n') && !(nextch=='\r') )
|
||||
{
|
||||
x+=a+b+c;
|
||||
if(x>wide)
|
||||
{
|
||||
x=0;
|
||||
y+=yAdd;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int ctr;
|
||||
for(ctr=1;;ctr++)
|
||||
{
|
||||
ch=_text[i+ctr];
|
||||
if( (ch==0) || (ch=='\n') || (ch=='\r') || (ch==' ') )
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
int a,b,c;
|
||||
font->getCharABCwide(ch,a,b,c);
|
||||
len+=a+b+c;
|
||||
}
|
||||
}
|
||||
|
||||
if((x+len)>wide)
|
||||
{
|
||||
x=0;
|
||||
y+=yAdd;
|
||||
}
|
||||
|
||||
for(int j=0;j<ctr;j++)
|
||||
{
|
||||
ch=_text[i+j];
|
||||
font->getCharABCwide(ch,a,b,c);
|
||||
drawPrintChar(x,y,ch);
|
||||
x+=a+b+c;
|
||||
}
|
||||
|
||||
i+=ctr-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TextImage::getTextSizeWrapped(int& wideo,int& tallo)
|
||||
{
|
||||
wideo=0;
|
||||
tallo=0;
|
||||
|
||||
if(_text==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int wide,tall;
|
||||
getSize(wide,tall);
|
||||
|
||||
Font* font=getFont();
|
||||
|
||||
int yAdd=font->getTall();
|
||||
int x=0,y=0;
|
||||
|
||||
for(int i=0;;i++)
|
||||
{
|
||||
int ch=_text[i];
|
||||
|
||||
int a,b,c;
|
||||
|
||||
font->getCharABCwide(ch,a,b,c);
|
||||
int len=a+b+c;
|
||||
|
||||
if(ch==0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
if(ch=='\r')
|
||||
{
|
||||
}
|
||||
else
|
||||
if(ch=='\n')
|
||||
{
|
||||
x=0;
|
||||
y+=yAdd;
|
||||
}
|
||||
else
|
||||
if(ch==' ')
|
||||
{
|
||||
char nextch;
|
||||
nextch = _text[i+1];
|
||||
|
||||
font->getCharABCwide(' ',a,b,c);
|
||||
|
||||
if ( !(nextch==0) && !(nextch=='\n') && !(nextch=='\r') )
|
||||
{
|
||||
x+=a+b+c;
|
||||
if(x>wide)
|
||||
{
|
||||
x=0;
|
||||
y+=yAdd;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int ctr;
|
||||
for(ctr=1;;ctr++)
|
||||
{
|
||||
ch=_text[i+ctr];
|
||||
if( (ch==0) || (ch=='\n') || (ch=='\r') || (ch==' ') )
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
int a,b,c;
|
||||
font->getCharABCwide(ch,a,b,c);
|
||||
len+=a+b+c;
|
||||
}
|
||||
}
|
||||
|
||||
if((x+len)>wide)
|
||||
{
|
||||
x=0;
|
||||
y+=yAdd;
|
||||
}
|
||||
|
||||
for(int j=0;j<ctr;j++)
|
||||
{
|
||||
ch=_text[i+j];
|
||||
font->getCharABCwide(ch,a,b,c);
|
||||
|
||||
if((x+a+b+c)>wideo)
|
||||
{
|
||||
wideo=x+a+b+c;
|
||||
}
|
||||
if((y+yAdd)>tallo)
|
||||
{
|
||||
tallo=y+yAdd;
|
||||
}
|
||||
|
||||
x+=a+b+c;
|
||||
}
|
||||
|
||||
i+=ctr-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TextImage::getTextSize(int& wide,int& tall)
|
||||
{
|
||||
wide=0;
|
||||
tall=0;
|
||||
|
||||
if(_text==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Font* font=getFont();
|
||||
|
||||
if(font==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
font->getTextSize(_text,wide,tall);
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_TextPanel.h>
|
||||
#include<VGUI_TextImage.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
TextPanel::TextPanel(const char* text,int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
||||
{
|
||||
_textImage=new TextImage(text);
|
||||
_textImage->setSize(wide,tall);
|
||||
}
|
||||
|
||||
void TextPanel::setText(const char* text)
|
||||
{
|
||||
_textImage->setText(text);
|
||||
}
|
||||
|
||||
void TextPanel::setFont(vgui::Scheme::SchemeFont schemeFont)
|
||||
{
|
||||
_textImage->setFont(schemeFont);
|
||||
}
|
||||
|
||||
void TextPanel::setFont(vgui::Font* font)
|
||||
{
|
||||
_textImage->setFont(font);
|
||||
}
|
||||
|
||||
void TextPanel::paint()
|
||||
{
|
||||
_textImage->doPaint(this);
|
||||
}
|
||||
|
||||
void TextPanel::setSize(int wide,int tall)
|
||||
{
|
||||
Panel::setSize(wide,tall);
|
||||
getPaintSize(wide,tall);
|
||||
_textImage->setSize(wide,tall);
|
||||
}
|
||||
|
||||
void TextPanel::setFgColor(int r,int g,int b,int a)
|
||||
{
|
||||
Panel::setFgColor(r,g,b,a);
|
||||
_textImage->setColor(Color(r,g,b,a));
|
||||
}
|
||||
|
||||
void TextPanel::setFgColor(Scheme::SchemeColor sc)
|
||||
{
|
||||
Panel::setFgColor(sc);
|
||||
_textImage->setColor(Color(sc));
|
||||
}
|
||||
|
||||
TextImage* TextPanel::getTextImage()
|
||||
{
|
||||
return _textImage;
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_ToggleButton.h>
|
||||
#include<VGUI_ButtonController.h>
|
||||
#include<VGUI_InputSignal.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class FooDefaultToggleButtonController : public ButtonController, public InputSignal
|
||||
{
|
||||
public:
|
||||
FooDefaultToggleButtonController(ToggleButton* button)
|
||||
{
|
||||
_button=button;
|
||||
}
|
||||
public:
|
||||
virtual void addSignals(Button* button)
|
||||
{
|
||||
button->addInputSignal(this);
|
||||
}
|
||||
virtual void removeSignals(Button* button)
|
||||
{
|
||||
button->removeInputSignal(this);
|
||||
}
|
||||
public:
|
||||
virtual void cursorMoved(int x,int y,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void cursorEntered(Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void cursorExited(Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void mousePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
_button->setSelected(!_button->isEnabled());
|
||||
_button->fireActionSignal();
|
||||
_button->repaint();
|
||||
}
|
||||
virtual void mouseDoublePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void mouseReleased(MouseCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void mouseWheeled(int delta,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyPressed(KeyCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyTyped(KeyCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyReleased(KeyCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyFocusTicked(Panel* panel)
|
||||
{
|
||||
}
|
||||
protected:
|
||||
ToggleButton* _button;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
ToggleButton::ToggleButton(const char* text,int x,int y,int wide,int tall) : Button(text,x,y,wide,tall)
|
||||
{
|
||||
setButtonController(new FooDefaultToggleButtonController(this));
|
||||
}
|
||||
|
||||
ToggleButton::ToggleButton(const char* text,int x,int y) : Button(text,x,y)
|
||||
{
|
||||
setButtonController(new FooDefaultToggleButtonController(this));
|
||||
}
|
|
@ -1,250 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_TreeFolder.h>
|
||||
#include<VGUI_InputSignal.h>
|
||||
#include<VGUI_Label.h>
|
||||
#include<VGUI_Layout.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class FooTabFolderVerticalLayout : public Layout
|
||||
{
|
||||
public:
|
||||
FooTabFolderVerticalLayout() : Layout()
|
||||
{
|
||||
_hgap=30;
|
||||
_vgap=3;
|
||||
}
|
||||
public:
|
||||
virtual void performLayout(Panel* panel)
|
||||
{
|
||||
TreeFolder* folder;
|
||||
|
||||
int maxx=0;
|
||||
int wide,tall,xx,yy=0;
|
||||
|
||||
for(int i=0;i<panel->getChildCount();i++)
|
||||
{
|
||||
Panel* child=panel->getChild(i);
|
||||
|
||||
folder=dynamic_cast<TreeFolder*>(child);
|
||||
if(folder!=null)
|
||||
{
|
||||
folder->invalidateLayout(true);
|
||||
}
|
||||
|
||||
child->getSize(wide,tall);
|
||||
|
||||
if(i==0)
|
||||
{
|
||||
xx=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
xx=_hgap;
|
||||
}
|
||||
|
||||
child->setPos(xx,yy);
|
||||
|
||||
if(xx+wide>maxx)
|
||||
{
|
||||
maxx=xx+wide;
|
||||
}
|
||||
|
||||
yy+=tall+_vgap;
|
||||
}
|
||||
|
||||
folder=dynamic_cast<TreeFolder*>(panel);
|
||||
if(folder!=null)
|
||||
{
|
||||
if(folder->isOpened())
|
||||
{
|
||||
panel->setSize(maxx+2,yy);
|
||||
}
|
||||
else
|
||||
{
|
||||
Panel*child=panel->getChild(0);
|
||||
if(child!=null)
|
||||
{
|
||||
child->getSize(wide,tall);
|
||||
folder->setSize(wide,tall);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
protected:
|
||||
int _hgap;
|
||||
int _vgap;
|
||||
};
|
||||
|
||||
class FooTreeFolderDefaultHandler : public InputSignal
|
||||
{
|
||||
public:
|
||||
FooTreeFolderDefaultHandler(TreeFolder* treeFolder)
|
||||
{
|
||||
_treeFolder=treeFolder;
|
||||
}
|
||||
public:
|
||||
virtual void cursorMoved(int x,int y,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void cursorEntered(Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void cursorExited(Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void mousePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
_treeFolder->setOpened(!_treeFolder->isOpened());
|
||||
}
|
||||
virtual void mouseDoublePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void mouseReleased(MouseCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void mouseWheeled(int delta,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyPressed(KeyCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyTyped(KeyCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyReleased(KeyCode code,Panel* panel)
|
||||
{
|
||||
}
|
||||
virtual void keyFocusTicked(Panel* panel)
|
||||
{
|
||||
}
|
||||
protected:
|
||||
TreeFolder* _treeFolder;
|
||||
};
|
||||
}
|
||||
|
||||
void TreeFolder::init(const char* name)
|
||||
{
|
||||
_opened=false;
|
||||
|
||||
Label* label=new Label(name,0,0);
|
||||
label->addInputSignal(new FooTreeFolderDefaultHandler(this));
|
||||
label->setParent(this);
|
||||
|
||||
setLayout(new FooTabFolderVerticalLayout());
|
||||
}
|
||||
|
||||
TreeFolder::TreeFolder(const char* name) : Panel(0,0,500,500)
|
||||
{
|
||||
init(name);
|
||||
}
|
||||
|
||||
TreeFolder::TreeFolder(const char* name,int x,int y) : Panel(x,y,500,500)
|
||||
{
|
||||
init(name);
|
||||
}
|
||||
|
||||
void TreeFolder::setOpened(bool state)
|
||||
{
|
||||
if(_opened!=state)
|
||||
{
|
||||
_opened=state;
|
||||
|
||||
TreeFolder* top=null;
|
||||
Panel* trav=this;
|
||||
while(trav!=null)
|
||||
{
|
||||
TreeFolder* folder=dynamic_cast<TreeFolder*>(trav);
|
||||
if(folder!=null)
|
||||
{
|
||||
folder->invalidateLayout(true);
|
||||
top=folder;
|
||||
}
|
||||
trav=trav->getParent();
|
||||
}
|
||||
if(top!=null)
|
||||
{
|
||||
top->repaintParent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TreeFolder::isOpened()
|
||||
{
|
||||
return _opened;
|
||||
}
|
||||
|
||||
void TreeFolder::paintBackground()
|
||||
{
|
||||
drawSetColor(Scheme::sc_black);
|
||||
|
||||
const int x0=15;
|
||||
const int x1=30;
|
||||
const int y0=10;
|
||||
int y1=10;
|
||||
|
||||
int i;
|
||||
for(i=1;i<getChildCount();i++)
|
||||
{
|
||||
Panel* child=getChild(i);
|
||||
int x,y,wide,tall;
|
||||
child->getBounds(x,y,wide,tall);
|
||||
if(dynamic_cast<TreeFolder*>(child)!=null)
|
||||
{
|
||||
y+=10;
|
||||
}
|
||||
else
|
||||
{
|
||||
y+=tall/2;
|
||||
}
|
||||
|
||||
drawFilledRect(x0,y,x1,y+1);
|
||||
y1=y;
|
||||
}
|
||||
|
||||
drawFilledRect(x0,y0,x0+1,y1);
|
||||
|
||||
for(i=1;i<getChildCount();i++)
|
||||
{
|
||||
Panel* child=getChild(i);
|
||||
int x,y,wide,tall;
|
||||
child->getBounds(x,y,wide,tall);
|
||||
TreeFolder* folder=dynamic_cast<TreeFolder*>(child);
|
||||
if(folder!=null)
|
||||
{
|
||||
y+=10;
|
||||
drawSetColor(Scheme::sc_white);
|
||||
drawFilledRect(x0-5,y-5,x0+6,y+6);
|
||||
drawSetColor(Scheme::sc_black);
|
||||
drawOutlinedRect(x0-5,y-5,x0+6,y+6);
|
||||
drawFilledRect(x0-3,y,x0+4,y+1);
|
||||
|
||||
if(!folder->isOpened())
|
||||
{
|
||||
drawFilledRect(x0,y-3,x0+1,y+4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TreeFolder::setOpenedTraverse(bool state)
|
||||
{
|
||||
setOpened(true);
|
||||
|
||||
for(int i=0;i<getChildCount();i++)
|
||||
{
|
||||
TreeFolder* folder=dynamic_cast<TreeFolder*>(getChild(i));
|
||||
if(folder!=null)
|
||||
{
|
||||
folder->setOpenedTraverse(state);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,453 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<assert.h>
|
||||
#include<VGUI_WizardPanel.h>
|
||||
#include<VGUI_ActionSignal.h>
|
||||
#include<VGUI_App.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class FooBackHandler : public ActionSignal
|
||||
{
|
||||
private:
|
||||
WizardPanel* _wizardPanel;
|
||||
public:
|
||||
FooBackHandler(WizardPanel* wizardPanel)
|
||||
{
|
||||
_wizardPanel=wizardPanel;
|
||||
}
|
||||
public:
|
||||
virtual void actionPerformed(Panel* panel)
|
||||
{
|
||||
_wizardPanel->doBack();
|
||||
}
|
||||
};
|
||||
|
||||
class FooNextHandler : public ActionSignal
|
||||
{
|
||||
private:
|
||||
WizardPanel* _wizardPanel;
|
||||
public:
|
||||
FooNextHandler(WizardPanel* wizardPanel)
|
||||
{
|
||||
_wizardPanel=wizardPanel;
|
||||
}
|
||||
public:
|
||||
virtual void actionPerformed(Panel* panel)
|
||||
{
|
||||
_wizardPanel->doNext();
|
||||
}
|
||||
};
|
||||
|
||||
void fooGetText(const char* src,char* dst,int dstLen)
|
||||
{
|
||||
assert(dst!=null);
|
||||
assert(dstLen>=0);
|
||||
assert(src!=null);
|
||||
|
||||
int srcLen=strlen(src)+1;
|
||||
if(srcLen>dstLen)
|
||||
{
|
||||
srcLen=dstLen;
|
||||
}
|
||||
|
||||
memcpy(dst,src,srcLen-1);
|
||||
dst[srcLen-1]=0;
|
||||
}
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::init()
|
||||
{
|
||||
_backWizardPage=null;
|
||||
_nextWizardPage=null;
|
||||
_backButtonEnabled=false;
|
||||
_nextButtonEnabled=false;
|
||||
_finishedButtonEnabled=false;
|
||||
_cancelButtonEnabled=true;
|
||||
_backButtonText=null;
|
||||
_nextButtonText=null;
|
||||
_finishedButtonText=null;
|
||||
_cancelButtonText=null;
|
||||
_wantedFocus=null;
|
||||
_title=null;
|
||||
_backButtonVisible=true;
|
||||
_nextButtonVisible=true;
|
||||
_finishedButtonVisible=true;
|
||||
_cancelButtonVisible=true;
|
||||
|
||||
setTitle("Untitled");
|
||||
setBackButtonText("<< Back");
|
||||
setNextButtonText("Next >>");
|
||||
setFinishedButtonText("Finished");
|
||||
setCancelButtonText("Cancel");
|
||||
}
|
||||
|
||||
WizardPanel::WizardPage::WizardPage() : Panel(0,0,64,64)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
WizardPanel::WizardPage::WizardPage(int wide,int tall) : Panel(0,0,wide,tall)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::setBackWizardPage(WizardPage* backWizardPage)
|
||||
{
|
||||
_backWizardPage=backWizardPage;
|
||||
setBackButtonEnabled(backWizardPage!=null);
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::setNextWizardPage(WizardPage* nextWizardPage)
|
||||
{
|
||||
_nextWizardPage=nextWizardPage;
|
||||
setNextButtonEnabled(nextWizardPage!=null);
|
||||
}
|
||||
|
||||
WizardPanel::WizardPage* WizardPanel::WizardPage::getBackWizardPage()
|
||||
{
|
||||
return _backWizardPage;
|
||||
}
|
||||
|
||||
WizardPanel::WizardPage* WizardPanel::WizardPage::getNextWizardPage()
|
||||
{
|
||||
return _nextWizardPage;
|
||||
}
|
||||
|
||||
bool WizardPanel::WizardPage::isBackButtonEnabled()
|
||||
{
|
||||
return _backButtonEnabled;
|
||||
}
|
||||
|
||||
bool WizardPanel::WizardPage::isNextButtonEnabled()
|
||||
{
|
||||
return _nextButtonEnabled;
|
||||
}
|
||||
|
||||
bool WizardPanel::WizardPage::isFinishedButtonEnabled()
|
||||
{
|
||||
return _finishedButtonEnabled;
|
||||
}
|
||||
|
||||
bool WizardPanel::WizardPage::isCancelButtonEnabled()
|
||||
{
|
||||
return _cancelButtonEnabled;
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::setBackButtonEnabled(bool state)
|
||||
{
|
||||
_backButtonEnabled=state;
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::setNextButtonEnabled(bool state)
|
||||
{
|
||||
_nextButtonEnabled=state;
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::setFinishedButtonEnabled(bool state)
|
||||
{
|
||||
_finishedButtonEnabled=state;
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::setCancelButtonEnabled(bool state)
|
||||
{
|
||||
_cancelButtonEnabled=state;
|
||||
}
|
||||
|
||||
bool WizardPanel::WizardPage::isBackButtonVisible()
|
||||
{
|
||||
return _backButtonVisible;
|
||||
}
|
||||
|
||||
bool WizardPanel::WizardPage::isNextButtonVisible()
|
||||
{
|
||||
return _nextButtonVisible;
|
||||
}
|
||||
|
||||
bool WizardPanel::WizardPage::isFinishedButtonVisible()
|
||||
{
|
||||
return _finishedButtonVisible;
|
||||
}
|
||||
|
||||
bool WizardPanel::WizardPage::isCancelButtonVisible()
|
||||
{
|
||||
return _cancelButtonVisible;
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::setBackButtonVisible(bool state)
|
||||
{
|
||||
_backButtonVisible=state;
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::setNextButtonVisible(bool state)
|
||||
{
|
||||
_nextButtonVisible=state;
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::setFinishedButtonVisible(bool state)
|
||||
{
|
||||
_finishedButtonVisible=state;
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::setCancelButtonVisible(bool state)
|
||||
{
|
||||
_cancelButtonVisible=state;
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::getBackButtonText(char* text,int textLen)
|
||||
{
|
||||
fooGetText(_backButtonText,text,textLen);
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::getNextButtonText(char* text,int textLen)
|
||||
{
|
||||
fooGetText(_nextButtonText,text,textLen);
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::getFinishedButtonText(char* text,int textLen)
|
||||
{
|
||||
fooGetText(_finishedButtonText,text,textLen);
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::getCancelButtonText(char* text,int textLen)
|
||||
{
|
||||
fooGetText(_cancelButtonText,text,textLen);
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::setBackButtonText(const char* text)
|
||||
{
|
||||
delete[] _backButtonText;
|
||||
_backButtonText=vgui_strdup(text);
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::setNextButtonText(const char* text)
|
||||
{
|
||||
delete[] _nextButtonText;
|
||||
_nextButtonText=vgui_strdup(text);
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::setFinishedButtonText(const char* text)
|
||||
{
|
||||
delete[] _finishedButtonText;
|
||||
_finishedButtonText=vgui_strdup(text);
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::setCancelButtonText(const char* text)
|
||||
{
|
||||
delete[] _cancelButtonText;
|
||||
_cancelButtonText=vgui_strdup(text);
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::addSwitchingToBackPageSignal(ActionSignal* s)
|
||||
{
|
||||
_switchingToBackPageSignalDar.putElement(s);
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::addSwitchingToNextPageSignal(ActionSignal* s)
|
||||
{
|
||||
_switchingToNextPageSignalDar.putElement(s);
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::fireSwitchingToBackPageSignals()
|
||||
{
|
||||
for(int i=0;i<_switchingToBackPageSignalDar.getCount();i++)
|
||||
{
|
||||
_switchingToBackPageSignalDar[i]->actionPerformed(this);
|
||||
}
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::fireSwitchingToNextPageSignals()
|
||||
{
|
||||
for(int i=0;i<_switchingToBackPageSignalDar.getCount();i++)
|
||||
{
|
||||
_switchingToBackPageSignalDar[i]->actionPerformed(this);
|
||||
}
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::setTitle(const char* title)
|
||||
{
|
||||
delete[] _title;
|
||||
_title=vgui_strdup(title);
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::getTitle(char* buf,int bufLen)
|
||||
{
|
||||
vgui_strcpy(buf,bufLen,_title);
|
||||
}
|
||||
|
||||
void WizardPanel::WizardPage::setWantedFocus(Panel* panel)
|
||||
{
|
||||
_wantedFocus=panel;
|
||||
}
|
||||
|
||||
Panel* WizardPanel::WizardPage::getWantedFocus()
|
||||
{
|
||||
return _wantedFocus;
|
||||
}
|
||||
|
||||
WizardPanel::WizardPanel(int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
||||
{
|
||||
_currentWizardPage=null;
|
||||
|
||||
_backButton=new Button("back",20,100);
|
||||
_backButton->setParent(this);
|
||||
_backButton->addActionSignal(new FooBackHandler(this));
|
||||
|
||||
_nextButton=new Button("next",80,100);
|
||||
_nextButton->setParent(this);
|
||||
_nextButton->addActionSignal(new FooNextHandler(this));
|
||||
|
||||
_nextButton=new Button("finished",120,100);
|
||||
_nextButton->setParent(this);
|
||||
|
||||
_nextButton=new Button("cancel",180,100);
|
||||
_nextButton->setParent(this);
|
||||
}
|
||||
|
||||
void WizardPanel::performLayout()
|
||||
{
|
||||
int wide,tall;
|
||||
getPaintSize(wide,tall);
|
||||
|
||||
_backButton->setVisible(false);
|
||||
_nextButton->setVisible(false);
|
||||
_finishedButton->setVisible(false);
|
||||
_cancelButton->setVisible(false);
|
||||
|
||||
if(_currentWizardPage!=null)
|
||||
{
|
||||
int bTall=_backButton->getTall();
|
||||
_currentWizardPage->setBounds(2,2,wide-4,tall-bTall-8);
|
||||
|
||||
char buf[256];
|
||||
int gap=2;
|
||||
int x=wide-(gap*2);
|
||||
int y=tall-bTall-gap;
|
||||
|
||||
_currentWizardPage->getCancelButtonText(buf,sizeof(buf));
|
||||
_cancelButton->setText(buf);
|
||||
_cancelButton->setEnabled(_currentWizardPage->isCancelButtonEnabled());
|
||||
_cancelButton->setVisible(_currentWizardPage->isCancelButtonVisible());
|
||||
_cancelButton->setPos(x-_cancelButton->getWide(),y);
|
||||
if(_currentWizardPage->isCancelButtonVisible())
|
||||
{
|
||||
x-=_cancelButton->getWide()+(gap*2);
|
||||
}
|
||||
|
||||
_currentWizardPage->getFinishedButtonText(buf,sizeof(buf));
|
||||
_finishedButton->setText(buf);
|
||||
_finishedButton->setEnabled(_currentWizardPage->isFinishedButtonEnabled());
|
||||
_finishedButton->setVisible(_currentWizardPage->isFinishedButtonVisible());
|
||||
_finishedButton->setPos(x-_finishedButton->getWide(),y);
|
||||
if(_currentWizardPage->isFinishedButtonVisible())
|
||||
{
|
||||
x-=_finishedButton->getWide()+(gap*2);
|
||||
}
|
||||
|
||||
_currentWizardPage->getNextButtonText(buf,sizeof(buf));
|
||||
_nextButton->setText(buf);
|
||||
_nextButton->setEnabled(_currentWizardPage->isNextButtonEnabled());
|
||||
_nextButton->setVisible(_currentWizardPage->isNextButtonVisible());
|
||||
_nextButton->setPos(x-_nextButton->getWide(),y);
|
||||
if(_currentWizardPage->isNextButtonVisible())
|
||||
{
|
||||
x-=_nextButton->getWide()+(gap*2);
|
||||
}
|
||||
|
||||
_currentWizardPage->getBackButtonText(buf,sizeof(buf));
|
||||
_backButton->setText(buf);
|
||||
_backButton->setEnabled(_currentWizardPage->isBackButtonEnabled());
|
||||
_backButton->setVisible(_currentWizardPage->isBackButtonVisible());
|
||||
_backButton->setPos(x-_backButton->getWide(),y);
|
||||
if(_currentWizardPage->isBackButtonVisible())
|
||||
{
|
||||
x-=_backButton->getWide()+(gap*2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WizardPanel::setCurrentWizardPage(WizardPage* currentWizardPage)
|
||||
{
|
||||
if(_currentWizardPage!=null)
|
||||
{
|
||||
removeChild(_currentWizardPage);
|
||||
}
|
||||
_currentWizardPage=currentWizardPage;
|
||||
|
||||
if(_currentWizardPage!=null)
|
||||
{
|
||||
_currentWizardPage->setParent(this);
|
||||
getApp()->requestFocus(_currentWizardPage->getWantedFocus());
|
||||
}
|
||||
|
||||
firePageChangedActionSignal();
|
||||
invalidateLayout(false);
|
||||
}
|
||||
|
||||
void WizardPanel::addFinishedActionSignal(ActionSignal* s)
|
||||
{
|
||||
_finishedButton->addActionSignal(s);
|
||||
}
|
||||
|
||||
void WizardPanel::addCancelledActionSignal(ActionSignal* s)
|
||||
{
|
||||
_cancelButton->addActionSignal(s);
|
||||
}
|
||||
|
||||
void WizardPanel::addPageChangedActionSignal(ActionSignal* s)
|
||||
{
|
||||
_pageChangedActionSignalDar.putElement(s);
|
||||
}
|
||||
|
||||
void WizardPanel::fireFinishedActionSignal()
|
||||
{
|
||||
_finishedButton->fireActionSignal();
|
||||
}
|
||||
|
||||
void WizardPanel::fireCancelledActionSignal()
|
||||
{
|
||||
_cancelButton->fireActionSignal();
|
||||
}
|
||||
|
||||
void WizardPanel::firePageChangedActionSignal()
|
||||
{
|
||||
for(int i=0;i<_pageChangedActionSignalDar.getCount();i++)
|
||||
{
|
||||
_pageChangedActionSignalDar[i]->actionPerformed(this);
|
||||
}
|
||||
}
|
||||
|
||||
void WizardPanel::doBack()
|
||||
{
|
||||
if(_currentWizardPage!=null)
|
||||
{
|
||||
_currentWizardPage->fireSwitchingToBackPageSignals();
|
||||
setCurrentWizardPage(_currentWizardPage->getBackWizardPage());
|
||||
}
|
||||
}
|
||||
|
||||
void WizardPanel::doNext()
|
||||
{
|
||||
if(_currentWizardPage!=null)
|
||||
{
|
||||
_currentWizardPage->fireSwitchingToNextPageSignals();
|
||||
setCurrentWizardPage(_currentWizardPage->getNextWizardPage());
|
||||
}
|
||||
}
|
||||
|
||||
void WizardPanel::getCurrentWizardPageTitle(char* buf,int bufLen)
|
||||
{
|
||||
_currentWizardPage->getTitle(buf,bufLen);
|
||||
}
|
||||
|
||||
WizardPanel::WizardPage* WizardPanel::getCurrentWizardPage()
|
||||
{
|
||||
return _currentWizardPage;
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<assert.h>
|
||||
#if defined( OSX )
|
||||
#include<malloc/malloc.h>
|
||||
#else
|
||||
#include<malloc.h>
|
||||
#endif
|
||||
#include<string.h>
|
||||
#include<stdio.h>
|
||||
#include<stdarg.h>
|
||||
#include<VGUI.h>
|
||||
|
||||
static void*(*staticMalloc)(size_t size)=malloc;
|
||||
static void(*staticFree)(void* memblock)=free;
|
||||
|
||||
void *operator new(size_t size)
|
||||
{
|
||||
return staticMalloc(size);
|
||||
}
|
||||
|
||||
void operator delete(void* memblock)
|
||||
{
|
||||
staticFree(memblock);
|
||||
}
|
||||
|
||||
void *operator new [] (size_t size)
|
||||
{
|
||||
return staticMalloc(size);
|
||||
}
|
||||
|
||||
void operator delete [] (void *pMem)
|
||||
{
|
||||
staticFree(pMem);
|
||||
}
|
||||
|
||||
void vgui_setMalloc(void *(*theMalloc)(size_t size))
|
||||
{
|
||||
if(theMalloc==null)
|
||||
{
|
||||
theMalloc=malloc;
|
||||
}
|
||||
|
||||
staticMalloc=theMalloc;
|
||||
}
|
||||
|
||||
void vgui_setFree(void (*theFree)(void* memblock))
|
||||
{
|
||||
if(theFree==null)
|
||||
{
|
||||
theFree=free;
|
||||
}
|
||||
|
||||
staticFree=theFree;
|
||||
}
|
||||
|
||||
namespace vgui
|
||||
{
|
||||
void vgui_strcpy(char* dst,int dstLen,const char* src)
|
||||
{
|
||||
assert(dst!=null);
|
||||
assert(dstLen>=0);
|
||||
assert(src!=null);
|
||||
|
||||
int srcLen=strlen(src)+1;
|
||||
if(srcLen>dstLen)
|
||||
{
|
||||
srcLen=dstLen;
|
||||
}
|
||||
|
||||
memcpy(dst,src,srcLen-1);
|
||||
dst[srcLen-1]=0;
|
||||
}
|
||||
|
||||
char* vgui_strdup(const char* src)
|
||||
{
|
||||
assert(src!=null);
|
||||
|
||||
int len=strlen(src)+1;
|
||||
char* dst=new char[len];
|
||||
memcpy(dst,src,len-1);
|
||||
dst[len-1]=0;
|
||||
return dst;
|
||||
}
|
||||
|
||||
int vgui_printf(const char* format,...)
|
||||
{
|
||||
char buf[2048];
|
||||
va_list argList;
|
||||
|
||||
va_start(argList,format);
|
||||
int ret=vsprintf(buf,format,argList);
|
||||
va_end(argList);
|
||||
|
||||
printf("%s",buf);
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -1,845 +0,0 @@
|
|||
# Microsoft Developer Studio Project File - Name="vgui" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=vgui - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "vgui.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "vgui.mak" CFG="vgui - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "vgui - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "vgui - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "vgui - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "..\..\..\temp\vgui\!release"
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "VGUI_DLL_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GR /GX /O2 /I "..\include" /I "..\..\..\engine" /I "..\..\..\common" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 msvcrt.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98
|
||||
# Begin Custom Build
|
||||
TargetDir=\Xash3D\src_main\temp\vgui\!release
|
||||
InputPath=\Xash3D\src_main\temp\vgui\!release\vgui.dll
|
||||
SOURCE="$(InputPath)"
|
||||
|
||||
BuildCmds= \
|
||||
copy $(TargetDir)\vgui.dll "D:\Xash3D\vgui.dll" \
|
||||
copy $(TargetDir)\vgui.lib "D:\Xash3D\src_main\utils\vgui\lib\win32_vc6\vgui.lib" \
|
||||
|
||||
|
||||
"D:\Xash3D\vgui.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"D:\Xash3D\src_main\utils\vgui\lib\win32_vc6\vgui.lib" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "vgui - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "..\..\..\temp\vgui\!debug"
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "VGUI_DLL_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /Gi /GR /GX /ZI /Od /I "..\include" /I "..\..\..\engine" /I "..\..\..\common" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FAs /FR /FD /GZ /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 msvcrtd.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"LIBCMTD" /pdbtype:sept
|
||||
# Begin Custom Build
|
||||
TargetDir=\Xash3D\src_main\temp\vgui\!debug
|
||||
InputPath=\Xash3D\src_main\temp\vgui\!debug\vgui.dll
|
||||
SOURCE="$(InputPath)"
|
||||
|
||||
"D:\Xash3D\src_main\utils\vgui\lib\win32_vc6\vgui.lib" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
copy $(TargetDir)\vgui.dll "D:\Xash3D\vgui.dll"
|
||||
copy $(TargetDir)\vgui.lib "D:\Xash3D\src_main\utils\vgui\lib\win32_vc6\vgui.lib"
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "vgui - Win32 Release"
|
||||
# Name "vgui - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Group "win32"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="win32_vc6\App.cpp"
|
||||
|
||||
!IF "$(CFG)" == "vgui - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!release\win32"
|
||||
|
||||
!ELSEIF "$(CFG)" == "vgui - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!debug\win32"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="win32_vc6\Cursor.cpp"
|
||||
|
||||
!IF "$(CFG)" == "vgui - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!release\win32"
|
||||
|
||||
!ELSEIF "$(CFG)" == "vgui - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!debug\win32"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="win32_vc6\fileimage.cpp"
|
||||
|
||||
!IF "$(CFG)" == "vgui - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!release\win32"
|
||||
|
||||
!ELSEIF "$(CFG)" == "vgui - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!debug\win32"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="win32_vc6\fileimage.h"
|
||||
|
||||
!IF "$(CFG)" == "vgui - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!release\win32"
|
||||
|
||||
!ELSEIF "$(CFG)" == "vgui - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!debug\win32"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="win32_vc6\Font.cpp"
|
||||
|
||||
!IF "$(CFG)" == "vgui - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!release\win32"
|
||||
|
||||
!ELSEIF "$(CFG)" == "vgui - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!debug\win32"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="win32_vc6\Surface.cpp"
|
||||
|
||||
!IF "$(CFG)" == "vgui - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!release\win32"
|
||||
|
||||
!ELSEIF "$(CFG)" == "vgui - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!debug\win32"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="win32_vc6\vfontdata.cpp"
|
||||
|
||||
!IF "$(CFG)" == "vgui - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!release\win32"
|
||||
|
||||
!ELSEIF "$(CFG)" == "vgui - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!debug\win32"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="win32_vc6\vfontdata.h"
|
||||
|
||||
!IF "$(CFG)" == "vgui - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!release\win32"
|
||||
|
||||
!ELSEIF "$(CFG)" == "vgui - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!debug\win32"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="win32_vc6\vgui.cpp"
|
||||
|
||||
!IF "$(CFG)" == "vgui - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!release\win32"
|
||||
|
||||
!ELSEIF "$(CFG)" == "vgui - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!debug\win32"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="win32_vc6\vgui_win32.h"
|
||||
|
||||
!IF "$(CFG)" == "vgui - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!release\win32"
|
||||
|
||||
!ELSEIF "$(CFG)" == "vgui - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "..\..\..\temp\vgui\!debug\win32"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="App.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="Bitmap.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="BitmapTGA.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="Border.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="BorderLayout.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="BorderPair.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="BuildGroup.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="Button.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="ButtonGroup.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="CheckButton.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="Color.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="ConfigWizard.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="Cursor.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="DataInputStream.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="Desktop.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="DesktopIcon.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="EditPanel.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="EtchedBorder.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="FileInputStream.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="FlowLayout.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="FocusNavGroup.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="Font.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="Frame.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="GridLayout.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="HeaderPanel.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="Image.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="ImagePanel.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="IntLabel.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="Label.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="Layout.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="LineBorder.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="ListPanel.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="LoweredBorder.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="Menu.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="MenuItem.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="MenuSeparator.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="MessageBox.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="MiniApp.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="Panel.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="PopupMenu.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="ProgressBar.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="RadioButton.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="RaisedBorder.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="Scheme.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="ScrollBar.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="ScrollPanel.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="Slider.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="StackLayout.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="String.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="Surface.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="SurfaceBase.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="TablePanel.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="TabPanel.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="TaskBar.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="TextEntry.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="TextGrid.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="TextImage.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="TextPanel.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="ToggleButton.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="TreeFolder.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="vgui.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="WizardPanel.cpp"
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_ActionSignal.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_App.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_Bitmap.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_BitmapTGA.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_Border.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_BorderLayout.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_BorderPair.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_BuildGroup.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_Button.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_ButtonController.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_ButtonGroup.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_ChangeSignal.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_CheckButton.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_Color.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_ComboKey.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_ConfigWizard.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_Cursor.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_Dar.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_DataInputStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_Desktop.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_DesktopIcon.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_EditPanel.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_EtchedBorder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_FileInputStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_FlowLayout.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_FocusChangeSignal.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_FocusNavGroup.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_Font.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_Frame.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_FrameSignal.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_GridLayout.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_HeaderPanel.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_Image.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_ImagePanel.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_InputSignal.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_InputStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_IntChangeSignal.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_IntLabel.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_KeyCode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_Label.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_Layout.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_LayoutInfo.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_LineBorder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_ListPanel.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_LoweredBorder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_Menu.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_MenuItem.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_MenuSeparator.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_MessageBox.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_MiniApp.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_MouseCode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_Panel.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_Point.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_PopupMenu.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_ProgressBar.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_RadioButton.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_RaisedBorder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_RepaintSignal.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_Scheme.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_ScrollBar.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_ScrollPanel.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_Slider.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_StackLayout.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_String.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_Surface.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_SurfaceBase.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_SurfaceGL.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_TablePanel.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_TabPanel.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_TaskBar.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_TextEntry.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_TextGrid.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_TextImage.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_TextPanel.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_TickSignal.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_ToggleButton.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_TreeFolder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\VGUI_WizardPanel.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
|
@ -1,332 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_App.h>
|
||||
#include<VGUI_SurfaceBase.h>
|
||||
#include"vgui_win32.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
void App::platTick()
|
||||
{
|
||||
::MSG msg;
|
||||
while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
|
||||
{
|
||||
BOOL ret = ::GetMessage(&msg, NULL, 0, 0);
|
||||
if (ret == 0)
|
||||
break;
|
||||
|
||||
if (ret == -1)
|
||||
{
|
||||
stop();
|
||||
break;
|
||||
}
|
||||
|
||||
::DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
|
||||
void App::setCursorPos(int x,int y)
|
||||
{
|
||||
}
|
||||
|
||||
void App::getCursorPos(int& x,int& y)
|
||||
{
|
||||
}
|
||||
|
||||
void App::internalSetMouseArena(int x0,int y0,int x1,int y1,bool enabled)
|
||||
{
|
||||
RECT rc;
|
||||
rc.left = x0;
|
||||
rc.top = y0;
|
||||
rc.bottom = y1;
|
||||
rc.right = x1;
|
||||
ClipCursor(enabled?&rc:NULL);
|
||||
}
|
||||
|
||||
long App::getTimeMillis()
|
||||
{
|
||||
return GetTickCount();
|
||||
}
|
||||
|
||||
void App::setClipboardText(const char* text,int textLen)
|
||||
{
|
||||
if (!text)
|
||||
return;
|
||||
|
||||
if (textLen <= 0)
|
||||
return;
|
||||
|
||||
if (!OpenClipboard(NULL))
|
||||
return;
|
||||
|
||||
EmptyClipboard();
|
||||
|
||||
HANDLE hmem = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, textLen + 1);
|
||||
if (hmem)
|
||||
{
|
||||
void *ptr = GlobalLock(hmem);
|
||||
if (ptr != null)
|
||||
{
|
||||
memset(ptr, 0, textLen + 1);
|
||||
memcpy(ptr, text, textLen);
|
||||
GlobalUnlock(hmem);
|
||||
|
||||
SetClipboardData(CF_TEXT, hmem);
|
||||
}
|
||||
}
|
||||
|
||||
CloseClipboard();
|
||||
}
|
||||
|
||||
int App::getClipboardTextCount()
|
||||
{
|
||||
int count = 0;
|
||||
if (!OpenClipboard(NULL))
|
||||
return 0;
|
||||
|
||||
HANDLE hmem = GetClipboardData(CF_TEXT);
|
||||
if (hmem)
|
||||
{
|
||||
count = GlobalSize(hmem);
|
||||
}
|
||||
|
||||
CloseClipboard();
|
||||
return count;
|
||||
}
|
||||
|
||||
int App::getClipboardText(int offset,char* buf,int bufLen)
|
||||
{
|
||||
if (!buf)
|
||||
return 0;
|
||||
|
||||
if (bufLen <= 0)
|
||||
return 0;
|
||||
|
||||
int count = 0;
|
||||
if (!OpenClipboard(NULL))
|
||||
return 0;
|
||||
|
||||
HANDLE hmem = GetClipboardData(CF_UNICODETEXT);
|
||||
if (hmem)
|
||||
{
|
||||
int len = GlobalSize(hmem);
|
||||
count = len - offset;
|
||||
if (count <= 0)
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bufLen < count)
|
||||
{
|
||||
count = bufLen;
|
||||
}
|
||||
void *ptr = GlobalLock(hmem);
|
||||
if (ptr)
|
||||
{
|
||||
memcpy(buf, ((char *)ptr) + offset, count);
|
||||
GlobalUnlock(hmem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CloseClipboard();
|
||||
return count;
|
||||
}
|
||||
|
||||
static bool staticSplitRegistryKey(const char *key, char *key0, int key0Len, char *key1, int key1Len)
|
||||
{
|
||||
if(key==null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int len=strlen(key);
|
||||
if(len<=0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int state=0;
|
||||
int Start=-1;
|
||||
for(int i=len-1;i>=0;i--)
|
||||
{
|
||||
if(key[i]=='\\')
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Start=i;
|
||||
}
|
||||
}
|
||||
|
||||
if(Start==-1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
vgui_strcpy(key0,Start+1,key);
|
||||
vgui_strcpy(key1,(len-Start)+1,key+Start);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool App::setRegistryString(const char* key,const char* value)
|
||||
{
|
||||
HKEY hKey;
|
||||
|
||||
HKEY hSlot = HKEY_CURRENT_USER;
|
||||
if (!strncmp(key, "HKEY_LOCAL_MACHINE", 18))
|
||||
{
|
||||
hSlot = HKEY_LOCAL_MACHINE;
|
||||
key += 19;
|
||||
}
|
||||
else if (!strncmp(key, "HKEY_CURRENT_USER", 17))
|
||||
{
|
||||
hSlot = HKEY_CURRENT_USER;
|
||||
key += 18;
|
||||
}
|
||||
|
||||
char key0[256],key1[256];
|
||||
if(!staticSplitRegistryKey(key,key0,256,key1,256))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(RegCreateKeyEx(hSlot,key0,null,null,REG_OPTION_NON_VOLATILE,KEY_WRITE,null,&hKey,null)!=ERROR_SUCCESS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(RegSetValueEx(hKey,key1,null,REG_SZ,(uchar*)value,strlen(value)+1)==ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return true;
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool App::getRegistryString(const char* key,char* value,int valueLen)
|
||||
{
|
||||
HKEY hKey;
|
||||
|
||||
HKEY hSlot = HKEY_CURRENT_USER;
|
||||
if (!strncmp(key, "HKEY_LOCAL_MACHINE", 18))
|
||||
{
|
||||
hSlot = HKEY_LOCAL_MACHINE;
|
||||
key += 19;
|
||||
}
|
||||
else if (!strncmp(key, "HKEY_CURRENT_USER", 17))
|
||||
{
|
||||
hSlot = HKEY_CURRENT_USER;
|
||||
key += 18;
|
||||
}
|
||||
|
||||
char key0[256],key1[256];
|
||||
if(!staticSplitRegistryKey(key,key0,256,key1,256))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(RegOpenKeyEx(hSlot,key0,null,KEY_READ,&hKey)!=ERROR_SUCCESS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ulong len=valueLen;
|
||||
if(RegQueryValueEx(hKey,key1,null,null,(uchar*)value,&len)==ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return true;
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool App::setRegistryInteger(const char* key,int value)
|
||||
{
|
||||
HKEY hKey;
|
||||
HKEY hSlot = HKEY_CURRENT_USER;
|
||||
if (!strncmp(key, "HKEY_LOCAL_MACHINE", 18))
|
||||
{
|
||||
hSlot = HKEY_LOCAL_MACHINE;
|
||||
key += 19;
|
||||
}
|
||||
else if (!strncmp(key, "HKEY_CURRENT_USER", 17))
|
||||
{
|
||||
hSlot = HKEY_CURRENT_USER;
|
||||
key += 18;
|
||||
}
|
||||
|
||||
char key0[256],key1[256];
|
||||
if(!staticSplitRegistryKey(key,key0,256,key1,256))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(RegCreateKeyEx(hSlot,key0,null,null,REG_OPTION_NON_VOLATILE,KEY_WRITE,null,&hKey,null)!=ERROR_SUCCESS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(RegSetValueEx(hKey,key1,null,REG_DWORD,(uchar*)&value,4)==ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return true;
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool App::getRegistryInteger(const char* key,int& value)
|
||||
{
|
||||
HKEY hKey;
|
||||
HKEY hSlot = HKEY_CURRENT_USER;
|
||||
if (!strncmp(key, "HKEY_LOCAL_MACHINE", 18))
|
||||
{
|
||||
hSlot = HKEY_LOCAL_MACHINE;
|
||||
key += 19;
|
||||
}
|
||||
else if (!strncmp(key, "HKEY_CURRENT_USER", 17))
|
||||
{
|
||||
hSlot = HKEY_CURRENT_USER;
|
||||
key += 18;
|
||||
}
|
||||
|
||||
char key0[256],key1[256];
|
||||
if(!staticSplitRegistryKey(key,key0,256,key1,256))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(RegOpenKeyEx(hSlot,key0,null,KEY_READ,&hKey)!=ERROR_SUCCESS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ulong len=4;
|
||||
if(RegQueryValueEx(hKey,key1,null,null,(uchar*)&value,&len)==ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return true;
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
return false;
|
||||
}
|
||||
|
||||
App* App::getInstance()
|
||||
{
|
||||
return _instance;
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_Cursor.h>
|
||||
#include<VGUI_Bitmap.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
class CursorBitmap : public Bitmap
|
||||
{
|
||||
private:
|
||||
int _hotspot[2];
|
||||
public:
|
||||
CursorBitmap(Cursor::DefaultCursor dc)
|
||||
{
|
||||
_hotspot[0]=8;
|
||||
_hotspot[1]=8;
|
||||
|
||||
if(dc!=Cursor::dc_none)
|
||||
{
|
||||
int wide=16;
|
||||
int tall=16;
|
||||
setSize(wide,tall);
|
||||
|
||||
int i,j;
|
||||
for(j=0;j<16;j++)
|
||||
{
|
||||
for(i=0;i<16;i++)
|
||||
{
|
||||
setRGBA(i,j,0,0,0,0);
|
||||
}
|
||||
}
|
||||
for(i=0;i<16;i++)
|
||||
{
|
||||
setRGBA(i,8,0,255,0,255);
|
||||
}
|
||||
for(i=0;i<16;i++)
|
||||
{
|
||||
setRGBA(8,i,0,0,255,255);
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void getHotspot(int& x,int& y)
|
||||
{
|
||||
x=_hotspot[0];
|
||||
y=_hotspot[1];
|
||||
}
|
||||
};
|
||||
|
||||
Cursor::Cursor(Cursor::DefaultCursor dc)
|
||||
{
|
||||
_dc=dc;
|
||||
CursorBitmap *cursorBitmap=new CursorBitmap(_dc);
|
||||
|
||||
int hx,hy;
|
||||
cursorBitmap->getHotspot(hx,hy);
|
||||
privateInit(_bitmap,hx,hy);
|
||||
}
|
|
@ -1,345 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<VGUI_Font.h>
|
||||
#include<VGUI_Dar.h>
|
||||
#include"vgui_win32.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
static int staticFontId=100;
|
||||
static Dar<BaseFontPlat*> staticFontPlatDar;
|
||||
|
||||
FontPlat::FontPlat(const char* name,int tall,int wide,float rotation,int weight,bool italic,bool underline,bool strikeout,bool symbol)
|
||||
{
|
||||
m_szName = strdup(name);
|
||||
m_iTall = tall;
|
||||
m_iWide = wide;
|
||||
m_flRotation = rotation;
|
||||
m_iWeight = weight;
|
||||
m_bItalic = italic;
|
||||
m_bUnderline = underline;
|
||||
m_bStrikeOut = strikeout;
|
||||
m_bSymbol = symbol;
|
||||
|
||||
int charset = symbol ? SYMBOL_CHARSET : ANSI_CHARSET;
|
||||
m_hFont = ::CreateFontA(tall, wide, (int)(rotation*10), (int)(rotation*10),
|
||||
weight,
|
||||
italic,
|
||||
underline,
|
||||
strikeout,
|
||||
charset,
|
||||
OUT_DEFAULT_PRECIS,
|
||||
CLIP_DEFAULT_PRECIS,
|
||||
DEFAULT_QUALITY,
|
||||
DEFAULT_PITCH,
|
||||
m_szName);
|
||||
|
||||
m_hDC = ::CreateCompatibleDC(NULL);
|
||||
|
||||
// set as the active font
|
||||
::SelectObject(m_hDC, m_hFont);
|
||||
::SetTextAlign(m_hDC, TA_LEFT | TA_TOP | TA_UPDATECP);
|
||||
|
||||
// get info about the font
|
||||
GetTextMetrics(m_hDC, &tm);
|
||||
|
||||
// code for rendering to a bitmap
|
||||
bufSize[0] = tm.tmMaxCharWidth;
|
||||
bufSize[1] = tm.tmHeight + tm.tmAscent + tm.tmDescent;
|
||||
|
||||
::BITMAPINFOHEADER header;
|
||||
memset(&header, 0, sizeof(header));
|
||||
header.biSize = sizeof(header);
|
||||
header.biWidth = bufSize[0];
|
||||
header.biHeight = -bufSize[1];
|
||||
header.biPlanes = 1;
|
||||
header.biBitCount = 32;
|
||||
header.biCompression = BI_RGB;
|
||||
|
||||
m_hDIB = ::CreateDIBSection(m_hDC, (BITMAPINFO*)&header, DIB_RGB_COLORS, (void**)(&buf), NULL, 0);
|
||||
::SelectObject(m_hDC, m_hDIB);
|
||||
|
||||
// get char spacing
|
||||
// a is space before character (can be negative)
|
||||
// b is the width of the character
|
||||
// c is the space after the character
|
||||
memset(m_ABCWidthsCache, 0, sizeof(m_ABCWidthsCache));
|
||||
if (!::GetCharABCWidthsA(m_hDC, 0, ABCWIDTHS_CACHE_SIZE - 1, m_ABCWidthsCache))
|
||||
{
|
||||
// since that failed, it must be fixed width, zero everything so a and c will be zeros, then
|
||||
// fill b with the value from TEXTMETRIC
|
||||
for (int i = 0; i < ABCWIDTHS_CACHE_SIZE; i++)
|
||||
{
|
||||
m_ABCWidthsCache[i].abcB = (char)tm.tmAveCharWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FontPlat::~FontPlat()
|
||||
{
|
||||
}
|
||||
|
||||
bool FontPlat::equals(const char* name,int tall,int wide,float rotation,int weight,bool italic,bool underline,bool strikeout,bool symbol)
|
||||
{
|
||||
if (!stricmp(name, m_szName)
|
||||
&& m_iTall == tall
|
||||
&& m_iWide == wide
|
||||
&& m_flRotation == rotation
|
||||
&& m_iWeight == weight
|
||||
&& m_bItalic == italic
|
||||
&& m_bUnderline == underline
|
||||
&& m_bStrikeOut == strikeout
|
||||
&& m_bSymbol == symbol)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void FontPlat::getCharRGBA(int ch,int rgbaX,int rgbaY,int rgbaWide,int rgbaTall,uchar* rgba)
|
||||
{
|
||||
// set us up to render into our dib
|
||||
::SelectObject(m_hDC, m_hFont);
|
||||
|
||||
// use render-to-bitmap to get our font texture
|
||||
::SetBkColor(m_hDC, RGB(0, 0, 0));
|
||||
::SetTextColor(m_hDC, RGB(255, 255, 255));
|
||||
::SetBkMode(m_hDC, OPAQUE);
|
||||
::MoveToEx(m_hDC, -m_ABCWidthsCache[ch].abcA, 0, NULL);
|
||||
|
||||
// render the character
|
||||
char wch = (char)ch;
|
||||
::ExtTextOutA(m_hDC, 0, 0, 0, NULL, &wch, 1, NULL);
|
||||
::SetBkMode(m_hDC, TRANSPARENT);
|
||||
|
||||
int wide = m_ABCWidthsCache[ch].abcB;
|
||||
if (wide > bufSize[0])
|
||||
{
|
||||
wide = bufSize[0];
|
||||
}
|
||||
int tall = tm.tmHeight;
|
||||
if (tall > bufSize[1])
|
||||
{
|
||||
tall = bufSize[1];
|
||||
}
|
||||
|
||||
// iterate through copying the generated dib into the texture
|
||||
for (int j = 0; j < tall; j++)
|
||||
{
|
||||
for (int i = 0; i < wide; i++)
|
||||
{
|
||||
int x = rgbaX + i;
|
||||
int y = rgbaY + j;
|
||||
if ((x < rgbaWide) && (y < rgbaTall))
|
||||
{
|
||||
unsigned char *src = &buf[(j*bufSize[0]+i)*4];
|
||||
|
||||
float r = (src[0]) / 255.0f;
|
||||
float g = (src[1]) / 255.0f;
|
||||
float b = (src[2]) / 255.0f;
|
||||
|
||||
// Don't want anything drawn for tab characters.
|
||||
if (ch == '\t')
|
||||
{
|
||||
r = g = b = 0;
|
||||
}
|
||||
|
||||
unsigned char *dst = &rgba[(y*rgbaWide+x)*4];
|
||||
dst[0] = (unsigned char)(r * 255.0f);
|
||||
dst[1] = (unsigned char)(g * 255.0f);
|
||||
dst[2] = (unsigned char)(b * 255.0f);
|
||||
dst[3] = (unsigned char)((r * 0.34f + g * 0.55f + b * 0.11f) * 255.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FontPlat::getCharABCwide(int ch,int& a,int& b,int& c)
|
||||
{
|
||||
a = m_ABCWidthsCache[ch].abcA;
|
||||
b = m_ABCWidthsCache[ch].abcB;
|
||||
c = m_ABCWidthsCache[ch].abcC;
|
||||
|
||||
if (a < 0)
|
||||
{
|
||||
a = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int FontPlat::getTall()
|
||||
{
|
||||
return tm.tmHeight;
|
||||
}
|
||||
|
||||
void FontPlat::drawSetTextFont(SurfacePlat* plat)
|
||||
{
|
||||
::SelectObject(plat->hdc, m_hFont);
|
||||
}
|
||||
|
||||
FontPlat_Bitmap::FontPlat_Bitmap()
|
||||
{
|
||||
m_pName=null;
|
||||
}
|
||||
|
||||
FontPlat_Bitmap::~FontPlat_Bitmap()
|
||||
{
|
||||
}
|
||||
|
||||
FontPlat_Bitmap* FontPlat_Bitmap::Create(const char* name, FileImageStream* pStream)
|
||||
{
|
||||
FontPlat_Bitmap* pBitmap=new FontPlat_Bitmap();
|
||||
if(pBitmap==null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if(!LoadVFontDataFrom32BitTGA(pStream,&pBitmap->m_FontData))
|
||||
{
|
||||
delete pBitmap;
|
||||
return null;
|
||||
}
|
||||
|
||||
pBitmap->m_pName=new char[strlen(name)+1];
|
||||
if(pBitmap->m_pName==null)
|
||||
{
|
||||
delete pBitmap;
|
||||
return null;
|
||||
}
|
||||
|
||||
strcpy(pBitmap->m_pName,name);
|
||||
return pBitmap;
|
||||
}
|
||||
|
||||
bool FontPlat_Bitmap::equals(const char* name,int tall,int wide,float rotation,int weight,bool italic,bool underline,bool strikeout,bool symbol)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void FontPlat_Bitmap::getCharRGBA(int ch,int rgbaX,int rgbaY,int rgbaWide,int rgbaTall,uchar* rgba)
|
||||
{
|
||||
uchar* pSrcPos;
|
||||
uchar* pOutPos;
|
||||
int x,y,outX,outY;
|
||||
|
||||
if(ch<0)
|
||||
ch=0;
|
||||
else if(ch>=256)
|
||||
ch=256;
|
||||
|
||||
for(y=0;y<m_FontData.m_BitmapCharHeight;y++)
|
||||
{
|
||||
pSrcPos=&m_FontData.m_pBitmap[m_FontData.m_BitmapCharWidth*(ch+y*256)];
|
||||
for(x=0;x<m_FontData.m_BitmapCharWidth;x++)
|
||||
{
|
||||
outX=rgbaX+x;
|
||||
outY=rgbaY+y;
|
||||
if ((outX<rgbaWide)&&(outY<rgbaTall))
|
||||
{
|
||||
pOutPos=&rgba[(outY*rgbaWide+outX)*4];
|
||||
if(pSrcPos[x]!=0)
|
||||
{
|
||||
pOutPos[0]=pOutPos[1]=pOutPos[2]=pOutPos[3]=255;
|
||||
}
|
||||
else
|
||||
{
|
||||
pOutPos[0]=pOutPos[1]=pOutPos[2]=pOutPos[3]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FontPlat_Bitmap::getCharABCwide(int ch,int& a,int& b,int& c)
|
||||
{
|
||||
if(ch<0)
|
||||
ch=0;
|
||||
else if(ch>255)
|
||||
ch=255;
|
||||
|
||||
a=c=0;
|
||||
b=m_FontData.m_CharWidths[ch]+1;
|
||||
}
|
||||
|
||||
int FontPlat_Bitmap::getTall()
|
||||
{
|
||||
return m_FontData.m_BitmapCharHeight;
|
||||
}
|
||||
|
||||
void FontPlat_Bitmap::drawSetTextFont(SurfacePlat* plat)
|
||||
{
|
||||
}
|
||||
|
||||
Font::Font(const char* name,int tall,int wide,float rotation,int weight,bool italic,bool underline,bool strikeout,bool symbol)
|
||||
{
|
||||
init(name,null,0,wide,tall,rotation,weight,italic,underline,strikeout,symbol);
|
||||
}
|
||||
|
||||
Font::Font(const char* name,void *pFileData,int fileDataLen, int tall,int wide,float rotation,int weight,bool italic,bool underline,bool strikeout,bool symbol)
|
||||
{
|
||||
init(name,pFileData,fileDataLen,wide,tall,rotation,weight,italic,underline,strikeout,symbol);
|
||||
}
|
||||
|
||||
void Font::init(const char* name,void *pFileData,int fileDataLen, int tall,int wide,float rotation,int weight,bool italic,bool underline,bool strikeout,bool symbol)
|
||||
{
|
||||
FontPlat_Bitmap*pBitmapFont=null;
|
||||
|
||||
_name=strdup(name);
|
||||
_id=-1;
|
||||
|
||||
if(pFileData!=null)
|
||||
{
|
||||
FileImageStream_Memory memStream(pFileData,fileDataLen);
|
||||
pBitmapFont=FontPlat_Bitmap::Create(name,&memStream);
|
||||
if(pBitmapFont!=null)
|
||||
{
|
||||
_plat=pBitmapFont;
|
||||
staticFontPlatDar.addElement(_plat);
|
||||
_id=staticFontId++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_plat=null;
|
||||
for(int i=0;i<staticFontPlatDar.getCount();i++)
|
||||
{
|
||||
if(staticFontPlatDar[i]->equals(name,tall,wide,rotation,weight,italic,underline,strikeout,symbol))
|
||||
{
|
||||
_plat=staticFontPlatDar[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(_plat==null)
|
||||
{
|
||||
_plat=new FontPlat(name,tall,wide,rotation,weight,italic,underline,strikeout,symbol);
|
||||
staticFontPlatDar.addElement(_plat);
|
||||
_id=staticFontId++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Font::getCharRGBA(int ch,int rgbaX,int rgbaY,int rgbaWide,int rgbaTall,uchar* rgba)
|
||||
{
|
||||
_plat->getCharRGBA(ch,rgbaX,rgbaY,rgbaWide,rgbaTall,rgba);
|
||||
}
|
||||
|
||||
void Font::getCharABCwide(int ch,int& a,int& b,int& c)
|
||||
{
|
||||
_plat->getCharABCwide(ch,a,b,c);
|
||||
}
|
||||
|
||||
int Font::getTall()
|
||||
{
|
||||
return _plat->getTall();
|
||||
}
|
||||
|
||||
namespace vgui
|
||||
{
|
||||
void Font_Reset()
|
||||
{
|
||||
staticFontPlatDar.removeAll();
|
||||
}
|
||||
}
|
|
@ -1,769 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<assert.h>
|
||||
#include<stdio.h>
|
||||
#include<VGUI_Surface.h>
|
||||
#include<VGUI_Cursor.h>
|
||||
#include<VGUI_KeyCode.h>
|
||||
#include<VGUI_Panel.h>
|
||||
#include<VGUI_App.h>
|
||||
#include<VGUI_ImagePanel.h>
|
||||
#include<VGUI_Bitmap.h>
|
||||
#include<VGUI_Font.h>
|
||||
#include"vgui_win32.h"
|
||||
#include<zmouse.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
class Texture
|
||||
{
|
||||
public:
|
||||
int _id;
|
||||
HBITMAP _bitmap;
|
||||
int _wide;
|
||||
int _tall;
|
||||
void *_dib;
|
||||
};
|
||||
|
||||
#define MAXTEXTURECOUNT 128
|
||||
static int staticTextureCount = 0;
|
||||
static Texture staticTexture[MAXTEXTURECOUNT];
|
||||
static Texture *staticTextureCurrent = NULL;
|
||||
|
||||
static Texture *staticGetTextureById(int id)
|
||||
{
|
||||
if(staticTextureCurrent!=null)
|
||||
{
|
||||
if(staticTextureCurrent->_id==id)
|
||||
{
|
||||
return staticTextureCurrent;
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0;i<staticTextureCount;i++)
|
||||
{
|
||||
if(staticTexture[i]._id==id)
|
||||
{
|
||||
return &staticTexture[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static KeyCode s_pVirtualKeyToKeyCode[256];
|
||||
static HICON staticDefaultCursor[20];
|
||||
static HICON staticCurrentCursor = NULL;
|
||||
static WNDCLASS staticWndclass = { NULL };
|
||||
static ATOM staticWndclassAtom = 0;
|
||||
|
||||
// these functions defined below
|
||||
LRESULT CALLBACK staticProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
|
||||
|
||||
bool Surface::createPlat()
|
||||
{
|
||||
//load up all default cursors, this gets called everytime a Surface is created, but
|
||||
//who cares
|
||||
staticDefaultCursor[Cursor::dc_none] =null;
|
||||
staticDefaultCursor[Cursor::dc_arrow] =(HICON)LoadCursor(null,(LPCTSTR)OCR_NORMAL);
|
||||
staticDefaultCursor[Cursor::dc_ibeam] =(HICON)LoadCursor(null,(LPCTSTR)OCR_IBEAM);
|
||||
staticDefaultCursor[Cursor::dc_hourglass]=(HICON)LoadCursor(null,(LPCTSTR)OCR_WAIT);
|
||||
staticDefaultCursor[Cursor::dc_crosshair]=(HICON)LoadCursor(null,(LPCTSTR)OCR_CROSS);
|
||||
staticDefaultCursor[Cursor::dc_up] =(HICON)LoadCursor(null,(LPCTSTR)OCR_UP);
|
||||
staticDefaultCursor[Cursor::dc_sizenwse] =(HICON)LoadCursor(null,(LPCTSTR)OCR_SIZENWSE);
|
||||
staticDefaultCursor[Cursor::dc_sizenesw] =(HICON)LoadCursor(null,(LPCTSTR)OCR_SIZENESW);
|
||||
staticDefaultCursor[Cursor::dc_sizewe] =(HICON)LoadCursor(null,(LPCTSTR)OCR_SIZEWE);
|
||||
staticDefaultCursor[Cursor::dc_sizens] =(HICON)LoadCursor(null,(LPCTSTR)OCR_SIZENS);
|
||||
staticDefaultCursor[Cursor::dc_sizeall] =(HICON)LoadCursor(null,(LPCTSTR)OCR_SIZEALL);
|
||||
staticDefaultCursor[Cursor::dc_no] =(HICON)LoadCursor(null,(LPCTSTR)OCR_NO);
|
||||
staticDefaultCursor[Cursor::dc_hand] =(HICON)LoadCursor(null,(LPCTSTR)32649);
|
||||
|
||||
s_pVirtualKeyToKeyCode['0'] =vgui::KEY_0;
|
||||
s_pVirtualKeyToKeyCode['1'] =vgui::KEY_1;
|
||||
s_pVirtualKeyToKeyCode['2'] =vgui::KEY_2;
|
||||
s_pVirtualKeyToKeyCode['3'] =vgui::KEY_3;
|
||||
s_pVirtualKeyToKeyCode['4'] =vgui::KEY_4;
|
||||
s_pVirtualKeyToKeyCode['5'] =vgui::KEY_5;
|
||||
s_pVirtualKeyToKeyCode['6'] =vgui::KEY_6;
|
||||
s_pVirtualKeyToKeyCode['7'] =vgui::KEY_7;
|
||||
s_pVirtualKeyToKeyCode['8'] =vgui::KEY_8;
|
||||
s_pVirtualKeyToKeyCode['9'] =vgui::KEY_9;
|
||||
s_pVirtualKeyToKeyCode['A'] =vgui::KEY_A;
|
||||
s_pVirtualKeyToKeyCode['B'] =vgui::KEY_B;
|
||||
s_pVirtualKeyToKeyCode['C'] =vgui::KEY_C;
|
||||
s_pVirtualKeyToKeyCode['D'] =vgui::KEY_D;
|
||||
s_pVirtualKeyToKeyCode['E'] =vgui::KEY_E;
|
||||
s_pVirtualKeyToKeyCode['F'] =vgui::KEY_F;
|
||||
s_pVirtualKeyToKeyCode['G'] =vgui::KEY_G;
|
||||
s_pVirtualKeyToKeyCode['H'] =vgui::KEY_H;
|
||||
s_pVirtualKeyToKeyCode['I'] =vgui::KEY_I;
|
||||
s_pVirtualKeyToKeyCode['J'] =vgui::KEY_J;
|
||||
s_pVirtualKeyToKeyCode['K'] =vgui::KEY_K;
|
||||
s_pVirtualKeyToKeyCode['L'] =vgui::KEY_L;
|
||||
s_pVirtualKeyToKeyCode['M'] =vgui::KEY_M;
|
||||
s_pVirtualKeyToKeyCode['N'] =vgui::KEY_N;
|
||||
s_pVirtualKeyToKeyCode['O'] =vgui::KEY_O;
|
||||
s_pVirtualKeyToKeyCode['P'] =vgui::KEY_P;
|
||||
s_pVirtualKeyToKeyCode['Q'] =vgui::KEY_Q;
|
||||
s_pVirtualKeyToKeyCode['R'] =vgui::KEY_R;
|
||||
s_pVirtualKeyToKeyCode['S'] =vgui::KEY_S;
|
||||
s_pVirtualKeyToKeyCode['T'] =vgui::KEY_T;
|
||||
s_pVirtualKeyToKeyCode['U'] =vgui::KEY_U;
|
||||
s_pVirtualKeyToKeyCode['V'] =vgui::KEY_V;
|
||||
s_pVirtualKeyToKeyCode['W'] =vgui::KEY_W;
|
||||
s_pVirtualKeyToKeyCode['X'] =vgui::KEY_X;
|
||||
s_pVirtualKeyToKeyCode['Y'] =vgui::KEY_Y;
|
||||
s_pVirtualKeyToKeyCode['Z'] =vgui::KEY_Z;
|
||||
s_pVirtualKeyToKeyCode[VK_NUMPAD0] =vgui::KEY_PAD_0;
|
||||
s_pVirtualKeyToKeyCode[VK_NUMPAD1] =vgui::KEY_PAD_1;
|
||||
s_pVirtualKeyToKeyCode[VK_NUMPAD2] =vgui::KEY_PAD_2;
|
||||
s_pVirtualKeyToKeyCode[VK_NUMPAD3] =vgui::KEY_PAD_3;
|
||||
s_pVirtualKeyToKeyCode[VK_NUMPAD4] =vgui::KEY_PAD_4;
|
||||
s_pVirtualKeyToKeyCode[VK_NUMPAD5] =vgui::KEY_PAD_5;
|
||||
s_pVirtualKeyToKeyCode[VK_NUMPAD6] =vgui::KEY_PAD_6;
|
||||
s_pVirtualKeyToKeyCode[VK_NUMPAD7] =vgui::KEY_PAD_7;
|
||||
s_pVirtualKeyToKeyCode[VK_NUMPAD8] =vgui::KEY_PAD_8;
|
||||
s_pVirtualKeyToKeyCode[VK_NUMPAD9] =vgui::KEY_PAD_9;
|
||||
s_pVirtualKeyToKeyCode[VK_DIVIDE] =vgui::KEY_PAD_DIVIDE;
|
||||
s_pVirtualKeyToKeyCode[VK_MULTIPLY] =vgui::KEY_PAD_MULTIPLY;
|
||||
s_pVirtualKeyToKeyCode[VK_SUBTRACT] =vgui::KEY_PAD_MINUS;
|
||||
s_pVirtualKeyToKeyCode[VK_ADD] =vgui::KEY_PAD_PLUS;
|
||||
s_pVirtualKeyToKeyCode[VK_DECIMAL] =vgui::KEY_PAD_DECIMAL;
|
||||
s_pVirtualKeyToKeyCode[0xdb] =vgui::KEY_LBRACKET;
|
||||
s_pVirtualKeyToKeyCode[0xdd] =KEY_RBRACKET;
|
||||
s_pVirtualKeyToKeyCode[0xba] =KEY_SEMICOLON;
|
||||
s_pVirtualKeyToKeyCode[0xde] =KEY_APOSTROPHE;
|
||||
s_pVirtualKeyToKeyCode[0xc0] =KEY_BACKQUOTE;
|
||||
s_pVirtualKeyToKeyCode[0xbc] =KEY_COMMA;
|
||||
s_pVirtualKeyToKeyCode[0xbe] =KEY_PERIOD;
|
||||
s_pVirtualKeyToKeyCode[0xbf] =KEY_SLASH;
|
||||
s_pVirtualKeyToKeyCode[0xdc] =KEY_BACKSLASH;
|
||||
s_pVirtualKeyToKeyCode[0xbd] =KEY_MINUS;
|
||||
s_pVirtualKeyToKeyCode[0xbb] =KEY_EQUAL;
|
||||
s_pVirtualKeyToKeyCode[VK_RETURN] =vgui::KEY_ENTER;
|
||||
s_pVirtualKeyToKeyCode[VK_SPACE] =vgui::KEY_SPACE;
|
||||
s_pVirtualKeyToKeyCode[VK_BACK] =vgui::KEY_BACKSPACE;
|
||||
s_pVirtualKeyToKeyCode[VK_TAB] =vgui::KEY_TAB;
|
||||
s_pVirtualKeyToKeyCode[VK_CAPITAL] =vgui::KEY_CAPSLOCK;
|
||||
s_pVirtualKeyToKeyCode[VK_NUMLOCK] =vgui::KEY_NUMLOCK;
|
||||
s_pVirtualKeyToKeyCode[VK_ESCAPE] =vgui::KEY_ESCAPE;
|
||||
s_pVirtualKeyToKeyCode[VK_SCROLL] =vgui::KEY_SCROLLLOCK;
|
||||
s_pVirtualKeyToKeyCode[VK_INSERT] =vgui::KEY_INSERT;
|
||||
s_pVirtualKeyToKeyCode[VK_DELETE] =vgui::KEY_DELETE;
|
||||
s_pVirtualKeyToKeyCode[VK_HOME] =vgui::KEY_HOME;
|
||||
s_pVirtualKeyToKeyCode[VK_END] =vgui::KEY_END;
|
||||
s_pVirtualKeyToKeyCode[VK_PRIOR] =vgui::KEY_PAGEUP;
|
||||
s_pVirtualKeyToKeyCode[VK_NEXT] =vgui::KEY_PAGEDOWN;
|
||||
s_pVirtualKeyToKeyCode[VK_PAUSE] =KEY_BREAK;
|
||||
s_pVirtualKeyToKeyCode[VK_SHIFT] =KEY_RSHIFT;
|
||||
s_pVirtualKeyToKeyCode[VK_MENU] =KEY_RALT;
|
||||
s_pVirtualKeyToKeyCode[VK_CONTROL] =KEY_RCONTROL;
|
||||
s_pVirtualKeyToKeyCode[VK_LWIN] =KEY_LWIN;
|
||||
s_pVirtualKeyToKeyCode[VK_RWIN] =KEY_RWIN;
|
||||
s_pVirtualKeyToKeyCode[VK_APPS] =KEY_APP;
|
||||
s_pVirtualKeyToKeyCode[VK_UP] =KEY_UP;
|
||||
s_pVirtualKeyToKeyCode[VK_LEFT] =KEY_LEFT;
|
||||
s_pVirtualKeyToKeyCode[VK_DOWN] =KEY_DOWN;
|
||||
s_pVirtualKeyToKeyCode[VK_RIGHT] =KEY_RIGHT;
|
||||
s_pVirtualKeyToKeyCode[VK_F1] =KEY_F1;
|
||||
s_pVirtualKeyToKeyCode[VK_F2] =KEY_F2;
|
||||
s_pVirtualKeyToKeyCode[VK_F3] =KEY_F3;
|
||||
s_pVirtualKeyToKeyCode[VK_F4] =KEY_F4;
|
||||
s_pVirtualKeyToKeyCode[VK_F5] =KEY_F5;
|
||||
s_pVirtualKeyToKeyCode[VK_F6] =KEY_F6;
|
||||
s_pVirtualKeyToKeyCode[VK_F7] =KEY_F7;
|
||||
s_pVirtualKeyToKeyCode[VK_F8] =KEY_F8;
|
||||
s_pVirtualKeyToKeyCode[VK_F9] =KEY_F9;
|
||||
s_pVirtualKeyToKeyCode[VK_F10] =KEY_F10;
|
||||
s_pVirtualKeyToKeyCode[VK_F11] =KEY_F11;
|
||||
s_pVirtualKeyToKeyCode[VK_F12] =KEY_F12;
|
||||
|
||||
// make and register a very simple Window Class
|
||||
memset( &staticWndclass,0,sizeof(staticWndclass) );
|
||||
staticWndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
|
||||
staticWndclass.lpfnWndProc = staticProc;
|
||||
staticWndclass.hInstance = GetModuleHandle(NULL);
|
||||
staticWndclass.lpszClassName = "Surface";
|
||||
staticWndclassAtom = ::RegisterClass( &staticWndclass );
|
||||
|
||||
int x,y,wide,tall;
|
||||
getPanel()->getBounds(x,y,wide,tall);
|
||||
|
||||
//create the window and initialize platform specific data
|
||||
//window is initial a popup and not visible
|
||||
//when applyChanges is called the window will be shown unless
|
||||
//it setVisible(false) is called
|
||||
SurfacePlat *plat = new SurfacePlat();
|
||||
plat->hwnd = CreateWindowEx(0, "Surface", "", WS_POPUP, x, y, wide, tall, NULL, NULL, GetModuleHandle(NULL), NULL);
|
||||
plat->clipRgn = CreateRectRgn(0,0,64,64);
|
||||
plat->hdc = CreateCompatibleDC(NULL);
|
||||
plat->hwndDC = GetDC(_plat->hwnd);
|
||||
plat->bitmap = null;
|
||||
plat->bitmapSize[0] = 0;
|
||||
plat->bitmapSize[1] = 0;
|
||||
plat->isFullscreen = false;
|
||||
|
||||
::SetBkMode(plat->hdc, TRANSPARENT);
|
||||
::SetWindowLong(plat->hwnd, GWL_USERDATA, (LONG)this);
|
||||
::SetTextAlign(plat->hdc, TA_LEFT | TA_TOP | TA_UPDATECP);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK staticProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
|
||||
{
|
||||
LRESULT ret = TRUE;
|
||||
|
||||
Surface *surface = (Surface *)GetWindowLong(hwnd, GWL_USERDATA);
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case WM_SETFOCUS:
|
||||
{
|
||||
surface->getPanel()->requestFocus();
|
||||
break;
|
||||
}
|
||||
case WM_SETCURSOR:
|
||||
{
|
||||
SetCursor(staticCurrentCursor);
|
||||
break;
|
||||
}
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
POINT pt;
|
||||
pt.x = (short)LOWORD(lparam);
|
||||
pt.y = (short)HIWORD(lparam);
|
||||
surface->getApp()->internalCursorMoved(pt.x, pt.y, surface);
|
||||
break;
|
||||
}
|
||||
case WM_LBUTTONDOWN:
|
||||
{
|
||||
surface->getApp()->internalMousePressed(MOUSE_LEFT, surface);
|
||||
break;
|
||||
}
|
||||
case WM_RBUTTONDOWN:
|
||||
{
|
||||
surface->getApp()->internalMousePressed(MOUSE_RIGHT, surface);
|
||||
break;
|
||||
}
|
||||
case WM_MBUTTONDOWN:
|
||||
{
|
||||
surface->getApp()->internalMousePressed(MOUSE_MIDDLE, surface);
|
||||
break;
|
||||
}
|
||||
case WM_LBUTTONDBLCLK:
|
||||
{
|
||||
surface->getApp()->internalMouseDoublePressed(MOUSE_LEFT, surface);
|
||||
break;
|
||||
}
|
||||
case WM_RBUTTONDBLCLK:
|
||||
{
|
||||
surface->getApp()->internalMouseDoublePressed(MOUSE_RIGHT, surface);
|
||||
break;
|
||||
}
|
||||
case WM_MBUTTONDBLCLK:
|
||||
{
|
||||
surface->getApp()->internalMouseDoublePressed(MOUSE_MIDDLE, surface);
|
||||
break;
|
||||
}
|
||||
case WM_LBUTTONUP:
|
||||
{
|
||||
surface->getApp()->internalMouseReleased(MOUSE_LEFT, surface);
|
||||
break;
|
||||
}
|
||||
case WM_RBUTTONUP:
|
||||
{
|
||||
surface->getApp()->internalMouseReleased(MOUSE_RIGHT, surface);
|
||||
break;
|
||||
}
|
||||
case WM_MBUTTONUP:
|
||||
{
|
||||
surface->getApp()->internalMouseReleased(MOUSE_MIDDLE, surface);
|
||||
break;
|
||||
}
|
||||
case WM_MOUSEWHEEL:
|
||||
{
|
||||
surface->getApp()->internalMouseWheeled(((short)HIWORD(wparam))/WHEEL_DELTA, surface);
|
||||
break;
|
||||
}
|
||||
case WM_KEYDOWN:
|
||||
case WM_SYSKEYDOWN:
|
||||
{
|
||||
int code = wparam;
|
||||
if (!(lparam & (1<<30)))
|
||||
{
|
||||
surface->getApp()->internalKeyPressed(s_pVirtualKeyToKeyCode[code], surface);
|
||||
}
|
||||
surface->getApp()->internalKeyTyped(s_pVirtualKeyToKeyCode[code], surface);
|
||||
break;
|
||||
}
|
||||
case WM_KEYUP:
|
||||
case WM_SYSKEYUP:
|
||||
{
|
||||
int code=wparam;
|
||||
surface->getApp()->internalKeyReleased(s_pVirtualKeyToKeyCode[code], surface);
|
||||
break;
|
||||
}
|
||||
case WM_ERASEBKGND:
|
||||
{
|
||||
//since the vgui invalidate call does not erase the background
|
||||
//this will only be called when windows itselfs wants a repaint.
|
||||
//this is the desired behavior because this call will for the
|
||||
//surface and all its children to end up being repainted, which
|
||||
//is what you want when windows wants you to repaint the surface,
|
||||
//but not what you want when say a control wants to be painted
|
||||
//Panel::repaint will always invalidate the surface so it will
|
||||
//get a WM_PAINT, but that does not necessarily mean you want
|
||||
//the whole surface painted
|
||||
//simply this means.. this call only happens when windows wants the repaint
|
||||
//and WM_PAINT gets called just after this to do the real painting
|
||||
|
||||
surface->getPanel()->repaint();
|
||||
break;
|
||||
}
|
||||
case WM_PAINT:
|
||||
{
|
||||
//surface was by repainted vgui or by windows itself, do the repainting all repainting
|
||||
//will goes through here and nowhere else
|
||||
|
||||
PAINTSTRUCT ps;
|
||||
HDC hDC=::BeginPaint(hwnd,&ps);
|
||||
surface->getPanel()->solveTraverse();
|
||||
surface->getPanel()->paintTraverse();
|
||||
::EndPaint(hwnd,&ps);
|
||||
|
||||
//clear the update rectangle so it does not get another repaint
|
||||
::ValidateRect(hwnd, NULL);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
return DefWindowProc(hwnd,msg,wparam,lparam);
|
||||
}
|
||||
|
||||
bool Surface::recreateContext()
|
||||
{
|
||||
int wide,tall;
|
||||
getPanel()->getSize(wide,tall);
|
||||
|
||||
// rebuild bitmap only if necessary
|
||||
// simple scheme to prevent excessive allocations by allocating only when
|
||||
// bigger. It also adds in 100 extra for subsequent sizings
|
||||
// it will also realloc if the size is 200 smaller to shrink memory usage
|
||||
if ((wide > _plat->bitmapSize[0])
|
||||
|| (tall > _plat->bitmapSize[1])
|
||||
|| (wide < (_plat->bitmapSize[0] - 200))
|
||||
|| (tall < (_plat->bitmapSize[1] - 200)))
|
||||
{
|
||||
if (_plat->bitmap != null)
|
||||
{
|
||||
::DeleteObject(_plat->bitmap);
|
||||
}
|
||||
|
||||
_plat->hwndDC = GetDC(_plat->hwnd);
|
||||
|
||||
_plat->bitmap = ::CreateCompatibleBitmap(_plat->hwndDC, wide + 100, tall + 100);
|
||||
_plat->bitmapSize[0] = wide + 100;
|
||||
_plat->bitmapSize[1] = tall + 100;
|
||||
|
||||
::SelectObject(_plat->hdc, _plat->bitmap);
|
||||
_plat->textureDC = ::CreateCompatibleDC(_plat->hdc);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Surface::applyChanges()
|
||||
{
|
||||
RECT rect;
|
||||
int x, y, wide, tall, sx, sy, swide, stall;
|
||||
|
||||
// get how big the win32 window
|
||||
::GetWindowRect(_plat->hwnd, &rect);
|
||||
sx = rect.left;
|
||||
sy = rect.top;
|
||||
swide = rect.right-rect.left;
|
||||
stall = rect.bottom-rect.top;
|
||||
|
||||
// how big is the embedded Panel
|
||||
getPanel()->getBounds(x, y, wide, tall);
|
||||
|
||||
// if they are not the same, then adjust the win32 window so it is
|
||||
if ((x != sx) || (y != sy) || (wide != swide) || (tall != stall))
|
||||
{
|
||||
::SetWindowPos(_plat->hwnd, null, x, y, wide, tall, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS);
|
||||
}
|
||||
|
||||
// check to see if the win32 window is visible
|
||||
if (::GetWindowLong(_plat->hwnd, GWL_STYLE) & WS_VISIBLE)
|
||||
{
|
||||
//check to see if embedded Panel is not visible, if so then hide the win32 window
|
||||
if (getPanel()->isVisible())
|
||||
{
|
||||
::ShowWindow(_plat->hwnd, SW_HIDE);
|
||||
}
|
||||
}
|
||||
else // win32 window is hidden
|
||||
{
|
||||
//check to see if embedded Panel is visible, if so then show the win32 window
|
||||
if (getPanel()->isVisible())
|
||||
{
|
||||
::ShowWindow(_plat->hwnd, SW_SHOWNA);
|
||||
}
|
||||
}
|
||||
|
||||
//if the win32 window changed size and is visible, then the context needs to be recreated
|
||||
if (((wide != swide) || (tall != stall)) && getPanel()->isVisible())
|
||||
{
|
||||
recreateContext();
|
||||
}
|
||||
}
|
||||
|
||||
void Surface::swapBuffers()
|
||||
{
|
||||
int wide,tall;
|
||||
getPanel()->getSize(wide,tall);
|
||||
|
||||
// reset origin and clipping then blit
|
||||
::SetRectRgn(_plat->clipRgn, 0, 0, wide, tall);
|
||||
::SelectObject(_plat->hdc, _plat->clipRgn);
|
||||
::SetViewportOrgEx(_plat->hdc, 0, 0, NULL);
|
||||
::BitBlt(_plat->hwndDC, 0, 0, wide, tall, _plat->hdc, 0, 0, SRCCOPY);
|
||||
}
|
||||
|
||||
void Surface::drawSetColor(int r,int g,int b,int a)
|
||||
{
|
||||
SetBkColor(_plat->hdc,RGB(r,g,b));
|
||||
}
|
||||
|
||||
void Surface::drawFilledRect(int x0,int y0,int x1,int y1)
|
||||
{
|
||||
// trick to draw filled rectangles using current background color
|
||||
RECT rect = { x0, y0, x1, y1};
|
||||
BOOL res = ExtTextOut(_plat->hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
void Surface::drawOutlinedRect(int x0,int y0,int x1,int y1)
|
||||
{
|
||||
// draw an outline of a rectangle using 4 filledRect
|
||||
drawFilledRect(x0,y0,x1,y0+1); // top
|
||||
drawFilledRect(x0,y1-1,x1,y1); // bottom
|
||||
drawFilledRect(x0,y0+1,x0+1,y1-1); // left
|
||||
drawFilledRect(x1-1,y0+1,x1,y1-1); // right
|
||||
}
|
||||
|
||||
void Surface::drawSetTextColor(int r,int g,int b,int a)
|
||||
{
|
||||
SetTextColor(_plat->hdc,RGB(r,g,b));
|
||||
}
|
||||
|
||||
void Surface::drawPrintText(const char* text,int textLen)
|
||||
{
|
||||
assert(text);
|
||||
if (!text)
|
||||
return;
|
||||
|
||||
if (textLen < 1)
|
||||
return;
|
||||
|
||||
ExtTextOut(_plat->hdc, 0, 0, 0, NULL, text, textLen, NULL);
|
||||
}
|
||||
|
||||
int Surface::createNewTextureID(void)
|
||||
{
|
||||
//!! hack, arbitrary base
|
||||
static int staticBindIndex = 2700;
|
||||
return staticBindIndex++;
|
||||
}
|
||||
|
||||
HBITMAP staticCreateBitmapHandle(int wide, int tall, HDC hdc, int bpp, void **dib)
|
||||
{
|
||||
BITMAPINFOHEADER bitmapInfoHeader;
|
||||
memset(&bitmapInfoHeader, 0, sizeof(bitmapInfoHeader));
|
||||
bitmapInfoHeader.biSize = sizeof(bitmapInfoHeader);
|
||||
bitmapInfoHeader.biWidth = wide;
|
||||
bitmapInfoHeader.biHeight = -tall;
|
||||
bitmapInfoHeader.biPlanes = 1;
|
||||
bitmapInfoHeader.biBitCount = bpp;
|
||||
bitmapInfoHeader.biCompression = BI_RGB;
|
||||
|
||||
return ::CreateDIBSection(hdc, (BITMAPINFO*)&bitmapInfoHeader, DIB_RGB_COLORS, dib, null, 0);
|
||||
}
|
||||
|
||||
void Surface::drawSetTextureRGBA(int id,const char* rgba,int wide,int tall)
|
||||
{
|
||||
Texture *texture = staticGetTextureById(id);
|
||||
if (!texture)
|
||||
{
|
||||
if (staticTextureCount >= MAXTEXTURECOUNT)
|
||||
return;
|
||||
|
||||
// allocate a new texture
|
||||
texture = &staticTexture[staticTextureCount++];
|
||||
texture->_id = id;
|
||||
}
|
||||
|
||||
if (texture->_bitmap)
|
||||
{
|
||||
::DeleteObject(texture->_bitmap);
|
||||
}
|
||||
|
||||
{
|
||||
// no texture or forced load the new texture
|
||||
texture->_wide = wide;
|
||||
texture->_tall = tall;
|
||||
texture->_bitmap = staticCreateBitmapHandle(texture->_wide,
|
||||
texture->_tall, _plat->hdc, 32, &texture->_dib );
|
||||
|
||||
// copy over the texture data
|
||||
memcpy(texture->_dib,rgba,wide*tall*4);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Surface::drawSetTexture(int id)
|
||||
{
|
||||
staticTextureCurrent = staticGetTextureById(id);
|
||||
}
|
||||
|
||||
void Surface::drawTexturedRect(int x0,int y0,int x1,int y1)
|
||||
{
|
||||
if (staticTextureCurrent == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_plat->textureDC == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
HBITMAP bitmap = staticTextureCurrent->_bitmap;
|
||||
int wide = staticTextureCurrent->_wide;
|
||||
int tall = staticTextureCurrent->_tall;
|
||||
|
||||
::SelectObject(_plat->textureDC, bitmap);
|
||||
::StretchBlt(_plat->hdc,x0,y0,x1-x0,y1-y0,_plat->textureDC,0,0,wide,tall,SRCCOPY);
|
||||
}
|
||||
|
||||
void Surface::pushMakeCurrent(Panel* panel,bool useInsets)
|
||||
{
|
||||
int inset[4];
|
||||
|
||||
//!! need to make the inset part of Panel
|
||||
panel->getInset(inset[0],inset[1],inset[2],inset[3]);
|
||||
|
||||
if(!useInsets)
|
||||
{
|
||||
inset[0]=0;
|
||||
inset[1]=0;
|
||||
inset[2]=0;
|
||||
inset[3]=0;
|
||||
}
|
||||
|
||||
int absThis[4];
|
||||
getPanel()->getAbsExtents(absThis[0],absThis[1],absThis[2],absThis[3]);
|
||||
|
||||
int absPanel[4];
|
||||
panel->getAbsExtents(absPanel[0],absPanel[1],absPanel[2],absPanel[3]);
|
||||
|
||||
int clipRect[4];
|
||||
panel->getClipRect(clipRect[0],clipRect[1],clipRect[2],clipRect[3]);
|
||||
|
||||
if ( getPanel() == panel )
|
||||
{
|
||||
// this panel has it's own window, so use screen space
|
||||
::SetViewportOrgEx(_plat->hdc,0+inset[0],0+inset[1],null);
|
||||
}
|
||||
else
|
||||
{
|
||||
// child window, so set win32 up so all subsequent drawing calls are done in local space
|
||||
::SetViewportOrgEx(_plat->hdc,(absPanel[0]+inset[0])-absThis[0],(absPanel[1]+inset[1])-absThis[1],null);
|
||||
}
|
||||
|
||||
// setup clipping
|
||||
// get and translate clipRect into surface space, then factor in inset
|
||||
int x0 = clipRect[0] - absThis[0];
|
||||
int y0 = clipRect[1] - absThis[1];
|
||||
int x1 = clipRect[2] - absThis[0];
|
||||
int y1 = clipRect[3] - absThis[1];
|
||||
|
||||
//set the rect and select to make it current
|
||||
::SetRectRgn(_plat->clipRgn,x0,y0,x1,y1);
|
||||
::SelectObject(_plat->hdc, _plat->clipRgn);
|
||||
}
|
||||
|
||||
void Surface::popMakeCurrent(Panel* panel)
|
||||
{
|
||||
}
|
||||
|
||||
void Surface::enableMouseCapture(bool state)
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
HWND wnd = ::SetCapture(_plat->hwnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
::ReleaseCapture();
|
||||
}
|
||||
}
|
||||
|
||||
void Surface::setCursor(Cursor* cursor)
|
||||
{
|
||||
_currentCursor = cursor;
|
||||
|
||||
if (cursor != null)
|
||||
{
|
||||
_emulatedCursor->setImage(cursor->getBitmap());
|
||||
|
||||
switch (cursor->getDefaultCursor())
|
||||
{
|
||||
case Cursor::dc_none:
|
||||
case Cursor::dc_arrow:
|
||||
case Cursor::dc_ibeam:
|
||||
case Cursor::dc_hourglass:
|
||||
case Cursor::dc_crosshair:
|
||||
case Cursor::dc_up:
|
||||
case Cursor::dc_sizenwse:
|
||||
case Cursor::dc_sizenesw:
|
||||
case Cursor::dc_sizewe:
|
||||
case Cursor::dc_sizens:
|
||||
case Cursor::dc_sizeall:
|
||||
case Cursor::dc_no:
|
||||
case Cursor::dc_hand:
|
||||
{
|
||||
staticCurrentCursor = staticDefaultCursor[cursor->getDefaultCursor()];
|
||||
break;
|
||||
}
|
||||
case Cursor::dc_user:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
staticCurrentCursor = NULL;
|
||||
_emulatedCursor->setImage(null);
|
||||
}
|
||||
|
||||
::SetCursor(staticCurrentCursor);
|
||||
}
|
||||
|
||||
void Surface::invalidate(Panel *panel)
|
||||
{
|
||||
InvalidateRect(_plat->hwnd, NULL, false);
|
||||
}
|
||||
|
||||
void Surface::drawSetTextFont(Font* font)
|
||||
{
|
||||
assert(font);
|
||||
if (!font)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
font->getPlat()->drawSetTextFont(_plat);
|
||||
}
|
||||
|
||||
void Surface::setTitle(const char* title)
|
||||
{
|
||||
SetWindowTextA(_plat->hwnd, title);
|
||||
}
|
||||
|
||||
bool Surface::hasFocus()
|
||||
{
|
||||
return GetFocus() == _plat->hwnd;
|
||||
}
|
||||
|
||||
int Surface::getModeInfoCount()
|
||||
{
|
||||
resetModeInfo();
|
||||
addModeInfo(640,480,16);
|
||||
addModeInfo(800,600,16);
|
||||
return SurfaceBase::getModeInfoCount();
|
||||
}
|
||||
|
||||
bool Surface::setFullscreenMode(int wide,int tall,int bpp)
|
||||
{
|
||||
if (_plat->isFullscreen && _plat->fullscreenInfo[0] == wide && _plat->fullscreenInfo[1] == tall && _plat->fullscreenInfo[2] == bpp)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_modeInfoDar.getCount() == 0)
|
||||
{
|
||||
getModeInfoCount();
|
||||
}
|
||||
for (int i = 0; i < _modeInfoDar.getCount(); i++)
|
||||
{
|
||||
int modewide, modetall, modebpp;
|
||||
sscanf(_modeInfoDar[i], "%dx%dx%d", &modewide, &modetall, &modebpp);
|
||||
if (wide == modewide && tall == modetall && bpp == modebpp)
|
||||
{
|
||||
DEVMODE dm;
|
||||
memset(&dm, 0, sizeof(dm));
|
||||
|
||||
dm.dmSize = sizeof(dm);
|
||||
dm.dmPelsWidth = wide;
|
||||
dm.dmPelsHeight = tall;
|
||||
dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
|
||||
dm.dmBitsPerPel = bpp;
|
||||
|
||||
if (ChangeDisplaySettings(&dm, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL)
|
||||
{
|
||||
if (!_plat->isFullscreen)
|
||||
{
|
||||
getPanel()->getBounds(_plat->restoreInfo[0], _plat->restoreInfo[1], _plat->restoreInfo[2], _plat->restoreInfo[3]);
|
||||
SetWindowPos(_plat->hwnd,HWND_TOPMOST,-1,-1,-1,-1,SWP_NOMOVE|SWP_NOSIZE);
|
||||
}
|
||||
getPanel()->setBounds(0,0,wide,tall);
|
||||
applyChanges();
|
||||
_plat->isFullscreen = true;
|
||||
_plat->fullscreenInfo[0] = wide;
|
||||
_plat->fullscreenInfo[1] = tall;
|
||||
_plat->fullscreenInfo[2] = bpp;
|
||||
getPanel()->repaint();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Surface::setWindowedMode()
|
||||
{
|
||||
if (_plat->isFullscreen)
|
||||
{
|
||||
getPanel()->setBounds(_plat->restoreInfo[0], _plat->restoreInfo[1], _plat->restoreInfo[2], _plat->restoreInfo[3]);
|
||||
ChangeDisplaySettings(NULL, 0);
|
||||
applyChanges();
|
||||
_plat->isFullscreen = false;
|
||||
getPanel()->repaint();
|
||||
}
|
||||
}
|
||||
|
||||
void Surface::drawSetTextPos(int x,int y)
|
||||
{
|
||||
MoveToEx(_plat->hdc,x,y,null);
|
||||
}
|
||||
|
||||
void Surface::setAsTopMost(bool state)
|
||||
{
|
||||
if (state)
|
||||
SetWindowPos(_plat->hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
|
||||
else
|
||||
SetWindowPos(_plat->hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
|
||||
}
|
||||
|
||||
bool Surface::isWithin(int x,int y)
|
||||
{
|
||||
POINT pnt={x,y};
|
||||
return _plat->hwnd == WindowFromPoint(pnt);
|
||||
}
|
|
@ -1,208 +0,0 @@
|
|||
//========= Copyright ?1996-2003, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
||||
// The contents may be used and/or copied only with the written permission of
|
||||
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
||||
// the agreement/contract under which the contents have been supplied.
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include <string.h>
|
||||
#include "fileimage.h"
|
||||
|
||||
// TGA header.
|
||||
#pragma pack(1)
|
||||
class TGAFileHeader
|
||||
{
|
||||
public:
|
||||
unsigned char m_IDLength;
|
||||
unsigned char m_ColorMapType;
|
||||
unsigned char m_ImageType;
|
||||
unsigned short m_CMapStart;
|
||||
unsigned short m_CMapLength;
|
||||
unsigned char m_CMapDepth;
|
||||
unsigned short m_XOffset;
|
||||
unsigned short m_YOffset;
|
||||
unsigned short m_Width;
|
||||
unsigned short m_Height;
|
||||
unsigned char m_PixelDepth;
|
||||
unsigned char m_ImageDescriptor;
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------- //
|
||||
// FileImageStream_Memory.
|
||||
// ---------------------------------------------------------------------------------------- //
|
||||
FileImageStream_Memory::FileImageStream_Memory(void *pData, int dataLen)
|
||||
{
|
||||
m_pData = (unsigned char*)pData;
|
||||
m_DataLen = dataLen;
|
||||
m_CurPos = 0;
|
||||
m_bError = false;
|
||||
}
|
||||
|
||||
void FileImageStream_Memory::Read(void *pData, int len)
|
||||
{
|
||||
unsigned char *pOut;
|
||||
int i;
|
||||
|
||||
pOut = (unsigned char*)pData;
|
||||
for(i=0; i < len; i++)
|
||||
{
|
||||
if(m_CurPos < m_DataLen)
|
||||
{
|
||||
pOut[i] = m_pData[m_CurPos];
|
||||
++m_CurPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
pOut[i] = 0;
|
||||
m_bError = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool FileImageStream_Memory::ErrorStatus()
|
||||
{
|
||||
bool ret=m_bError;
|
||||
m_bError=false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------- //
|
||||
// Encode/decode functions.
|
||||
// ---------------------------------------------------------------------------------------- //
|
||||
static void WriteRun(unsigned char *pColor, FILE *fp, int runLength)
|
||||
{
|
||||
unsigned char runCount;
|
||||
|
||||
runCount = runLength - 1;
|
||||
runCount |= (1 << 7);
|
||||
fwrite( &runCount, 1, 1, fp );
|
||||
fwrite( pColor, 1, 4, fp );
|
||||
}
|
||||
|
||||
|
||||
// Load in a 32-bit TGA file.
|
||||
bool Load32BitTGA(
|
||||
FileImageStream *fp,
|
||||
FileImage *pImage)
|
||||
{
|
||||
TGAFileHeader hdr;
|
||||
char dummyChar;
|
||||
int i, x, y;
|
||||
long color;
|
||||
int runLength, curOut;
|
||||
unsigned char *pLine;
|
||||
unsigned char packetHeader;
|
||||
|
||||
|
||||
pImage->Term();
|
||||
|
||||
// Read and verify the header.
|
||||
fp->Read(&hdr, sizeof(hdr));
|
||||
if(hdr.m_PixelDepth != 32 || hdr.m_ImageType != 10)
|
||||
return false;
|
||||
|
||||
// Skip the ID area..
|
||||
for(i=0; i < hdr.m_IDLength; i++)
|
||||
fp->Read(&dummyChar, 1);
|
||||
|
||||
pImage->m_Width = hdr.m_Width;
|
||||
pImage->m_Height = hdr.m_Height;
|
||||
pImage->m_pData = new unsigned char[hdr.m_Width * hdr.m_Height * 4];
|
||||
if(!pImage->m_pData)
|
||||
return false;
|
||||
|
||||
// Read in the data..
|
||||
for(y=pImage->m_Height-1; y >= 0; y--)
|
||||
{
|
||||
pLine = &pImage->m_pData[y*pImage->m_Width*4];
|
||||
|
||||
curOut = 0;
|
||||
while(curOut < pImage->m_Width)
|
||||
{
|
||||
fp->Read(&packetHeader, 1);
|
||||
|
||||
runLength = (int)(packetHeader & ~(1 << 7)) + 1;
|
||||
if(curOut + runLength > pImage->m_Width)
|
||||
return false;
|
||||
|
||||
if(packetHeader & (1 << 7))
|
||||
{
|
||||
fp->Read(&color, 4);
|
||||
for(x=0; x < runLength; x++)
|
||||
{
|
||||
*((long*)pLine) = color;
|
||||
pLine += 4;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(x=0; x < runLength; x++)
|
||||
{
|
||||
fp->Read(&color, 4);
|
||||
*((long*)pLine) = color;
|
||||
pLine += 4;
|
||||
}
|
||||
}
|
||||
|
||||
curOut += runLength;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Write a 32-bit TGA file.
|
||||
void Save32BitTGA(
|
||||
FILE *fp,
|
||||
FileImage *pImage)
|
||||
{
|
||||
TGAFileHeader hdr;
|
||||
int y, runStart, x;
|
||||
unsigned char *pLine;
|
||||
|
||||
|
||||
memset(&hdr, 0, sizeof(hdr));
|
||||
hdr.m_PixelDepth = 32;
|
||||
hdr.m_ImageType = 10; // Run-length encoded RGB.
|
||||
hdr.m_Width = pImage->m_Width;
|
||||
hdr.m_Height = pImage->m_Height;
|
||||
|
||||
fwrite(&hdr, 1, sizeof(hdr), fp );
|
||||
|
||||
// Lines are written bottom-up.
|
||||
for(y=pImage->m_Height-1; y >= 0; y--)
|
||||
{
|
||||
pLine = &pImage->m_pData[y*pImage->m_Width*4];
|
||||
|
||||
runStart = 0;
|
||||
for(x=0; x < pImage->m_Width; x++)
|
||||
{
|
||||
if((x - runStart) >= 128 ||
|
||||
*((long*)&pLine[runStart*4]) != *((long*)&pLine[x*4]))
|
||||
{
|
||||
// Encode this Run.
|
||||
WriteRun(&pLine[runStart*4], fp, x - runStart);
|
||||
runStart = x;
|
||||
}
|
||||
}
|
||||
|
||||
// Encode the last Run.
|
||||
if(x - runStart > 0)
|
||||
{
|
||||
WriteRun(&pLine[runStart*4], fp, x - runStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
//========= Copyright © 1996-2003, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
||||
// The contents may be used and/or copied only with the written permission of
|
||||
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
||||
// the agreement/contract under which the contents have been supplied.
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#ifndef __FILEIMAGE_H__
|
||||
#define __FILEIMAGE_H__
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
typedef void *FileHandle_t;
|
||||
|
||||
class FileImageStream
|
||||
{
|
||||
public:
|
||||
virtual void Read(void *pOut, int len)=0;
|
||||
|
||||
// Returns true if there were any Read errors.
|
||||
// Clears error status.
|
||||
virtual bool ErrorStatus()=0;
|
||||
};
|
||||
|
||||
|
||||
// Use to read out of a memory buffer..
|
||||
class FileImageStream_Memory : public FileImageStream
|
||||
{
|
||||
public:
|
||||
FileImageStream_Memory(void *pData, int dataLen);
|
||||
|
||||
virtual void Read(void *pOut, int len);
|
||||
virtual bool ErrorStatus();
|
||||
|
||||
|
||||
private:
|
||||
unsigned char *m_pData;
|
||||
int m_DataLen;
|
||||
int m_CurPos;
|
||||
bool m_bError;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Generic image representation..
|
||||
class FileImage
|
||||
{
|
||||
public:
|
||||
FileImage()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
~FileImage()
|
||||
{
|
||||
Term();
|
||||
}
|
||||
|
||||
void Term()
|
||||
{
|
||||
if(m_pData)
|
||||
delete [] m_pData;
|
||||
|
||||
Clear();
|
||||
}
|
||||
|
||||
// Clear the structure without deallocating.
|
||||
void Clear()
|
||||
{
|
||||
m_Width = m_Height = 0;
|
||||
m_pData = NULL;
|
||||
}
|
||||
|
||||
int m_Width, m_Height;
|
||||
unsigned char *m_pData;
|
||||
};
|
||||
|
||||
|
||||
// Functions to load/save FileImages.
|
||||
bool Load32BitTGA(
|
||||
FileImageStream *fp,
|
||||
FileImage *pImage);
|
||||
|
||||
void Save32BitTGA(
|
||||
FileHandle_t fp,
|
||||
FileImage *pImage);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "vfontdata.h"
|
||||
|
||||
VFontData::VFontData()
|
||||
{
|
||||
m_BitmapCharWidth = m_BitmapCharHeight = 0;
|
||||
m_pBitmap = NULL;
|
||||
}
|
||||
|
||||
VFontData::~VFontData()
|
||||
{
|
||||
if (m_pBitmap)
|
||||
delete [] m_pBitmap;
|
||||
}
|
||||
|
||||
bool LoadVFontDataFrom32BitTGA(FileImageStream *fp, VFontData *pData)
|
||||
{
|
||||
FileImage fileImage;
|
||||
|
||||
unsigned char *pInLine, *pOutLine;
|
||||
int i, x, y;
|
||||
int rightX;
|
||||
|
||||
if (!Load32BitTGA(fp, &fileImage))
|
||||
return false;
|
||||
|
||||
pData->m_pBitmap = new unsigned char [fileImage.m_Width*fileImage.m_Height];
|
||||
if (pData->m_pBitmap)
|
||||
{
|
||||
pData->m_BitmapCharWidth = fileImage.m_Width/256;
|
||||
pData->m_BitmapCharHeight = fileImage.m_Height;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
rightX = 0;
|
||||
pInLine = &fileImage.m_pData[i*pData->m_BitmapCharWidth*4];
|
||||
pOutLine = &pData->m_pBitmap[i*pData->m_BitmapCharWidth];
|
||||
|
||||
for (y = 0; y < pData->m_BitmapCharHeight; y++)
|
||||
{
|
||||
for (x = 0; x < pData->m_BitmapCharWidth; x++)
|
||||
{
|
||||
if (pInLine[x*4+0] != 0 || pInLine[x*4+1] != 0 || pInLine[x*4 +2] != 0 || pInLine[x*4+2] != 0)
|
||||
{
|
||||
pOutLine[x] = 1;
|
||||
if (x > rightX)
|
||||
rightX = x;
|
||||
}
|
||||
else
|
||||
pOutLine[x] = 0;
|
||||
}
|
||||
pInLine += 256*pData->m_BitmapCharWidth*4;
|
||||
pOutLine += 256*pData->m_BitmapCharWidth;
|
||||
}
|
||||
pData->m_CharWidths[i] = (i == 32) ? pData->m_BitmapCharWidth/4 : rightX;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#ifndef __VFONTDATA_H__
|
||||
#define __VFONTDATA_H__
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "fileimage.h"
|
||||
|
||||
class VFontData
|
||||
{
|
||||
public:
|
||||
VFontData();
|
||||
~VFontData();
|
||||
|
||||
public:
|
||||
int GetLineWidth();
|
||||
int m_CharWidths[256];
|
||||
int m_BitmapCharWidth;
|
||||
int m_BitmapCharHeight;
|
||||
unsigned char *m_pBitmap;
|
||||
};
|
||||
|
||||
bool LoadVFontDataFrom32BitTGA(
|
||||
FileImageStream *fp, VFontData *pData);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
//========= Copyright ?1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include<stdio.h>
|
||||
#include<windows.h>
|
||||
|
||||
namespace vgui
|
||||
{
|
||||
int vgui_dprintf(const char* format,...)
|
||||
{
|
||||
char buf[2048];
|
||||
va_list argList;
|
||||
|
||||
va_start(argList,format);
|
||||
int ret=vsprintf(buf,format,argList);
|
||||
va_end(argList);
|
||||
|
||||
::OutputDebugString(buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int vgui_dprintf2(const char* format,...)
|
||||
{
|
||||
char buf[2048];
|
||||
va_list argList;
|
||||
static int ctr=0;
|
||||
|
||||
sprintf(buf,"%d:",ctr++);
|
||||
|
||||
va_start(argList,format);
|
||||
int ret=vsprintf(buf+strlen(buf),format,argList);
|
||||
va_end(argList);
|
||||
|
||||
::OutputDebugString(buf);
|
||||
return ret;
|
||||
}
|
||||
}
|
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue