blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
5
146
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
7
license_type
stringclasses
2 values
repo_name
stringlengths
6
79
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
4 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.07k
426M
star_events_count
int64
0
27
fork_events_count
int64
0
12
gha_license_id
stringclasses
3 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
6 values
src_encoding
stringclasses
26 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
1 class
length_bytes
int64
20
6.28M
extension
stringclasses
20 values
content
stringlengths
20
6.28M
authors
sequencelengths
1
16
author_lines
sequencelengths
1
16
a58793d3315363e2922097c96c91331e80c9e809
df5277b77ad258cc5d3da348b5986294b055a2be
/ChatServer/WindowsLibrary/ProgressBar.hpp
f738d7b13bec48b6652a9e05bb108905d517ac9a
[]
no_license
beentaken/cs260-last2
147eaeb1ab15d03c57ad7fdc5db2d4e0824c0c22
61b2f84d565cc94a0283cc14c40fb52189ec1ba5
refs/heads/master
2021-03-20T16:27:10.552333
2010-04-26T00:47:13
2010-04-26T00:47:13
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
1,469
hpp
/**************************************************************************************************/ /*! @file ProgressBar.hpp @author Robert Onulak @author Justin Keane @par email: robert.onulak@@digipen.edu @par email: justin.keane@@digipen.edu @par Course: CS260 @par Assignment #3 ---------------------------------------------------------------------------------------------------- @attention © Copyright 2010: DigiPen Institute of Technology (USA). All Rights Reserved. */ /**************************************************************************************************/ #pragma once #define NOMINMAX #include "Window.hpp" #include <string> #include "Threading.hpp" class ProgressBar : public RoutineObject { public: ProgressBar( const std::string &title ); virtual ~ProgressBar( void ) throw(); void SetRange( unsigned short min, unsigned short max ); void SetStep( unsigned short step ); void Step( void ); private: void Destroy( void ); virtual void InitializeThread( void ); virtual void Run( void ); virtual void ExitThread( void ) throw(); virtual void FlushThread( void ); private: // Main window info of the progress bar WNDCLASSEX window_; HWND win_; /// Handle to the progress bar (which is a child of the window.) HWND pbHandle_; std::string title_; Event quit_; }; // ProgressBar
[ "rziugy@af704e40-745a-32bd-e5ce-d8b418a3b9ef", "ProstheticMind43@af704e40-745a-32bd-e5ce-d8b418a3b9ef" ]
[ [ [ 1, 21 ], [ 25, 27 ], [ 29, 37 ], [ 45, 53 ], [ 56, 57 ] ], [ [ 22, 24 ], [ 28, 28 ], [ 38, 44 ], [ 54, 55 ] ] ]
fcdfbfcf8323e7de4665172bda3688babcea89d9
1c80a726376d6134744d82eec3129456b0ab0cbf
/Project/C++/C++/练习/Visual C++程序设计与应用教程/Li3_2/MainFrm.cpp
987832eb04853c8db5e3a524263d6caaa2096f69
[]
no_license
dabaopku/project_pku
338a8971586b6c4cdc52bf82cdd301d398ad909f
b97f3f15cdc3f85a9407e6bf35587116b5129334
refs/heads/master
2021-01-19T11:35:53.500533
2010-09-01T03:42:40
2010-09-01T03:42:40
null
0
0
null
null
null
null
GB18030
C++
false
false
1,884
cpp
// MainFrm.cpp : CMainFrame 类的实现 // #include "stdafx.h" #include "Li3_2.h" #include "MainFrm.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CMainFrame IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) ON_WM_CREATE() END_MESSAGE_MAP() static UINT indicators[] = { ID_SEPARATOR, // 状态行指示器 ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, }; // CMainFrame 构造/析构 CMainFrame::CMainFrame() { // TODO: 在此添加成员初始化代码 } CMainFrame::~CMainFrame() { } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("未能创建工具栏\n"); return -1; // 未能创建 } if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("未能创建状态栏\n"); return -1; // 未能创建 } // TODO: 如果不需要可停靠工具栏,则删除这三行 m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); return 0; } BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if( !CFrameWnd::PreCreateWindow(cs) ) return FALSE; // TODO: 在此处通过修改 // CREATESTRUCT cs 来修改窗口类或样式 return TRUE; } // CMainFrame 诊断 #ifdef _DEBUG void CMainFrame::AssertValid() const { CFrameWnd::AssertValid(); } void CMainFrame::Dump(CDumpContext& dc) const { CFrameWnd::Dump(dc); } #endif //_DEBUG // CMainFrame 消息处理程序
[ "[email protected]@592586dc-1302-11df-8689-7786f20063ad" ]
[ [ [ 1, 102 ] ] ]
2c50f29d7da2490785a227481cb2b42894b37612
b2d46af9c6152323ce240374afc998c1574db71f
/cursovideojuegos/theflostiproject/3rdParty/boost/libs/config/test/has_sigaction_fail.cpp
9f267b0bf504036308a970276fd9cfc034babc93
[]
no_license
bugbit/cipsaoscar
601b4da0f0a647e71717ed35ee5c2f2d63c8a0f4
52aa8b4b67d48f59e46cb43527480f8b3552e96d
refs/heads/master
2021-01-10T21:31:18.653163
2011-09-28T16:39:12
2011-09-28T16:39:12
33,032,640
0
0
null
null
null
null
UTF-8
C++
false
false
1,166
cpp
// This file was automatically generated on Sun Jul 25 11:47:49 GMTDT 2004, // by libs/config/tools/generate // Copyright John Maddock 2002-4. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org/libs/config for the most recent version. // Test file for macro BOOST_HAS_SIGACTION // This file should not compile, if it does then // BOOST_HAS_SIGACTION may be defined. // see boost_has_sigaction.ipp for more details // Do not edit this file, it was generated automatically by // ../tools/generate from boost_has_sigaction.ipp on // Sun Jul 25 11:47:49 GMTDT 2004 // Must not have BOOST_ASSERT_CONFIG set; it defeats // the objective of this file: #ifdef BOOST_ASSERT_CONFIG # undef BOOST_ASSERT_CONFIG #endif #include <boost/config.hpp> #include "test.hpp" #ifndef BOOST_HAS_SIGACTION #include "boost_has_sigaction.ipp" #else #error "this file should not compile" #endif int main( int, char *[] ) { return boost_has_sigaction::test(); }
[ "ohernandezba@71d53fa2-cca5-e1f2-4b5e-677cbd06613a" ]
[ [ [ 1, 39 ] ] ]
1f4e5ae53f099779e0b7e3dfb7e7773dbb5b07ec
478570cde911b8e8e39046de62d3b5966b850384
/apicompatanamdw/bcdrivers/os/lbs/LocAcquisition/inc/testpositioner.h
e29b244560250134f68fc2e818a265016c42ac02
[]
no_license
SymbianSource/oss.FCL.sftools.ana.compatanamdw
a6a8abf9ef7ad71021d43b7f2b2076b504d4445e
1169475bbf82ebb763de36686d144336fcf9d93b
refs/heads/master
2020-12-24T12:29:44.646072
2010-11-11T14:03:20
2010-11-11T14:03:20
72,994,432
0
0
null
null
null
null
UTF-8
C++
false
false
8,428
h
/* * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: Test Class For RPositioner * */ #ifndef CTESTPOSITIONER_H #define CTESTPOSITIONER_H // System Includes #include <StifLogger.h> #include <StifParser.h> #include <StifTestModule.h> #include <e32base.h> #include <e32std.h> #include <bautils.h> #include <f32file.h> #include <lbs.h> #include <LbsPositionInfo.h> #include <LbsCommon.h> #include <LbsRequestor.h> #include <lbssatellite.h> #include <lbsclasstypes.h> #include <LbsCriteria.h> // Constants // CLASS DECLARATION /** * Test Class to invoke the RPositioner methods * * This class is a helper class. The status variable of this active obect is * used to provide the asynchronous method Calls. * * @lib testlbslocacquisition.lib * @since S60 v3.2 */ class CTestPositioner :public CActive,public RPositioner { public: //Enumerators enum TRequsted { /** GetLastKnownPosition Requested */ EGetLastKnownPosition = 0, /** GetPositionInfo Requested */ EPositionInfo = 1, /** No Requests */ ENone = 2 }; // Constructors and destructor /** * C++ default constructor. */ CTestPositioner(CStifLogger* aLog); /** * Destructor. */ ~CTestPositioner(); public: //From CActive void RunL(); void DoCancel(); TInt RunError(TInt aError); TInt CancelRequest(); // New functions /** * Test Case for Connect to Position Sever * This will test for Successful Connect * * @since S60 v3.2 * Returns KErrNone if successful. * */ TInt Connect(); /** * Test Case for Disconnect to Position Sever * This will test for Successful Disconnect * * @since S60 v3.2 * */ void Disconnect(); /** * Test Case for Resolving Which Open has to be called * for Opening Position Module * This will redirect the call to Open Positioner method. * * @since S60 v3.2 * */ TInt OpenPositionerResolver(RPositionServer& aPosServer, CStifItemParser& aItem ); /** * Test Case for Opening a Positioning Module * This will test for Successful Open * * @since S60 v3.2 * Returns KErrNone if successful. * */ TInt OpenPositioner(RPositionServer& aPosServer); /** * Test Case for Opening a Positioning Module by Id * This will test for Successful Open * * @since S60 v3.2 * Returns KErrNone if successful. * */ TInt OpenPositionerById(RPositionServer& aPosServer, const TUid aPsyUid); /** * Test Case for Opening a Positioning Module by Id * This will test for Successful Open * * @since S60 v3.2 * Returns KErrNone if successful. * */ TInt OpenPositionerByCriteria(RPositionServer& aPosServer); /** * Test Case for Closing a Positioning Module * This will test for Successful Disconnect * * @since S60 v3.2 * */ void ClosePositioner(); /** * Method to set the Request State(GetLastKnown/GetPositionInfo) * Helper method * * @since S60 v3.2 * */ void SetRequestStateL( CStifItemParser& aItem ); /** * Method for Closing Position Sever/Positioning Module * This will test for Panic on Closing Position Sever/Positioning Module * while the request in Pending(Not Cancelled) * * @since S60 v3.2 * */ void ClosePosServerPanic(TPositionInfoBase *aPosInfo); /** * Test Case for setting the Requestor * This will test for Successful Set * * @since S60 v3.2 * */ TInt SetRequestor( TInt aType, TInt aFormat,const TDesC & aData ); /** * Test Case for setting the Requestor Stack * This will test for Successful Set * * @since S60 v3.2 * */ TInt SetRequestorStackL( CStifItemParser& aItem ); /** * Test Case for Setting Update Options * This will test for Successful Setting of Update Options * * @since S60 v3.2 * */ TInt SetUpdateOp(TInt aInterval,TInt aTimeOut,TInt aAge); /** * Test Case for Getting Update Options * This will test for Successful Getting of Update Options * * @since S60 v3.2 * */ TInt GetUpdateOp(TInt aInterval,TInt aTimeOut,TInt aAge); /** * Method for Resolving the call to Get Last Known Position * This will redirect to correct Get Last Known Position method * * @since S60 v3.2 * */ TInt GetLastKnownPostionResolverL( CStifItemParser& aItem ); /** * Method for Getting the Last Known Position * This will fetch the Position Info from Cache * * @since S60 v3.2 * */ TInt GetLastKnownPostionL(TPositionInfoBase *aPosInfo); /** * Method for Resolving the call to Cancel * Get Last Known Position * This will redirect to correct Cancel method * * @since S60 v3.2 * */ TInt GetLastKnownPostionCancelResolverL( CStifItemParser& aItem ); /** * * Method to Cancel the Get Last Known Position * * @since S60 v3.2 * */ TInt GetLastKnownPostionCancel(TPositionInfoBase *aPosInfo); /** * Method for Resolving the call to Get Position Info * This will redirect to correct Get Position Info method * * @since S60 v3.2 * */ TInt GetPositionInfoResolverL( CStifItemParser& aItem ); /** * Method to Get the Position Info from Positioning Module * Gets the Notification on Successfull. * * @since S60 v3.2 * */ TInt GetPositionInfoL(TPositionInfoBase *aPosInfo); /** * Method to Handle Duplicate Panic * on Get Position Info from Positioning Module * * @since S60 v3.2 * */ void GetPositionInfoPanicDuplicate(TPositionInfoBase *aPosInfo); /** * Method for Resolving the call to Cancel Get Position Info * This will redirect to correct Cancel method * * @since S60 v3.2 * */ TInt GetPositionInfoCancelResolverL( CStifItemParser& aItem ); /** * Method for Cancelling the Get Position Info Request * * @since S60 v3.2 * */ TInt GetPositionInfoCancelL(TPositionInfoBase *aPosInfo); /** * Method for Testing ExtendedInterface * * @since S60 v3.2 * */ TInt TestExtendedInterface(); /** * Utility Method to Delete the Cache * * @since S60 v3.2 * */ TInt DeleteLastKnownPostionCacheL(); private: //data /** * Session for Postion Server */ RPositionServer iPosServer; /** * Sub Session for Postion Server */ RPositioner iPositioner; /** * Pointer to Stif Logger - Does not Own */ CStifLogger* iLog; /** * ModuleEvent with Event on Request Complete */ TPositionModuleStatusEvent iModuleEvent; /** * Requested Service */ TRequsted iState; }; #endif // CTESTPOSITIONER_H // End of File
[ "none@none" ]
[ [ [ 1, 335 ] ] ]
564a52bf3f5853a8f682e8ff4558c56044347e58
668dc83d4bc041d522e35b0c783c3e073fcc0bd2
/fbide-rw/sdk/variant.h
1a8c15f3b091d62a5f87533ab2922e12781f2c6a
[]
no_license
albeva/fbide-old-svn
4add934982ce1ce95960c9b3859aeaf22477f10b
bde1e72e7e182fabc89452738f7655e3307296f4
refs/heads/master
2021-01-13T10:22:25.921182
2009-11-19T16:50:48
2009-11-19T16:50:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,253
h
/* * This file is part of FBIde project * * FBIde is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * FBIde is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with FBIde. If not, see <http://www.gnu.org/licenses/>. * * Author: Albert Varaksin <[email protected]> * Copyright (C) The FBIde development team */ #pragma once namespace fb { /** * Simple SDK specific variant class * * internally all are stored as strings so conversions * between the types are possible. * * supported types * - string, int, bool, float * - wxSize, wxColour, wxPoint */ struct SDK_DLL Variant { // default constructor and destructor Variant () = default; ~Variant () = default; // Variant Variant (const Variant & value); void operator = (const Variant & rhs); bool operator == (const Variant & rhs) const; bool operator != (const Variant & rhs) const; // wxString Variant (const wxString & value); void operator = (const wxString & rhs); bool operator == (const wxString & rhs) const; bool operator != (const wxString & rhs) const; wxString AsString (const wxString & def = "") const; inline operator wxString () const { return AsString(); } // const char * Variant (const char * value); void operator = (const char * rhs); bool operator == (const char * rhs) const; bool operator != (const char * rhs) const; // const wxChar * Variant (const wxChar * value); void operator = (const wxChar * rhs); bool operator == (const wxChar * rhs) const; bool operator != (const wxChar * rhs) const; // integer ( works for bools too ) Variant (int value); void operator = (int rhs); bool operator == (int rhs) const; bool operator != (int rhs) const; int AsInt (int def = 0) const; inline operator int () const { return AsInt(); } // boolean values bool AsBool (bool def = false) const; // double Variant (double value); void operator = (double rhs); bool operator == (double rhs) const; bool operator != (double rhs) const; double AsDouble (double def = 0.0) const; inline operator double () const { return AsDouble(); } // wxSize {w, h} Variant (const wxSize & size); void operator = (const wxSize & rhs); bool operator == (const wxSize & rhs) const; bool operator != (const wxSize & rhs) const; wxSize AsSize (const wxSize & def = wxDefaultSize) const; static wxString MakeString (const wxSize & size); inline operator wxSize () const { return AsSize(); } // wxPoint {x, y} Variant (const wxPoint & point); void operator = (const wxPoint & rhs); bool operator == (const wxPoint & rhs) const; bool operator != (const wxPoint & rhs) const; wxPoint AsPoint (const wxPoint & def = wxDefaultPosition) const; static wxString MakeString (const wxPoint & point); inline operator wxPoint () const { return AsPoint(); } // wxColour Variant (const wxColour & colour); void operator = (const wxColour & rhs); bool operator == (const wxColour & rhs) const; bool operator != (const wxColour & rhs) const; wxColour AsColour (const wxColour & def = *wxBLACK) const; static wxString MakeString (const wxColour & colour); inline operator wxColour () const { return AsColour(); } private : wxString m_value; }; }
[ "vongodric@957c6b5c-1c3a-0410-895f-c76cfc11fbc7" ]
[ [ [ 1, 118 ] ] ]
0cf4e4474656e2ac5e814a74898ce1a456641155
0f8559dad8e89d112362f9770a4551149d4e738f
/Wall_Destruction/Havok/Source/Common/SceneData/Scene/hkxScene.h
b079ed40986ad27254d6ac848384f70138f9c1b1
[]
no_license
TheProjecter/olafurabertaymsc
9360ad4c988d921e55b8cef9b8dcf1959e92d814
456d4d87699342c5459534a7992f04669e75d2e1
refs/heads/master
2021-01-10T15:15:49.289873
2010-09-20T12:58:48
2010-09-20T12:58:48
45,933,002
0
0
null
null
null
null
UTF-8
C++
false
false
4,807
h
/* * * Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's * prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok. * Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2009 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement. * */ #ifndef HKSCENEDATA_SCENE_HKXSCENE_HKCLASS_H #define HKSCENEDATA_SCENE_HKXSCENE_HKCLASS_H #include <Common/SceneData/Graph/hkxNode.h> #include <Common/SceneData/Selection/hkxNodeSelectionSet.h> #include <Common/SceneData/Camera/hkxCamera.h> #include <Common/SceneData/Light/hkxLight.h> #include <Common/SceneData/Mesh/hkxMesh.h> #include <Common/SceneData/Material/hkxTextureInplace.h> #include <Common/SceneData/Material/hkxTextureFile.h> #include <Common/SceneData/Skin/hkxSkinBinding.h> /// hkxScene meta information extern const class hkClass hkxSceneClass; /// A simple info storage class to allow the exporters to specify extra information /// that might be useful overall (frames per second, total scene length, etc) class hkxScene : public hkReferencedObject { //+vtable(true) //+version(1) public: HK_DECLARE_CLASS_ALLOCATOR( HK_MEMORY_CLASS_SCENE_DATA ); HK_DECLARE_REFLECTION(); hkxScene(); hkxScene(hkFinishLoadedObjectFlag f) : hkReferencedObject(f), m_modeller(f), m_asset(f), m_rootNode(f), m_selectionSets(f), m_cameras(f), m_lights(f), m_meshes(f), m_materials(f), m_inplaceTextures(f), m_externalTextures(f), m_skinBindings(f) { } virtual ~hkxScene(); // // Members // public: /// A text string describing the modeller used to create this scene hkStringPtr m_modeller; /// The full path and filename of the asset that was exported to make this scene. hkStringPtr m_asset; /// The total length of the scene, in seconds. Assumes that when you are given /// key frames, they will be evenly spaced across this period. hkReal m_sceneLength; /// Scene Graph root node hkRefPtr< class hkxNode > m_rootNode; /// Array of selection sets in the scene. Holds ref. hkArray< hkRefPtr<class hkxNodeSelectionSet> > m_selectionSets; /// Array of cameras in the scene. Holds ref. hkArray< hkRefPtr<class hkxCamera> > m_cameras; /// Array of cameras in the scene. Holds ref. hkArray< hkRefPtr<class hkxLight> > m_lights; /// Meshes in the scene. Holds ref. hkArray< hkRefPtr<class hkxMesh> > m_meshes; /// Materials in the scene. Holds ref. hkArray< hkRefPtr<class hkxMaterial> > m_materials; /// In place (loaded) textures in the scene. Holds ref. hkArray< hkRefPtr<class hkxTextureInplace> > m_inplaceTextures; /// External texture filenames. Holds ref. hkArray< hkRefPtr<class hkxTextureFile> > m_externalTextures; /// Extra mesh info required to bind a skin to a hierarchy. Holds ref. hkArray< hkRefPtr<class hkxSkinBinding> > m_skinBindings; /// Transform applied to the scene hkMatrix3 m_appliedTransform; //+default(1 0 0 0 0 1 0 0 0 0 1 0) /// Recursively looks for a node by name (case insensitive), using depth-first search. /// Returns HK_NULL if not found, the node otherwise hkxNode* findNodeByName (const char* name) const; /// Constructs the full path (parent-first list of nodes from the root to the node itself, both included) /// Returns HK_FAILURE if the node doesn't belong to this scene hkResult getFullPathToNode (const hkxNode* theNode, hkArray<const hkxNode*>& pathOut) const; /// Gets the worldFromNode transform of the given node, by concatenating /// the transforms of its parents. By default, it uses the first stored key. /// Returns HK_FAILURE if the node doesn't belong to this scene hkResult getWorldFromNodeTransform (const hkxNode* theNode, class hkMatrix4& worldFromNodeOut, int key=0) const; }; #endif // HKSCENEDATA_SCENE_HKXSCENE_HKCLASS_H /* * Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20091222) * * Confidential Information of Havok. (C) Copyright 1999-2009 * Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok * Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership * rights, and intellectual property rights in the Havok software remain in * Havok and/or its suppliers. * * Use of this software for evaluation purposes is subject to and indicates * acceptance of the End User licence Agreement for this product. A copy of * the license is included with this software and is also available at www.havok.com/tryhavok. * */
[ [ [ 1, 113 ] ] ]
876c46f46edf9d72537fef84c223796b8ec5c4ba
01c236af2890d74ca5b7c25cec5e7b1686283c48
/Src/GameManager.cpp
87c7f8e6dea01769004daf5aa75e588bc1b81bb3
[ "MIT" ]
permissive
muffinista/palm-pitch
80c5900d4f623204d3b837172eefa09c4efbe5e3
aa09c857b1ccc14672b3eb038a419bd13abc0925
refs/heads/master
2021-01-19T05:43:04.740676
2010-07-08T14:42:18
2010-07-08T14:42:18
763,958
1
0
null
null
null
null
UTF-8
C++
false
false
16,292
cpp
#include <PalmOS.h> #include "Common.h" #include "ComputerPlayer.h" #include "GameManager.h" #include "GameTable.h" #include "HumanPlayer.h" #include "PitchApp.h" GameManager::GameManager() { // // set some defaults // cutthroat = false; winning_score = 11; first_game = true; scores[0] = 0; scores[1] = 0; scores[2] = 0; numPlayers = 0; game_status = PreGame; trick_rounds = 0; cards_played = 0; human = NULL; current = NULL; games_won[0] = 0; games_won[1] = 0; games_won[2] = 0; ai_level = 100; // // create some objects // theDeck = new Deck(); trk = new Trick(); tbl = new GameTable(); } GameManager::~GameManager() { delete theDeck; delete trk; delete tbl; for( Int16 i = 0; i < numPlayers; i++ ) { delete players[i]; } } void GameManager::Reset() { delete theDeck; delete trk; delete tbl; for( Int16 i = 0; i < numPlayers; i++ ) { delete players[i]; } players.DeleteAll(); Player::playerIndex_static = 0; first_game = true; scores[0] = 0; scores[1] = 0; scores[2] = 0; numPlayers = 0; game_status = PreGame; trick_rounds = 0; cards_played = 0; human = NULL; current = NULL; theDeck = new Deck(); trk = new Trick(); tbl = new GameTable(); } void GameManager::ShortDelay() { if ( HostGremlinIsRunning() == false ) { SysTaskDelay( play_delay_ticks * 3 / 4); } } void GameManager::LongDelay() { if ( HostGremlinIsRunning() == false ) { SysTaskDelay( play_delay_ticks ); } } void GameManager::Load() { CAppPrefStream pref(CreatorID, PrefID, PrefVersion); if ( pref.Read() ) { Int16 tmp = 0; // load the GameStatus pref >> tmp; Status((GameStatus)tmp); // load the # of players pref >> numPlayers; if ( numPlayers ) { createPlayers(); } // load player data accoring to # of players for ( Int16 i = 0; i < numPlayers; i++ ) { players[i]->Read(pref); } // for assignTeams(); // load the human pref >> tmp; if ( tmp != -1 ) { human = getPlayerIter(tmp); } else { human = NULL; } // load the current player pref >> tmp; if ( tmp != -1 ) { current = getPlayerIter(tmp); } else { current = NULL; } pref >> scores[0]; pref >> scores[1]; pref >> scores[2]; pref >> first_hand; pref >> first_game; pref >> winning_score; for ( int i = 0; i < 4; i++ ) { pref >> player_names[i]; } pref >> play_delay_ticks; pref >> no_trump_first_trick; pref >> dealer_take_bid; pref >> win_on_bid; pref >> games_played; pref >> games_won[0]; pref >> games_won[1]; pref >> games_won[2]; pref >> cards_played; pref >> trick_rounds; pref >> ai_level; pref >> win_on_smudge; pref >> cutthroat; // load any trick data trk->Read(pref); // load the game table tbl->Read(pref); pref.Close(); } else { cutthroat = false; no_trump_first_trick = true; dealer_take_bid = true; win_on_bid = true; play_delay_ticks = SysTicksPerSecond(); const char *random_name[] = {"Chuck", "Mary", "Bob", "Igor", "Marge", "Jill", "Billy", "Beth", "Jane", "Izzy", "Yvette", "Han", "Peter", "Bruce", "Brian", "Phil", "Eunice"}; const Int16 name_count = 16; Int16 random_num[3]; random_num[0] = SysRandom(0) % name_count; random_num[1] = SysRandom(0) % name_count; random_num[2] = SysRandom(0) % name_count; while ( random_num[0] == random_num[1] || random_num[0] == random_num[2] || random_num[1] == random_num[2] ) { random_num[0] = SysRandom(0) % name_count; random_num[1] = SysRandom(0) % name_count; random_num[2] = SysRandom(0) % name_count; } player_names[1] = random_name[random_num[0]]; player_names[2] = random_name[random_num[1]]; player_names[3] = random_name[random_num[2]]; const char *human = "Human"; player_names[0] = human; games_played = 0; } } void GameManager::Save() { CAppPrefStream pref(CreatorID, PrefID, PrefVersion); pref.SetSaved(true); // save the GameStatus pref << (Int16)Status(); // save the # of players pref << numPlayers; // save player data for ( Int16 i = 0; i < numPlayers; i++ ) { players[i]->Write(pref); } // for // save the human if ( human ) { pref << (*human)->playerIndex; } else { pref << -1; } // save the current player if ( current ) { pref << (*current)->playerIndex; } else { pref << -1; } pref << scores[0]; pref << scores[1]; pref << scores[2]; pref << first_hand; pref << first_game; pref << winning_score; for ( int i = 0; i < 4; i++ ) { pref << player_names[i]; } pref << play_delay_ticks; pref << no_trump_first_trick; pref << dealer_take_bid; pref << win_on_bid; pref << games_played; pref << games_won[0]; pref << games_won[1]; pref << games_won[2]; pref << cards_played; pref << trick_rounds; pref << ai_level; pref << win_on_smudge; pref << cutthroat; // save any trick data trk->Write(pref); // save the game table tbl->Write(pref); } // Save Boolean GameManager::CutThroat() { return cutthroat; } void GameManager::CutThroat(Boolean x) { if ( players.GetCount() == 0 ) { createPlayers(); } if ( cutthroat != x && x == true ) { // if ( players.GetCount() == 4 ) { // delete players[3]; // numPlayers = 3; players[0]->team = 'a'; players[1]->team = 'b'; players[2]->team = 'c'; // } } else if ( cutthroat != x && x == false ) { if ( players.GetCount() == 3 ) { players.Add( new ComputerPlayer('b', player_names[3]) ); numPlayers = 4; } players[0]->team = 'a'; players[2]->team = 'a'; players[1]->team = 'b'; players[3]->team = 'b'; // } } cutthroat = x; } void GameManager::createPlayers() { if ( players.GetCount() == 0 ) { if ( numPlayers == 3 || CutThroat() ) { numPlayers = 3; humanIndex = 0; CString name1 = player_names[0]; CString name2 = player_names[1]; CString name3 = player_names[2]; players.Add( new HumanPlayer('a', name1) ); players.Add( new ComputerPlayer('b', name2) ); players.Add( new ComputerPlayer('c', name3) ); // players.Add( new HumanPlayer('a', player_names[0]) ); // players.Add( new ComputerPlayer('b', player_names[1]) ); // players.Add( new ComputerPlayer('c', player_names[2]) ); } else { numPlayers = 4; humanIndex = 0; CString name1 = player_names[0]; CString name2 = player_names[1]; CString name3 = player_names[2]; CString name4 = player_names[3]; players.Add( new HumanPlayer('a', name1) ); players.Add( new ComputerPlayer('b', name2) ); players.Add( new ComputerPlayer('a', name3) ); players.Add( new ComputerPlayer('b', name4) ); // players.Add( new HumanPlayer('a', player_names[0]) ); // players.Add( new ComputerPlayer('b', player_names[1]) ); // players.Add( new ComputerPlayer('a', player_names[2]) ); // players.Add( new ComputerPlayer('b', player_names[3]) ); } } current = players.BeginIterator(); tbl->lead = players[0]; tbl->winning_bidder = NULL; human = players.BeginIterator(); humanIndex = 0; } Player* GameManager::getPlayer(Int16 index) { Player *tmp = players[index]; return tmp; } CArray <Player*>::iterator GameManager::getPlayerIter(Int16 index) { CArray <Player*>::iterator tmp = players.BeginIterator(); for ( Int16 i = 0; i < index; i++ ) { tmp++; } return tmp; } CArray <Player*>::iterator GameManager::getNextPlayerIter(CArray<Player*>::iterator i) { Int16 index = (*i)->playerIndex; if ( index == numPlayers - 1 ) { CArray <Player*>::iterator tmp = players.BeginIterator(); return tmp; } return getPlayerIter(index + 1); } Player* GameManager::getNextPlayer(Player *p) { if ( p->playerIndex == numPlayers - 1 ) { return players[0]; } return players[p->playerIndex + 1]; } Player* GameManager::getPrevPlayer(Player *p) { if ( p->playerIndex == 0 ) { return players[numPlayers - 1]; } return players[p->playerIndex - 1]; } Player* GameManager::getNextPlayer(CArray <Player*>::iterator i) { Int16 index = (*i)->playerIndex; return getNextPlayer(players[index]); } void GameManager::assignTeams() { for (CArray <Player*>::iterator i = players.BeginIterator(); i != players.EndIterator(); i++ ) { for (CArray <Player*>::iterator a = players.BeginIterator(); a != players.EndIterator(); a++ ) { if( (*a)->getTeam() == (*i)->getTeam() & (*a) != (*i) ) { (*a)->assignPartner(*i); (*i)->assignPartner(*a); } } } } Boolean GameManager::tied() { if ( CutThroat() && ( scores[0] == scores[1] || scores[0] == scores[2] || scores[1] == scores[2] ) ) { return true; } else if ( scores[0] == scores[1] ) { return true; } return false; } void GameManager::dealCards() { // clear out our list of played cards tbl->clear_played_cards(); theDeck->reset(); for (CArray <Player*>::iterator i = players.BeginIterator(); i != players.EndIterator(); i++ ) { (*i)->dealCards(*theDeck, CARDS_IN_HAND); (*i)->clearWinnings(); } } void GameManager::FinalizeBidding( ) { } void GameManager::BidSummary( ) { } void GameManager::ResetBidding() { // winner = tbl->dealer; tbl->winning_bidder = NULL; tbl->high_bid = -1; } Boolean GameManager::GetNextBid(Trick *trk, Boolean bid_already_set ) { Player *p = *tbl->current_bidder; Int16 tmp = -1; /* if ( tbl->winning_bidder ) { tmp = p->BeginBidProcess( (*tbl->dealer), *tbl->winning_bidder ); } else { tmp = p->BeginBidProcess( (*tbl->dealer), NULL ); } if ( p->playerIndex == (*tbl->dealer)->playerIndex && tmp < 2 && tbl->high_bid < 2 ) { tmp = 2; } */ if ( p->playerIndex == (*tbl->dealer)->playerIndex && tbl->high_bid < 2 ) { p->BeginBidProcess( (*tbl->dealer), NULL ); tmp = 2; } else if ( tbl->winning_bidder ) { tmp = p->BeginBidProcess( (*tbl->dealer), *tbl->winning_bidder ); } else { tmp = p->BeginBidProcess( (*tbl->dealer), NULL ); } // // the bid either must be higher, or the dealer can take the bid - if that pref is set // if ( tmp > tbl->high_bid || ( dealer_take_bid && (*tbl->current_bidder)->playerIndex == (*tbl->dealer)->playerIndex && tmp >= tbl->high_bid ) ) { // // this bidder is the new winner // tbl->winning_bidder = tbl->current_bidder; tbl->lead = (*tbl->winning_bidder); // don't let the dealer bid more than has already been // bid, unless it's smudge if ( tbl->winning_bidder == tbl->dealer && tmp != 5 ) { tmp = tbl->high_bid; } if ( tbl->winning_bidder == tbl->dealer ) { if ( tmp <= 2 ) { tmp = 2; tbl->high_bid = 2; (*tbl->winning_bidder)->bid = 2; } tbl->high_bid = tmp; tbl->bid = tmp; } else { tbl->high_bid = tmp; tbl->bid = tmp; } return true; } else if ( tbl->winning_bidder == tbl->dealer && tbl->high_bid < 2 ) { tbl->high_bid = 2; return true; } if ( tbl->current_bidder == tbl->dealer && tbl->high_bid < 2 ) { tbl->winning_bidder = tbl->dealer; tbl->lead = (*tbl->winning_bidder); (*tbl->winning_bidder)->bid = 2; return true; } // this was not a winning bid return false; } void GameManager::NewGame() { Reset(); createPlayers(); assignTeams(); tbl->Reset(); Status(SetGameInfo); } void GameManager::NewTrick() { NewTrick(true); } void GameManager::NewTrick(Boolean move_deal) { trk->CleanUp(); cards_played = 0; tbl->Reset(move_deal); } Boolean GameManager::IsTrickOver() { if ( cards_played == numPlayers ) { return true; } return false; } Boolean GameManager::IsHandOver() { if ( trick_rounds == CARDS_IN_HAND ) { return true; } // if ( rounds == 6 ) return false; } void GameManager::HandleEndOfTrick() { tbl->lead = trk->Winner(); current = getPlayerIter( tbl->lead->playerIndex ); cards_played = 0; trick_rounds++; for (CArray <Player*>::iterator i = players.BeginIterator(); i != players.EndIterator(); i++ ) { if ( (*i)->played_card != NULL ) { (*i)->played_card = NULL; } } trk->book->DeleteAll(); trk->current_winner = NULL; trk->lead = NULL; Status(ReadyToPlay); } void GameManager::HandleEndOfHand() { Status(HandOver); trick_rounds = 0; trk->PostHandCleanUp(); tbl->Reset(); Int16 cnt = 0; for (cnt = 0; cnt < numPlayers; cnt++ ) { players[cnt]->post_hand_cleanup(); } } Boolean GameManager::GetNextPlay(Trick *trk ) { Boolean result = (*current)->PickCard(trk); if ( result == true ) { char hand[22]; hand[0] = 0; for (int cnt = 0; cnt < (*current)->hand.GetCount(); cnt++ ) { char tmpstr[4]; tmpstr[0] = (*current)->hand[cnt]->FaceChar(); tmpstr[1] = (*current)->hand[cnt]->SuitChar(); tmpstr[2] = ' '; tmpstr[3] = 0; StrCat(hand, tmpstr); } HostTraceOutputTL(sysErrorClass, "%d: %s -> %c%c ", (*current)->playerIndex, hand, (*current)->PlayedCard()->FaceChar(), (*current)->PlayedCard()->SuitChar() ); if ( cards_played + 1 == numPlayers ) { HostTraceOutputTL(sysErrorClass, "*********************"); } } return result; } Boolean GameManager::NextPlayedCard(Player *p, Card *c) { if ( c != NULL ) { cards_played++; // // analyze the current standings for this hand // trk->RecordPlayedCard( p, c ); current = getNextPlayerIter(current); // add the card to the vector of played cards // so that our AI can do some figuring tbl->played_cards.Add(c); return true; } return false; } GameStatus GameManager::CheckGameCondition() { return game_status; } void GameManager::Status(GameStatus x) { game_status = x; } GameStatus GameManager::Status() { return game_status; } void GameManager::DealHands() { dealCards(); trick_rounds = 0; cards_played = 0; Status(GetHandBids); } /* if neither team has won, return true */ Boolean GameManager::NoWinner() { if ( // don't allow ties!! ( ! win_on_bid && tied() ) || // can't win if you have to win on a bid ( win_on_bid && tbl->last_bid_winner == -1 ) ) { return true; } // // if you can win on smudge and someone got it, game over // if ( win_on_bid && win_on_smudge && tbl->last_bid_winner != -1 && tbl->won_smudge == true ) { return false; } if ( CutThroat() && scores[2] >= winning_score && ( ! win_on_bid || tbl->last_bid_winner == 2 ) ) { return false; } if ( ( scores[1] >= winning_score ) && ( ! win_on_bid || tbl->last_bid_winner == 1 || tbl->last_bid_winner == 3 ) ) { return false; } if ( ( scores[0] >= winning_score ) && ( ! win_on_bid || tbl->last_bid_winner == 0 || tbl->last_bid_winner == 2 ) ) { return false; } return true; } Player * GameManager::GetWinner() { // // if you must win on a bid, // the last bid winner will be the winner; // if ( win_on_bid && tbl->last_bid_winner != -1 ) { return players[tbl->last_bid_winner]; } // // otherwise, just pick the higher score // if ( scores[2] != 0 ) { if ( scores[2] >= scores[1] && scores[2] >= scores[0] ) { return players[2]; } } else if ( scores[0] >= scores[1] ) { return players[0]; } return players[1]; } Int16 GameManager::GetTeamPoints(char t) { for (CArray <Player*>::iterator i = players.BeginIterator(); i != players.EndIterator(); i++ ) { Player *p = (*i); if ( p->team == t && p->partner != NULL ) { return p->getPoints() + p->partner->getPoints(); } else if ( p->team == t ) { return p->getPoints(); } } return 0; }
[ [ [ 1, 885 ] ] ]
5d77f307c1c12431047aa7600260325e7c71e6e1
fc3691e5b88f10ce159d61fd198f5742fb2f643c
/src/resources/types/ceconomy.cpp
d93917090618a3111d4ccb3feb3ab76318bb0388
[]
no_license
hardyx/openpirates
6f438ed04ec1c64cb1d35e7da4e56aa919c91750
5833ee50474398bc7c364902343d3ff52f5306a6
refs/heads/master
2020-03-11T09:40:55.969627
2010-07-26T00:47:56
2010-07-26T00:47:56
129,919,203
2
0
null
null
null
null
UTF-8
C++
false
false
930
cpp
/*** * openPirates * Copyright (C) 2010 Scott Smith * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ceconomy.h" CEconomy::CEconomy() : mTag (0), mForts (0), mPopulation (0), mSoldiers (0), mGold (0), mName () { } CEconomy::~CEconomy() { }
[ "pickle136@3faa6364-4847-409f-afa2-7fad3069fade" ]
[ [ [ 1, 33 ] ] ]
3d3b5f0267f35becd1511ded309e89ef045a151d
b002ebd2938f8d79c6b09fc652064001a2d92887
/source/CItem.cpp
b7e7896a271be96278c03329e084fbb7c9137988
[]
no_license
benbaker76/DetectiveDS
104a175738970dfd12ea8557685a63245b2a3fbe
ca487610b8088a07fc7fe62e345557ccb9663b20
refs/heads/master
2022-11-25T17:22:07.218401
2011-07-30T13:13:23
2011-07-30T13:13:23
241,390,011
1
0
null
null
null
null
UTF-8
C++
false
false
994
cpp
#include <nds.h> #include "CItem.h" #include "CItemCache.h" #include "CSave.h" CItem::CItem(ItemType itemType, int itemAttribs) { m_itemType = itemType; m_itemAttribs = itemAttribs; m_parent = NULL; m_itemCache = NULL; m_keyItemType = ITEM_NONE; m_locked = false; if(itemAttribs & ITEMATTRIB_OPEN) m_itemCache = new CItemCache(ITEMLOCATION_ITEM, this); } CItem::CItem(ItemType itemType, int itemAttribs, int itemCount) { m_itemType = itemType; m_itemAttribs = itemAttribs; m_parent = NULL; m_itemCache = NULL; m_keyItemType = ITEM_NONE; m_locked = false; if(itemAttribs & ITEMATTRIB_OPEN) m_itemCache = new CItemCache(ITEMLOCATION_ITEM, itemCount, this); } CItem::~CItem() { } void CItem::Save(CSave* pSave) { pSave->WriteBool(m_locked); if(m_itemCache != NULL) m_itemCache->Save(pSave); } void CItem::Load(CSave* pSave) { pSave->ReadBool(&m_locked); if(m_itemCache != NULL) m_itemCache->Load(pSave); }
[ [ [ 1, 51 ] ] ]
b99441ddbca4d4a6315bc11427df4c3d6aee22fa
413d5224c2cc2c710e047cdd9cf87e509cfb6a36
/Zadanie6/Zadanie6INACZEJ.cpp
17f3d2a7d6934e49c3f10680fd488b87c8444bb1
[]
no_license
mzbikows/CodeCPP
83b6276576f2d9ffbaad0a2f094cdf991d71d990
be28f185496b811fe79efe2424bfe33a8cf5d1e5
refs/heads/master
2020-05-20T13:03:49.802006
2010-12-26T19:11:31
2010-12-26T19:11:31
1,185,141
0
0
null
null
null
null
UTF-8
C++
false
false
3,988
cpp
#include <iostream> #include <cstdlib> using namespace std; /***************************************/ enum Banks {PKO, BGZ, BRE, BPH}; /***************************************/ struct Account { Banks bank; int balance; }; struct Person { char name[20]; Account account; }; struct Couple { Person he; Person she; }; /***************************************/ void WypiszTabliceChar(char *tablica, int size) { int licznik; cout << "\n"; for(licznik = 0; licznik < size; ++licznik) { cout << "Pozycja #" << licznik << " : " << tablica[licznik] << " : " << (int)tablica[licznik] << "\n"; } } /***************************************/ void WypiszPare(Couple* para) { cout << (para->he).name << " & " << (para->she).name << " : " << (para->he).account.balance + (para->she).account.balance << "\n"; } /***************************************/ Couple* bestClient(Couple* cpls, int size, Banks bank) { int licznik; int findstatus, licznikmax, sumamax; findstatus = 0; for(licznik = 0; licznik < size; ++licznik) { if( (cpls[licznik].he.account.bank == bank) || (cpls[licznik].she.account.bank == bank) ) { if(findstatus == 0) { licznikmax = licznik; sumamax = cpls[licznik].he.account.balance + cpls[licznik].she.account.balance; findstatus = 1; } else if ((findstatus == 1) && (sumamax < cpls[licznik].he.account.balance + cpls[licznik].she.account.balance) ) { licznikmax = licznik; sumamax = cpls[licznik].he.account.balance + cpls[licznik].she.account.balance; } } } //cout << "Wynik z wewnatrz : " << cpls[licznikmax].he.account.balance << "\n"; if(findstatus == 0) { return NULL; } else { return (&(cpls[licznikmax])); } } /***************************************/ int main() { Couple cpls[4]; Couple *wynik; cpls[0].he.name[0] = 'J'; cpls[0].he.name[1] = 'o'; cpls[0].he.name[2] = 'h'; cpls[0].he.name[3] = 'n'; cpls[0].he.name[4] = 'y'; cpls[0].he.name[5] = NULL; cpls[0].he.account.bank = PKO; cpls[0].he.account.balance = 1100; cpls[0].she.name[0] = 'M'; cpls[0].she.name[1] = 'a'; cpls[0].she.name[2] = 'r'; cpls[0].she.name[3] = 'y'; cpls[0].she.name[4] = NULL; cpls[0].she.account.bank = BGZ; cpls[0].she.account.balance = 1500; cpls[1].he.name[0] = 'P'; cpls[1].he.name[1] = 'e'; cpls[1].he.name[2] = 't'; cpls[1].he.name[3] = 'e'; cpls[1].he.name[4] = 'r'; cpls[1].he.name[5] = NULL; cpls[1].he.account.bank = BGZ; cpls[1].he.account.balance = 1400; cpls[1].she.name[0] = 'S'; cpls[1].she.name[1] = 'u'; cpls[1].she.name[2] = 'z'; cpls[1].she.name[3] = 'y'; cpls[1].she.name[4] = NULL; cpls[1].she.account.bank = BRE; cpls[1].she.account.balance = 1300; cpls[2].he.name[0] = 'K'; cpls[2].he.name[1] = 'e'; cpls[2].he.name[2] = 'v'; cpls[2].he.name[3] = 'i'; cpls[2].he.name[4] = 'n'; cpls[2].he.name[5] = NULL; cpls[2].he.account.bank = PKO; cpls[2].he.account.balance = 1600; cpls[2].she.name[0] = 'K'; cpls[2].she.name[1] = 'a'; cpls[2].she.name[2] = 't'; cpls[2].she.name[3] = 'y'; cpls[2].she.name[4] = NULL; cpls[2].she.account.bank = BPH; cpls[2].she.account.balance = 1500; cpls[3].he.name[0] = 'K'; cpls[3].he.name[1] = 'e'; cpls[3].he.name[2] = 'n'; cpls[3].he.name[3] = 'n'; cpls[3].he.name[4] = 'y'; cpls[3].he.name[5] = NULL; cpls[3].he.account.bank = BPH; cpls[3].he.account.balance = 1800; cpls[3].she.name[0] = 'L'; cpls[3].she.name[1] = 'u'; cpls[3].she.name[2] = 'c'; cpls[3].she.name[3] = 'y'; cpls[3].she.name[4] = NULL; cpls[3].she.account.bank = BRE; cpls[3].she.account.balance = 1700; wynik = bestClient(cpls, 4, BGZ); WypiszPare(wynik); //cout << "Wynik z zewnatrz " << (wynik->he).account.balance << "\n"; //WypiszTabliceChar(wynik->she.name, 20); //system("pause"); }
[ [ [ 1, 172 ] ] ]
0db626c81ad4b70883155e1493d8e22a6746ad8f
944e19e1a68ac1d4c5f6e7ccde1061a43e791887
/OBBDetection/boost_lib_include/include/boost/config/compiler/visualc.hpp
f0dadbde69f44fa7ac6f0afffdb3f62a7575e3d4
[]
no_license
Fredrib/obbdetection
0a797ecac2c24be1a75ddd67fd928e35ddc586f5
41e065c379ddfb7ec0ca4ec0616be5204736b984
refs/heads/master
2020-04-22T14:03:17.358440
2011-01-17T15:24:09
2011-01-17T15:24:09
41,830,450
1
0
null
null
null
null
UTF-8
C++
false
false
8,167
hpp
// (C) Copyright John Maddock 2001 - 2003. // (C) Copyright Darin Adler 2001 - 2002. // (C) Copyright Peter Dimov 2001. // (C) Copyright Aleksey Gurtovoy 2002. // (C) Copyright David Abrahams 2002 - 2003. // (C) Copyright Beman Dawes 2002 - 2003. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org for most recent version. // Microsoft Visual C++ compiler setup: #define BOOST_MSVC _MSC_VER #if _MSC_FULL_VER > 100000000 # define BOOST_MSVC_FULL_VER _MSC_FULL_VER #else # define BOOST_MSVC_FULL_VER (_MSC_FULL_VER * 10) #endif // turn off the warnings before we #include anything #pragma warning( disable : 4503 ) // warning: decorated name length exceeded #if _MSC_VER < 1300 // 1200 == VC++ 6.0, 1200-1202 == eVC++4 # pragma warning( disable : 4786 ) // ident trunc to '255' chars in debug info # define BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS # define BOOST_NO_VOID_RETURNS # define BOOST_NO_EXCEPTION_STD_NAMESPACE # if BOOST_MSVC == 1202 # define BOOST_NO_STD_TYPEINFO # endif // disable min/max macro defines on vc6: // #endif #if (_MSC_VER <= 1300) // 1300 == VC++ 7.0 # if !defined(_MSC_EXTENSIONS) && !defined(BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS) // VC7 bug with /Za # define BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS # endif # define BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS # define BOOST_NO_INCLASS_MEMBER_INITIALIZATION # define BOOST_NO_PRIVATE_IN_AGGREGATE # define BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP # define BOOST_NO_INTEGRAL_INT64_T # define BOOST_NO_DEDUCED_TYPENAME # define BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE // VC++ 6/7 has member templates but they have numerous problems including // cases of silent failure, so for safety we define: # define BOOST_NO_MEMBER_TEMPLATES // For VC++ experts wishing to attempt workarounds, we define: # define BOOST_MSVC6_MEMBER_TEMPLATES # define BOOST_NO_MEMBER_TEMPLATE_FRIENDS # define BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION # define BOOST_NO_CV_VOID_SPECIALIZATIONS # define BOOST_NO_FUNCTION_TEMPLATE_ORDERING # define BOOST_NO_USING_TEMPLATE # define BOOST_NO_SWPRINTF # define BOOST_NO_TEMPLATE_TEMPLATES # define BOOST_NO_SFINAE # define BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS # define BOOST_NO_IS_ABSTRACT # define BOOST_NO_FUNCTION_TYPE_SPECIALIZATIONS // TODO: what version is meant here? Have there really been any fixes in cl 12.01 (as e.g. shipped with eVC4)? # if (_MSC_VER > 1200) # define BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS # endif #endif #if _MSC_VER < 1400 // although a conforming signature for swprint exists in VC7.1 // it appears not to actually work: # define BOOST_NO_SWPRINTF #endif #if defined(UNDER_CE) // Windows CE does not have a conforming signature for swprintf # define BOOST_NO_SWPRINTF #endif #if _MSC_VER <= 1400 // 1400 == VC++ 8.0 # define BOOST_NO_MEMBER_TEMPLATE_FRIENDS #endif #if _MSC_VER <= 1600 // 1600 == VC++ 10.0 # define BOOST_NO_TWO_PHASE_NAME_LOOKUP #endif #if _MSC_VER == 1500 // 1500 == VC++ 9.0 // A bug in VC9: # define BOOST_NO_ADL_BARRIER #endif #if _MSC_VER <= 1500 || !defined(BOOST_STRICT_CONFIG) // 1500 == VC++ 9.0 # define BOOST_NO_INITIALIZER_LISTS #endif #ifndef _NATIVE_WCHAR_T_DEFINED # define BOOST_NO_INTRINSIC_WCHAR_T #endif #if defined(_WIN32_WCE) || defined(UNDER_CE) # define BOOST_NO_THREADEX # define BOOST_NO_GETSYSTEMTIMEASFILETIME # define BOOST_NO_SWPRINTF #endif // // check for exception handling support: #ifndef _CPPUNWIND # define BOOST_NO_EXCEPTIONS #endif // // __int64 support: // #if (_MSC_VER >= 1200) # define BOOST_HAS_MS_INT64 #endif #if (_MSC_VER >= 1310) && defined(_MSC_EXTENSIONS) # define BOOST_HAS_LONG_LONG #else # define BOOST_NO_LONG_LONG #endif #if (_MSC_VER >= 1400) && !defined(_DEBUG) # define BOOST_HAS_NRVO #endif // // disable Win32 API's if compiler extentions are // turned off: // #if !defined(_MSC_EXTENSIONS) && !defined(BOOST_DISABLE_WIN32) # define BOOST_DISABLE_WIN32 #endif #if !defined(_CPPRTTI) && !defined(BOOST_NO_RTTI) # define BOOST_NO_RTTI #endif // // all versions support __declspec: // #define BOOST_HAS_DECLSPEC // // C++0x features // // See above for BOOST_NO_LONG_LONG // C++ features supported by VC++ 10 (aka 2010) // #if _MSC_VER < 1600 #define BOOST_NO_AUTO_DECLARATIONS #define BOOST_NO_AUTO_MULTIDECLARATIONS #define BOOST_NO_DECLTYPE #define BOOST_NO_LAMBDAS #define BOOST_NO_RVALUE_REFERENCES #define BOOST_NO_STATIC_ASSERT #endif // _MSC_VER < 1600 // C++0x features not supported by any versions #define BOOST_NO_CHAR16_T #define BOOST_NO_CHAR32_T #define BOOST_NO_CONCEPTS #define BOOST_NO_CONSTEXPR #define BOOST_NO_DEFAULTED_FUNCTIONS #define BOOST_NO_DELETED_FUNCTIONS #define BOOST_NO_EXPLICIT_CONVERSION_OPERATORS #define BOOST_NO_EXTERN_TEMPLATE #define BOOST_NO_FUNCTION_TEMPLATE_DEFAULT_ARGS #define BOOST_NO_INITIALIZER_LISTS #define BOOST_NO_NULLPTR #define BOOST_NO_RAW_LITERALS #define BOOST_NO_SCOPED_ENUMS #define BOOST_NO_SFINAE_EXPR #define BOOST_NO_TEMPLATE_ALIASES #define BOOST_NO_UNICODE_LITERALS #define BOOST_NO_VARIADIC_TEMPLATES // // prefix and suffix headers: // #ifndef BOOST_ABI_PREFIX # define BOOST_ABI_PREFIX "boost/config/abi/msvc_prefix.hpp" #endif #ifndef BOOST_ABI_SUFFIX # define BOOST_ABI_SUFFIX "boost/config/abi/msvc_suffix.hpp" #endif // TODO: // these things are mostly bogus. 1200 means version 12.0 of the compiler. The // artificial versions assigned to them only refer to the versions of some IDE // these compilers have been shipped with, and even that is not all of it. Some // were shipped with freely downloadable SDKs, others as crosscompilers in eVC. // IOW, you can't use these 'versions' in any sensible way. Sorry. # if defined(UNDER_CE) # if _MSC_VER < 1200 // Note: these are so far off, they are not really supported # elif _MSC_VER < 1300 // eVC++ 4 comes with 1200-1202 # define BOOST_COMPILER_VERSION evc4.0 # elif _MSC_VER == 1400 # define BOOST_COMPILER_VERSION evc8 # elif _MSC_VER == 1500 # define BOOST_COMPILER_VERSION evc9 # elif _MSC_VER == 1600 # define BOOST_COMPILER_VERSION evc10 # else # if defined(BOOST_ASSERT_CONFIG) # error "Unknown EVC++ compiler version - please run the configure tests and report the results" # else # pragma message("Unknown EVC++ compiler version - please run the configure tests and report the results") # endif # endif # else # if _MSC_VER < 1200 // Note: these are so far off, they are not really supported # define BOOST_COMPILER_VERSION 5.0 # elif _MSC_VER < 1300 # define BOOST_COMPILER_VERSION 6.0 # elif _MSC_VER == 1300 # define BOOST_COMPILER_VERSION 7.0 # elif _MSC_VER == 1310 # define BOOST_COMPILER_VERSION 7.1 # elif _MSC_VER == 1400 # define BOOST_COMPILER_VERSION 8.0 # elif _MSC_VER == 1500 # define BOOST_COMPILER_VERSION 9.0 # elif _MSC_VER == 1600 # define BOOST_COMPILER_VERSION 10.0 # else # define BOOST_COMPILER_VERSION _MSC_VER # endif # endif #define BOOST_COMPILER "Microsoft Visual C++ version " BOOST_STRINGIZE(BOOST_COMPILER_VERSION) // // versions check: // we don't support Visual C++ prior to version 6: #if _MSC_VER < 1200 #error "Compiler not supported or configured - please reconfigure" #endif // // last known and checked version is 1600 (VC10, aka 2010): #if (_MSC_VER > 1600) # if defined(BOOST_ASSERT_CONFIG) # error "Unknown compiler version - please run the configure tests and report the results" # else # pragma message("Unknown compiler version - please run the configure tests and report the results") # endif #endif
[ "jonathantompson@5e2a6976-228a-6e25-3d16-ad1625af6446" ]
[ [ [ 1, 258 ] ] ]
390725e65211da7a58d8dc1f0e0bc8131db8f6f5
480c44ff4e052723caa9326457921ea1eada5b25
/admin/src/AccountDialog.h
ed1412df9f0d90cfea665e47ebfb9eec9a25a2dc
[]
no_license
kevinhs1150/open-online-judge
cd898329cf039e0d07835eb98f45b8bd87cff609
979e3bffd2965eb21904a73e84cd5bb12a48dbb8
refs/heads/master
2020-12-25T18:17:15.013425
2011-07-16T13:15:49
2011-07-16T13:15:49
32,213,625
0
0
null
null
null
null
UTF-8
C++
false
false
456
h
#ifndef _ACCOUNTDIALOG_H_ #define _ACCOUNTDIALOG_H_ #include "gui.h" class AccountDialog: public AccountGUI{ private: bool newAccount; void OnClose( wxCloseEvent& event ); void OnButtonClickOK( wxCommandEvent& event ); void OnButtonClickCancel( wxCommandEvent& event ); public: AccountDialog(wxWindow *parent, wxString name = wxEmptyString, unsigned int type = 0, unsigned int account_id = 0); ~AccountDialog(); }; #endif
[ "fishy0903@e3896563-57da-0129-da3f-310c26432eee" ]
[ [ [ 1, 18 ] ] ]
39e800c8bc1f36167fb7e77d2c49ce69f79705a1
011359e589f99ae5fe8271962d447165e9ff7768
/src/burn/misc/pre90s/d_blueprnt.cpp
298ef08af7dcdf1b3a8f2a5e1b8668f792914dc0
[]
no_license
PS3emulators/fba-next-slim
4c753375fd68863c53830bb367c61737393f9777
d082dea48c378bddd5e2a686fe8c19beb06db8e1
refs/heads/master
2021-01-17T23:05:29.479865
2011-12-01T18:16:02
2011-12-01T18:16:02
2,899,840
1
0
null
null
null
null
UTF-8
C++
false
false
20,593
cpp
// FB Alpha Blue Print driver module // Based on MAME driver by Nicola Salmoria #include "tiles_generic.h" #include "driver.h" extern "C" { #include "ay8910.h" } static unsigned char *AllMem; static unsigned char *MemEnd; static unsigned char *RamEnd; static unsigned char *AllRam; static unsigned char *DrvZ80ROM0; static unsigned char *DrvZ80ROM1; static unsigned char *DrvGfxROM0; static unsigned char *DrvGfxROM1; static unsigned char *DrvColRAM; static unsigned char *DrvVidRAM; static unsigned char *DrvScrollRAM; static unsigned char *DrvSprRAM; static unsigned char *DrvZ80RAM0; static unsigned char *DrvZ80RAM1; static unsigned int *DrvPalette; static short *pAY8910Buffer[6]; static unsigned char *watchdog; static unsigned char *dipsw; static unsigned char *soundlatch; static unsigned char *flipscreen; static unsigned char *gfx_bank; static unsigned char DrvReset; static unsigned char DrvJoy1[8]; static unsigned char DrvJoy2[8]; static unsigned char DrvDips[2]; static unsigned char DrvInputs[2]; static unsigned char DrvRecalc; static struct BurnInputInfo BlueprntInputList[] = { {"P1 Coin", BIT_DIGITAL, DrvJoy1 + 0, "p1 coin" }, {"P1 Start", BIT_DIGITAL, DrvJoy1 + 1, "p1 start" }, {"P1 Up", BIT_DIGITAL, DrvJoy1 + 6, "p1 up" }, {"P1 Down", BIT_DIGITAL, DrvJoy1 + 7, "p1 down" }, {"P1 Left", BIT_DIGITAL, DrvJoy1 + 4, "p1 left" }, {"P1 Right", BIT_DIGITAL, DrvJoy1 + 5, "p1 right" }, {"P1 Button 1", BIT_DIGITAL, DrvJoy1 + 3, "p1 fire 1" }, {"P2 Coin", BIT_DIGITAL, DrvJoy2 + 0, "p2 coin" }, {"P2 Start", BIT_DIGITAL, DrvJoy2 + 1, "p2 start" }, {"P2 Up", BIT_DIGITAL, DrvJoy2 + 6, "p2 up" }, {"P2 Down", BIT_DIGITAL, DrvJoy2 + 7, "p2 down" }, {"P2 Left", BIT_DIGITAL, DrvJoy2 + 4, "p2 left" }, {"P2 Right", BIT_DIGITAL, DrvJoy2 + 5, "p2 right" }, {"P2 Button 1", BIT_DIGITAL, DrvJoy2 + 3, "p2 fire 1" }, {"Reset", BIT_DIGITAL, &DrvReset, "reset" }, {"Service", BIT_DIGITAL, DrvJoy2 + 2, "service" }, {"Tilt", BIT_DIGITAL, DrvJoy1 + 2, "tilt" }, {"Dip A", BIT_DIPSWITCH, DrvDips + 0, "dip" }, {"Dip B", BIT_DIPSWITCH, DrvDips + 1, "dip" }, }; STDINPUTINFO(Blueprnt) static struct BurnDIPInfo BlueprntDIPList[]= { {0x11, 0xff, 0xff, 0xc3, NULL }, {0x12, 0xff, 0xff, 0xd5, NULL }, {0 , 0xfe, 0 , 4, "Bonus Life" }, {0x11, 0x01, 0x06, 0x00, "20K" }, {0x11, 0x01, 0x06, 0x02, "30K" }, {0x11, 0x01, 0x06, 0x04, "40K" }, {0x11, 0x01, 0x06, 0x06, "50K" }, {0 , 0xfe, 0 , 2, "Free Play" }, {0x11, 0x01, 0x08, 0x00, "Off" }, {0x11, 0x01, 0x08, 0x08, "On" }, {0 , 0xfe, 0 , 2, "Maze Monster Appears In" }, {0x11, 0x01, 0x10, 0x00, "2nd Maze" }, {0x11, 0x01, 0x10, 0x10, "3rd Maze" }, {0 , 0xfe, 0 , 2, "Coin A" }, {0x11, 0x01, 0x20, 0x20, "2 Coins 1 Credits " }, {0x11, 0x01, 0x20, 0x00, "1 Coin 1 Credits " }, {0 , 0xfe, 0 , 2, "Coin B" }, {0x11, 0x01, 0x40, 0x40, "1 Coin 3 Credits " }, {0x11, 0x01, 0x40, 0x00, "1 Coin 5 Credits " }, {0 , 0xfe, 0 , 4, "Lives" }, {0x12, 0x01, 0x03, 0x00, "2" }, {0x12, 0x01, 0x03, 0x01, "3" }, {0x12, 0x01, 0x03, 0x02, "4" }, {0x12, 0x01, 0x03, 0x03, "5" }, {0 , 0xfe, 0 , 2, "Cabinet" }, {0x12, 0x01, 0x08, 0x00, "Upright" }, {0x12, 0x01, 0x08, 0x08, "Cocktail" }, {0 , 0xfe, 0 , 4, "Difficulty" }, {0x12, 0x01, 0x30, 0x00, "Level 1" }, {0x12, 0x01, 0x30, 0x10, "Level 2" }, {0x12, 0x01, 0x30, 0x20, "Level 3" }, {0x12, 0x01, 0x30, 0x30, "Level 4" }, }; STDDIPINFO(Blueprnt) static struct BurnInputInfo SaturnInputList[] = { {"P1 Coin", BIT_DIGITAL, DrvJoy1 + 0, "p1 coin" }, {"P1 Start", BIT_DIGITAL, DrvJoy1 + 1, "p1 start" }, {"P1 Up", BIT_DIGITAL, DrvJoy1 + 6, "p1 up" }, {"P1 Down", BIT_DIGITAL, DrvJoy1 + 7, "p1 down" }, {"P1 Left", BIT_DIGITAL, DrvJoy1 + 4, "p1 left" }, {"P1 Right", BIT_DIGITAL, DrvJoy1 + 5, "p1 right" }, {"P1 Button 1", BIT_DIGITAL, DrvJoy1 + 3, "p1 fire 1" }, {"P1 Button 2", BIT_DIGITAL, DrvJoy1 + 2, "p1 fire 2" }, {"P2 Coin", BIT_DIGITAL, DrvJoy2 + 0, "p2 coin" }, {"P2 Start", BIT_DIGITAL, DrvJoy2 + 1, "p2 start" }, {"P2 Up", BIT_DIGITAL, DrvJoy2 + 6, "p2 up" }, {"P2 Down", BIT_DIGITAL, DrvJoy2 + 7, "p2 down" }, {"P2 Left", BIT_DIGITAL, DrvJoy2 + 4, "p2 left" }, {"P2 Right", BIT_DIGITAL, DrvJoy2 + 5, "p2 right" }, {"P2 Button 1", BIT_DIGITAL, DrvJoy2 + 3, "p2 fire 1" }, {"P2 Button 2", BIT_DIGITAL, DrvJoy2 + 2, "p2 fire 2" }, {"Reset", BIT_DIGITAL, &DrvReset, "reset" }, {"Dip A", BIT_DIPSWITCH, DrvDips + 0, "dip" }, {"Dip B", BIT_DIPSWITCH, DrvDips + 1, "dip" }, }; STDINPUTINFO(Saturn) static struct BurnDIPInfo SaturnDIPList[]= { {0x11, 0xff, 0xff, 0x00, NULL }, {0x12, 0xff, 0xff, 0x04, NULL }, {0 , 0xfe, 0 , 2, "Cabinet" }, {0x11, 0x01, 0x02, 0x00, "Upright" }, {0x11, 0x01, 0x02, 0x02, "Cocktail" }, {0 , 0xfe, 0 , 4, "Lives" }, {0x11, 0x01, 0xc0, 0x00, "3" }, {0x11, 0x01, 0xc0, 0x40, "4" }, {0x11, 0x01, 0xc0, 0x80, "5" }, {0x11, 0x01, 0xc0, 0xc0, "6" }, {0 , 0xfe, 0 , 2, "Coinage" }, {0x12, 0x01, 0x02, 0x02, "A 2/1 B 1/3" }, {0x12, 0x01, 0x02, 0x00, "A 1/1 B 1/6" }, {0 , 0xfe, 0 , 2, "Demo Sounds" }, {0x12, 0x01, 0x04, 0x00, "Off" }, {0x12, 0x01, 0x04, 0x04, "On" }, }; STDDIPINFO(Saturn) void __fastcall blueprint_write(unsigned short address, unsigned char data) { switch (address) { case 0xd000: { *soundlatch = data; ZetClose(); ZetOpen(1); ZetNmi(); ZetClose(); ZetOpen(0); } return; case 0xe000: { *flipscreen = ~data & 2; *gfx_bank = (data >> 2) & 1; } return; } } unsigned char __fastcall blueprint_read(unsigned short address) { switch (address) { case 0xc000: case 0xc001: return DrvInputs[address & 1]; case 0xc003: return *dipsw; case 0xe000: *watchdog = 0; return 0; } return 0; } void __fastcall blueprint_sound_write(unsigned short address, unsigned char data) { switch (address) { case 0x6000: AY8910Write(0, 0, data); return; case 0x6001: AY8910Write(0, 1, data); return; case 0x8000: AY8910Write(1, 0, data); return; case 0x8001: AY8910Write(1, 1, data); return; } } unsigned char __fastcall blueprint_sound_read(unsigned short address) { switch (address) { case 0x6002: return AY8910Read(0); case 0x8002: return AY8910Read(1); } return 0; } unsigned char ay8910_0_read_port_1(unsigned int) { return *soundlatch; } void ay8910_0_write_port_0(unsigned int, unsigned int data) { *dipsw = data & 0xff; } unsigned char ay8910_1_read_port_0(unsigned int) { return DrvDips[0]; } unsigned char ay8910_1_read_port_1(unsigned int) { return DrvDips[1]; } static void palette_init() { for (int i = 0; i < 512 + 8; i++) { unsigned char pen; if (i < 0x200) pen = ((i & 0x100) >> 5) | ((i & 0x002) ? ((i & 0x0e0) >> 5) : 0) | ((i & 0x001) ? ((i & 0x01c) >> 2) : 0); else pen = i - 0x200; int r = ((pen >> 0) & 1) * (((pen & 8) >> 1) ^ 0xff); int g = ((pen >> 2) & 1) * (((pen & 8) >> 1) ^ 0xff); int b = ((pen >> 1) & 1) * (((pen & 8) >> 1) ^ 0xff); DrvPalette[i] = BurnHighCol(r, g, b, 0); } } static int DrvGfxDecode() { int Plane[3] = { (0x1000 * 8) * 2, (0x1000 * 8) * 1, (0x1000 * 8) * 0 }; int XOffs[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; int YOffs[16] = { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 }; unsigned char *tmp = (unsigned char*)malloc(0x03000); if (tmp == NULL) { return 1; } memcpy (tmp, DrvGfxROM0, 0x02000); GfxDecode(0x0200, 2, 8, 8, Plane + 1, XOffs, YOffs, 0x040, tmp, DrvGfxROM0); memcpy (tmp, DrvGfxROM1, 0x03000); GfxDecode(0x0100, 3, 8, 16, Plane + 0, XOffs, YOffs, 0x080, tmp, DrvGfxROM1); free (tmp); return 0; } static int DrvDoReset() { DrvReset = 0; memset (AllRam, 0, RamEnd - AllRam); ZetOpen(0); ZetReset(); ZetClose(); ZetOpen(1); ZetReset(); ZetClose(); AY8910Reset(0); AY8910Reset(1); return 0; } static int MemIndex() { unsigned char *Next; Next = AllMem; DrvZ80ROM0 = Next; Next += 0x010000; DrvZ80ROM1 = Next; Next += 0x010000; DrvGfxROM0 = Next; Next += 0x008000; DrvGfxROM1 = Next; Next += 0x008000; DrvPalette = (unsigned int*)Next; Next += 0x0208 * sizeof(int); pAY8910Buffer[0] = (short*)Next; Next += nBurnSoundLen * sizeof(short); pAY8910Buffer[1] = (short*)Next; Next += nBurnSoundLen * sizeof(short); pAY8910Buffer[2] = (short*)Next; Next += nBurnSoundLen * sizeof(short); pAY8910Buffer[3] = (short*)Next; Next += nBurnSoundLen * sizeof(short); pAY8910Buffer[4] = (short*)Next; Next += nBurnSoundLen * sizeof(short); pAY8910Buffer[5] = (short*)Next; Next += nBurnSoundLen * sizeof(short); AllRam = Next; DrvColRAM = Next; Next += 0x000400; DrvVidRAM = Next; Next += 0x000400; DrvScrollRAM = Next; Next += 0x000100; DrvSprRAM = Next; Next += 0x000100; DrvZ80RAM0 = Next; Next += 0x000800; DrvZ80RAM1 = Next; Next += 0x000800; dipsw = Next; Next += 0x000001; soundlatch = Next; Next += 0x000001; flipscreen = Next; Next += 0x000001; gfx_bank = Next; Next += 0x000001; watchdog = Next; Next += 0x000001; RamEnd = Next; MemEnd = Next; return 0; } static int DrvInit() { AllMem = NULL; MemIndex(); int nLen = MemEnd - (unsigned char *)0; if ((AllMem = (unsigned char *)malloc(nLen)) == NULL) return 1; memset(AllMem, 0, nLen); MemIndex(); { int lofst = 0; if (BurnLoadRom(DrvZ80ROM0 + 0x0000, 0, 1)) return 1; if (BurnLoadRom(DrvZ80ROM0 + 0x1000, 1, 1)) return 1; if (BurnLoadRom(DrvZ80ROM0 + 0x2000, 2, 1)) return 1; if (BurnLoadRom(DrvZ80ROM0 + 0x3000, 3, 1)) return 1; if (BurnLoadRom(DrvZ80ROM0 + 0x4000, 4, 1)) return 1; if (!strcmp(BurnDrvGetTextA(DRV_NAME), "saturn")) { if (BurnLoadRom(DrvZ80ROM0 + 0x5000, 5, 1)) return 1; lofst = 1; } if (BurnLoadRom(DrvZ80ROM1 + 0x0000, 5+lofst, 1)) return 1; if (BurnLoadRom(DrvZ80ROM1 + 0x2000, 6+lofst, 1)) return 1; if (BurnLoadRom(DrvGfxROM0 + 0x0000, 7+lofst, 1)) return 1; if (BurnLoadRom(DrvGfxROM0 + 0x1000, 8+lofst, 1)) return 1; if (BurnLoadRom(DrvGfxROM1 + 0x0000, 9+lofst, 1)) return 1; if (BurnLoadRom(DrvGfxROM1 + 0x1000, 10+lofst,1)) return 1; if (BurnLoadRom(DrvGfxROM1 + 0x2000, 11+lofst,1)) return 1; DrvGfxDecode(); } ZetInit(2); ZetOpen(0); ZetMapArea(0x0000, 0x7fff, 0, DrvZ80ROM0); ZetMapArea(0x0000, 0x7fff, 2, DrvZ80ROM0); ZetMapArea(0x8000, 0x87ff, 0, DrvZ80RAM0); ZetMapArea(0x8000, 0x87ff, 1, DrvZ80RAM0); ZetMapArea(0x8000, 0x87ff, 2, DrvZ80RAM0); ZetMapArea(0x9000, 0x93ff, 0, DrvVidRAM); ZetMapArea(0x9000, 0x93ff, 1, DrvVidRAM); ZetMapArea(0x9000, 0x93ff, 2, DrvVidRAM); ZetMapArea(0x9400, 0x97ff, 0, DrvVidRAM); ZetMapArea(0x9400, 0x97ff, 1, DrvVidRAM); ZetMapArea(0x9400, 0x97ff, 2, DrvVidRAM); ZetMapArea(0xa000, 0xa0ff, 0, DrvScrollRAM); ZetMapArea(0xa000, 0xa0ff, 1, DrvScrollRAM); ZetMapArea(0xa000, 0xa0ff, 2, DrvScrollRAM); ZetMapArea(0xb000, 0xb0ff, 0, DrvSprRAM); ZetMapArea(0xb000, 0xb0ff, 1, DrvSprRAM); ZetMapArea(0xb000, 0xb0ff, 2, DrvSprRAM); ZetMapArea(0xf000, 0xf3ff, 0, DrvColRAM); ZetMapArea(0xf000, 0xf3ff, 1, DrvColRAM); ZetMapArea(0xf000, 0xf3ff, 2, DrvColRAM); ZetSetWriteHandler(blueprint_write); ZetSetReadHandler(blueprint_read); ZetMemEnd(); ZetClose(); ZetOpen(1); ZetMapArea(0x0000, 0x2fff, 0, DrvZ80ROM1); ZetMapArea(0x0000, 0x2fff, 2, DrvZ80ROM1); ZetMapArea(0x4000, 0x43ff, 0, DrvZ80RAM1); ZetMapArea(0x4000, 0x43ff, 1, DrvZ80RAM1); ZetMapArea(0x4000, 0x43ff, 2, DrvZ80RAM1); ZetSetWriteHandler(blueprint_sound_write); ZetSetReadHandler(blueprint_sound_read); ZetMemEnd(); ZetClose(); AY8910Init(0, 625000, nBurnSoundRate, NULL, &ay8910_0_read_port_1, &ay8910_0_write_port_0, NULL); AY8910Init(1, 625000, nBurnSoundRate, &ay8910_1_read_port_0, &ay8910_1_read_port_1, NULL, NULL); GenericTilesInit(); DrvDoReset(); return 0; } static int DrvExit() { GenericTilesExit(); ZetExit(); AY8910Exit(0); AY8910Exit(1); free (AllMem); AllMem = NULL; return 0; } static void draw_layer(int prio) { for (int offs = 0; offs < 32 * 32; offs++) { int attr = DrvColRAM[offs]; if ((attr >> 7) != prio) continue; int code = DrvVidRAM[offs] | (*gfx_bank << 8); int color = attr & 0x7f; int sx = (~offs & 0x3e0) >> 2; int sy = (offs & 0x1f) << 3; sy -= DrvScrollRAM[(30 + *flipscreen) - (sx >> 3)]; if (sy < -7) sy += 0x100; if (*flipscreen) { Render8x8Tile_Mask_FlipXY_Clip(pTransDraw, code, sx ^ 0xf8, (248 - sy) - 16, color, 2, 0, 0, DrvGfxROM0); } else { Render8x8Tile_Mask_Clip(pTransDraw, code, sx, sy - 16, color, 2, 0, 0, DrvGfxROM0); } } } static void draw_8x16_tile(int code, int sx, int sy, int fx, int fy) { unsigned char *src = DrvGfxROM1 + (code << 7); for (int y = 0; y < 16; y++) { int yy = sy + y; for (int x = 0; x < 8; x++) { int xx = sx + x; int d = src[((y ^ fy) << 3) | (x ^ fx)]; if (yy < 0 || xx < 0 || yy >= nScreenHeight || xx >= nScreenWidth || !d) continue; pTransDraw[(yy * nScreenWidth) + xx] = d | 0x200; } } } static void draw_sprites() { for (int offs = 0; offs < 0x100; offs += 4) { int code = DrvSprRAM[offs + 1]; int sx = DrvSprRAM[offs + 3]; int sy = 240 - DrvSprRAM[offs]; int flipx = (DrvSprRAM[offs + 2] >> 6) & 1; int flipy = (DrvSprRAM[offs + 2 - 4] >> 7) & 1; if (*flipscreen) { sx = 248 - sx; sy = 240 - sy; flipx ^= 1; flipy ^= 1; } draw_8x16_tile(code, sx+2, sy-17, flipx * 0x07, flipy * 0x0f); } } static int DrvDraw() { if (DrvRecalc) { palette_init(); } memset (pTransDraw, 0, nScreenWidth * nScreenHeight * 2); draw_layer(0); draw_sprites(); draw_layer(1); BurnTransferCopy(DrvPalette); return 0; } static int DrvFrame() { if (DrvReset) { DrvDoReset(); } { if (*watchdog > 180) { DrvDoReset(); } *watchdog = *watchdog + 1; } { DrvInputs[0] = DrvInputs[1] = 0; for (int i = 0; i < 8; i++) { DrvInputs[0] |= (DrvJoy1[i] & 1) << i; DrvInputs[1] |= (DrvJoy2[i] & 1) << i; } } int nSegment; int nInterleave = 256; int nTotalCycles[2] = { 3500000 / 60, 625000 / 60 }; int nCyclesDone[2] = { 0, 0 }; for (int i = 0; i < nInterleave; i++) { nSegment = (nTotalCycles[0] - nCyclesDone[0]) / (nInterleave - i); ZetOpen(0); nCyclesDone[0] += ZetRun(nSegment); if (i == 255) ZetSetIRQLine(0, ZET_IRQSTATUS_AUTO); ZetClose(); nSegment = (nTotalCycles[1] - nCyclesDone[1]) / (nInterleave - i); ZetOpen(1); nCyclesDone[1] += ZetRun(nSegment); if ((i & 0x3f) == 0x3f) ZetSetIRQLine(0, ZET_IRQSTATUS_AUTO); ZetClose(); } if (pBurnSoundOut) { int nSample; int nSegmentLength = nBurnSoundLen; short* pSoundBuf = pBurnSoundOut; if (nSegmentLength) { AY8910Update(0, &pAY8910Buffer[0], nSegmentLength); AY8910Update(1, &pAY8910Buffer[3], nSegmentLength); for (int n = 0; n < nSegmentLength; n++) { nSample = pAY8910Buffer[0][n] >> 2; nSample += pAY8910Buffer[1][n] >> 2; nSample += pAY8910Buffer[2][n] >> 2; nSample += pAY8910Buffer[3][n] >> 2; nSample += pAY8910Buffer[4][n] >> 2; nSample += pAY8910Buffer[5][n] >> 2; if (nSample < -32768) { nSample = -32768; } else { if (nSample > 32767) { nSample = 32767; } } pSoundBuf[(n << 1) + 0] = nSample; pSoundBuf[(n << 1) + 1] = nSample; } } } if (pBurnDraw) { DrvDraw(); } return 0; } static int DrvScan(int nAction,int *pnMin) { struct BurnArea ba; if (pnMin) { *pnMin = 0x029698; } if (nAction & ACB_VOLATILE) { memset(&ba, 0, sizeof(ba)); ba.Data = AllRam; ba.nLen = RamEnd - AllRam; ba.szName = "All Ram"; BurnAcb(&ba); ZetScan(nAction); AY8910Scan(nAction, pnMin); } return 0; } // Blue Print (Midway) static struct BurnRomInfo blueprntRomDesc[] = { { "bp-1.1m", 0x1000, 0xb20069a6, 1 | BRF_PRG | BRF_ESS }, // 0 68k Code { "bp-2.1n", 0x1000, 0x4a30302e, 1 | BRF_PRG | BRF_ESS }, // 1 { "bp-3.1p", 0x1000, 0x6866ca07, 1 | BRF_PRG | BRF_ESS }, // 2 { "bp-4.1r", 0x1000, 0x5d3cfac3, 1 | BRF_PRG | BRF_ESS }, // 3 { "bp-5.1s", 0x1000, 0xa556cac4, 1 | BRF_PRG | BRF_ESS }, // 4 { "snd-1.3u", 0x1000, 0xfd38777a, 2 | BRF_PRG | BRF_ESS }, // 5 Z80 Code { "snd-2.3v", 0x1000, 0x33d5bf5b, 2 | BRF_PRG | BRF_ESS }, // 6 { "bg-1.3c", 0x1000, 0xac2a61bc, 3 | BRF_GRA }, // 7 Background Tiles { "bg-2.3d", 0x1000, 0x81fe85d7, 3 | BRF_GRA }, // 8 { "red.17d", 0x1000, 0xa73b6483, 4 | BRF_GRA }, // 9 Sprites { "blue.18d", 0x1000, 0x7d622550, 4 | BRF_GRA }, // 10 { "green.20d", 0x1000, 0x2fcb4f26, 4 | BRF_GRA }, // 11 }; STD_ROM_PICK(blueprnt) STD_ROM_FN(blueprnt) struct BurnDriver BurnDrvBlueprnt = { "blueprnt", NULL, NULL, "1982", "Blue Print (Midway)\0", NULL, "[Zilec Electronics] Bally Midway", "hardware", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_MISC, NULL, blueprntRomInfo, blueprntRomName, BlueprntInputInfo, BlueprntDIPInfo, DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 224, 256, 3, 4 }; // Blue Print (Jaleco) static struct BurnRomInfo blueprntjRomDesc[] = { { "bp-1j.1m", 0x1000, 0x2e746693, 1 | BRF_PRG | BRF_ESS }, // 0 68k Code { "bp-2j.1n", 0x1000, 0xa0eb0b8e, 1 | BRF_PRG | BRF_ESS }, // 1 { "bp-3j.1p", 0x1000, 0xc34981bb, 1 | BRF_PRG | BRF_ESS }, // 2 { "bp-4j.1r", 0x1000, 0x525e77b5, 1 | BRF_PRG | BRF_ESS }, // 3 { "bp-5j.1s", 0x1000, 0x431a015f, 1 | BRF_PRG | BRF_ESS }, // 4 { "snd-1.3u", 0x1000, 0xfd38777a, 2 | BRF_PRG | BRF_ESS }, // 5 Z80 Code { "snd-2.3v", 0x1000, 0x33d5bf5b, 2 | BRF_PRG | BRF_ESS }, // 6 { "bg-1j.3c", 0x0800, 0x43718c34, 3 | BRF_GRA }, // 7 Background Tiles { "bg-2j.3d", 0x0800, 0xd3ce077d, 3 | BRF_GRA }, // 8 { "redj.17d", 0x1000, 0x83da108f, 4 | BRF_GRA }, // 9 Sprites { "bluej.18d", 0x1000, 0xb440f32f, 4 | BRF_GRA }, // 10 { "greenj.20d", 0x1000, 0x23026765, 4 | BRF_GRA }, // 11 }; STD_ROM_PICK(blueprntj) STD_ROM_FN(blueprntj) struct BurnDriver BurnDrvBlueprntj = { "blueprntj", "blueprnt", NULL, "1982", "Blue Print (Jaleco)\0", NULL, "[Zilec Electronics] Jaleco", "hardware", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_MISC, NULL, blueprntjRomInfo, blueprntjRomName, BlueprntInputInfo, BlueprntDIPInfo, DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 224, 256, 3, 4 }; // Saturn static struct BurnRomInfo saturnRomDesc[] = { { "r1", 0x1000, 0x18a6d68e, 1 | BRF_PRG | BRF_ESS }, // 0 68k Code { "r2", 0x1000, 0xa7dd2665, 1 | BRF_PRG | BRF_ESS }, // 1 { "r3", 0x1000, 0xb9cfa791, 1 | BRF_PRG | BRF_ESS }, // 2 { "r4", 0x1000, 0xc5a997e7, 1 | BRF_PRG | BRF_ESS }, // 3 { "r5", 0x1000, 0x43444d00, 1 | BRF_PRG | BRF_ESS }, // 4 { "r6", 0x1000, 0x4d4821f6, 1 | BRF_PRG | BRF_ESS }, // 5 { "r7", 0x1000, 0xdd43e02f, 2 | BRF_PRG | BRF_ESS }, // 6 Z80 Code { "r8", 0x1000, 0x7f9d0877, 2 | BRF_PRG | BRF_ESS }, // 7 { "r10", 0x1000, 0x35987d61, 3 | BRF_GRA }, // 8 Background Tiles { "r9", 0x1000, 0xca6a7fda, 3 | BRF_GRA }, // 9 { "r11", 0x1000, 0x6e4e6e5d, 4 | BRF_GRA }, // 10 Sprites { "r12", 0x1000, 0x46fc049e, 4 | BRF_GRA }, // 11 { "r13", 0x1000, 0x8b3e8c32, 4 | BRF_GRA }, // 12 }; STD_ROM_PICK(saturn) STD_ROM_FN(saturn) struct BurnDriver BurnDrvSaturn = { "saturn", NULL, NULL, "1983", "Saturn\0", NULL, "[Zilec Electronics] Jaleco", "hardware", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_MISC, NULL, saturnRomInfo, saturnRomName, BlueprntInputInfo, BlueprntDIPInfo, DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 224, 256, 3, 4 };
[ [ [ 1, 757 ] ] ]
9ac6171ef82e3aac4256466119b9828da4426256
580738f96494d426d6e5973c5b3493026caf8b6a
/Include/Vcl/sysconst.hpp
aceca3accc506dccef81e62b11cca2c2e7e113c8
[]
no_license
bravesoftdz/cbuilder-vcl
6b460b4d535d17c309560352479b437d99383d4b
7b91ef1602681e094a6a7769ebb65ffd6f291c59
refs/heads/master
2021-01-10T14:21:03.726693
2010-01-11T11:23:45
2010-01-11T11:23:45
48,485,606
2
1
null
null
null
null
UTF-8
C++
false
false
21,873
hpp
// Borland C++ Builder // Copyright (c) 1995, 2002 by Borland Software Corporation // All rights reserved // (DO NOT EDIT: machine generated header) 'SysConst.pas' rev: 6.00 #ifndef SysConstHPP #define SysConstHPP #pragma delphiheader begin #pragma option push -w- #pragma option push -Vx #include <SysInit.hpp> // Pascal unit #include <System.hpp> // Pascal unit //-- user supplied ----------------------------------------------------------- namespace Sysconst { //-- type declarations ------------------------------------------------------- //-- var, const, procedure --------------------------------------------------- extern PACKAGE System::ResourceString _SUnknown; #define Sysconst_SUnknown System::LoadResourceString(&Sysconst::_SUnknown) extern PACKAGE System::ResourceString _SInvalidInteger; #define Sysconst_SInvalidInteger System::LoadResourceString(&Sysconst::_SInvalidInteger) extern PACKAGE System::ResourceString _SInvalidFloat; #define Sysconst_SInvalidFloat System::LoadResourceString(&Sysconst::_SInvalidFloat) extern PACKAGE System::ResourceString _SInvalidCurrency; #define Sysconst_SInvalidCurrency System::LoadResourceString(&Sysconst::_SInvalidCurrency) extern PACKAGE System::ResourceString _SInvalidDate; #define Sysconst_SInvalidDate System::LoadResourceString(&Sysconst::_SInvalidDate) extern PACKAGE System::ResourceString _SInvalidTime; #define Sysconst_SInvalidTime System::LoadResourceString(&Sysconst::_SInvalidTime) extern PACKAGE System::ResourceString _SInvalidDateTime; #define Sysconst_SInvalidDateTime System::LoadResourceString(&Sysconst::_SInvalidDateTime) extern PACKAGE System::ResourceString _SInvalidDateTimeFloat; #define Sysconst_SInvalidDateTimeFloat System::LoadResourceString(&Sysconst::_SInvalidDateTimeFloat) extern PACKAGE System::ResourceString _SInvalidTimeStamp; #define Sysconst_SInvalidTimeStamp System::LoadResourceString(&Sysconst::_SInvalidTimeStamp) extern PACKAGE System::ResourceString _SInvalidGUID; #define Sysconst_SInvalidGUID System::LoadResourceString(&Sysconst::_SInvalidGUID) extern PACKAGE System::ResourceString _SInvalidBoolean; #define Sysconst_SInvalidBoolean System::LoadResourceString(&Sysconst::_SInvalidBoolean) extern PACKAGE System::ResourceString _STimeEncodeError; #define Sysconst_STimeEncodeError System::LoadResourceString(&Sysconst::_STimeEncodeError) extern PACKAGE System::ResourceString _SDateEncodeError; #define Sysconst_SDateEncodeError System::LoadResourceString(&Sysconst::_SDateEncodeError) extern PACKAGE System::ResourceString _SOutOfMemory; #define Sysconst_SOutOfMemory System::LoadResourceString(&Sysconst::_SOutOfMemory) extern PACKAGE System::ResourceString _SInOutError; #define Sysconst_SInOutError System::LoadResourceString(&Sysconst::_SInOutError) extern PACKAGE System::ResourceString _SFileNotFound; #define Sysconst_SFileNotFound System::LoadResourceString(&Sysconst::_SFileNotFound) extern PACKAGE System::ResourceString _SInvalidFilename; #define Sysconst_SInvalidFilename System::LoadResourceString(&Sysconst::_SInvalidFilename) extern PACKAGE System::ResourceString _STooManyOpenFiles; #define Sysconst_STooManyOpenFiles System::LoadResourceString(&Sysconst::_STooManyOpenFiles) extern PACKAGE System::ResourceString _SAccessDenied; #define Sysconst_SAccessDenied System::LoadResourceString(&Sysconst::_SAccessDenied) extern PACKAGE System::ResourceString _SEndOfFile; #define Sysconst_SEndOfFile System::LoadResourceString(&Sysconst::_SEndOfFile) extern PACKAGE System::ResourceString _SDiskFull; #define Sysconst_SDiskFull System::LoadResourceString(&Sysconst::_SDiskFull) extern PACKAGE System::ResourceString _SInvalidInput; #define Sysconst_SInvalidInput System::LoadResourceString(&Sysconst::_SInvalidInput) extern PACKAGE System::ResourceString _SDivByZero; #define Sysconst_SDivByZero System::LoadResourceString(&Sysconst::_SDivByZero) extern PACKAGE System::ResourceString _SRangeError; #define Sysconst_SRangeError System::LoadResourceString(&Sysconst::_SRangeError) extern PACKAGE System::ResourceString _SIntOverflow; #define Sysconst_SIntOverflow System::LoadResourceString(&Sysconst::_SIntOverflow) extern PACKAGE System::ResourceString _SInvalidOp; #define Sysconst_SInvalidOp System::LoadResourceString(&Sysconst::_SInvalidOp) extern PACKAGE System::ResourceString _SZeroDivide; #define Sysconst_SZeroDivide System::LoadResourceString(&Sysconst::_SZeroDivide) extern PACKAGE System::ResourceString _SOverflow; #define Sysconst_SOverflow System::LoadResourceString(&Sysconst::_SOverflow) extern PACKAGE System::ResourceString _SUnderflow; #define Sysconst_SUnderflow System::LoadResourceString(&Sysconst::_SUnderflow) extern PACKAGE System::ResourceString _SInvalidPointer; #define Sysconst_SInvalidPointer System::LoadResourceString(&Sysconst::_SInvalidPointer) extern PACKAGE System::ResourceString _SInvalidCast; #define Sysconst_SInvalidCast System::LoadResourceString(&Sysconst::_SInvalidCast) extern PACKAGE System::ResourceString _SAccessViolation; #define Sysconst_SAccessViolation System::LoadResourceString(&Sysconst::_SAccessViolation) extern PACKAGE System::ResourceString _SStackOverflow; #define Sysconst_SStackOverflow System::LoadResourceString(&Sysconst::_SStackOverflow) extern PACKAGE System::ResourceString _SControlC; #define Sysconst_SControlC System::LoadResourceString(&Sysconst::_SControlC) extern PACKAGE System::ResourceString _SQuit; #define Sysconst_SQuit System::LoadResourceString(&Sysconst::_SQuit) extern PACKAGE System::ResourceString _SPrivilege; #define Sysconst_SPrivilege System::LoadResourceString(&Sysconst::_SPrivilege) extern PACKAGE System::ResourceString _SOperationAborted; #define Sysconst_SOperationAborted System::LoadResourceString(&Sysconst::_SOperationAborted) extern PACKAGE System::ResourceString _SException; #define Sysconst_SException System::LoadResourceString(&Sysconst::_SException) extern PACKAGE System::ResourceString _SExceptTitle; #define Sysconst_SExceptTitle System::LoadResourceString(&Sysconst::_SExceptTitle) extern PACKAGE System::ResourceString _SInvalidFormat; #define Sysconst_SInvalidFormat System::LoadResourceString(&Sysconst::_SInvalidFormat) extern PACKAGE System::ResourceString _SArgumentMissing; #define Sysconst_SArgumentMissing System::LoadResourceString(&Sysconst::_SArgumentMissing) extern PACKAGE System::ResourceString _SDispatchError; #define Sysconst_SDispatchError System::LoadResourceString(&Sysconst::_SDispatchError) extern PACKAGE System::ResourceString _SReadAccess; #define Sysconst_SReadAccess System::LoadResourceString(&Sysconst::_SReadAccess) extern PACKAGE System::ResourceString _SWriteAccess; #define Sysconst_SWriteAccess System::LoadResourceString(&Sysconst::_SWriteAccess) extern PACKAGE System::ResourceString _SResultTooLong; #define Sysconst_SResultTooLong System::LoadResourceString(&Sysconst::_SResultTooLong) extern PACKAGE System::ResourceString _SFormatTooLong; #define Sysconst_SFormatTooLong System::LoadResourceString(&Sysconst::_SFormatTooLong) extern PACKAGE System::ResourceString _SVarArrayCreate; #define Sysconst_SVarArrayCreate System::LoadResourceString(&Sysconst::_SVarArrayCreate) extern PACKAGE System::ResourceString _SVarArrayBounds; #define Sysconst_SVarArrayBounds System::LoadResourceString(&Sysconst::_SVarArrayBounds) extern PACKAGE System::ResourceString _SVarArrayLocked; #define Sysconst_SVarArrayLocked System::LoadResourceString(&Sysconst::_SVarArrayLocked) extern PACKAGE System::ResourceString _SInvalidVarCast; #define Sysconst_SInvalidVarCast System::LoadResourceString(&Sysconst::_SInvalidVarCast) extern PACKAGE System::ResourceString _SInvalidVarOp; #define Sysconst_SInvalidVarOp System::LoadResourceString(&Sysconst::_SInvalidVarOp) extern PACKAGE System::ResourceString _SInvalidVarOpWithHResult; #define Sysconst_SInvalidVarOpWithHResult System::LoadResourceString(&Sysconst::_SInvalidVarOpWithHResult) extern PACKAGE System::ResourceString _SVarNotArray; #define Sysconst_SVarNotArray System::LoadResourceString(&Sysconst::_SVarNotArray) extern PACKAGE System::ResourceString _SVarTypeUnknown; #define Sysconst_SVarTypeUnknown System::LoadResourceString(&Sysconst::_SVarTypeUnknown) extern PACKAGE System::ResourceString _SVarTypeOutOfRange; #define Sysconst_SVarTypeOutOfRange System::LoadResourceString(&Sysconst::_SVarTypeOutOfRange) extern PACKAGE System::ResourceString _SVarTypeAlreadyUsed; #define Sysconst_SVarTypeAlreadyUsed System::LoadResourceString(&Sysconst::_SVarTypeAlreadyUsed) extern PACKAGE System::ResourceString _SVarTypeNotUsable; #define Sysconst_SVarTypeNotUsable System::LoadResourceString(&Sysconst::_SVarTypeNotUsable) extern PACKAGE System::ResourceString _SVarTypeTooManyCustom; #define Sysconst_SVarTypeTooManyCustom System::LoadResourceString(&Sysconst::_SVarTypeTooManyCustom) extern PACKAGE System::ResourceString _SVarTypeCouldNotConvert; #define Sysconst_SVarTypeCouldNotConvert System::LoadResourceString(&Sysconst::_SVarTypeCouldNotConvert) extern PACKAGE System::ResourceString _SVarTypeConvertOverflow; #define Sysconst_SVarTypeConvertOverflow System::LoadResourceString(&Sysconst::_SVarTypeConvertOverflow) extern PACKAGE System::ResourceString _SVarOverflow; #define Sysconst_SVarOverflow System::LoadResourceString(&Sysconst::_SVarOverflow) extern PACKAGE System::ResourceString _SVarInvalid; #define Sysconst_SVarInvalid System::LoadResourceString(&Sysconst::_SVarInvalid) extern PACKAGE System::ResourceString _SVarBadType; #define Sysconst_SVarBadType System::LoadResourceString(&Sysconst::_SVarBadType) extern PACKAGE System::ResourceString _SVarNotImplemented; #define Sysconst_SVarNotImplemented System::LoadResourceString(&Sysconst::_SVarNotImplemented) extern PACKAGE System::ResourceString _SVarOutOfMemory; #define Sysconst_SVarOutOfMemory System::LoadResourceString(&Sysconst::_SVarOutOfMemory) extern PACKAGE System::ResourceString _SVarUnexpected; #define Sysconst_SVarUnexpected System::LoadResourceString(&Sysconst::_SVarUnexpected) extern PACKAGE System::ResourceString _SVarDataClearRecursing; #define Sysconst_SVarDataClearRecursing System::LoadResourceString(&Sysconst::_SVarDataClearRecursing) extern PACKAGE System::ResourceString _SVarDataCopyRecursing; #define Sysconst_SVarDataCopyRecursing System::LoadResourceString(&Sysconst::_SVarDataCopyRecursing) extern PACKAGE System::ResourceString _SVarDataCopyNoIndRecursing; #define Sysconst_SVarDataCopyNoIndRecursing System::LoadResourceString(&Sysconst::_SVarDataCopyNoIndRecursing) extern PACKAGE System::ResourceString _SVarDataInitRecursing; #define Sysconst_SVarDataInitRecursing System::LoadResourceString(&Sysconst::_SVarDataInitRecursing) extern PACKAGE System::ResourceString _SVarDataCastToRecursing; #define Sysconst_SVarDataCastToRecursing System::LoadResourceString(&Sysconst::_SVarDataCastToRecursing) extern PACKAGE System::ResourceString _SVarIsEmpty; #define Sysconst_SVarIsEmpty System::LoadResourceString(&Sysconst::_SVarIsEmpty) extern PACKAGE System::ResourceString _sUnknownFromType; #define Sysconst_sUnknownFromType System::LoadResourceString(&Sysconst::_sUnknownFromType) extern PACKAGE System::ResourceString _sUnknownToType; #define Sysconst_sUnknownToType System::LoadResourceString(&Sysconst::_sUnknownToType) extern PACKAGE System::ResourceString _SExternalException; #define Sysconst_SExternalException System::LoadResourceString(&Sysconst::_SExternalException) extern PACKAGE System::ResourceString _SAssertionFailed; #define Sysconst_SAssertionFailed System::LoadResourceString(&Sysconst::_SAssertionFailed) extern PACKAGE System::ResourceString _SIntfCastError; #define Sysconst_SIntfCastError System::LoadResourceString(&Sysconst::_SIntfCastError) extern PACKAGE System::ResourceString _SSafecallException; #define Sysconst_SSafecallException System::LoadResourceString(&Sysconst::_SSafecallException) extern PACKAGE System::ResourceString _SAssertError; #define Sysconst_SAssertError System::LoadResourceString(&Sysconst::_SAssertError) extern PACKAGE System::ResourceString _SAbstractError; #define Sysconst_SAbstractError System::LoadResourceString(&Sysconst::_SAbstractError) extern PACKAGE System::ResourceString _SModuleAccessViolation; #define Sysconst_SModuleAccessViolation System::LoadResourceString(&Sysconst::_SModuleAccessViolation) extern PACKAGE System::ResourceString _SCannotReadPackageInfo; #define Sysconst_SCannotReadPackageInfo System::LoadResourceString(&Sysconst::_SCannotReadPackageInfo) extern PACKAGE System::ResourceString _sErrorLoadingPackage; #define Sysconst_sErrorLoadingPackage System::LoadResourceString(&Sysconst::_sErrorLoadingPackage) extern PACKAGE System::ResourceString _SInvalidPackageFile; #define Sysconst_SInvalidPackageFile System::LoadResourceString(&Sysconst::_SInvalidPackageFile) extern PACKAGE System::ResourceString _SInvalidPackageHandle; #define Sysconst_SInvalidPackageHandle System::LoadResourceString(&Sysconst::_SInvalidPackageHandle) extern PACKAGE System::ResourceString _SDuplicatePackageUnit; #define Sysconst_SDuplicatePackageUnit System::LoadResourceString(&Sysconst::_SDuplicatePackageUnit) extern PACKAGE System::ResourceString _SOSError; #define Sysconst_SOSError System::LoadResourceString(&Sysconst::_SOSError) extern PACKAGE System::ResourceString _SUnkOSError; #define Sysconst_SUnkOSError System::LoadResourceString(&Sysconst::_SUnkOSError) extern PACKAGE System::ResourceString _SWin32Error; #define Sysconst_SWin32Error System::LoadResourceString(&Sysconst::_SWin32Error) extern PACKAGE System::ResourceString _SUnkWin32Error; #define Sysconst_SUnkWin32Error System::LoadResourceString(&Sysconst::_SUnkWin32Error) extern PACKAGE System::ResourceString _SNL; #define Sysconst_SNL System::LoadResourceString(&Sysconst::_SNL) extern PACKAGE System::ResourceString _SConvIncompatibleTypes2; #define Sysconst_SConvIncompatibleTypes2 System::LoadResourceString(&Sysconst::_SConvIncompatibleTypes2) extern PACKAGE System::ResourceString _SConvIncompatibleTypes3; #define Sysconst_SConvIncompatibleTypes3 System::LoadResourceString(&Sysconst::_SConvIncompatibleTypes3) extern PACKAGE System::ResourceString _SConvIncompatibleTypes4; #define Sysconst_SConvIncompatibleTypes4 System::LoadResourceString(&Sysconst::_SConvIncompatibleTypes4) extern PACKAGE System::ResourceString _SConvUnknownType; #define Sysconst_SConvUnknownType System::LoadResourceString(&Sysconst::_SConvUnknownType) extern PACKAGE System::ResourceString _SConvDuplicateType; #define Sysconst_SConvDuplicateType System::LoadResourceString(&Sysconst::_SConvDuplicateType) extern PACKAGE System::ResourceString _SConvUnknownFamily; #define Sysconst_SConvUnknownFamily System::LoadResourceString(&Sysconst::_SConvUnknownFamily) extern PACKAGE System::ResourceString _SConvDuplicateFamily; #define Sysconst_SConvDuplicateFamily System::LoadResourceString(&Sysconst::_SConvDuplicateFamily) extern PACKAGE System::ResourceString _SConvUnknownDescription; #define Sysconst_SConvUnknownDescription System::LoadResourceString(&Sysconst::_SConvUnknownDescription) extern PACKAGE System::ResourceString _SConvIllegalType; #define Sysconst_SConvIllegalType System::LoadResourceString(&Sysconst::_SConvIllegalType) extern PACKAGE System::ResourceString _SConvIllegalFamily; #define Sysconst_SConvIllegalFamily System::LoadResourceString(&Sysconst::_SConvIllegalFamily) extern PACKAGE System::ResourceString _SConvFactorZero; #define Sysconst_SConvFactorZero System::LoadResourceString(&Sysconst::_SConvFactorZero) extern PACKAGE System::ResourceString _SShortMonthNameJan; #define Sysconst_SShortMonthNameJan System::LoadResourceString(&Sysconst::_SShortMonthNameJan) extern PACKAGE System::ResourceString _SShortMonthNameFeb; #define Sysconst_SShortMonthNameFeb System::LoadResourceString(&Sysconst::_SShortMonthNameFeb) extern PACKAGE System::ResourceString _SShortMonthNameMar; #define Sysconst_SShortMonthNameMar System::LoadResourceString(&Sysconst::_SShortMonthNameMar) extern PACKAGE System::ResourceString _SShortMonthNameApr; #define Sysconst_SShortMonthNameApr System::LoadResourceString(&Sysconst::_SShortMonthNameApr) extern PACKAGE System::ResourceString _SShortMonthNameMay; #define Sysconst_SShortMonthNameMay System::LoadResourceString(&Sysconst::_SShortMonthNameMay) extern PACKAGE System::ResourceString _SShortMonthNameJun; #define Sysconst_SShortMonthNameJun System::LoadResourceString(&Sysconst::_SShortMonthNameJun) extern PACKAGE System::ResourceString _SShortMonthNameJul; #define Sysconst_SShortMonthNameJul System::LoadResourceString(&Sysconst::_SShortMonthNameJul) extern PACKAGE System::ResourceString _SShortMonthNameAug; #define Sysconst_SShortMonthNameAug System::LoadResourceString(&Sysconst::_SShortMonthNameAug) extern PACKAGE System::ResourceString _SShortMonthNameSep; #define Sysconst_SShortMonthNameSep System::LoadResourceString(&Sysconst::_SShortMonthNameSep) extern PACKAGE System::ResourceString _SShortMonthNameOct; #define Sysconst_SShortMonthNameOct System::LoadResourceString(&Sysconst::_SShortMonthNameOct) extern PACKAGE System::ResourceString _SShortMonthNameNov; #define Sysconst_SShortMonthNameNov System::LoadResourceString(&Sysconst::_SShortMonthNameNov) extern PACKAGE System::ResourceString _SShortMonthNameDec; #define Sysconst_SShortMonthNameDec System::LoadResourceString(&Sysconst::_SShortMonthNameDec) extern PACKAGE System::ResourceString _SLongMonthNameJan; #define Sysconst_SLongMonthNameJan System::LoadResourceString(&Sysconst::_SLongMonthNameJan) extern PACKAGE System::ResourceString _SLongMonthNameFeb; #define Sysconst_SLongMonthNameFeb System::LoadResourceString(&Sysconst::_SLongMonthNameFeb) extern PACKAGE System::ResourceString _SLongMonthNameMar; #define Sysconst_SLongMonthNameMar System::LoadResourceString(&Sysconst::_SLongMonthNameMar) extern PACKAGE System::ResourceString _SLongMonthNameApr; #define Sysconst_SLongMonthNameApr System::LoadResourceString(&Sysconst::_SLongMonthNameApr) extern PACKAGE System::ResourceString _SLongMonthNameMay; #define Sysconst_SLongMonthNameMay System::LoadResourceString(&Sysconst::_SLongMonthNameMay) extern PACKAGE System::ResourceString _SLongMonthNameJun; #define Sysconst_SLongMonthNameJun System::LoadResourceString(&Sysconst::_SLongMonthNameJun) extern PACKAGE System::ResourceString _SLongMonthNameJul; #define Sysconst_SLongMonthNameJul System::LoadResourceString(&Sysconst::_SLongMonthNameJul) extern PACKAGE System::ResourceString _SLongMonthNameAug; #define Sysconst_SLongMonthNameAug System::LoadResourceString(&Sysconst::_SLongMonthNameAug) extern PACKAGE System::ResourceString _SLongMonthNameSep; #define Sysconst_SLongMonthNameSep System::LoadResourceString(&Sysconst::_SLongMonthNameSep) extern PACKAGE System::ResourceString _SLongMonthNameOct; #define Sysconst_SLongMonthNameOct System::LoadResourceString(&Sysconst::_SLongMonthNameOct) extern PACKAGE System::ResourceString _SLongMonthNameNov; #define Sysconst_SLongMonthNameNov System::LoadResourceString(&Sysconst::_SLongMonthNameNov) extern PACKAGE System::ResourceString _SLongMonthNameDec; #define Sysconst_SLongMonthNameDec System::LoadResourceString(&Sysconst::_SLongMonthNameDec) extern PACKAGE System::ResourceString _SShortDayNameSun; #define Sysconst_SShortDayNameSun System::LoadResourceString(&Sysconst::_SShortDayNameSun) extern PACKAGE System::ResourceString _SShortDayNameMon; #define Sysconst_SShortDayNameMon System::LoadResourceString(&Sysconst::_SShortDayNameMon) extern PACKAGE System::ResourceString _SShortDayNameTue; #define Sysconst_SShortDayNameTue System::LoadResourceString(&Sysconst::_SShortDayNameTue) extern PACKAGE System::ResourceString _SShortDayNameWed; #define Sysconst_SShortDayNameWed System::LoadResourceString(&Sysconst::_SShortDayNameWed) extern PACKAGE System::ResourceString _SShortDayNameThu; #define Sysconst_SShortDayNameThu System::LoadResourceString(&Sysconst::_SShortDayNameThu) extern PACKAGE System::ResourceString _SShortDayNameFri; #define Sysconst_SShortDayNameFri System::LoadResourceString(&Sysconst::_SShortDayNameFri) extern PACKAGE System::ResourceString _SShortDayNameSat; #define Sysconst_SShortDayNameSat System::LoadResourceString(&Sysconst::_SShortDayNameSat) extern PACKAGE System::ResourceString _SLongDayNameSun; #define Sysconst_SLongDayNameSun System::LoadResourceString(&Sysconst::_SLongDayNameSun) extern PACKAGE System::ResourceString _SLongDayNameMon; #define Sysconst_SLongDayNameMon System::LoadResourceString(&Sysconst::_SLongDayNameMon) extern PACKAGE System::ResourceString _SLongDayNameTue; #define Sysconst_SLongDayNameTue System::LoadResourceString(&Sysconst::_SLongDayNameTue) extern PACKAGE System::ResourceString _SLongDayNameWed; #define Sysconst_SLongDayNameWed System::LoadResourceString(&Sysconst::_SLongDayNameWed) extern PACKAGE System::ResourceString _SLongDayNameThu; #define Sysconst_SLongDayNameThu System::LoadResourceString(&Sysconst::_SLongDayNameThu) extern PACKAGE System::ResourceString _SLongDayNameFri; #define Sysconst_SLongDayNameFri System::LoadResourceString(&Sysconst::_SLongDayNameFri) extern PACKAGE System::ResourceString _SLongDayNameSat; #define Sysconst_SLongDayNameSat System::LoadResourceString(&Sysconst::_SLongDayNameSat) extern PACKAGE System::ResourceString _SCannotCreateDir; #define Sysconst_SCannotCreateDir System::LoadResourceString(&Sysconst::_SCannotCreateDir) } /* namespace Sysconst */ using namespace Sysconst; #pragma option pop // -w- #pragma option pop // -Vx #pragma delphiheader end. //-- end unit ---------------------------------------------------------------- #endif // SysConst
[ "bitscode@7bd08ab0-fa70-11de-930f-d36749347e7b" ]
[ [ [ 1, 312 ] ] ]
fcbe98776e8b4df10563d5c338c146f29a308acb
b4d726a0321649f907923cc57323942a1e45915b
/CODE/windows_stub/STUBS.CPP
2feca2814e26bb8d58563fe5657a39edaa7989c2
[]
no_license
chief1983/Imperial-Alliance
f1aa664d91f32c9e244867aaac43fffdf42199dc
6db0102a8897deac845a8bd2a7aa2e1b25086448
refs/heads/master
2016-09-06T02:40:39.069630
2010-10-06T22:06:24
2010-10-06T22:06:24
967,775
2
0
null
null
null
null
UTF-8
C++
false
false
4,943
cpp
// stub routines for porting #include <stdarg.h> #include <errno.h> #include <fcntl.h> #include <unistd.h> #include <sys/stat.h> #include <ctype.h> #include "globalincs/pstypes.h" void WinAssert(char * text, char *filename, int line) { fprintf(stderr, "ASSERTION FAILED: \"%s\" at %s:%d\n", text, filename, line); abort(); } void Warning( char * filename, int line, char * format, ... ) { va_list args; va_start(args, format); fprintf (stderr, "WARNING: \""); vfprintf(stderr, format, args); fprintf (stderr, "\" at %s:%d\n", filename, line ); va_end(args); } void Error( char * filename, int line, char * format, ... ) { va_list args; va_start(args, format); fprintf (stderr, "ERROR: \""); vfprintf(stderr, format, args); fprintf (stderr, "\" at %s:%d\n", filename, line ); va_end(args); abort(); } char *clean_filename(char *name) { char *p = name+strlen(name)-1; // Move p to point to first letter of EXE filename while( (p > name) && (*p!='\\') && (*p!='/') && (*p!=':') ) p--; p++; return p; } #ifndef NDEBUG int TotalRam = 0; #endif int Watch_malloc = 0; DCF_BOOL(watch_malloc, Watch_malloc ); #ifndef NDEBUG void windebug_memwatch_init() { //_CrtSetAllocHook(MyAllocHook); TotalRam = 0; } #endif int vm_init(int min_heap_size) { #ifndef NDEBUG TotalRam = 0; #endif return 1; } int _getcwd(char *buffer, unsigned int len) { if (getcwd(buffer, len) == NULL) { Error(__FILE__, __LINE__, "buffer overflow in getcwd (buf size = %u)", len); } } int _chdir(const char *path) { int status = chdir(path); #ifndef NDEBUG if (status) { Warning(__FILE__, __LINE__, "Cannot chdir to %s: %s", path, sys_errlist[errno]); } #endif return status; } int _mkdir(const char *path) { int status = mkdir(path, 0777); #ifndef NDEBUG if (status) { Warning(__FILE__, __LINE__, "Cannot mkdir %s: %s", path, sys_errlist[errno]); } #endif return status; } int MessageBox(HWND h, const char *s1, const char *s2, int i) { Error(__FILE__, __LINE__, "MessageBox called!\n s1 = \"%s\"\n s2 = \"%s\"", s1, s2); return 0; } int MulDiv(int number, int numerator, int denominator) { int result; #if defined(__i386__) __asm( "movl %1,%%eax\n" " movl %2,%%ebx\n" " imul %%ebx\n" " movl %3,%%ebx\n" " idiv %%ebx\n" : "=eax" (result) : "m" (number), "m" (numerator), "m" (denominator) : "ebx","edx"); #else longlong tmp; tmp = ((longlong) number) * ((longlong) numerator); tmp /= (longlong) denominator; result = (int) tmp; #endif return result; } void strlwr(char *s) { if (s == NULL) return; while (*s) { *s = tolower(*s); s++; } } char *itoa(int value, char *str, int radix) { Assert(radix == 10); sprintf(str, "%d", value); return str; } #ifdef unix void DeleteCriticalSection(CRITICAL_SECTION *mutex) { pthread_mutex_destroy(mutex); } void InitializeCriticalSection(CRITICAL_SECTION *mutex) { pthread_mutex_init(mutex, NULL); } void EnterCriticalSection(CRITICAL_SECTION *mutex) { pthread_mutex_lock(mutex); } void LeaveCriticalSection(CRITICAL_SECTION *mutex) { pthread_mutex_unlock(mutex); } #undef malloc #undef free #undef strdup #ifndef NDEBUG void *vm_malloc( int size, char *filename, int line ) #else void *vm_malloc( int size ) #endif { #ifndef NDEBUG TotalRam += size; return malloc(size); #endif void *ptr = malloc(size ); if ( ptr == NULL ) { Error(LOCATION, "Out of memory."); } #ifndef NDEBUG if ( Watch_malloc ) { mprintf(( "Malloc %d bytes [%s(%d)]\n", size, clean_filename(filename), line )); } TotalRam += size; #endif return ptr; } #ifndef NDEBUG char *vm_strdup( const char *ptr, char *filename, int line ) #else char *vm_strdup( const char *ptr ) #endif { char *dst; int len = strlen(ptr); #ifndef NDEBUG dst = (char *)vm_malloc( len+1, filename, line ); #else dst = (char *)vm_malloc( len+1 ); #endif strcpy( dst, ptr ); return dst; } #ifndef NDEBUG void vm_free( void *ptr, char *filename, int line ) #else void vm_free( void *ptr ) #endif { if ( !ptr ) { #ifndef NDEBUG mprintf(("Why are you trying to free a NULL pointer? [%s(%d)]\n", clean_filename(filename), line)); #else mprintf(("Why are you trying to free a NULL pointer?\n")); #endif return; } #ifndef NDEBUG #ifdef _WIN32 _CrtMemBlockHeader *phd = pHdr(ptr); int nSize = phd->nDataSize; TotalRam -= nSize; #else // mharris TODO: figure out size of block... #endif // ifdef WIN32 #endif // ifndef NDEBUG free(ptr); } void vm_free_all() { } #endif
[ [ [ 1, 287 ] ] ]
b19366a0b5290119749d6d74b9011ec1c7e08812
2112057af069a78e75adfd244a3f5b224fbab321
/branches/ref1/src-root/include/common/Ogre/paging_landscape/OgrePagingLandScapeListener.h
c95cda243aef987ea8aa8ed3264669d00cacb543
[]
no_license
blockspacer/ireon
120bde79e39fb107c961697985a1fe4cb309bd81
a89fa30b369a0b21661c992da2c4ec1087aac312
refs/heads/master
2023-04-15T00:22:02.905112
2010-01-07T20:31:07
2010-01-07T20:31:07
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
3,612
h
/*----------------------------------------------------------------------------- This source file is part of OGRE (Object-oriented Graphics Rendering Engine) For the latest info, see http://www.ogre3d.org/ Copyright © 2000-2004 The OGRE Team Also see acknowledgements in Readme.html This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt. -----------------------------------------------------------------------------*/ #ifndef __PagingLandscapePageSourceListener_H__ #define __PagingLandscapePageSourceListener_H__ #include "OgrePagingLandScapePrerequisites.h" namespace Ogre { /** Abstract class which classes can override to receive notifications when a page is ready to be added to the terrain manager. */ class _OgrePagingLandScapeExport PagingLandscapeListener { public: /** Listener method called when a new page is about to be constructed. @param pagex, pagez The index of the page being constructed @param heightData Array of normalised height data (0..1). The size of this buffer will conform to the scene manager page size. The listener may modify the data if it wishes. */ virtual void pagePreloaded( const size_t pagex, const size_t pagez, const Real* heightData, const AxisAlignedBox &Bbox ) = 0; virtual void pageLoaded( const size_t pagex, const size_t pagez, const Real* heightData, const AxisAlignedBox &Bbox ) = 0; virtual void pageUnloaded( const size_t pagex, const size_t pagez, const Real* heightData, const AxisAlignedBox &Bbox ) = 0; virtual void pagePostunloaded( const size_t pagex, const size_t pagez) = 0; virtual void pageShow( const size_t pagex, const size_t pagez, const Real* heightData, const AxisAlignedBox &Bbox ) = 0; virtual void pageHide( const size_t pagex, const size_t pagez, const Real* heightData, const AxisAlignedBox &Bbox ) = 0; virtual void tileLoaded( const size_t pagex, const size_t pagez, const size_t tilex, const size_t tilez, const AxisAlignedBox &Bbox ) = 0; virtual void tileUnloaded( const size_t pagex, const size_t pagez, const size_t tilex, const size_t tilez, const AxisAlignedBox &Bbox ) = 0; virtual void tileDeformed( const size_t pagex, const size_t pagez, const size_t tilex, const size_t tilez, const AxisAlignedBox &Bbox ) = 0; virtual void tileShow( const size_t pagex, const size_t pagez, const size_t tilex, const size_t tilez, const AxisAlignedBox &Bbox ) = 0; virtual void tileHide( const size_t pagex, const size_t pagez, const size_t tilex, const size_t tilez, const AxisAlignedBox &Bbox ) = 0; virtual void terrainReady( void ) = 0; }; } #endif //__PagingLandscapePageSourceListener_H__
[ [ [ 1, 58 ] ] ]
e5adfa9d6dd525c7e71c8b4fd253858ed51f223a
8253a563255bdd5797873c9f80d2a48a690c5bb0
/settingsengines/sdb/tests/native/SdbTest/src/Tests.cpp
58f4cf963270a1c802661cec501b315baa047aab
[]
no_license
SymbianSource/oss.FCL.sftools.depl.swconfigmdw
4e6ab52bf564299f1ed7036755cf16321bd656ee
d2feb88baf0e94da760738fc3b436c3d5d1ff35f
refs/heads/master
2020-03-28T10:16:11.362176
2010-11-06T14:59:14
2010-11-06T14:59:14
73,009,096
0
0
null
null
null
null
UTF-8
C++
false
false
1,191
cpp
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" // which accompanies this distribution, and is available // at the URL "http://www.eclipse.org/legal/epl-v10.html". // // Initial Contributors: // Nokia Corporation - initial contribution. // // Contributors: // // Description: // /* * Tests.cpp * */ #include "SdbTest.h" extern void RegisterTestL(const TDesC&, TTestFunction); // // // Add a test function prototype here int ExampleTestL(RSdbTest& aTest); // // // Register your test here // void RegisterTestsL() { _LIT(KExampleTestName, "ExampleTest"); RegisterTestL(KExampleTestName, &ExampleTestL); } // // // You can add int ExampleTestL(RSdbTest& aTest) { CCommandLineArguments* cmdLine = aTest.CommandLineArgumentsL(); aTest.AssertTrueL(ETrue , __LINE__); aTest.Next(_L("Test #1")); aTest.AssertNotErrorL(KErrNone, __LINE__); aTest.EndL(KErrNone); aTest.Printf(_L("You can print stuff like this %d\n"), KErrNone); return KErrNone; }
[ "none@none" ]
[ [ [ 1, 53 ] ] ]
984cc2f6279e35a89e90d22a399bb1645f13f10a
aa5491d8b31750da743472562e85dd4987f1258a
/Main/server/pickup.cpp
f663680c6b15ef48e54b5a7c5755284e3b597167
[]
no_license
LBRGeorge/jmnvc
d841ad694eaa761d0a45ab95b210758c50750d17
064402f0a9f1536229b99cf45f6e7536e1ae7bb5
refs/heads/master
2016-08-04T03:12:18.402941
2009-05-31T18:40:42
2009-05-31T18:40:42
39,416,169
2
0
null
null
null
null
UTF-8
C++
false
false
827
cpp
#include "netgame.h" #include <math.h> extern CNetGame *pNetGame; CPickup::CPickup(BYTE byteModel, VECTOR *vecPos) { m_SpawnInfo.bytePickupModel = byteModel; m_SpawnInfo.vecPos.X = vecPos->X; m_SpawnInfo.vecPos.Y = vecPos->Y; m_SpawnInfo.vecPos.Z = vecPos->Z; m_bIsActive = TRUE; m_bPickedUp = FALSE; } void CPickup::SpawnForPlayer(BYTE byteForPlayerID) { RakNet::BitStream bsPickupSpawn; bsPickupSpawn.Write(m_bytePickupID); bsPickupSpawn.Write(m_SpawnInfo.bytePickupModel); bsPickupSpawn.Write(m_SpawnInfo.vecPos.X); bsPickupSpawn.Write(m_SpawnInfo.vecPos.Y); bsPickupSpawn.Write(m_SpawnInfo.vecPos.Z); bsPickupSpawn.Write(m_bPickedUp); pNetGame->GetNetSends()->ClientCall(true, pNetGame->GetRakServer()->GetPlayerIDFromIndex(byteForPlayerID), "PickupSpawn", bsPickupSpawn); }
[ "jacks.mini.net@45e629aa-34f5-11de-82fb-7f665ef830f7" ]
[ [ [ 1, 28 ] ] ]
b6d415b33ea6fc4242a77bf5b5b92d38a6267ac4
7b379862f58f587d9327db829ae4c6493b745bb1
/JuceLibraryCode/modules/juce_gui_basics/components/juce_Component.cpp
8fd56577a0a54001184569abc202a1238c83187d
[]
no_license
owenvallis/Nomestate
75e844e8ab68933d481640c12019f0d734c62065
7fe7c06c2893421a3c77b5180e5f27ab61dd0ffd
refs/heads/master
2021-01-19T07:35:14.301832
2011-12-28T07:42:50
2011-12-28T07:42:50
2,950,072
2
0
null
null
null
null
UTF-8
C++
false
false
93,283
cpp
/* ============================================================================== This file is part of the JUCE library - "Jules' Utility Class Extensions" Copyright 2004-11 by Raw Material Software Ltd. ------------------------------------------------------------------------------ JUCE can be redistributed and/or modified under the terms of the GNU General Public License (Version 2), as published by the Free Software Foundation. A copy of the license is included in the JUCE distribution, or can be found online at www.gnu.org/licenses. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are available: visit www.rawmaterialsoftware.com/juce for more information. ============================================================================== */ BEGIN_JUCE_NAMESPACE //============================================================================== #define CHECK_MESSAGE_MANAGER_IS_LOCKED jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager()); Component* Component::currentlyFocusedComponent = nullptr; //============================================================================== class Component::MouseListenerList { public: MouseListenerList() noexcept : numDeepMouseListeners (0) { } void addListener (MouseListener* const newListener, const bool wantsEventsForAllNestedChildComponents) { if (! listeners.contains (newListener)) { if (wantsEventsForAllNestedChildComponents) { listeners.insert (0, newListener); ++numDeepMouseListeners; } else { listeners.add (newListener); } } } void removeListener (MouseListener* const listenerToRemove) { const int index = listeners.indexOf (listenerToRemove); if (index >= 0) { if (index < numDeepMouseListeners) --numDeepMouseListeners; listeners.remove (index); } } static void sendMouseEvent (Component& comp, BailOutChecker& checker, void (MouseListener::*eventMethod) (const MouseEvent&), const MouseEvent& e) { if (checker.shouldBailOut()) return; { MouseListenerList* const list = comp.mouseListeners; if (list != nullptr) { for (int i = list->listeners.size(); --i >= 0;) { (list->listeners.getUnchecked(i)->*eventMethod) (e); if (checker.shouldBailOut()) return; i = jmin (i, list->listeners.size()); } } } Component* p = comp.parentComponent; while (p != nullptr) { MouseListenerList* const list = p->mouseListeners; if (list != nullptr && list->numDeepMouseListeners > 0) { BailOutChecker2 checker2 (checker, p); for (int i = list->numDeepMouseListeners; --i >= 0;) { (list->listeners.getUnchecked(i)->*eventMethod) (e); if (checker2.shouldBailOut()) return; i = jmin (i, list->numDeepMouseListeners); } } p = p->parentComponent; } } static void sendWheelEvent (Component& comp, BailOutChecker& checker, const MouseEvent& e, const float wheelIncrementX, const float wheelIncrementY) { { MouseListenerList* const list = comp.mouseListeners; if (list != nullptr) { for (int i = list->listeners.size(); --i >= 0;) { list->listeners.getUnchecked(i)->mouseWheelMove (e, wheelIncrementX, wheelIncrementY); if (checker.shouldBailOut()) return; i = jmin (i, list->listeners.size()); } } } Component* p = comp.parentComponent; while (p != nullptr) { MouseListenerList* const list = p->mouseListeners; if (list != nullptr && list->numDeepMouseListeners > 0) { BailOutChecker2 checker2 (checker, p); for (int i = list->numDeepMouseListeners; --i >= 0;) { list->listeners.getUnchecked(i)->mouseWheelMove (e, wheelIncrementX, wheelIncrementY); if (checker2.shouldBailOut()) return; i = jmin (i, list->numDeepMouseListeners); } } p = p->parentComponent; } } private: Array <MouseListener*> listeners; int numDeepMouseListeners; class BailOutChecker2 { public: BailOutChecker2 (BailOutChecker& checker_, Component* const component) : checker (checker_), safePointer (component) { } bool shouldBailOut() const noexcept { return checker.shouldBailOut() || safePointer == 0; } private: BailOutChecker& checker; const WeakReference<Component> safePointer; JUCE_DECLARE_NON_COPYABLE (BailOutChecker2); }; JUCE_DECLARE_NON_COPYABLE (MouseListenerList); }; //============================================================================== class Component::ComponentHelpers { public: //============================================================================== #if JUCE_MODAL_LOOPS_PERMITTED static void* runModalLoopCallback (void* userData) { return (void*) (pointer_sized_int) static_cast <Component*> (userData)->runModalLoop(); } #endif static Identifier getColourPropertyId (const int colourId) { String s; s.preallocateBytes (32); s << "jcclr_" << String::toHexString (colourId); return s; } //============================================================================== static inline bool hitTest (Component& comp, const Point<int>& localPoint) { return isPositiveAndBelow (localPoint.x, comp.getWidth()) && isPositiveAndBelow (localPoint.y, comp.getHeight()) && comp.hitTest (localPoint.x, localPoint.y); } static Point<int> convertFromParentSpace (const Component& comp, const Point<int>& pointInParentSpace) { if (comp.affineTransform == nullptr) return pointInParentSpace - comp.getPosition(); return pointInParentSpace.toFloat().transformedBy (comp.affineTransform->inverted()).toInt() - comp.getPosition(); } static Rectangle<int> convertFromParentSpace (const Component& comp, const Rectangle<int>& areaInParentSpace) { if (comp.affineTransform == nullptr) return areaInParentSpace - comp.getPosition(); return areaInParentSpace.toFloat().transformed (comp.affineTransform->inverted()).getSmallestIntegerContainer() - comp.getPosition(); } static Point<int> convertToParentSpace (const Component& comp, const Point<int>& pointInLocalSpace) { if (comp.affineTransform == nullptr) return pointInLocalSpace + comp.getPosition(); return (pointInLocalSpace + comp.getPosition()).toFloat().transformedBy (*comp.affineTransform).toInt(); } static Rectangle<int> convertToParentSpace (const Component& comp, const Rectangle<int>& areaInLocalSpace) { if (comp.affineTransform == nullptr) return areaInLocalSpace + comp.getPosition(); return (areaInLocalSpace + comp.getPosition()).toFloat().transformed (*comp.affineTransform).getSmallestIntegerContainer(); } template <typename Type> static Type convertFromDistantParentSpace (const Component* parent, const Component& target, const Type& coordInParent) { const Component* const directParent = target.getParentComponent(); jassert (directParent != nullptr); if (directParent == parent) return convertFromParentSpace (target, coordInParent); return convertFromParentSpace (target, convertFromDistantParentSpace (parent, *directParent, coordInParent)); } template <typename Type> static Type convertCoordinate (const Component* target, const Component* source, Type p) { while (source != nullptr) { if (source == target) return p; if (source->isParentOf (target)) return convertFromDistantParentSpace (source, *target, p); if (source->isOnDesktop()) { p = source->getPeer()->localToGlobal (p); source = nullptr; } else { p = convertToParentSpace (*source, p); source = source->getParentComponent(); } } jassert (source == nullptr); if (target == nullptr) return p; const Component* const topLevelComp = target->getTopLevelComponent(); if (topLevelComp->isOnDesktop()) p = topLevelComp->getPeer()->globalToLocal (p); else p = convertFromParentSpace (*topLevelComp, p); if (topLevelComp == target) return p; return convertFromDistantParentSpace (topLevelComp, *target, p); } static Rectangle<int> getUnclippedArea (const Component& comp) { Rectangle<int> r (comp.getLocalBounds()); Component* const p = comp.getParentComponent(); if (p != nullptr) r = r.getIntersection (convertFromParentSpace (comp, getUnclippedArea (*p))); return r; } static void clipObscuredRegions (const Component& comp, Graphics& g, const Rectangle<int>& clipRect, const Point<int>& delta) { for (int i = comp.childComponentList.size(); --i >= 0;) { const Component& child = *comp.childComponentList.getUnchecked(i); if (child.isVisible() && ! child.isTransformed()) { const Rectangle<int> newClip (clipRect.getIntersection (child.bounds)); if (! newClip.isEmpty()) { if (child.isOpaque() && child.componentTransparency == 0) { g.excludeClipRegion (newClip + delta); } else { const Point<int> childPos (child.getPosition()); clipObscuredRegions (child, g, newClip - childPos, childPos + delta); } } } } } static void subtractObscuredRegions (const Component& comp, RectangleList& result, const Point<int>& delta, const Rectangle<int>& clipRect, const Component* const compToAvoid) { for (int i = comp.childComponentList.size(); --i >= 0;) { const Component* const c = comp.childComponentList.getUnchecked(i); if (c != compToAvoid && c->isVisible()) { if (c->isOpaque() && c->componentTransparency == 0) { Rectangle<int> childBounds (c->bounds.getIntersection (clipRect)); childBounds.translate (delta.x, delta.y); result.subtract (childBounds); } else { Rectangle<int> newClip (clipRect.getIntersection (c->bounds)); newClip.translate (-c->getX(), -c->getY()); subtractObscuredRegions (*c, result, c->getPosition() + delta, newClip, compToAvoid); } } } } static Rectangle<int> getParentOrMainMonitorBounds (const Component& comp) { return comp.getParentComponent() != nullptr ? comp.getParentComponent()->getLocalBounds() : Desktop::getInstance().getMainMonitorArea(); } }; //============================================================================== class StandardCachedComponentImage : public CachedComponentImage { public: StandardCachedComponentImage (Component& owner_) noexcept : owner (owner_) {} void paint (Graphics& g) { const Rectangle<int> bounds (owner.getLocalBounds()); if (image.isNull() || image.getBounds() != bounds) { image = Image (owner.isOpaque() ? Image::RGB : Image::ARGB, jmax (1, bounds.getWidth()), jmax (1, bounds.getHeight()), ! owner.isOpaque()); validArea.clear(); } { Graphics imG (image); LowLevelGraphicsContext* const lg = imG.getInternalContext(); for (RectangleList::Iterator i (validArea); i.next();) lg->excludeClipRectangle (*i.getRectangle()); if (! lg->isClipEmpty()) { if (! owner.isOpaque()) { lg->setFill (Colours::transparentBlack); lg->fillRect (bounds, true); lg->setFill (Colours::black); } owner.paintEntireComponent (imG, true); } } validArea = bounds; g.setColour (Colours::black.withAlpha (owner.getAlpha())); g.drawImageAt (image, 0, 0); } void invalidateAll() { validArea.clear(); } void invalidate (const Rectangle<int>& area) { validArea.subtract (area); } void releaseResources() { image = Image::null; } private: Image image; RectangleList validArea; Component& owner; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StandardCachedComponentImage); }; //============================================================================== Component::Component() : parentComponent (nullptr), lookAndFeel (nullptr), effect (nullptr), componentFlags (0), componentTransparency (0) { } Component::Component (const String& name) : componentName (name), parentComponent (nullptr), lookAndFeel (nullptr), effect (nullptr), componentFlags (0), componentTransparency (0) { } Component::~Component() { #if ! JUCE_VC6 // (access to private union not allowed in VC6) static_jassert (sizeof (flags) <= sizeof (componentFlags)); #endif componentListeners.call (&ComponentListener::componentBeingDeleted, *this); masterReference.clear(); while (childComponentList.size() > 0) removeChildComponent (childComponentList.size() - 1, false, true); if (parentComponent != nullptr) parentComponent->removeChildComponent (parentComponent->childComponentList.indexOf (this), true, false); else if (currentlyFocusedComponent == this || isParentOf (currentlyFocusedComponent)) giveAwayFocus (currentlyFocusedComponent != this); if (flags.hasHeavyweightPeerFlag) removeFromDesktop(); // Something has added some children to this component during its destructor! Not a smart idea! jassert (childComponentList.size() == 0); } //============================================================================== void Component::setName (const String& name) { // if component methods are being called from threads other than the message // thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. CHECK_MESSAGE_MANAGER_IS_LOCKED if (componentName != name) { componentName = name; if (flags.hasHeavyweightPeerFlag) { ComponentPeer* const peer = getPeer(); jassert (peer != nullptr); if (peer != nullptr) peer->setTitle (name); } BailOutChecker checker (this); componentListeners.callChecked (checker, &ComponentListener::componentNameChanged, *this); } } void Component::setComponentID (const String& newID) { componentID = newID; } void Component::setVisible (bool shouldBeVisible) { if (flags.visibleFlag != shouldBeVisible) { // if component methods are being called from threads other than the message // thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. CHECK_MESSAGE_MANAGER_IS_LOCKED const WeakReference<Component> safePointer (this); flags.visibleFlag = shouldBeVisible; if (shouldBeVisible) repaint(); else repaintParent(); sendFakeMouseMove(); if (! shouldBeVisible) { if (cachedImage != nullptr) cachedImage->releaseResources(); if (currentlyFocusedComponent == this || isParentOf (currentlyFocusedComponent)) { if (parentComponent != nullptr) parentComponent->grabKeyboardFocus(); else giveAwayFocus (true); } } if (safePointer != nullptr) { sendVisibilityChangeMessage(); if (safePointer != nullptr && flags.hasHeavyweightPeerFlag) { ComponentPeer* const peer = getPeer(); jassert (peer != nullptr); if (peer != nullptr) { peer->setVisible (shouldBeVisible); internalHierarchyChanged(); } } } } } void Component::visibilityChanged() { } void Component::sendVisibilityChangeMessage() { BailOutChecker checker (this); visibilityChanged(); if (! checker.shouldBailOut()) componentListeners.callChecked (checker, &ComponentListener::componentVisibilityChanged, *this); } bool Component::isShowing() const { if (flags.visibleFlag) { if (parentComponent != nullptr) { return parentComponent->isShowing(); } else { const ComponentPeer* const peer = getPeer(); return peer != nullptr && ! peer->isMinimised(); } } return false; } //============================================================================== void* Component::getWindowHandle() const { const ComponentPeer* const peer = getPeer(); if (peer != nullptr) return peer->getNativeHandle(); return nullptr; } //============================================================================== void Component::addToDesktop (int styleWanted, void* nativeWindowToAttachTo) { // if component methods are being called from threads other than the message // thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. CHECK_MESSAGE_MANAGER_IS_LOCKED if (isOpaque()) styleWanted &= ~ComponentPeer::windowIsSemiTransparent; else styleWanted |= ComponentPeer::windowIsSemiTransparent; int currentStyleFlags = 0; // don't use getPeer(), so that we only get the peer that's specifically // for this comp, and not for one of its parents. ComponentPeer* peer = ComponentPeer::getPeerFor (this); if (peer != nullptr) currentStyleFlags = peer->getStyleFlags(); if (styleWanted != currentStyleFlags || ! flags.hasHeavyweightPeerFlag) { const WeakReference<Component> safePointer (this); #if JUCE_LINUX // it's wise to give the component a non-zero size before // putting it on the desktop, as X windows get confused by this, and // a (1, 1) minimum size is enforced here. setSize (jmax (1, getWidth()), jmax (1, getHeight())); #endif const Point<int> topLeft (getScreenPosition()); bool wasFullscreen = false; bool wasMinimised = false; ComponentBoundsConstrainer* currentConstainer = nullptr; Rectangle<int> oldNonFullScreenBounds; if (peer != nullptr) { wasFullscreen = peer->isFullScreen(); wasMinimised = peer->isMinimised(); currentConstainer = peer->getConstrainer(); oldNonFullScreenBounds = peer->getNonFullScreenBounds(); removeFromDesktop(); setTopLeftPosition (topLeft); } if (parentComponent != nullptr) parentComponent->removeChildComponent (this); if (safePointer != nullptr) { flags.hasHeavyweightPeerFlag = true; peer = createNewPeer (styleWanted, nativeWindowToAttachTo); Desktop::getInstance().addDesktopComponent (this); bounds.setPosition (topLeft); peer->setBounds (topLeft.x, topLeft.y, getWidth(), getHeight(), false); peer->setVisible (isVisible()); if (wasFullscreen) { peer->setFullScreen (true); peer->setNonFullScreenBounds (oldNonFullScreenBounds); } if (wasMinimised) peer->setMinimised (true); if (isAlwaysOnTop()) peer->setAlwaysOnTop (true); peer->setConstrainer (currentConstainer); repaint(); } internalHierarchyChanged(); } } void Component::removeFromDesktop() { // if component methods are being called from threads other than the message // thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. CHECK_MESSAGE_MANAGER_IS_LOCKED if (flags.hasHeavyweightPeerFlag) { ComponentPeer* const peer = ComponentPeer::getPeerFor (this); flags.hasHeavyweightPeerFlag = false; jassert (peer != nullptr); delete peer; Desktop::getInstance().removeDesktopComponent (this); } } bool Component::isOnDesktop() const noexcept { return flags.hasHeavyweightPeerFlag; } void Component::userTriedToCloseWindow() { /* This means that the user's trying to get rid of your window with the 'close window' system menu option (on windows) or possibly the task manager - you should really handle this and delete or hide your component in an appropriate way. If you want to ignore the event and don't want to trigger this assertion, just override this method and do nothing. */ jassertfalse; } void Component::minimisationStateChanged (bool) { } //============================================================================== void Component::setOpaque (const bool shouldBeOpaque) { if (shouldBeOpaque != flags.opaqueFlag) { flags.opaqueFlag = shouldBeOpaque; if (flags.hasHeavyweightPeerFlag) { const ComponentPeer* const peer = ComponentPeer::getPeerFor (this); if (peer != nullptr) { // to make it recreate the heavyweight window addToDesktop (peer->getStyleFlags()); } } repaint(); } } bool Component::isOpaque() const noexcept { return flags.opaqueFlag; } //============================================================================== void Component::setCachedComponentImage (CachedComponentImage* newCachedImage) { cachedImage = newCachedImage; } void Component::setBufferedToImage (const bool shouldBeBuffered) { // This assertion means that this component is already using a custom CachedComponentImage, // so by calling setBufferedToImage, you'll be deleting the custom one - this is almost certainly // not what you wanted to happen... If you really do know what you're doing here, and want to // avoid this assertion, just call setCachedComponentImage (nullptr) before setBufferedToImage(). jassert (cachedImage == nullptr || dynamic_cast <StandardCachedComponentImage*> (cachedImage.get()) != nullptr); if (shouldBeBuffered) { if (cachedImage == nullptr) cachedImage = new StandardCachedComponentImage (*this); } else { cachedImage = nullptr; } } //============================================================================== void Component::moveChildInternal (const int sourceIndex, const int destIndex) { if (sourceIndex != destIndex) { Component* const c = childComponentList.getUnchecked (sourceIndex); jassert (c != nullptr); c->repaintParent(); childComponentList.move (sourceIndex, destIndex); sendFakeMouseMove(); internalChildrenChanged(); } } void Component::toFront (const bool setAsForeground) { // if component methods are being called from threads other than the message // thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. CHECK_MESSAGE_MANAGER_IS_LOCKED if (flags.hasHeavyweightPeerFlag) { ComponentPeer* const peer = getPeer(); if (peer != nullptr) { peer->toFront (setAsForeground); if (setAsForeground && ! hasKeyboardFocus (true)) grabKeyboardFocus(); } } else if (parentComponent != nullptr) { const Array<Component*>& childList = parentComponent->childComponentList; if (childList.getLast() != this) { const int index = childList.indexOf (this); if (index >= 0) { int insertIndex = -1; if (! flags.alwaysOnTopFlag) { insertIndex = childList.size() - 1; while (insertIndex > 0 && childList.getUnchecked (insertIndex)->isAlwaysOnTop()) --insertIndex; } parentComponent->moveChildInternal (index, insertIndex); } } if (setAsForeground) { internalBroughtToFront(); grabKeyboardFocus(); } } } void Component::toBehind (Component* const other) { if (other != nullptr && other != this) { // the two components must belong to the same parent.. jassert (parentComponent == other->parentComponent); if (parentComponent != nullptr) { const Array<Component*>& childList = parentComponent->childComponentList; const int index = childList.indexOf (this); if (index >= 0 && childList [index + 1] != other) { int otherIndex = childList.indexOf (other); if (otherIndex >= 0) { if (index < otherIndex) --otherIndex; parentComponent->moveChildInternal (index, otherIndex); } } } else if (isOnDesktop()) { jassert (other->isOnDesktop()); if (other->isOnDesktop()) { ComponentPeer* const us = getPeer(); ComponentPeer* const them = other->getPeer(); jassert (us != nullptr && them != nullptr); if (us != nullptr && them != nullptr) us->toBehind (them); } } } } void Component::toBack() { if (isOnDesktop()) { jassertfalse; //xxx need to add this to native window } else if (parentComponent != nullptr) { const Array<Component*>& childList = parentComponent->childComponentList; if (childList.getFirst() != this) { const int index = childList.indexOf (this); if (index > 0) { int insertIndex = 0; if (flags.alwaysOnTopFlag) while (insertIndex < childList.size() && ! childList.getUnchecked (insertIndex)->isAlwaysOnTop()) ++insertIndex; parentComponent->moveChildInternal (index, insertIndex); } } } } void Component::setAlwaysOnTop (const bool shouldStayOnTop) { if (shouldStayOnTop != flags.alwaysOnTopFlag) { BailOutChecker checker (this); flags.alwaysOnTopFlag = shouldStayOnTop; if (isOnDesktop()) { ComponentPeer* const peer = getPeer(); jassert (peer != nullptr); if (peer != nullptr) { if (! peer->setAlwaysOnTop (shouldStayOnTop)) { // some kinds of peer can't change their always-on-top status, so // for these, we'll need to create a new window const int oldFlags = peer->getStyleFlags(); removeFromDesktop(); addToDesktop (oldFlags); } } } if (shouldStayOnTop && ! checker.shouldBailOut()) toFront (false); if (! checker.shouldBailOut()) internalHierarchyChanged(); } } bool Component::isAlwaysOnTop() const noexcept { return flags.alwaysOnTopFlag; } //============================================================================== int Component::proportionOfWidth (const float proportion) const noexcept { return roundToInt (proportion * bounds.getWidth()); } int Component::proportionOfHeight (const float proportion) const noexcept { return roundToInt (proportion * bounds.getHeight()); } int Component::getParentWidth() const noexcept { return parentComponent != nullptr ? parentComponent->getWidth() : getParentMonitorArea().getWidth(); } int Component::getParentHeight() const noexcept { return parentComponent != nullptr ? parentComponent->getHeight() : getParentMonitorArea().getHeight(); } int Component::getScreenX() const { return getScreenPosition().x; } int Component::getScreenY() const { return getScreenPosition().y; } Point<int> Component::getScreenPosition() const { return localPointToGlobal (Point<int>()); } Rectangle<int> Component::getScreenBounds() const { return localAreaToGlobal (getLocalBounds()); } Point<int> Component::getLocalPoint (const Component* source, const Point<int>& point) const { return ComponentHelpers::convertCoordinate (this, source, point); } Rectangle<int> Component::getLocalArea (const Component* source, const Rectangle<int>& area) const { return ComponentHelpers::convertCoordinate (this, source, area); } Point<int> Component::localPointToGlobal (const Point<int>& point) const { return ComponentHelpers::convertCoordinate (nullptr, this, point); } Rectangle<int> Component::localAreaToGlobal (const Rectangle<int>& area) const { return ComponentHelpers::convertCoordinate (nullptr, this, area); } /* Deprecated methods... */ Point<int> Component::relativePositionToGlobal (const Point<int>& relativePosition) const { return localPointToGlobal (relativePosition); } Point<int> Component::globalPositionToRelative (const Point<int>& screenPosition) const { return getLocalPoint (nullptr, screenPosition); } Point<int> Component::relativePositionToOtherComponent (const Component* const targetComponent, const Point<int>& positionRelativeToThis) const { return targetComponent == nullptr ? localPointToGlobal (positionRelativeToThis) : targetComponent->getLocalPoint (this, positionRelativeToThis); } //============================================================================== void Component::setBounds (const int x, const int y, int w, int h) { // if component methods are being called from threads other than the message // thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. CHECK_MESSAGE_MANAGER_IS_LOCKED if (w < 0) w = 0; if (h < 0) h = 0; const bool wasResized = (getWidth() != w || getHeight() != h); const bool wasMoved = (getX() != x || getY() != y); #if JUCE_DEBUG // It's a very bad idea to try to resize a window during its paint() method! jassert (! (flags.isInsidePaintCall && wasResized && isOnDesktop())); #endif if (wasMoved || wasResized) { const bool showing = isShowing(); if (showing) { // send a fake mouse move to trigger enter/exit messages if needed.. sendFakeMouseMove(); if (! flags.hasHeavyweightPeerFlag) repaintParent(); } bounds.setBounds (x, y, w, h); if (showing) { if (wasResized) repaint(); else if (! flags.hasHeavyweightPeerFlag) repaintParent(); } else if (cachedImage != nullptr) { cachedImage->invalidateAll(); } if (flags.hasHeavyweightPeerFlag) { ComponentPeer* const peer = getPeer(); if (peer != nullptr) { if (wasMoved && wasResized) peer->setBounds (getX(), getY(), getWidth(), getHeight(), false); else if (wasMoved) peer->setPosition (getX(), getY()); else if (wasResized) peer->setSize (getWidth(), getHeight()); } } sendMovedResizedMessages (wasMoved, wasResized); } } void Component::sendMovedResizedMessages (const bool wasMoved, const bool wasResized) { BailOutChecker checker (this); if (wasMoved) { moved(); if (checker.shouldBailOut()) return; } if (wasResized) { resized(); if (checker.shouldBailOut()) return; for (int i = childComponentList.size(); --i >= 0;) { childComponentList.getUnchecked(i)->parentSizeChanged(); if (checker.shouldBailOut()) return; i = jmin (i, childComponentList.size()); } } if (parentComponent != nullptr) parentComponent->childBoundsChanged (this); if (! checker.shouldBailOut()) componentListeners.callChecked (checker, &ComponentListener::componentMovedOrResized, *this, wasMoved, wasResized); } void Component::setSize (const int w, const int h) { setBounds (getX(), getY(), w, h); } void Component::setTopLeftPosition (const int x, const int y) { setBounds (x, y, getWidth(), getHeight()); } void Component::setTopLeftPosition (const Point<int>& pos) { setBounds (pos.x, pos.y, getWidth(), getHeight()); } void Component::setTopRightPosition (const int x, const int y) { setTopLeftPosition (x - getWidth(), y); } void Component::setBounds (const Rectangle<int>& r) { setBounds (r.getX(), r.getY(), r.getWidth(), r.getHeight()); } void Component::setBounds (const RelativeRectangle& newBounds) { newBounds.applyToComponent (*this); } void Component::setBounds (const String& newBoundsExpression) { setBounds (RelativeRectangle (newBoundsExpression)); } void Component::setBoundsRelative (const float x, const float y, const float w, const float h) { const int pw = getParentWidth(); const int ph = getParentHeight(); setBounds (roundToInt (x * pw), roundToInt (y * ph), roundToInt (w * pw), roundToInt (h * ph)); } void Component::setCentrePosition (const int x, const int y) { setTopLeftPosition (x - getWidth() / 2, y - getHeight() / 2); } void Component::setCentreRelative (const float x, const float y) { setCentrePosition (roundToInt (getParentWidth() * x), roundToInt (getParentHeight() * y)); } void Component::centreWithSize (const int width, const int height) { const Rectangle<int> parentArea (ComponentHelpers::getParentOrMainMonitorBounds (*this)); setBounds (parentArea.getCentreX() - width / 2, parentArea.getCentreY() - height / 2, width, height); } void Component::setBoundsInset (const BorderSize<int>& borders) { setBounds (borders.subtractedFrom (ComponentHelpers::getParentOrMainMonitorBounds (*this))); } void Component::setBoundsToFit (int x, int y, int width, int height, const Justification& justification, const bool onlyReduceInSize) { // it's no good calling this method unless both the component and // target rectangle have a finite size. jassert (getWidth() > 0 && getHeight() > 0 && width > 0 && height > 0); if (getWidth() > 0 && getHeight() > 0 && width > 0 && height > 0) { int newW, newH; if (onlyReduceInSize && getWidth() <= width && getHeight() <= height) { newW = getWidth(); newH = getHeight(); } else { const double imageRatio = getHeight() / (double) getWidth(); const double targetRatio = height / (double) width; if (imageRatio <= targetRatio) { newW = width; newH = jmin (height, roundToInt (newW * imageRatio)); } else { newH = height; newW = jmin (width, roundToInt (newH / imageRatio)); } } if (newW > 0 && newH > 0) setBounds (justification.appliedToRectangle (Rectangle<int> (newW, newH), Rectangle<int> (x, y, width, height))); } } //============================================================================== bool Component::isTransformed() const noexcept { return affineTransform != nullptr; } void Component::setTransform (const AffineTransform& newTransform) { // If you pass in a transform with no inverse, the component will have no dimensions, // and there will be all sorts of maths errors when converting coordinates. jassert (! newTransform.isSingularity()); if (newTransform.isIdentity()) { if (affineTransform != nullptr) { repaint(); affineTransform = nullptr; repaint(); sendMovedResizedMessages (false, false); } } else if (affineTransform == nullptr) { repaint(); affineTransform = new AffineTransform (newTransform); repaint(); sendMovedResizedMessages (false, false); } else if (*affineTransform != newTransform) { repaint(); *affineTransform = newTransform; repaint(); sendMovedResizedMessages (false, false); } } AffineTransform Component::getTransform() const { return affineTransform != nullptr ? *affineTransform : AffineTransform::identity; } //============================================================================== bool Component::hitTest (int x, int y) { if (! flags.ignoresMouseClicksFlag) return true; if (flags.allowChildMouseClicksFlag) { for (int i = childComponentList.size(); --i >= 0;) { Component& child = *childComponentList.getUnchecked (i); if (child.isVisible() && ComponentHelpers::hitTest (child, ComponentHelpers::convertFromParentSpace (child, Point<int> (x, y)))) return true; } } return false; } void Component::setInterceptsMouseClicks (const bool allowClicks, const bool allowClicksOnChildComponents) noexcept { flags.ignoresMouseClicksFlag = ! allowClicks; flags.allowChildMouseClicksFlag = allowClicksOnChildComponents; } void Component::getInterceptsMouseClicks (bool& allowsClicksOnThisComponent, bool& allowsClicksOnChildComponents) const noexcept { allowsClicksOnThisComponent = ! flags.ignoresMouseClicksFlag; allowsClicksOnChildComponents = flags.allowChildMouseClicksFlag; } bool Component::contains (const Point<int>& point) { if (ComponentHelpers::hitTest (*this, point)) { if (parentComponent != nullptr) { return parentComponent->contains (ComponentHelpers::convertToParentSpace (*this, point)); } else if (flags.hasHeavyweightPeerFlag) { const ComponentPeer* const peer = getPeer(); if (peer != nullptr) return peer->contains (point, true); } } return false; } bool Component::reallyContains (const Point<int>& point, const bool returnTrueIfWithinAChild) { if (! contains (point)) return false; Component* const top = getTopLevelComponent(); const Component* const compAtPosition = top->getComponentAt (top->getLocalPoint (this, point)); return (compAtPosition == this) || (returnTrueIfWithinAChild && isParentOf (compAtPosition)); } Component* Component::getComponentAt (const Point<int>& position) { if (flags.visibleFlag && ComponentHelpers::hitTest (*this, position)) { for (int i = childComponentList.size(); --i >= 0;) { Component* child = childComponentList.getUnchecked(i); child = child->getComponentAt (ComponentHelpers::convertFromParentSpace (*child, position)); if (child != nullptr) return child; } return this; } return nullptr; } Component* Component::getComponentAt (const int x, const int y) { return getComponentAt (Point<int> (x, y)); } //============================================================================== void Component::addChildComponent (Component* const child, int zOrder) { // if component methods are being called from threads other than the message // thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. CHECK_MESSAGE_MANAGER_IS_LOCKED if (child != nullptr && child->parentComponent != this) { if (child->parentComponent != nullptr) child->parentComponent->removeChildComponent (child); else child->removeFromDesktop(); child->parentComponent = this; if (child->isVisible()) child->repaintParent(); if (! child->isAlwaysOnTop()) { if (zOrder < 0 || zOrder > childComponentList.size()) zOrder = childComponentList.size(); while (zOrder > 0) { if (! childComponentList.getUnchecked (zOrder - 1)->isAlwaysOnTop()) break; --zOrder; } } childComponentList.insert (zOrder, child); child->internalHierarchyChanged(); internalChildrenChanged(); } } void Component::addAndMakeVisible (Component* const child, int zOrder) { if (child != nullptr) { child->setVisible (true); addChildComponent (child, zOrder); } } void Component::removeChildComponent (Component* const child) { removeChildComponent (childComponentList.indexOf (child), true, true); } Component* Component::removeChildComponent (const int index) { return removeChildComponent (index, true, true); } Component* Component::removeChildComponent (const int index, bool sendParentEvents, const bool sendChildEvents) { // if component methods are being called from threads other than the message // thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. CHECK_MESSAGE_MANAGER_IS_LOCKED Component* const child = childComponentList [index]; if (child != nullptr) { sendParentEvents = sendParentEvents && child->isShowing(); if (sendParentEvents) { sendFakeMouseMove(); if (child->isVisible()) child->repaintParent(); } childComponentList.remove (index); child->parentComponent = nullptr; if (child->cachedImage != nullptr) child->cachedImage->releaseResources(); // (NB: there are obscure situations where child->isShowing() = false, but it still has the focus) if (currentlyFocusedComponent == child || child->isParentOf (currentlyFocusedComponent)) { if (sendParentEvents) { const WeakReference<Component> thisPointer (this); giveAwayFocus (sendChildEvents || currentlyFocusedComponent != child); if (thisPointer == nullptr) return child; grabKeyboardFocus(); } else { giveAwayFocus (sendChildEvents || currentlyFocusedComponent != child); } } if (sendChildEvents) child->internalHierarchyChanged(); if (sendParentEvents) internalChildrenChanged(); } return child; } //============================================================================== void Component::removeAllChildren() { while (childComponentList.size() > 0) removeChildComponent (childComponentList.size() - 1); } void Component::deleteAllChildren() { while (childComponentList.size() > 0) delete (removeChildComponent (childComponentList.size() - 1)); } //============================================================================== int Component::getNumChildComponents() const noexcept { return childComponentList.size(); } Component* Component::getChildComponent (const int index) const noexcept { return childComponentList [index]; } int Component::getIndexOfChildComponent (const Component* const child) const noexcept { return childComponentList.indexOf (const_cast <Component*> (child)); } Component* Component::findChildWithID (const String& targetID) const noexcept { for (int i = childComponentList.size(); --i >= 0;) { Component* const c = childComponentList.getUnchecked(i); if (c->componentID == targetID) return c; } return nullptr; } Component* Component::getTopLevelComponent() const noexcept { const Component* comp = this; while (comp->parentComponent != nullptr) comp = comp->parentComponent; return const_cast <Component*> (comp); } bool Component::isParentOf (const Component* possibleChild) const noexcept { while (possibleChild != nullptr) { possibleChild = possibleChild->parentComponent; if (possibleChild == this) return true; } return false; } //============================================================================== void Component::parentHierarchyChanged() { } void Component::childrenChanged() { } void Component::internalChildrenChanged() { if (componentListeners.isEmpty()) { childrenChanged(); } else { BailOutChecker checker (this); childrenChanged(); if (! checker.shouldBailOut()) componentListeners.callChecked (checker, &ComponentListener::componentChildrenChanged, *this); } } void Component::internalHierarchyChanged() { BailOutChecker checker (this); parentHierarchyChanged(); if (checker.shouldBailOut()) return; componentListeners.callChecked (checker, &ComponentListener::componentParentHierarchyChanged, *this); if (checker.shouldBailOut()) return; for (int i = childComponentList.size(); --i >= 0;) { childComponentList.getUnchecked (i)->internalHierarchyChanged(); if (checker.shouldBailOut()) { // you really shouldn't delete the parent component during a callback telling you // that it's changed.. jassertfalse; return; } i = jmin (i, childComponentList.size()); } } //============================================================================== #if JUCE_MODAL_LOOPS_PERMITTED int Component::runModalLoop() { if (! MessageManager::getInstance()->isThisTheMessageThread()) { // use a callback so this can be called from non-gui threads return (int) (pointer_sized_int) MessageManager::getInstance() ->callFunctionOnMessageThread (&ComponentHelpers::runModalLoopCallback, this); } if (! isCurrentlyModal()) enterModalState (true); return ModalComponentManager::getInstance()->runEventLoopForCurrentComponent(); } #endif //============================================================================== void Component::enterModalState (const bool shouldTakeKeyboardFocus, ModalComponentManager::Callback* callback, const bool deleteWhenDismissed) { // if component methods are being called from threads other than the message // thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. CHECK_MESSAGE_MANAGER_IS_LOCKED // Check for an attempt to make a component modal when it already is! // This can cause nasty problems.. jassert (! flags.currentlyModalFlag); if (! isCurrentlyModal()) { ModalComponentManager* const mcm = ModalComponentManager::getInstance(); mcm->startModal (this, deleteWhenDismissed); mcm->attachCallback (this, callback); flags.currentlyModalFlag = true; setVisible (true); if (shouldTakeKeyboardFocus) grabKeyboardFocus(); } } void Component::exitModalState (const int returnValue) { if (flags.currentlyModalFlag) { if (MessageManager::getInstance()->isThisTheMessageThread()) { ModalComponentManager::getInstance()->endModal (this, returnValue); flags.currentlyModalFlag = false; ModalComponentManager::getInstance()->bringModalComponentsToFront(); } else { class ExitModalStateMessage : public CallbackMessage { public: ExitModalStateMessage (Component* const target_, const int result_) : target (target_), result (result_) {} void messageCallback() { if (target.get() != nullptr) // (get() required for VS2003 bug) target->exitModalState (result); } private: WeakReference<Component> target; int result; }; (new ExitModalStateMessage (this, returnValue))->post(); } } } bool Component::isCurrentlyModal() const noexcept { return flags.currentlyModalFlag && getCurrentlyModalComponent() == this; } bool Component::isCurrentlyBlockedByAnotherModalComponent() const { Component* const mc = getCurrentlyModalComponent(); return ! (mc == nullptr || mc == this || mc->isParentOf (this) || mc->canModalEventBeSentToComponent (this)); } int JUCE_CALLTYPE Component::getNumCurrentlyModalComponents() noexcept { return ModalComponentManager::getInstance()->getNumModalComponents(); } Component* JUCE_CALLTYPE Component::getCurrentlyModalComponent (int index) noexcept { return ModalComponentManager::getInstance()->getModalComponent (index); } //============================================================================== void Component::setBroughtToFrontOnMouseClick (const bool shouldBeBroughtToFront) noexcept { flags.bringToFrontOnClickFlag = shouldBeBroughtToFront; } bool Component::isBroughtToFrontOnMouseClick() const noexcept { return flags.bringToFrontOnClickFlag; } //============================================================================== void Component::setMouseCursor (const MouseCursor& newCursor) { if (cursor != newCursor) { cursor = newCursor; if (flags.visibleFlag) updateMouseCursor(); } } MouseCursor Component::getMouseCursor() { return cursor; } void Component::updateMouseCursor() const { Desktop::getInstance().getMainMouseSource().forceMouseCursorUpdate(); } //============================================================================== void Component::setRepaintsOnMouseActivity (const bool shouldRepaint) noexcept { flags.repaintOnMouseActivityFlag = shouldRepaint; } //============================================================================== void Component::setAlpha (const float newAlpha) { const uint8 newIntAlpha = (uint8) (255 - jlimit (0, 255, roundToInt (newAlpha * 255.0))); if (componentTransparency != newIntAlpha) { componentTransparency = newIntAlpha; if (flags.hasHeavyweightPeerFlag) { ComponentPeer* const peer = getPeer(); if (peer != nullptr) peer->setAlpha (newAlpha); } else { repaint(); } } } float Component::getAlpha() const { return (255 - componentTransparency) / 255.0f; } //============================================================================== void Component::repaint() { internalRepaintUnchecked (getLocalBounds(), true); } void Component::repaint (const int x, const int y, const int w, const int h) { internalRepaint (Rectangle<int> (x, y, w, h)); } void Component::repaint (const Rectangle<int>& area) { internalRepaint (area); } void Component::repaintParent() { if (parentComponent != nullptr) parentComponent->internalRepaint (ComponentHelpers::convertToParentSpace (*this, getLocalBounds())); } void Component::internalRepaint (const Rectangle<int>& area) { const Rectangle<int> r (area.getIntersection (getLocalBounds())); if (! r.isEmpty()) internalRepaintUnchecked (r, false); } void Component::internalRepaintUnchecked (const Rectangle<int>& area, const bool isEntireComponent) { // if component methods are being called from threads other than the message // thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. CHECK_MESSAGE_MANAGER_IS_LOCKED if (flags.visibleFlag) { if (flags.hasHeavyweightPeerFlag) { ComponentPeer* const peer = getPeer(); if (peer != nullptr) peer->repaint (area); } else { if (cachedImage != nullptr) { if (isEntireComponent) cachedImage->invalidateAll(); else cachedImage->invalidate (area); } if (parentComponent != nullptr) parentComponent->internalRepaint (ComponentHelpers::convertToParentSpace (*this, area)); } } } //============================================================================== void Component::paintWithinParentContext (Graphics& g) { g.setOrigin (getX(), getY()); if (cachedImage != nullptr) cachedImage->paint (g); else paintEntireComponent (g, false); } void Component::paintComponentAndChildren (Graphics& g) { const Rectangle<int> clipBounds (g.getClipBounds()); if (flags.dontClipGraphicsFlag) { paint (g); } else { g.saveState(); ComponentHelpers::clipObscuredRegions (*this, g, clipBounds, Point<int>()); if (! g.isClipEmpty()) paint (g); g.restoreState(); } for (int i = 0; i < childComponentList.size(); ++i) { Component& child = *childComponentList.getUnchecked (i); if (child.isVisible()) { if (child.affineTransform != nullptr) { g.saveState(); g.addTransform (*child.affineTransform); if ((child.flags.dontClipGraphicsFlag && ! g.isClipEmpty()) || g.reduceClipRegion (child.getBounds())) child.paintWithinParentContext (g); g.restoreState(); } else if (clipBounds.intersects (child.getBounds())) { g.saveState(); if (child.flags.dontClipGraphicsFlag) { child.paintWithinParentContext (g); } else if (g.reduceClipRegion (child.getBounds())) { bool nothingClipped = true; for (int j = i + 1; j < childComponentList.size(); ++j) { const Component& sibling = *childComponentList.getUnchecked (j); if (sibling.flags.opaqueFlag && sibling.isVisible() && sibling.affineTransform == nullptr) { nothingClipped = false; g.excludeClipRegion (sibling.getBounds()); } } if (nothingClipped || ! g.isClipEmpty()) child.paintWithinParentContext (g); } g.restoreState(); } } } g.saveState(); paintOverChildren (g); g.restoreState(); } void Component::paintEntireComponent (Graphics& g, const bool ignoreAlphaLevel) { #if JUCE_DEBUG flags.isInsidePaintCall = true; #endif if (effect != nullptr) { Image effectImage (flags.opaqueFlag ? Image::RGB : Image::ARGB, getWidth(), getHeight(), ! flags.opaqueFlag); { Graphics g2 (effectImage); paintComponentAndChildren (g2); } effect->applyEffect (effectImage, g, ignoreAlphaLevel ? 1.0f : getAlpha()); } else if (componentTransparency > 0 && ! ignoreAlphaLevel) { if (componentTransparency < 255) { g.beginTransparencyLayer (getAlpha()); paintComponentAndChildren (g); g.endTransparencyLayer(); } } else { paintComponentAndChildren (g); } #if JUCE_DEBUG flags.isInsidePaintCall = false; #endif } void Component::setPaintingIsUnclipped (const bool shouldPaintWithoutClipping) noexcept { flags.dontClipGraphicsFlag = shouldPaintWithoutClipping; } //============================================================================== Image Component::createComponentSnapshot (const Rectangle<int>& areaToGrab, const bool clipImageToComponentBounds) { Rectangle<int> r (areaToGrab); if (clipImageToComponentBounds) r = r.getIntersection (getLocalBounds()); Image componentImage (flags.opaqueFlag ? Image::RGB : Image::ARGB, jmax (1, r.getWidth()), jmax (1, r.getHeight()), true); Graphics imageContext (componentImage); imageContext.setOrigin (-r.getX(), -r.getY()); paintEntireComponent (imageContext, true); return componentImage; } void Component::setComponentEffect (ImageEffectFilter* const newEffect) { if (effect != newEffect) { effect = newEffect; repaint(); } } //============================================================================== LookAndFeel& Component::getLookAndFeel() const noexcept { const Component* c = this; do { if (c->lookAndFeel != nullptr) return *(c->lookAndFeel); c = c->parentComponent; } while (c != nullptr); return LookAndFeel::getDefaultLookAndFeel(); } void Component::setLookAndFeel (LookAndFeel* const newLookAndFeel) { if (lookAndFeel != newLookAndFeel) { lookAndFeel = newLookAndFeel; sendLookAndFeelChange(); } } void Component::lookAndFeelChanged() { } void Component::sendLookAndFeelChange() { repaint(); const WeakReference<Component> safePointer (this); lookAndFeelChanged(); if (safePointer != nullptr) { for (int i = childComponentList.size(); --i >= 0;) { childComponentList.getUnchecked (i)->sendLookAndFeelChange(); if (safePointer == nullptr) return; i = jmin (i, childComponentList.size()); } } } const Colour Component::findColour (const int colourId, const bool inheritFromParent) const { const var* const v = properties.getVarPointer (ComponentHelpers::getColourPropertyId (colourId)); if (v != nullptr) return Colour ((uint32) static_cast <int> (*v)); if (inheritFromParent && parentComponent != nullptr && (lookAndFeel == nullptr || ! lookAndFeel->isColourSpecified (colourId))) return parentComponent->findColour (colourId, true); return getLookAndFeel().findColour (colourId); } bool Component::isColourSpecified (const int colourId) const { return properties.contains (ComponentHelpers::getColourPropertyId (colourId)); } void Component::removeColour (const int colourId) { if (properties.remove (ComponentHelpers::getColourPropertyId (colourId))) colourChanged(); } void Component::setColour (const int colourId, const Colour& colour) { if (properties.set (ComponentHelpers::getColourPropertyId (colourId), (int) colour.getARGB())) colourChanged(); } void Component::copyAllExplicitColoursTo (Component& target) const { bool changed = false; for (int i = properties.size(); --i >= 0;) { const Identifier name (properties.getName(i)); if (name.toString().startsWith ("jcclr_")) if (target.properties.set (name, properties [name])) changed = true; } if (changed) target.colourChanged(); } void Component::colourChanged() { } //============================================================================== MarkerList* Component::getMarkers (bool /*xAxis*/) { return nullptr; } //============================================================================== Component::Positioner::Positioner (Component& component_) noexcept : component (component_) { } Component::Positioner* Component::getPositioner() const noexcept { return positioner; } void Component::setPositioner (Positioner* newPositioner) { // You can only assign a positioner to the component that it was created for! jassert (newPositioner == nullptr || this == &(newPositioner->getComponent())); positioner = newPositioner; } //============================================================================== Rectangle<int> Component::getLocalBounds() const noexcept { return Rectangle<int> (getWidth(), getHeight()); } Rectangle<int> Component::getBoundsInParent() const noexcept { return affineTransform == nullptr ? bounds : bounds.toFloat().transformed (*affineTransform).getSmallestIntegerContainer(); } void Component::getVisibleArea (RectangleList& result, const bool includeSiblings) const { result.clear(); const Rectangle<int> unclipped (ComponentHelpers::getUnclippedArea (*this)); if (! unclipped.isEmpty()) { result.add (unclipped); if (includeSiblings) { const Component* const c = getTopLevelComponent(); ComponentHelpers::subtractObscuredRegions (*c, result, getLocalPoint (c, Point<int>()), c->getLocalBounds(), this); } ComponentHelpers::subtractObscuredRegions (*this, result, Point<int>(), unclipped, nullptr); result.consolidate(); } } //============================================================================== void Component::mouseEnter (const MouseEvent&) { // base class does nothing } void Component::mouseExit (const MouseEvent&) { // base class does nothing } void Component::mouseDown (const MouseEvent&) { // base class does nothing } void Component::mouseUp (const MouseEvent&) { // base class does nothing } void Component::mouseDrag (const MouseEvent&) { // base class does nothing } void Component::mouseMove (const MouseEvent&) { // base class does nothing } void Component::mouseDoubleClick (const MouseEvent&) { // base class does nothing } void Component::mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY) { // the base class just passes this event up to its parent.. if (parentComponent != nullptr) parentComponent->mouseWheelMove (e.getEventRelativeTo (parentComponent), wheelIncrementX, wheelIncrementY); } //============================================================================== void Component::resized() { // base class does nothing } void Component::moved() { // base class does nothing } void Component::childBoundsChanged (Component*) { // base class does nothing } void Component::parentSizeChanged() { // base class does nothing } void Component::addComponentListener (ComponentListener* const newListener) { // if component methods are being called from threads other than the message // thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. CHECK_MESSAGE_MANAGER_IS_LOCKED componentListeners.add (newListener); } void Component::removeComponentListener (ComponentListener* const listenerToRemove) { componentListeners.remove (listenerToRemove); } //============================================================================== void Component::inputAttemptWhenModal() { ModalComponentManager::getInstance()->bringModalComponentsToFront(); getLookAndFeel().playAlertSound(); } bool Component::canModalEventBeSentToComponent (const Component*) { return false; } void Component::internalModalInputAttempt() { Component* const current = getCurrentlyModalComponent(); if (current != nullptr) current->inputAttemptWhenModal(); } //============================================================================== void Component::paint (Graphics&) { // all painting is done in the subclasses jassert (! isOpaque()); // if your component's opaque, you've gotta paint it! } void Component::paintOverChildren (Graphics&) { // all painting is done in the subclasses } //============================================================================== void Component::postCommandMessage (const int commandId) { class CustomCommandMessage : public CallbackMessage { public: CustomCommandMessage (Component* const target_, const int commandId_) : target (target_), commandId (commandId_) {} void messageCallback() { if (target.get() != nullptr) // (get() required for VS2003 bug) target->handleCommandMessage (commandId); } private: WeakReference<Component> target; int commandId; }; (new CustomCommandMessage (this, commandId))->post(); } void Component::handleCommandMessage (int) { // used by subclasses } //============================================================================== void Component::addMouseListener (MouseListener* const newListener, const bool wantsEventsForAllNestedChildComponents) { // if component methods are being called from threads other than the message // thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. CHECK_MESSAGE_MANAGER_IS_LOCKED // If you register a component as a mouselistener for itself, it'll receive all the events // twice - once via the direct callback that all components get anyway, and then again as a listener! jassert ((newListener != this) || wantsEventsForAllNestedChildComponents); if (mouseListeners == nullptr) mouseListeners = new MouseListenerList(); mouseListeners->addListener (newListener, wantsEventsForAllNestedChildComponents); } void Component::removeMouseListener (MouseListener* const listenerToRemove) { // if component methods are being called from threads other than the message // thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. CHECK_MESSAGE_MANAGER_IS_LOCKED if (mouseListeners != nullptr) mouseListeners->removeListener (listenerToRemove); } //============================================================================== void Component::internalMouseEnter (MouseInputSource& source, const Point<int>& relativePos, const Time& time) { if (isCurrentlyBlockedByAnotherModalComponent()) { // if something else is modal, always just show a normal mouse cursor source.showMouseCursor (MouseCursor::NormalCursor); return; } if (flags.repaintOnMouseActivityFlag) repaint(); BailOutChecker checker (this); const MouseEvent me (source, relativePos, source.getCurrentModifiers(), this, this, time, relativePos, time, 0, false); mouseEnter (me); if (checker.shouldBailOut()) return; Desktop::getInstance().getMouseListeners().callChecked (checker, &MouseListener::mouseEnter, me); MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseEnter, me); } void Component::internalMouseExit (MouseInputSource& source, const Point<int>& relativePos, const Time& time) { if (flags.repaintOnMouseActivityFlag) repaint(); BailOutChecker checker (this); const MouseEvent me (source, relativePos, source.getCurrentModifiers(), this, this, time, relativePos, time, 0, false); mouseExit (me); if (checker.shouldBailOut()) return; Desktop::getInstance().getMouseListeners().callChecked (checker, &MouseListener::mouseExit, me); MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseExit, me); } //============================================================================== void Component::internalMouseDown (MouseInputSource& source, const Point<int>& relativePos, const Time& time) { Desktop& desktop = Desktop::getInstance(); BailOutChecker checker (this); if (isCurrentlyBlockedByAnotherModalComponent()) { internalModalInputAttempt(); if (checker.shouldBailOut()) return; // If processing the input attempt has exited the modal loop, we'll allow the event // to be delivered.. if (isCurrentlyBlockedByAnotherModalComponent()) { // allow blocked mouse-events to go to global listeners.. const MouseEvent me (source, relativePos, source.getCurrentModifiers(), this, this, time, relativePos, time, source.getNumberOfMultipleClicks(), false); desktop.getMouseListeners().callChecked (checker, &MouseListener::mouseDown, me); return; } } { Component* c = this; while (c != nullptr) { if (c->isBroughtToFrontOnMouseClick()) { c->toFront (true); if (checker.shouldBailOut()) return; } c = c->parentComponent; } } if (! flags.dontFocusOnMouseClickFlag) { grabFocusInternal (focusChangedByMouseClick, true); if (checker.shouldBailOut()) return; } if (flags.repaintOnMouseActivityFlag) repaint(); const MouseEvent me (source, relativePos, source.getCurrentModifiers(), this, this, time, relativePos, time, source.getNumberOfMultipleClicks(), false); mouseDown (me); if (checker.shouldBailOut()) return; desktop.getMouseListeners().callChecked (checker, &MouseListener::mouseDown, me); MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDown, me); } //============================================================================== void Component::internalMouseUp (MouseInputSource& source, const Point<int>& relativePos, const Time& time, const ModifierKeys& oldModifiers) { BailOutChecker checker (this); if (flags.repaintOnMouseActivityFlag) repaint(); const MouseEvent me (source, relativePos, oldModifiers, this, this, time, getLocalPoint (nullptr, source.getLastMouseDownPosition()), source.getLastMouseDownTime(), source.getNumberOfMultipleClicks(), source.hasMouseMovedSignificantlySincePressed()); mouseUp (me); if (checker.shouldBailOut()) return; Desktop& desktop = Desktop::getInstance(); desktop.getMouseListeners().callChecked (checker, &MouseListener::mouseUp, me); MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseUp, me); if (checker.shouldBailOut()) return; // check for double-click if (me.getNumberOfClicks() >= 2) { mouseDoubleClick (me); if (checker.shouldBailOut()) return; desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDoubleClick, me); MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDoubleClick, me); } } void Component::internalMouseDrag (MouseInputSource& source, const Point<int>& relativePos, const Time& time) { BailOutChecker checker (this); const MouseEvent me (source, relativePos, source.getCurrentModifiers(), this, this, time, getLocalPoint (nullptr, source.getLastMouseDownPosition()), source.getLastMouseDownTime(), source.getNumberOfMultipleClicks(), source.hasMouseMovedSignificantlySincePressed()); mouseDrag (me); if (checker.shouldBailOut()) return; Desktop::getInstance().getMouseListeners().callChecked (checker, &MouseListener::mouseDrag, me); MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDrag, me); } void Component::internalMouseMove (MouseInputSource& source, const Point<int>& relativePos, const Time& time) { Desktop& desktop = Desktop::getInstance(); BailOutChecker checker (this); const MouseEvent me (source, relativePos, source.getCurrentModifiers(), this, this, time, relativePos, time, 0, false); if (isCurrentlyBlockedByAnotherModalComponent()) { // allow blocked mouse-events to go to global listeners.. desktop.sendMouseMove(); } else { mouseMove (me); if (checker.shouldBailOut()) return; desktop.getMouseListeners().callChecked (checker, &MouseListener::mouseMove, me); MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseMove, me); } } void Component::internalMouseWheel (MouseInputSource& source, const Point<int>& relativePos, const Time& time, const float amountX, const float amountY) { Desktop& desktop = Desktop::getInstance(); BailOutChecker checker (this); const float wheelIncrementX = amountX / 256.0f; const float wheelIncrementY = amountY / 256.0f; const MouseEvent me (source, relativePos, source.getCurrentModifiers(), this, this, time, relativePos, time, 0, false); if (isCurrentlyBlockedByAnotherModalComponent()) { // allow blocked mouse-events to go to global listeners.. desktop.mouseListeners.callChecked (checker, &MouseListener::mouseWheelMove, me, wheelIncrementX, wheelIncrementY); } else { mouseWheelMove (me, wheelIncrementX, wheelIncrementY); if (checker.shouldBailOut()) return; desktop.mouseListeners.callChecked (checker, &MouseListener::mouseWheelMove, me, wheelIncrementX, wheelIncrementY); if (! checker.shouldBailOut()) MouseListenerList::sendWheelEvent (*this, checker, me, wheelIncrementX, wheelIncrementY); } } void Component::sendFakeMouseMove() const { MouseInputSource& mainMouse = Desktop::getInstance().getMainMouseSource(); if (! mainMouse.isDragging()) mainMouse.triggerFakeMove(); } void Component::beginDragAutoRepeat (const int interval) { Desktop::getInstance().beginDragAutoRepeat (interval); } void Component::broughtToFront() { } void Component::internalBroughtToFront() { if (flags.hasHeavyweightPeerFlag) Desktop::getInstance().componentBroughtToFront (this); BailOutChecker checker (this); broughtToFront(); if (checker.shouldBailOut()) return; componentListeners.callChecked (checker, &ComponentListener::componentBroughtToFront, *this); if (checker.shouldBailOut()) return; // When brought to the front and there's a modal component blocking this one, // we need to bring the modal one to the front instead.. Component* const cm = getCurrentlyModalComponent(); if (cm != nullptr && cm->getTopLevelComponent() != getTopLevelComponent()) ModalComponentManager::getInstance()->bringModalComponentsToFront (false); // very important that this is false, otherwise in Windows, // non-front components can't get focus when another modal comp is // active, and therefore can't receive mouse-clicks } void Component::focusGained (FocusChangeType) { // base class does nothing } void Component::internalFocusGain (const FocusChangeType cause) { internalFocusGain (cause, WeakReference<Component> (this)); } void Component::internalFocusGain (const FocusChangeType cause, const WeakReference<Component>& safePointer) { focusGained (cause); if (safePointer != nullptr) internalChildFocusChange (cause, safePointer); } void Component::focusLost (FocusChangeType) { // base class does nothing } void Component::internalFocusLoss (const FocusChangeType cause) { const WeakReference<Component> safePointer (this); focusLost (focusChangedDirectly); if (safePointer != nullptr) internalChildFocusChange (cause, safePointer); } void Component::focusOfChildComponentChanged (FocusChangeType /*cause*/) { // base class does nothing } void Component::internalChildFocusChange (FocusChangeType cause, const WeakReference<Component>& safePointer) { const bool childIsNowFocused = hasKeyboardFocus (true); if (flags.childCompFocusedFlag != childIsNowFocused) { flags.childCompFocusedFlag = childIsNowFocused; focusOfChildComponentChanged (cause); if (safePointer == nullptr) return; } if (parentComponent != nullptr) parentComponent->internalChildFocusChange (cause, WeakReference<Component> (parentComponent)); } //============================================================================== bool Component::isEnabled() const noexcept { return (! flags.isDisabledFlag) && (parentComponent == nullptr || parentComponent->isEnabled()); } void Component::setEnabled (const bool shouldBeEnabled) { if (flags.isDisabledFlag == shouldBeEnabled) { flags.isDisabledFlag = ! shouldBeEnabled; // if any parent components are disabled, setting our flag won't make a difference, // so no need to send a change message if (parentComponent == nullptr || parentComponent->isEnabled()) sendEnablementChangeMessage(); } } void Component::sendEnablementChangeMessage() { const WeakReference<Component> safePointer (this); enablementChanged(); if (safePointer == nullptr) return; for (int i = getNumChildComponents(); --i >= 0;) { Component* const c = getChildComponent (i); if (c != nullptr) { c->sendEnablementChangeMessage(); if (safePointer == nullptr) return; } } } void Component::enablementChanged() { } //============================================================================== void Component::setWantsKeyboardFocus (const bool wantsFocus) noexcept { flags.wantsFocusFlag = wantsFocus; } void Component::setMouseClickGrabsKeyboardFocus (const bool shouldGrabFocus) { flags.dontFocusOnMouseClickFlag = ! shouldGrabFocus; } bool Component::getMouseClickGrabsKeyboardFocus() const noexcept { return ! flags.dontFocusOnMouseClickFlag; } bool Component::getWantsKeyboardFocus() const noexcept { return flags.wantsFocusFlag && ! flags.isDisabledFlag; } void Component::setFocusContainer (const bool shouldBeFocusContainer) noexcept { flags.isFocusContainerFlag = shouldBeFocusContainer; } bool Component::isFocusContainer() const noexcept { return flags.isFocusContainerFlag; } static const Identifier juce_explicitFocusOrderId ("_jexfo"); int Component::getExplicitFocusOrder() const { return properties [juce_explicitFocusOrderId]; } void Component::setExplicitFocusOrder (const int newFocusOrderIndex) { properties.set (juce_explicitFocusOrderId, newFocusOrderIndex); } KeyboardFocusTraverser* Component::createFocusTraverser() { if (flags.isFocusContainerFlag || parentComponent == nullptr) return new KeyboardFocusTraverser(); return parentComponent->createFocusTraverser(); } void Component::takeKeyboardFocus (const FocusChangeType cause) { // give the focus to this component if (currentlyFocusedComponent != this) { // get the focus onto our desktop window ComponentPeer* const peer = getPeer(); if (peer != nullptr) { const WeakReference<Component> safePointer (this); peer->grabFocus(); if (peer->isFocused() && currentlyFocusedComponent != this) { WeakReference<Component> componentLosingFocus (currentlyFocusedComponent); currentlyFocusedComponent = this; Desktop::getInstance().triggerFocusCallback(); // call this after setting currentlyFocusedComponent so that the one that's // losing it has a chance to see where focus is going if (componentLosingFocus != nullptr) componentLosingFocus->internalFocusLoss (cause); if (currentlyFocusedComponent == this) internalFocusGain (cause, safePointer); } } } } void Component::grabFocusInternal (const FocusChangeType cause, const bool canTryParent) { if (isShowing()) { if (flags.wantsFocusFlag && (isEnabled() || parentComponent == nullptr)) { takeKeyboardFocus (cause); } else { if (isParentOf (currentlyFocusedComponent) && currentlyFocusedComponent->isShowing()) { // do nothing if the focused component is actually a child of ours.. } else { // find the default child component.. ScopedPointer <KeyboardFocusTraverser> traverser (createFocusTraverser()); if (traverser != nullptr) { Component* const defaultComp = traverser->getDefaultComponent (this); traverser = nullptr; if (defaultComp != nullptr) { defaultComp->grabFocusInternal (cause, false); return; } } if (canTryParent && parentComponent != nullptr) { // if no children want it and we're allowed to try our parent comp, // then pass up to parent, which will try our siblings. parentComponent->grabFocusInternal (cause, true); } } } } } void Component::grabKeyboardFocus() { // if component methods are being called from threads other than the message // thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. CHECK_MESSAGE_MANAGER_IS_LOCKED grabFocusInternal (focusChangedDirectly, true); } void Component::moveKeyboardFocusToSibling (const bool moveToNext) { // if component methods are being called from threads other than the message // thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. CHECK_MESSAGE_MANAGER_IS_LOCKED if (parentComponent != nullptr) { ScopedPointer <KeyboardFocusTraverser> traverser (createFocusTraverser()); if (traverser != nullptr) { Component* const nextComp = moveToNext ? traverser->getNextComponent (this) : traverser->getPreviousComponent (this); traverser = nullptr; if (nextComp != nullptr) { if (nextComp->isCurrentlyBlockedByAnotherModalComponent()) { const WeakReference<Component> nextCompPointer (nextComp); internalModalInputAttempt(); if (nextCompPointer == nullptr || nextComp->isCurrentlyBlockedByAnotherModalComponent()) return; } nextComp->grabFocusInternal (focusChangedByTabKey, true); return; } } parentComponent->moveKeyboardFocusToSibling (moveToNext); } } bool Component::hasKeyboardFocus (const bool trueIfChildIsFocused) const { return (currentlyFocusedComponent == this) || (trueIfChildIsFocused && isParentOf (currentlyFocusedComponent)); } Component* JUCE_CALLTYPE Component::getCurrentlyFocusedComponent() noexcept { return currentlyFocusedComponent; } void Component::giveAwayFocus (const bool sendFocusLossEvent) { Component* const componentLosingFocus = currentlyFocusedComponent; currentlyFocusedComponent = nullptr; if (sendFocusLossEvent && componentLosingFocus != nullptr) componentLosingFocus->internalFocusLoss (focusChangedDirectly); Desktop::getInstance().triggerFocusCallback(); } //============================================================================== bool Component::isMouseOver (const bool includeChildren) const { const Desktop& desktop = Desktop::getInstance(); for (int i = desktop.getNumMouseSources(); --i >= 0;) { const MouseInputSource* const mi = desktop.getMouseSource(i); Component* const c = mi->getComponentUnderMouse(); if ((c == this || (includeChildren && isParentOf (c))) && c->reallyContains (c->getLocalPoint (nullptr, mi->getScreenPosition()), false)) return true; } return false; } bool Component::isMouseButtonDown() const { const Desktop& desktop = Desktop::getInstance(); for (int i = desktop.getNumMouseSources(); --i >= 0;) { const MouseInputSource* const mi = desktop.getMouseSource(i); if (mi->isDragging() && mi->getComponentUnderMouse() == this) return true; } return false; } bool Component::isMouseOverOrDragging() const { const Desktop& desktop = Desktop::getInstance(); for (int i = desktop.getNumMouseSources(); --i >= 0;) if (desktop.getMouseSource(i)->getComponentUnderMouse() == this) return true; return false; } bool JUCE_CALLTYPE Component::isMouseButtonDownAnywhere() noexcept { return ModifierKeys::getCurrentModifiers().isAnyMouseButtonDown(); } Point<int> Component::getMouseXYRelative() const { return getLocalPoint (nullptr, Desktop::getMousePosition()); } //============================================================================== Rectangle<int> Component::getParentMonitorArea() const { return Desktop::getInstance().getMonitorAreaContaining (getScreenBounds().getCentre()); } //============================================================================== void Component::addKeyListener (KeyListener* const newListener) { if (keyListeners == nullptr) keyListeners = new Array <KeyListener*>(); keyListeners->addIfNotAlreadyThere (newListener); } void Component::removeKeyListener (KeyListener* const listenerToRemove) { if (keyListeners != nullptr) keyListeners->removeValue (listenerToRemove); } bool Component::keyPressed (const KeyPress&) { return false; } bool Component::keyStateChanged (const bool /*isKeyDown*/) { return false; } void Component::modifierKeysChanged (const ModifierKeys& modifiers) { if (parentComponent != nullptr) parentComponent->modifierKeysChanged (modifiers); } void Component::internalModifierKeysChanged() { sendFakeMouseMove(); modifierKeysChanged (ModifierKeys::getCurrentModifiers()); } //============================================================================== ComponentPeer* Component::getPeer() const { if (flags.hasHeavyweightPeerFlag) return ComponentPeer::getPeerFor (this); else if (parentComponent == nullptr) return nullptr; return parentComponent->getPeer(); } //============================================================================== Component::BailOutChecker::BailOutChecker (Component* const component) : safePointer (component) { jassert (component != nullptr); } bool Component::BailOutChecker::shouldBailOut() const noexcept { return safePointer == nullptr; } END_JUCE_NAMESPACE
[ "ow3nskip" ]
[ [ [ 1, 3043 ] ] ]
2a201b5e5531afadbe1f30852b59b8f74ead2ff3
5a48b6a95f18598181ef75dba2930a9d1720deae
/LuaEngine/Process/ProcessLua_HGEHelp_hgeSprite.cpp
a331e4445cd3be5c1e7627f1398e08f4f8adb82e
[]
no_license
CBE7F1F65/f980f016e8cbe587c9148f07b799438c
078950c80e3680880bc6b3751fcc345ebc8fe8e5
1aaed5baef10a5b9144f20603d672ea5ac76b3cc
refs/heads/master
2021-01-15T10:42:46.944415
2010-08-28T19:25:48
2010-08-28T19:25:48
32,192,651
0
0
null
null
null
null
UTF-8
C++
false
false
9,303
cpp
#include "../Header/Process.h" #include "../Header/LuaConstDefine.h" hgeSprite * Process::_Helper_New_hgeSprite() { hgeSprite * _sprite = NULL; _sprite = new hgeSprite(); if (_sprite) { spriteList.push_back(_sprite); } return _sprite; } hgeSprite * Process::_Helper_New_hgeSprite(HTEXTURE tex, float x, float y, float w, float h) { hgeSprite * _sprite = NULL; _sprite = new hgeSprite(tex, x, y ,w, h); if (_sprite) { spriteList.push_back(_sprite); } return _sprite; } hgeSprite * Process::_Helper_New_hgeSprite(const hgeSprite & spr) { hgeSprite * _sprite = NULL; _sprite = new hgeSprite(spr); if (_sprite) { spriteList.push_back(_sprite); } return _sprite; } hgeSprite * Process::_LuaHelper_hgeSprite_Get(LuaStack * args) { LuaObject _obj = (*args)[1]; return (hgeSprite *)_LuaHelper_GetDWORD(&_obj); } void Process::_LuaHelper_hgeSprite_DeleteSprite(hgeSprite * _sprite) { if (_sprite) { delete _sprite; for (list<hgeSprite *>::iterator it=spriteList.begin(); it!=spriteList.end(); it++) { if ((*it) == _sprite) { spriteList.erase(it); break; } } _sprite = NULL; } } void Process::_LuaHelper_hgeSprite_DeleteAllSprite() { hgeSprite * _sprite; for (list<hgeSprite *>::iterator it=spriteList.begin(); it!=spriteList.end(); it++) { _sprite = *it; if (_sprite) { delete _sprite; _sprite = NULL; } } spriteList.clear(); } int Process::LuaFn_hgeSprite_NewSprite(LuaState * ls) { LuaStack args(ls); DWORD dret = 0; hgeSprite * _sprite = NULL; int argscount = args.Count(); if (argscount > 0) { LuaObject _obj; if (argscount > 1) { _obj = args[1]; HTEXTURE _htexture = _LuaHelper_GetHTEXTURE(&_obj); float x = args[2].GetFloat(); float y = args[3].GetFloat(); float w = args[4].GetFloat(); float h = args[5].GetFloat(); _sprite = _Helper_New_hgeSprite(_htexture, x, y, w, h); } else { _obj = args[1]; hgeSprite * __sprite = (hgeSprite *)(_LuaHelper_GetDWORD(&_obj)); _sprite = _Helper_New_hgeSprite(*__sprite); } } else { _sprite = _Helper_New_hgeSprite(); } dret = (DWORD)_sprite; _LuaHelper_PushDWORD(ls, dret); return 1; } int Process::LuaFn_hgeSprite_DeleteSprite(LuaState * ls) { LuaStack args(ls); if (args.Count() > 0) { hgeSprite * _sprite = _LuaHelper_hgeSprite_Get(&args); _LuaHelper_hgeSprite_DeleteSprite(_sprite); } else { _LuaHelper_hgeSprite_DeleteAllSprite(); } return 0; } int Process::LuaFn_hgeSprite_Render(LuaState * ls) { LuaStack args(ls); hgeSprite * _sprite = _LuaHelper_hgeSprite_Get(&args); int argscount = args.Count(); if (argscount > 2) { float rot = 0.0f; float hscale=1.0f; float vscale=0.0f; if (argscount > 3) { if (!args[4].IsNil()) { rot = args[4].GetFloat(); } if (argscount > 4) { if (!args[5].IsNil()) { hscale = args[5].GetFloat(); } if (argscount > 5) { if (!args[6].IsNil()) { vscale = args[6].GetFloat(); } } } } _sprite->RenderEx(args[2].GetFloat(), args[3].GetFloat(), rot, hscale, vscale); } else { _sprite->Render(args[2].GetFloat(), args[3].GetFloat()); } return 0; } int Process::LuaFn_hgeSprite_RenderStretch(LuaState * ls) { LuaStack args(ls); hgeSprite * _sprite = _LuaHelper_hgeSprite_Get(&args); _sprite->RenderStretch(args[2].GetFloat(), args[3].GetFloat(), args[4].GetFloat(), args[5].GetFloat()); return 0; } int Process::LuaFn_hgeSprite_Render4V(LuaState * ls) { LuaStack args(ls); hgeSprite * _sprite = _LuaHelper_hgeSprite_Get(&args); _sprite->Render4V(args[2].GetFloat(), args[3].GetFloat(), args[4].GetFloat(), args[5].GetFloat(), args[6].GetFloat(), args[7].GetFloat(), args[8].GetFloat(), args[9].GetFloat()); return 0; } int Process::LuaFn_hgeSprite_SetTexture(LuaState * ls) { LuaStack args(ls); hgeSprite * _sprite = _LuaHelper_hgeSprite_Get(&args); LuaObject _obj = args[2]; HTEXTURE _htexture = _LuaHelper_GetHTEXTURE(&_obj); _sprite->SetTexture(_htexture); return 0; } int Process::LuaFn_hgeSprite_SetTextureRect(LuaState * ls) { LuaStack args(ls); hgeSprite * _sprite = _LuaHelper_hgeSprite_Get(&args); bool adjSize = true; if (args.Count() > 5) { adjSize = args[6].GetBoolean(); } _sprite->SetTextureRect(args[2].GetFloat(), args[3].GetFloat(), args[4].GetFloat(), args[5].GetFloat(), adjSize); return 0; } int Process::LuaFn_hgeSprite_SetColor(LuaState * ls) { LuaStack args(ls); hgeSprite * _sprite = _LuaHelper_hgeSprite_Get(&args); int argscount = args.Count(); LuaObject _obj; if (argscount > 3) { DWORD col[4]; for (int i=0; i<4; i++) { _obj = args[i+2]; col[i] = _LuaHelper_GetColor(&_obj); } _sprite->SetColor(col[0], col[1], col[2], col[3]); } else { int i=-1; if (argscount > 2) { i = args[3].GetInteger(); } DWORD col; _obj = args[2]; col = _LuaHelper_GetColor(&_obj); _sprite->SetColor(col, i); } return 0; } int Process::LuaFn_hgeSprite_SetZ(LuaState * ls) { LuaStack args(ls); hgeSprite * _sprite = _LuaHelper_hgeSprite_Get(&args); int argscount = args.Count(); if (argscount > 3) { _sprite->SetZ(args[2].GetFloat(), args[3].GetFloat(), args[4].GetFloat(), args[5].GetFloat()); } else { int i=-1; if (argscount > 2) { i = args[3].GetInteger(); } _sprite->SetZ(args[2].GetFloat(), i); } return 0; } int Process::LuaFn_hgeSprite_SetBlendMode(LuaState * ls) { LuaStack args(ls); hgeSprite * _sprite = _LuaHelper_hgeSprite_Get(&args); _sprite->SetBlendMode(args[2].GetInteger()); return 0; } int Process::LuaFn_hgeSprite_SetHotSpot(LuaState * ls) { LuaStack args(ls); hgeSprite * _sprite = _LuaHelper_hgeSprite_Get(&args); _sprite->SetHotSpot(args[2].GetFloat(), args[3].GetFloat()); return 0; } int Process::LuaFn_hgeSprite_SetFlip(LuaState * ls) { LuaStack args(ls); hgeSprite * _sprite = _LuaHelper_hgeSprite_Get(&args); bool bHotSpot = false; if (args.Count() > 3) { bHotSpot = args[4].GetBoolean(); } _sprite->SetFlip(args[2].GetBoolean(), args[3].GetBoolean(), bHotSpot); return 0; } int Process::LuaFn_hgeSprite_GetTexture(LuaState * ls) { LuaStack args(ls); hgeSprite * _sprite = _LuaHelper_hgeSprite_Get(&args); HTEXTURE texret; texret = _sprite->GetTexture(); _LuaHelper_PushHTEXTURE(ls, texret); return 1; } int Process::LuaFn_hgeSprite_GetTextureRect(LuaState * ls) { LuaStack args(ls); hgeSprite * _sprite = _LuaHelper_hgeSprite_Get(&args); float x; float y; float w; float h; _sprite->GetTextureRect(&x, &y, &w, &h); ls->PushNumber(x); ls->PushNumber(y); ls->PushNumber(w); ls->PushNumber(h); return 4; } int Process::LuaFn_hgeSprite_GetColor(LuaState * ls) { LuaStack args(ls); hgeSprite * _sprite = _LuaHelper_hgeSprite_Get(&args); DWORD dret; int i=0; if (args.Count() > 1) { i = args[2].GetInteger(); } dret = _sprite->GetColor(i); _LuaHelper_PushDWORD(ls, dret); return 1; } int Process::LuaFn_hgeSprite_GetZ(LuaState * ls) { LuaStack args(ls); hgeSprite * _sprite = _LuaHelper_hgeSprite_Get(&args); float fret; int i=0; if (args.Count() > 1) { i = args[2].GetInteger(); } fret = _sprite->GetZ(i); ls->PushNumber(fret); return 1; } int Process::LuaFn_hgeSprite_GetBlendMode(LuaState * ls) { LuaStack args(ls); hgeSprite * _sprite = _LuaHelper_hgeSprite_Get(&args); int iret; iret = _sprite->GetBlendMode(); ls->PushInteger(iret); return 1; } int Process::LuaFn_hgeSprite_GetHotSpot(LuaState * ls) { LuaStack args(ls); hgeSprite * _sprite = _LuaHelper_hgeSprite_Get(&args); float x; float y; _sprite->GetHotSpot(&x, &y); ls->PushNumber(x); ls->PushNumber(y); return 2; } int Process::LuaFn_hgeSprite_GetFlip(LuaState * ls) { LuaStack args(ls); hgeSprite * _sprite = _LuaHelper_hgeSprite_Get(&args); bool bX; bool bY; _sprite->GetFlip(&bX, &bY); ls->PushBoolean(bX); ls->PushBoolean(bY); return 2; } int Process::LuaFn_hgeSprite_GetWidth(LuaState * ls) { LuaStack args(ls); hgeSprite * _sprite = _LuaHelper_hgeSprite_Get(&args); float fret; fret = _sprite->GetWidth(); ls->PushNumber(fret); return 1; } int Process::LuaFn_hgeSprite_GetHeight(LuaState * ls) { LuaStack args(ls); hgeSprite * _sprite = _LuaHelper_hgeSprite_Get(&args); float fret; fret = _sprite->GetHeight(); ls->PushNumber(fret); return 1; } int Process::LuaFn_hgeSprite_GetBoundingBox(LuaState * ls) { LuaStack args(ls); hgeSprite * _sprite = _LuaHelper_hgeSprite_Get(&args); hgeRect rect; if (args.Count() > 3) { _sprite->GetBoundingBoxEx(args[2].GetFloat(), args[3].GetFloat(), args[4].GetFloat(), args[5].GetFloat(), args[6].GetFloat(), &rect); } else { _sprite->GetBoundingBox(args[2].GetFloat(), args[3].GetFloat(), &rect); } ls->PushNumber(rect.x1); ls->PushNumber(rect.y1); ls->PushNumber(rect.x2-rect.x1); ls->PushNumber(rect.y2-rect.y1); return 4; }
[ "CBE7F1F65@120521f8-859b-11de-8382-973a19579e60" ]
[ [ [ 1, 459 ] ] ]
b3194acc667ccf5268d6da8cf33849637e095c8a
d01196cdfc4451c4e1c88343bdb1eb4db9c5ac18
/source/server/ents/baselogic.cpp
e565d6380546ea46b1b3deeeffb57a415b38315b
[]
no_license
ferhan66h/Xash3D_ancient
7491cd4ff1c7d0b48300029db24d7e08ba96e88a
075e0a6dae12a0952065eb9b2954be4a8827c72f
refs/heads/master
2021-12-10T07:55:29.592432
2010-05-09T00:00:00
2016-07-30T17:37:36
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
39,926
cpp
//======================================================================= // Copyright (C) Shambler Team 2004 // logicentity.cpp - all entities with prefix "logic_" // additional entities for smart system //======================================================================= #include "extdll.h" #include "utils.h" #include "cbase.h" #include "defaults.h" // Use CBaseDelay as main function (renamed as CBaseLogic, see declaration in cbase.h). //======================================================================= // main functions () //======================================================================= void CBaseLogic :: KeyValue( KeyValueData *pkvd ) { if (FStrEq( pkvd->szKeyName, "delay" )) { m_flDelay = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } else if (FStrEq( pkvd->szKeyName, "wait" )) { m_flWait = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } else if (FStrEq(pkvd->szKeyName, "master")) { m_sMaster = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } else CBaseEntity::KeyValue( pkvd ); } BOOL CBaseLogic :: IsLockedByMaster( void ) { if (UTIL_IsMasterTriggered(m_sMaster, m_hActivator)) return FALSE; return TRUE; } BOOL CBaseLogic :: IsLockedByMaster( CBaseEntity *pActivator ) { if (UTIL_IsMasterTriggered(m_sMaster, pActivator)) return FALSE; return TRUE; } BOOL CBaseLogic :: IsLockedByMaster( USE_TYPE useType ) { if (UTIL_IsMasterTriggered(m_sMaster, m_hActivator)) return FALSE; else if (useType == USE_SHOWINFO) return FALSE;//pass to debug info return TRUE; } TYPEDESCRIPTION CBaseLogic::m_SaveData[] = { DEFINE_FIELD( CBaseLogic, m_flDelay, FIELD_FLOAT ), DEFINE_FIELD( CBaseLogic, m_flWait, FIELD_FLOAT ), DEFINE_FIELD( CBaseLogic, m_hActivator, FIELD_EHANDLE ), DEFINE_FIELD( CBaseLogic, m_hTarget, FIELD_EHANDLE ), DEFINE_FIELD( CBaseLogic, m_iState, FIELD_INTEGER ), DEFINE_FIELD( CBaseLogic, m_sMaster, FIELD_STRING), DEFINE_FIELD( CBaseLogic, m_sSet, FIELD_STRING), DEFINE_FIELD( CBaseLogic, m_sReset, FIELD_STRING), };IMPLEMENT_SAVERESTORE( CBaseLogic, CBaseEntity ); //======================================================================= // Logic_generator //======================================================================= #define NORMAL_MODE 0 #define RANDOM_MODE 1 #define RANDOM_MODE_WITH_DEC 2 #define SF_RANDOM 0x2 #define SF_DEC 0x4 class CGenerator : public CBaseLogic { public: void KeyValue( KeyValueData *pkvd ); void Spawn( void ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void Think (void); virtual int Save( CSave &save ); virtual int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; private: int m_iFireCount; int m_iMaxFireCount; }; LINK_ENTITY_TO_CLASS( logic_generator, CGenerator ); void CGenerator :: Spawn() { // Xash 0.2 compatible if( pev->spawnflags & SF_RANDOM ) pev->button = RANDOM_MODE; if( pev->spawnflags & SF_DEC ) pev->button = RANDOM_MODE_WITH_DEC; if( pev->button == RANDOM_MODE || pev->button == RANDOM_MODE_WITH_DEC ) { // set delay with decceleration if( !m_flDelay || pev->button == RANDOM_MODE_WITH_DEC ) m_flDelay = 0.005f; // generate max count automaticallly, if not set on map if( !m_iMaxFireCount ) m_iMaxFireCount = RANDOM_LONG( 100, 200 ); } else { // Smart Field System © if ( !m_iMaxFireCount ) m_iMaxFireCount = -1; // disable counting for normal mode } if ( pev->spawnflags & SF_START_ON ) { m_iState = STATE_ON; // initialy off in random mode SetNextThink(m_flDelay); } } TYPEDESCRIPTION CGenerator :: m_SaveData[] = { DEFINE_FIELD( CGenerator, m_iMaxFireCount, FIELD_INTEGER ), DEFINE_FIELD( CGenerator, m_iFireCount, FIELD_INTEGER ), }; IMPLEMENT_SAVERESTORE( CGenerator, CBaseLogic ); void CGenerator :: KeyValue( KeyValueData *pkvd ) { if (FStrEq( pkvd->szKeyName, "maxcount" )) { m_iMaxFireCount = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } if (FStrEq( pkvd->szKeyName, "mode" )) { pev->button = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } else CBaseLogic::KeyValue( pkvd ); } void CGenerator :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if ( useType == USE_TOGGLE ) { if ( m_iState ) useType = USE_OFF; else useType = USE_ON; } if ( useType == USE_ON ) { if ( pev->button == RANDOM_MODE || pev->button == RANDOM_MODE_WITH_DEC ) { if( pev->button == RANDOM_MODE_WITH_DEC ) m_flDelay = 0.005; m_iFireCount = RANDOM_LONG( 0, m_iMaxFireCount / 2 ); } m_iState = STATE_ON; SetNextThink( 0 );//immediately start firing targets } else if ( useType == USE_OFF ) { m_iState = STATE_OFF; DontThink(); } else if ( useType == USE_SET ) { // set max count of impulses m_iMaxFireCount = fabs( value ); } else if ( useType == USE_RESET ) { // immediately reset m_iFireCount = 0; } else if ( useType == USE_SHOWINFO ) { ALERT( at_console, "======/Xash Debug System/======\n" ); ALERT( at_console, "classname: %s\n", STRING( pev->classname )); ALERT( at_console, "State: %s, Delay time %f\n", GetStringForState( GetState()), m_flDelay ); ALERT( at_console, "FireCount: %d, Max FireCount: %d\n", m_iFireCount, m_iMaxFireCount ); } } void CGenerator :: Think( void ) { if ( m_iFireCount != -1 ) { // if counter enabled if( m_iFireCount == m_iMaxFireCount ) { m_iState = STATE_OFF; m_iFireCount = 0; DontThink(); return; } else m_iFireCount++; } if ( pev->button == RANDOM_MODE_WITH_DEC ) { //deceleration for random mode if( m_iMaxFireCount - m_iFireCount < 40 ) m_flDelay += 0.005; } UTIL_FireTargets( pev->target, this, this, USE_TOGGLE ); SetNextThink( m_flDelay ); } //======================================================================= // Logic_watcher //======================================================================= #define LOGIC_AND 0 // fire if all objects active #define LOGIC_OR 1 // fire if any object active #define LOGIC_NAND 2 // fire if not all objects active #define LOGIC_NOR 3 // fire if all objects disable #define LOGIC_XOR 4 // fire if only one (any) object active #define LOGIC_XNOR 5 // fire if active any number objects, but < then all #define W_ON 0 #define W_OFF 1 #define W_TURNON 2 #define W_TURNOFF 3 #define W_IN_USE 4 class CStateWatcher : public CBaseLogic { public: void Spawn( void ); void Think( void ); void KeyValue( KeyValueData *pkvd ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); virtual STATE GetState( void ) { return m_iState; }; virtual STATE GetState( CBaseEntity *pActivator ) { return EvalLogic(pActivator) ? STATE_ON : STATE_OFF; }; virtual int Save( CSave &save ); virtual int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; int m_cTargets; // the total number of targets in this manager's fire list. int m_iTargetName[MAX_MULTI_TARGETS];// list of indexes into global string array BOOL EvalLogic( CBaseEntity *pEntity ); }; LINK_ENTITY_TO_CLASS( logic_watcher, CStateWatcher ); TYPEDESCRIPTION CStateWatcher::m_SaveData[] = { DEFINE_FIELD( CStateWatcher, m_cTargets, FIELD_INTEGER ), DEFINE_ARRAY( CStateWatcher, m_iTargetName, FIELD_STRING, MAX_MULTI_TARGETS ), };IMPLEMENT_SAVERESTORE(CStateWatcher,CBaseLogic); void CStateWatcher :: KeyValue( KeyValueData *pkvd ) { if (FStrEq(pkvd->szKeyName, "mode")) { pev->button = atof(pkvd->szValue); pkvd->fHandled = TRUE; } if (FStrEq(pkvd->szKeyName, "type")) { pev->body = atoi(pkvd->szValue); pkvd->fHandled = TRUE; } if (FStrEq(pkvd->szKeyName, "offtarget")) { pev->netname = ALLOC_STRING(pkvd->szValue); pkvd->fHandled = TRUE; } else // add this field to the target list { // this assumes that additional fields are targetnames and their values are delay values. if ( m_cTargets < MAX_MULTI_TARGETS ) { char tmp[128]; UTIL_StripToken( pkvd->szKeyName, tmp ); m_iTargetName [ m_cTargets ] = ALLOC_STRING( tmp ); m_cTargets++; pkvd->fHandled = TRUE; } } } void CStateWatcher :: Spawn ( void ) { SetNextThink( 0.1 ); } void CStateWatcher :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if (useType == USE_SHOWINFO) { ALERT(at_console, "======/Xash Debug System/======\n"); ALERT(at_console, "classname: %s\n", STRING(pev->classname)); ALERT(at_console, "State: %s, Number of targets %d\n", GetStringForState( GetState()), m_cTargets); ALERT(at_console, "Limit is %d entities\n", MAX_MULTI_TARGETS); } } void CStateWatcher :: Think ( void ) { if(EvalLogic(NULL)) { if(m_iState == STATE_OFF) { m_iState = STATE_ON; UTIL_FireTargets( pev->target, this, this, USE_ON ); } } else { if(m_iState == STATE_ON) { m_iState = STATE_OFF; UTIL_FireTargets( pev->netname, this, this, USE_OFF ); } } SetNextThink( 0.05 ); } BOOL CStateWatcher :: EvalLogic ( CBaseEntity *pActivator ) { int i; BOOL b; BOOL xorgot = FALSE; CBaseEntity* pEntity; for (i = 0; i < m_cTargets; i++) { pEntity = UTIL_FindEntityByTargetname(NULL,STRING(m_iTargetName[i]), pActivator); if (pEntity != NULL); else continue; b = FALSE; switch (pEntity->GetState()) { case STATE_ON: if (pev->body == W_ON) b = TRUE; break; case STATE_OFF: if (pev->body == W_OFF) b = TRUE; break; case STATE_TURN_ON: if (pev->body == W_TURNON) b = TRUE; break; case STATE_TURN_OFF: if (pev->body == W_TURNOFF) b = TRUE; break; case STATE_IN_USE: if (pev->body == W_IN_USE) b = TRUE; break; } // handle the states for this logic mode if (b) { switch (pev->button) { case LOGIC_OR: return TRUE; case LOGIC_NOR: return FALSE; case LOGIC_XOR: if(xorgot) return FALSE; xorgot = TRUE; break; case LOGIC_XNOR: if(xorgot) return TRUE; xorgot = TRUE; break; } } else // b is false { switch (pev->button) { case LOGIC_AND: return FALSE; case LOGIC_NAND: return TRUE; } } } // handle the default cases for each logic mode switch (pev->button) { case LOGIC_AND: case LOGIC_NOR: return TRUE; case LOGIC_XOR: return xorgot; case LOGIC_XNOR: return !xorgot; default: return FALSE; } } //======================================================================= // Logic_manager //======================================================================= #define FL_CLONE 0x80000000 #define SF_LOOP 0x2 class CMultiManager : public CBaseLogic { public: void KeyValue( KeyValueData *pkvd ); void PostActivate( void ); void Spawn ( void ); void Think ( void ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); virtual int Save( CSave &save ); virtual int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; int m_cTargets; // the total number of targets in this manager's fire list. int m_index; // Current target float m_startTime; // Time we started firing int m_iTargetName [ MAX_MULTI_TARGETS ];// list if indexes into global string array float m_flTargetDelay [ MAX_MULTI_TARGETS ];// delay (in seconds) private: inline BOOL IsClone( void ) { return (pev->spawnflags & FL_CLONE) ? TRUE : FALSE; } inline BOOL ShouldClone( void ) { if ( IsClone() )return FALSE; //work in progress and calling again ? return (m_iState == STATE_ON) ? TRUE : FALSE; } CMultiManager *Clone( void ); }; LINK_ENTITY_TO_CLASS( logic_manager, CMultiManager ); // Global Savedata for multi_manager TYPEDESCRIPTION CMultiManager::m_SaveData[] = { DEFINE_FIELD( CMultiManager, m_cTargets, FIELD_INTEGER ), DEFINE_FIELD( CMultiManager, m_index, FIELD_INTEGER ), DEFINE_FIELD( CMultiManager, m_startTime, FIELD_TIME ), DEFINE_ARRAY( CMultiManager, m_iTargetName, FIELD_STRING, MAX_MULTI_TARGETS ), DEFINE_ARRAY( CMultiManager, m_flTargetDelay, FIELD_FLOAT, MAX_MULTI_TARGETS ), };IMPLEMENT_SAVERESTORE(CMultiManager, CBaseLogic); void CMultiManager :: KeyValue( KeyValueData *pkvd ) { if (FStrEq( pkvd->szKeyName, "delay" )) { m_flDelay = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } else if (FStrEq( pkvd->szKeyName, "master" )) { m_sMaster = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } else if ( m_cTargets < MAX_MULTI_TARGETS ) { char tmp[128]; UTIL_StripToken( pkvd->szKeyName, tmp ); m_iTargetName[m_cTargets] = ALLOC_STRING( tmp ); m_flTargetDelay[m_cTargets] = atof( pkvd->szValue ); m_cTargets++; pkvd->fHandled = TRUE; } } void CMultiManager :: Spawn( void ) { // Sort targets // Quick and dirty bubble sort int swapped = 1; while ( swapped ) { swapped = 0; for ( int i = 1; i < m_cTargets; i++ ) { if ( m_flTargetDelay[i] < m_flTargetDelay[i-1] ) { // Swap out of order elements int name = m_iTargetName[i]; float delay = m_flTargetDelay[i]; m_iTargetName[i] = m_iTargetName[i-1]; m_flTargetDelay[i] = m_flTargetDelay[i-1]; m_iTargetName[i-1] = name; m_flTargetDelay[i-1] = delay; swapped = 1; } } } m_iState = STATE_OFF; m_index = 0; } void CMultiManager :: PostActivate( void ) { if ( pev->spawnflags & SF_START_ON ) { Use( this, this, USE_TOGGLE, 0 ); ClearBits( pev->spawnflags, SF_START_ON ); } } void CMultiManager :: Think( void ) { float time; time = gpGlobals->time - m_startTime; while ( m_index < m_cTargets && m_flTargetDelay[ m_index ] <= time ) { UTIL_FireTargets( m_iTargetName[ m_index ], m_hActivator, this, USE_TOGGLE, pev->frags ); m_index++; } if ( m_index >= m_cTargets )// have we fired all targets? { if ( pev->spawnflags & SF_LOOP)//continue firing { m_index = 0; m_startTime = m_flDelay + gpGlobals->time; } else { m_iState = STATE_OFF; DontThink(); return; } if ( IsClone() ) { UTIL_Remove( this ); return; } } m_iState = STATE_ON; //continue firing targets pev->nextthink = m_startTime + m_flTargetDelay[ m_index ]; } CMultiManager *CMultiManager::Clone( void ) { CMultiManager *pMulti = GetClassPtr( (CMultiManager *)NULL ); edict_t *pEdict = pMulti->pev->pContainingEntity; memcpy( pMulti->pev, pev, sizeof(*pev) ); pMulti->pev->pContainingEntity = pEdict; pMulti->pev->spawnflags |= FL_CLONE; pMulti->m_cTargets = m_cTargets; pMulti->m_flDelay = m_flDelay; pMulti->m_iState = m_iState; memcpy( pMulti->m_iTargetName, m_iTargetName, sizeof( m_iTargetName )); memcpy( pMulti->m_flTargetDelay, m_flTargetDelay, sizeof( m_flTargetDelay )); return pMulti; } void CMultiManager :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { m_hActivator = pActivator; if( IsLockedByMaster( useType )) return; pev->frags = value; // save our value if ( useType == USE_TOGGLE ) { // we send USE_ON or USE_OF from this if( m_iState == STATE_OFF ) useType = USE_ON; else useType = USE_OFF; } if (useType == USE_ON) { if ( ShouldClone() ) { // create clone if needed CMultiManager *pClone = Clone(); pClone->Use( pActivator, pCaller, useType, value ); return; } if ( m_iState == STATE_OFF ) { if( m_hActivator == this ) // ok, manager execute himself { // only for follow reason: auto start m_startTime = m_flDelay + gpGlobals->time; m_iState = STATE_TURN_ON; m_index = 0; SetNextThink( m_flDelay ); } else // ok no himself fire and manager on { m_startTime = m_flDelay + gpGlobals->time; m_iState = STATE_TURN_ON; m_index = 0; SetNextThink( m_flDelay ); } } } else if ( useType == USE_OFF ) { m_iState = STATE_OFF; DontThink(); } else if ( useType == USE_SET ) { m_index = 0; // reset fire index while ( m_index < m_cTargets ) { // firing all targets instantly UTIL_FireTargets( m_iTargetName[ m_index ], this, this, USE_TOGGLE ); m_index++; if(m_hActivator == this) break;//break if current target - himself } } else if ( useType == USE_RESET ) { m_index = 0; // reset fire index m_iState = STATE_TURN_ON; m_startTime = m_flDelay + gpGlobals->time; SetNextThink( m_flDelay ); } else if ( useType == USE_SHOWINFO ) { ALERT( at_console, "======/Xash Debug System/======\n"); ALERT( at_console, "classname: %s\n", STRING(pev->classname)); ALERT( at_console, "State: %s, number of targets %d\n", GetStringForState( GetState()), m_cTargets); if( m_iState == STATE_ON ) ALERT( at_console, "Current target %s, delay time %f\n", STRING(m_iTargetName[ m_index ]), m_flTargetDelay[ m_index ]); else ALERT( at_console, "No targets for firing.\n"); } } //======================================================================= // Logic_switcher //======================================================================= #define MODE_INCREMENT 0 #define MODE_DECREMENT 1 #define MODE_RANDOM_VALUE 2 class CSwitcher : public CBaseLogic { public: void KeyValue( KeyValueData *pkvd ); void Spawn ( void ); void Think ( void ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); virtual int Save( CSave &save ); virtual int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; int m_cTargets;// the total number of targets in this manager's fire list. int m_index; // Current target int m_iTargetName [ MAX_MULTI_TARGETS ];// list if indexes into global string array int m_iTargetNumber [ MAX_MULTI_TARGETS ];// list of target numbers }; LINK_ENTITY_TO_CLASS( logic_switcher, CSwitcher ); // Global Savedata for switcher TYPEDESCRIPTION CSwitcher::m_SaveData[] = { DEFINE_FIELD( CSwitcher, m_cTargets, FIELD_INTEGER ), DEFINE_FIELD( CSwitcher, m_index, FIELD_INTEGER ), DEFINE_ARRAY( CSwitcher, m_iTargetName, FIELD_STRING, MAX_MULTI_TARGETS ), DEFINE_ARRAY( CSwitcher, m_iTargetNumber, FIELD_INTEGER, MAX_MULTI_TARGETS ), };IMPLEMENT_SAVERESTORE(CSwitcher, CBaseLogic); void CSwitcher :: KeyValue( KeyValueData *pkvd ) { if (FStrEq( pkvd->szKeyName, "mode" )) { pev->button = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if (FStrEq( pkvd->szKeyName, "delay" )) { m_flDelay = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } else if ( m_cTargets < MAX_MULTI_TARGETS ) { // add this field to the target list // this assumes that additional fields are targetnames and their values are delay values. char tmp[128]; UTIL_StripToken( pkvd->szKeyName, tmp ); m_iTargetName [ m_cTargets ] = ALLOC_STRING( tmp ); m_iTargetNumber [ m_cTargets ] = atoi( pkvd->szValue ); m_cTargets++; pkvd->fHandled = TRUE; } } void CSwitcher :: Spawn( void ) { // Sort targets // Quick and dirty bubble sort int swapped = 1; while ( swapped ) { swapped = 0; for ( int i = 1; i < m_cTargets; i++ ) { if ( m_iTargetNumber[i] < m_iTargetNumber[i-1] ) { // Swap out of order elements int name = m_iTargetName[i]; int number = m_iTargetNumber[i]; m_iTargetName[i] = m_iTargetName[i-1]; m_iTargetNumber[i] = m_iTargetNumber[i-1]; m_iTargetName[i-1] = name; m_iTargetNumber[i-1] = number; swapped = 1; } } } m_iState = STATE_OFF; m_index = 0; if ( pev->spawnflags & SF_START_ON ) { m_iState = STATE_ON; SetNextThink ( m_flDelay ); } } void CSwitcher :: Think ( void ) { if ( pev->button == MODE_INCREMENT ) { // increase target number m_index++; if( m_index >= m_cTargets ) m_index = 0; } else if ( pev->button == MODE_DECREMENT ) { m_index--; if( m_index < 0 ) m_index = m_cTargets - 1; } else if ( pev->button == MODE_RANDOM_VALUE ) { m_index = RANDOM_LONG( 0, m_cTargets - 1 ); } SetNextThink ( m_flDelay ); } void CSwitcher :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { m_hActivator = pActivator; if(IsLockedByMaster( useType )) return; if ( useType == USE_SET ) { // set new target for activate (direct choose or increment\decrement) if( pev->spawnflags & SF_START_ON ) { m_iState = STATE_ON; SetNextThink (m_flDelay); return; } // set maximum priority for direct choose if( value ) { m_index = (value - 1); if( m_index >= m_cTargets ) m_index = -1; return; } if( pev->button == MODE_INCREMENT ) { m_index++; if ( m_index >= m_cTargets ) m_index = 0; } else if( pev->button == MODE_DECREMENT ) { m_index--; if ( m_index < 0 ) m_index = m_cTargets - 1; } else if( pev->button == MODE_RANDOM_VALUE ) { m_index = RANDOM_LONG( 0, m_cTargets - 1 ); } } else if ( useType == USE_RESET ) { // reset switcher m_iState = STATE_OFF; DontThink(); m_index = 0; return; } else if ( useType == USE_SHOWINFO ) { ALERT( at_console, "======/Xash Debug System/======\n"); ALERT( at_console, "classname: %s\n", STRING(pev->classname)); ALERT( at_console, "State: %s, number of targets %d\n", GetStringForState( GetState()), m_cTargets - 1); ALERT( at_console, "Current target %s, target number %d\n", STRING(m_iTargetName[ m_index ]), m_index ); } else if ( m_index != -1 ) // fire any other USE_TYPE and right index { UTIL_FireTargets( m_iTargetName[m_index], m_hActivator, this, useType, value ); } } //======================================================================= // logic_changetarget //======================================================================= class CLogicChangeTarget : public CBaseLogic { public: void KeyValue( KeyValueData *pkvd ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); int ObjectCaps( void ) { return CBaseLogic::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } }; LINK_ENTITY_TO_CLASS( logic_changetarget, CLogicChangeTarget ); LINK_ENTITY_TO_CLASS( trigger_changetarget, CLogicChangeTarget ); void CLogicChangeTarget::KeyValue( KeyValueData *pkvd ) { if ( FStrEq( pkvd->szKeyName, "newtarget" )) { pev->message = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } else CBaseLogic::KeyValue( pkvd ); } void CLogicChangeTarget::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { CBaseEntity *pTarget = UTIL_FindEntityByTargetname( NULL, STRING( pev->target ), pActivator ); if ( useType == USE_SHOWINFO ) { ALERT( at_console, "======/Xash Debug System/======\n"); ALERT( at_console, "classname: %s\n", STRING( pev->classname )); ALERT( at_console, "Current target %s, new target %s\n", STRING( pev->target ), STRING( pev->message )); ALERT( at_console, "target entity is: %s, current target: %s\n", STRING( pTarget->pev->classname ), STRING( pTarget->pev->target )); } else { if ( pTarget ) { const char *target = STRING( pev->message ); if ( FStrEq( target, "*this" ) || FStrEq( target, "*locus" )) // Xash 0.2 compatibility { if ( pActivator ) pTarget->pev->target = pActivator->pev->targetname; else ALERT( at_error, "%s \"%s\" requires a self pointer!\n", STRING( pev->classname ), STRING( pev->targetname )); } else { if ( pTarget->IsFuncScreen( )) pTarget->ChangeCamera( pev->message ); else pTarget->pev->target = pev->message; } CBaseMonster *pMonster = pTarget->MyMonsterPointer( ); if ( pMonster ) pMonster->m_pGoalEnt = NULL; // force to refresh goal entity } } } //======================================================================= // Logic_set //======================================================================= #define MODE_LOCAL 0 #define MODE_GLOBAL_WRITE 1 #define MODE_GLOBAL_READ 2 #define ACT_SAME 0 #define ACT_PLAYER 1 #define ACT_THIS 2 class CLogicSet : public CBaseLogic { public: void KeyValue( KeyValueData *pkvd ); void PostActivate( void ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void Think ( void ); virtual int Save( CSave &save ); virtual int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; string_t m_globalstate; float m_flValue; }; LINK_ENTITY_TO_CLASS( logic_set, CLogicSet ); void CLogicSet :: KeyValue( KeyValueData *pkvd ) { if (FStrEq( pkvd->szKeyName, "value" )) { m_flValue = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } else if (FStrEq( pkvd->szKeyName, "mode" )) { pev->frags = atoi(pkvd->szValue); pkvd->fHandled = TRUE; } else if (FStrEq( pkvd->szKeyName, "globalstate" )) { m_globalstate = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } else if (FStrEq( pkvd->szKeyName, "initialstate" )) { pev->impulse = atoi(pkvd->szValue); pkvd->fHandled = TRUE; } else if (FStrEq( pkvd->szKeyName, "activator" )) { pev->body = atoi(pkvd->szValue); pkvd->fHandled = TRUE; } else CBaseLogic::KeyValue( pkvd ); } // Global Savedata TYPEDESCRIPTION CLogicSet::m_SaveData[] = { DEFINE_FIELD( CLogicSet, m_flValue, FIELD_FLOAT ), DEFINE_FIELD( CLogicSet, m_globalstate, FIELD_STRING ), };IMPLEMENT_SAVERESTORE(CLogicSet, CBaseLogic); void CLogicSet :: PostActivate ( void ) { m_iState = STATE_OFF; if( pev->spawnflags & SF_START_ON ) { // write global state if( pev->frags == MODE_GLOBAL_WRITE ) Use( this, this, (USE_TYPE)pev->impulse, m_flValue ); else Use( this, this, USE_TOGGLE, m_flValue ); } } void CLogicSet :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { // get entity global state GLOBALESTATE curstate = gGlobalState.EntityGetState( m_globalstate ); //set activator if ( pev->body == ACT_SAME ) m_hActivator = pActivator; else if ( pev->body == ACT_PLAYER ) m_hActivator = UTIL_FindEntityByClassname( NULL, "player" ); else if ( pev->body == ACT_THIS ) m_hActivator = this; // save use type pev->button = (int)useType; if ( useType == USE_SHOWINFO ) { ALERT( at_console, "======/Xash Debug System/======\n"); ALERT( at_console, "classname: %s\n", STRING(pev->classname)); ALERT( at_console, "mode %s\n", pev->frags?"Global":"Local"); if( m_globalstate ) ALERT( at_console, "Global state: %s = %s\n", STRING( m_globalstate ), GetStringForGlobalState( curstate )); else ALERT( at_console, "Global state not found\n" ); } else // any other USE_TYPE { if( pev->frags == MODE_LOCAL ) { if( m_flDelay ) { m_iState = STATE_ON; SetNextThink( m_flDelay ); } else { UTIL_FireTargets( pev->target, m_hActivator, this, useType, m_flValue ); } } else if( pev->frags == MODE_GLOBAL_WRITE && m_globalstate ) { // can controlling entity in global mode if( curstate != GLOBAL_DEAD ) { if ( useType == USE_TOGGLE ) { if( curstate ) useType = USE_OFF; else useType = USE_ON; } if ( useType == USE_OFF ) pev->impulse = GLOBAL_OFF; else if ( useType == USE_ON ) pev->impulse = GLOBAL_ON; else if ( useType == USE_SET ) pev->impulse = GLOBAL_DEAD; } else pev->impulse = curstate; // originally loop, isn't true ? :) if( m_flDelay ) { m_iState = STATE_ON; SetNextThink( m_flDelay ); } else { // set global state with prefixes if ( gGlobalState.EntityInTable( m_globalstate )) gGlobalState.EntitySetState( m_globalstate, (GLOBALESTATE)pev->impulse ); else gGlobalState.EntityAdd( m_globalstate, gpGlobals->mapname, (GLOBALESTATE)pev->impulse ); // firing targets UTIL_FireTargets( pev->target, m_hActivator, this, useType, m_flValue ); } } else if( pev->frags == MODE_GLOBAL_READ && gGlobalState.EntityGetState( m_globalstate ) == GLOBAL_ON ) { // fire only if global mode == GLOBAL_ON if( m_flDelay ) { m_iState = STATE_ON; SetNextThink(m_flDelay); } else UTIL_FireTargets( pev->target, m_hActivator, this, useType, m_flValue ); } } } void CLogicSet :: Think ( void ) { if(pev->frags == MODE_GLOBAL_WRITE)//can controlling entity in global mode { // set state after delay if ( gGlobalState.EntityInTable( m_globalstate )) gGlobalState.EntitySetState( m_globalstate, (GLOBALESTATE)pev->impulse ); else gGlobalState.EntityAdd( m_globalstate, gpGlobals->mapname, (GLOBALESTATE)pev->impulse ); // firing targets UTIL_FireTargets( pev->target, m_hActivator, this, (USE_TYPE)pev->button, m_flValue ); } else UTIL_FireTargets( pev->target, m_hActivator, this, (USE_TYPE)pev->button, m_flValue ); // suhtdown m_iState = STATE_OFF; DontThink(); // just in case } //======================================================================= // Logic_counter //======================================================================= class CLogicCounter : public CBaseLogic { public: void Spawn( void ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void KeyValue( KeyValueData *pkvd ); }; LINK_ENTITY_TO_CLASS( logic_counter, CLogicCounter ); void CLogicCounter :: KeyValue( KeyValueData *pkvd ) { if (FStrEq( pkvd->szKeyName, "count" )) { pev->frags = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } if (FStrEq( pkvd->szKeyName, "maxcount" )) { pev->body = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else CBaseLogic::KeyValue( pkvd ); } void CLogicCounter :: Spawn( void ) { // smart Field System © if ( pev->frags == 0 ) pev->frags = 2; if ( pev->body == 0 ) pev->body = 100; if ( pev->frags == -1 ) pev->frags = RANDOM_LONG( 1, pev->body ); // save number of impulses pev->impulse = pev->frags; m_iState = STATE_OFF; // always disable } void CLogicCounter :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if ( useType == USE_SET ) { if( value ) pev->impulse = pev->frags = value; // write new value else pev->impulse = pev->frags = RANDOM_LONG( 1, pev->body ); // write random value } else if (useType == USE_RESET) pev->frags = pev->impulse; //restore counter to default else if (useType == USE_SHOWINFO) { ALERT(at_console, "======/Xash Debug System/======\n"); ALERT(at_console, "classname: %s\n", STRING(pev->classname)); ALERT(at_console, "start count %d, current count %.f\n",pev->impulse , pev->impulse - pev->frags ); ALERT(at_console, "left activates: %.f\n", pev->frags); } else //any other useType { pev->frags--; if(pev->frags > 0) return; pev->frags = 0; //don't reset counter in negative value UTIL_FireTargets( pev->target, pActivator, this, useType, value ); //activate target } } //======================================================================= // Logic_relay //======================================================================= class CLogicRelay : public CBaseLogic { public: void KeyValue( KeyValueData *pkvd ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void Spawn( void ); void Think ( void ); }; LINK_ENTITY_TO_CLASS( logic_relay, CLogicRelay ); void CLogicRelay::KeyValue( KeyValueData *pkvd ) { if (FStrEq( pkvd->szKeyName, "target2" )) { pev->message = ALLOC_STRING(pkvd->szValue); pkvd->fHandled = TRUE; } else CBaseLogic::KeyValue( pkvd ); } void CLogicRelay :: Spawn( void ) { m_iState = STATE_OFF; // always disable } void CLogicRelay::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { m_hActivator = pActivator; //save activator pev->button = (int)useType; //save use type pev->frags = value; //save our value if ( useType == USE_SHOWINFO ) { ALERT( at_console, "======/Xash Debug System/======\n"); ALERT( at_console, "classname: %s\n", STRING( pev->classname )); ALERT( at_console, "target is %s, mtarget %s\n", STRING( pev->target ), STRING( pev->message )); ALERT( at_console, "new value %.2f\n", pev->frags ); } else // activate target { if( m_flDelay ) { m_iState = STATE_ON; SetNextThink( m_flDelay ); } else SetNextThink( 0 ); // fire target immediately } } void CLogicRelay::Think ( void ) { if( IsLockedByMaster( )) UTIL_FireTargets( pev->message, m_hActivator, this, (USE_TYPE)pev->button, pev->frags ); else UTIL_FireTargets( pev->target, m_hActivator, this, (USE_TYPE)pev->button, pev->frags ); // shutdown m_iState = STATE_OFF; DontThink(); // just in case } //======================================================================= // Logic_state //======================================================================= class CLogicState : public CBaseLogic { public: void Spawn( void ); void Think( void ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); }; LINK_ENTITY_TO_CLASS( logic_state, CLogicState ); void CLogicState::Spawn( void ) { if ( pev->spawnflags & SF_START_ON ) m_iState = STATE_ON; else m_iState = STATE_OFF; } void CLogicState::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { m_hActivator = pActivator; // save activator pev->frags = value; // save value if(IsLockedByMaster( useType )) return; if ( useType == USE_TOGGLE ) { // set use type if( m_iState == STATE_TURN_OFF || m_iState == STATE_OFF ) useType = USE_ON; else if( m_iState == STATE_TURN_ON || m_iState == STATE_ON ) useType = USE_OFF; } if ( useType == USE_ON ) { //enable entity if ( m_iState == STATE_TURN_OFF || m_iState == STATE_OFF ) { // activate turning off entity if ( m_flDelay ) { // we have time to turning on m_iState = STATE_TURN_ON; SetNextThink( m_flDelay ); } else { // just enable entity m_iState = STATE_ON; UTIL_FireTargets( pev->target, pActivator, this, USE_ON, pev->frags ); DontThink(); // break thinking } } } else if( useType == USE_OFF ) { // disable entity if ( m_iState == STATE_TURN_ON || m_iState == STATE_ON ) { // deactivate turning on entity if ( m_flWait ) { // we have time to turning off m_iState = STATE_TURN_OFF; SetNextThink( m_flWait ); } else { // just disable entity m_iState = STATE_OFF; UTIL_FireTargets( pev->target, pActivator, this, USE_OFF, pev->frags ); DontThink();//break thinking } } } else if( useType == USE_SET ) { // explicit on m_iState = STATE_ON; DontThink(); } else if ( useType == USE_RESET ) { // explicit off m_iState = STATE_OFF; DontThink(); } else if ( useType == USE_SHOWINFO ) { ALERT( at_console, "======/Xash Debug System/======\n"); ALERT( at_console, "classname: %s\n", STRING(pev->classname)); ALERT( at_console, "time, before enable %.1f, time, before disable %.1f\n", m_flDelay, m_flWait ); ALERT( at_console, "current state %s\n", GetStringForState( GetState()) ); } } void CLogicState::Think( void ) { if ( m_iState == STATE_TURN_ON ) { m_iState = STATE_ON; UTIL_FireTargets( pev->target, m_hActivator, this, USE_ON, pev->frags ); } else if ( m_iState == STATE_TURN_OFF ) { m_iState = STATE_OFF; UTIL_FireTargets( pev->target, m_hActivator, this, USE_OFF, pev->frags ); } DontThink(); } //======================================================================= // Logic_usetype - sorting different usetypes //======================================================================= class CLogicUseType : public CBaseLogic { public: void KeyValue( KeyValueData *pkvd ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); }; LINK_ENTITY_TO_CLASS( logic_usetype, CLogicUseType ); void CLogicUseType::KeyValue( KeyValueData *pkvd ) { if ( FStrEq( pkvd->szKeyName, "toggle" )) { pev->target = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } else if ( FStrEq( pkvd->szKeyName, "enable" )) { pev->message = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } else if ( FStrEq( pkvd->szKeyName, "disable" )) { pev->netname = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } else if ( FStrEq( pkvd->szKeyName, "set" )) { m_sSet = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } else if ( FStrEq( pkvd->szKeyName, "reset" )) { m_sReset = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } else CBaseLogic::KeyValue( pkvd ); } void CLogicUseType::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if ( IsLockedByMaster( useType )) return; if ( useType == USE_TOGGLE ) UTIL_FireTargets( pev->target, pActivator, this, useType, value ); else if ( useType == USE_ON ) UTIL_FireTargets( pev->message, pActivator, this, useType, value ); else if ( useType == USE_OFF ) UTIL_FireTargets( pev->netname, pActivator, this, useType, value ); else if ( useType == USE_SET ) UTIL_FireTargets( m_sSet, pActivator, this, useType, value ); else if ( useType == USE_RESET )UTIL_FireTargets( m_sReset, pActivator, this, useType, value ); else if ( useType == USE_SHOWINFO ) { ALERT( at_console, "======/Xash Debug System/======\n" ); ALERT( at_console, "classname: %s\n", STRING( pev->classname )); ALERT( at_console, "This entity doesn't have displayed settings!\n\n" ); } } //======================================================================= // Logic_scale - apply scale for value //======================================================================= class CLogicScale : public CBaseLogic { public: void KeyValue( KeyValueData *pkvd ) { if (FStrEq(pkvd->szKeyName, "mode")) { pev->impulse = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else CBaseLogic::KeyValue( pkvd ); } void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if ( useType == USE_SHOWINFO ) { DEBUGHEAD; ALERT( at_console, "Mode %s. Scale %.3f.\n\n", pev->impulse ? "Bool" : "Float", pev->scale ); SHIFT; } else { if( pev->impulse == 0 ) // bool logic { if( value >= 0.99f ) UTIL_FireTargets(pev->target, pActivator, this, USE_ON, 1 ); if( value <= 0.01f ) UTIL_FireTargets(pev->target, pActivator, this, USE_OFF,0 ); } if( pev->impulse == 1 ) // direct scale UTIL_FireTargets( pev->target, pActivator, this, USE_SET, value * pev->scale ); if( pev->impulse == 2 ) // inverse sacle UTIL_FireTargets( pev->target, pActivator, this, USE_SET, pev->scale * ( 1 - value )); } } }; LINK_ENTITY_TO_CLASS( logic_scale, CLogicScale );
[ [ [ 1, 1381 ] ] ]
13562f26648e6ac63205b16cc274380d0e0ad346
3856c39683bdecc34190b30c6ad7d93f50dce728
/server/SocketServer.h
9450e48cdfd3b95dab30a71438ff35bea5a8aad3
[]
no_license
yoonhada/nlinelast
7ddcc28f0b60897271e4d869f92368b22a80dd48
5df3b6cec296ce09e35ff0ccd166a6937ddb2157
refs/heads/master
2021-01-20T09:07:11.577111
2011-12-21T22:12:36
2011-12-21T22:12:36
34,231,967
0
0
null
null
null
null
UTF-8
C++
false
false
2,459
h
#ifndef _SOCKETSERVER_H_ #define _SOCKETSERVER_H_ #include "stdafx.h" #include "NTClient.h" class CSocketServer { public: SOCKET m_ListenSocket; HANDLE m_hCompletionPort; HANDLE m_hAcceptThread; HANDLE m_hIOCPThread; CNTClient* m_pHostClient; BOOL m_bExistHost; BOOL m_bGameStart; INT m_iClientCount; INT m_iReadyCount; INT m_iLodingCompleteCount; WORD m_wUserNumber[4]; BOOL m_bSelected[4]; map<WORD, CNTClient*> m_Map_LogonClients; public: CSocketServer(); virtual ~CSocketServer(); BOOL Initialize(); VOID Clear(); BOOL StartServer( WORD a_wPort ); VOID Stop(); VOID UpdateFrame(); VOID OnAccept( SOCKET a_hSocket ); VOID OnServerClose(); VOID OnClientClose( CNTClient* a_pClient ); VOID CS_LOGON( CNTClient* a_pClient, CPacket& a_pk ); VOID CS_READY( CNTClient* a_pClient, CPacket& a_pk ); VOID CS_GAME_START( CNTClient* a_pClient, CPacket& a_pk ); VOID CS_LODING_COMPLETE( CNTClient* a_pClient, CPacket& a_pk ); VOID CS_CLIENT_DISCONNECT( CNTClient* a_pClient, CPacket& a_pk ); VOID CS_EVENT_STATE( CNTClient* a_pClient, CPacket& a_pk ); VOID CS_EVENT_COMBO_INFO( CNTClient* a_pClient, CPacket& a_pk ); VOID CS_EVENT_COMBO_SLOT_STATE( CNTClient* a_pClient, CPacket& a_pk ); VOID CS_EVENT_COMBO_RESULT( CNTClient* a_pClient, CPacket& a_pk ); VOID CS_EVENT_HEAL( CNTClient* a_pClient, CPacket& a_pk ); VOID CS_CHAT( CNTClient* a_pClient, CPacket& a_pk ); VOID CS_PLAYER_MOVE( CNTClient* a_pClient, CPacket& a_pk ); VOID CS_MONSTER_MOVE( CNTClient* a_pClient, CPacket& a_pk ); VOID CS_UTOM_ATTACK( CNTClient* a_pClient, CPacket& a_pk ); VOID CS_MTOU_ATTACK( CNTClient* a_pClient, CPacket& a_pk ); VOID CS_EVENT_ATTACK( CNTClient* a_pClient, CPacket& a_pk ); VOID CS_PLAYER_ATTACK_ANIMATION( CNTClient* a_pClient, CPacket& a_pk ); VOID CS_MONSTER_ATTACK_ANIMATION( CNTClient* a_pClient, CPacket& a_pk ); VOID CS_MONSTER_ATTACK_ANIMATION2( CNTClient* a_pClient, CPacket& a_pk ); VOID CS_MONSTER_LockOn( CNTClient* a_pClient, CPacket& a_pk ); VOID CS_GAME_RESULT( CNTClient* a_pClient, CPacket& a_pk ); VOID SC_INIT( CNTClient* a_pClient ); VOID SC_CLIENT_DISCONNECT( CNTClient* a_pClient ); VOID SendToClient( CNTClient* a_pClient, CPacket& a_pk ); VOID ProcessPacket( CNTClient* a_pClient, CPacket& a_pk ); static UINT WINAPI AcceptProc( VOID* p ); static UINT WINAPI IOCPWorkerProc( VOID* p ); }; #endif
[ "[email protected]@d02aaf57-2019-c8cd-d06c-d029ef2af4e0", "[email protected]@d02aaf57-2019-c8cd-d06c-d029ef2af4e0" ]
[ [ [ 1, 18 ], [ 20, 21 ], [ 23, 33 ], [ 35, 38 ], [ 70, 72 ], [ 74, 81 ] ], [ [ 19, 19 ], [ 22, 22 ], [ 34, 34 ], [ 39, 69 ], [ 73, 73 ] ] ]
cb480f67d97f78d5c94b808065d7783daabc6b9e
3856c39683bdecc34190b30c6ad7d93f50dce728
/LastProject/Source/EfSurface.h
90b4f5dc97baff3004d8da0bc580542e9624729d
[]
no_license
yoonhada/nlinelast
7ddcc28f0b60897271e4d869f92368b22a80dd48
5df3b6cec296ce09e35ff0ccd166a6937ddb2157
refs/heads/master
2021-01-20T09:07:11.577111
2011-12-21T22:12:36
2011-12-21T22:12:36
34,231,967
0
0
null
null
null
null
UTF-8
C++
false
false
972
h
#pragma once //typedef D3DXVECTOR3 VEC3; //typedef D3DXVECTOR4 VEC4; // //typedef LPDIRECT3DDEVICE9 PDEV; // //typedef LPDIRECT3DTEXTURE9 PDTX; //typedef LPDIRECT3DSURFACE9 PDSF; // // class CEfSurface { public: struct VtxwDUV { D3DXVECTOR4 p; DWORD d; FLOAT u,v; VtxwDUV() {} VtxwDUV(FLOAT X,FLOAT Y,FLOAT Z,FLOAT U,FLOAT V,DWORD D=0xFFFFFFFF) : p(X,Y,Z,1.F),u(U),v(V),d(D){} enum { FVF = (D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1)}; }; protected: LPDIRECT3DDEVICE9 m_pDev; LPDIRECT3DTEXTURE9 m_pTx; // Target Texture LPDIRECT3DSURFACE9 m_pTxSf; // Target Surface LPD3DXRENDERTOSURFACE m_pTxRs; // Render To Surface INT m_iTxW; // Render Target Texture Width VtxwDUV m_pVtx[4]; public: CEfSurface(); virtual ~CEfSurface(); INT Create(LPDIRECT3DDEVICE9 pDev); void Destroy(); INT Restore(); INT Update( IObject * a_pObject ); void Render(); };
[ "[email protected]@d02aaf57-2019-c8cd-d06c-d029ef2af4e0" ]
[ [ [ 1, 49 ] ] ]
5c813764a7f7a17e14ed1f17f00dc909f4428dc6
519a3884c80f7a3926880b28df5755935ec7aa57
/DicomShell/DicomColumnProvider.cpp
5bdd90938d76a419fd8c990e6557ca80f306e785
[]
no_license
Jeffrey2008/dicomshell
71ef9844ed83c38c2529a246b6efffdd5645ed92
14c98fcd9238428e1541e50b7d0a67878cf8add4
refs/heads/master
2020-10-01T17:39:11.786479
2009-09-02T17:49:27
2009-09-02T17:49:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,428
cpp
// DicomColumnProvider.cpp : Implementation of CDicomColumnProvider #include "stdafx.h" #include "DicomColumnProvider.h" // CDicomColumnProvider DicomTagList CDicomColumnProvider::s_tags(TEXT("columns")); CDicomColumnProvider::CDicomColumnProvider() { } HRESULT CDicomColumnProvider::Initialize(LPCSHCOLUMNINIT psci) { try { CopyMemory(&m_init, psci, sizeof(m_init)); m_columns = & s_tags.getTags(); return S_OK; } catch (...) { return E_FAIL; } } HRESULT CDicomColumnProvider::GetColumnInfo(DWORD dwIndex, SHCOLUMNINFO *psci) { try { USES_CONVERSION; DicomTagList::TagCollection const& columns = *m_columns; if (dwIndex < columns.size()) { psci->scid.fmtid = CLSID_DicomColumnProvider; psci->scid.pid = dwIndex; psci->vt = VT_I4; psci->fmt = LVCFMT_LEFT; psci->cChars = 20; psci->csFlags = SHCOLSTATE_TYPE_STR | SHCOLSTATE_SECONDARYUI; lstrcpyW(psci->wszTitle, A2W(DcmTag(columns[dwIndex]).getTagName())); lstrcpyW(psci->wszDescription, A2W(DcmTag(columns[dwIndex]).getTagName())); return S_OK; } else { return S_FALSE; } } catch (...) { return E_FAIL; } } bool CDicomColumnProvider::selectFile(const char* path) { std::string fileName(path); if (fileName == m_currentFileName) { return true; } else { try { m_currentFileName = std::string(); m_currentFileName = fileName; m_currentFile.setReadMode(ERM_fileOnly); OFCondition status = m_currentFile.loadFile(fileName.c_str(), EXS_Unknown, EGL_noChange, DCM_MaxReadLength, ERM_fileOnly); if (status.good()) { return true; } else { return false; } } catch (...) { return false; } } } HRESULT CDicomColumnProvider::GetItemData(LPCSHCOLUMNID pscid, LPCSHCOLUMNDATA pscd, VARIANT *pvarData) { try { USES_CONVERSION; DicomTagList::TagCollection const& columns = *m_columns; if (pscid->fmtid == CLSID_DicomColumnProvider) { if (pscid->pid < columns.size()) { if (selectFile(W2A(pscd->wszFile))) { OFString value; if (m_currentFile.getDataset()->findAndGetOFString(columns[pscid->pid], value).good()) { CComVariant v(A2W(value.c_str())); v.Detach(pvarData); return S_OK; } } } } return S_FALSE; } catch (...) { return E_FAIL; } }
[ "andreas.grimme@715416e8-819e-11dd-8f04-175a6ebbc832" ]
[ [ [ 1, 121 ] ] ]
981ce0dee5fa02d2eb770e6ed260acd28091a17c
9756190964e5121271a44aba29a5649b6f95f506
/SimpleParam/Param/src/Param/TransFunctor.cc
541ee37ddfaa496ba20be368e01c0f7fc03ba24f
[]
no_license
feengg/Parameterization
40f71bedd1adc7d2ccbbc45cc0c3bf0e1d0b1103
f8d2f26ff83d6f53ac8a6abb4c38d9b59db1d507
refs/heads/master
2020-03-23T05:18:25.675256
2011-01-21T15:19:08
2011-01-21T15:19:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
15,741
cc
#include "TransFunctor.h" #include "ChartCreator.h" #include <hj_3rd/hjlib/math/blas_lapack.h> #include <hj_3rd/zjucad/matrix/lapack.h> #include <map> #include <set> #include <queue> #include <iostream> #include <limits> namespace PARAM { TransFunctor::TransFunctor(boost::shared_ptr<ChartCreator> _p_chart_creator) : p_chart_creator(_p_chart_creator) {} TransFunctor::~TransFunctor(){} zjucad::matrix::matrix<double> TransFunctor::GetTransMatrix(int from_chart_id, int to_chart_id, int vid) const { zjucad::matrix::matrix<double> trans_mat(zjucad::matrix::eye<double>(3)); if(from_chart_id == to_chart_id ) return trans_mat; std::vector<int> trans_list; if(!GetTranslistBetweenTwoCharts(from_chart_id, to_chart_id, trans_list)) { std::cout<< "Cannot get the transition list!\n"; return trans_mat; } assert(trans_list.size() >=2); // std::cout << "Trans list : " << from_chart_id <<" " << to_chart_id << " : " << std::endl; // for(size_t k=0; k<trans_list.size(); ++k){ // std::cout << trans_list[k] <<" "; // } // std::cout << std::endl; for(size_t k=1; k<trans_list.size(); ++k) { zjucad::matrix::matrix<double> temp_trans_mat = trans_mat; trans_mat = GetTransMatrixOfAdjCharts(trans_list[k-1], trans_list[k], vid) * temp_trans_mat; } return trans_mat; } zjucad::matrix::matrix<double> TransFunctor::GetTransMatrix(int from_vid, int from_chart_id, int to_vid, int to_chart_id) const { zjucad::matrix::matrix<double> trans_mat(zjucad::matrix::eye<double>(3)); if(from_chart_id == to_chart_id ) return trans_mat; std::vector<int> trans_list; std::map < std::pair<int, int>, std::vector<int> >::const_iterator iter = m_edge_trans_list.find(std::make_pair(from_vid, to_vid)); if(iter != m_edge_trans_list.end()){ trans_list = iter->second; }else{ if(!GetTranslistBetweenTwoCharts(from_chart_id, to_chart_id, trans_list)) { std::cout<< "Cannot get the transition list!\n"; return trans_mat; } } assert(trans_list.size() >=2); for(size_t k=1; k<trans_list.size(); ++k) { zjucad::matrix::matrix<double> temp_trans_mat = trans_mat; trans_mat = GetTransMatrixOfAdjCharts(trans_list[k-1], trans_list[k],from_vid) * temp_trans_mat; } return trans_mat; } bool TransFunctor::GetTranslistBetweenTwoCharts(int from_chart_id, int to_chart_id, std::vector<int>& trans_list) const { trans_list.clear(); const std::vector<ParamPatch>& patch_array = p_chart_creator->GetPatchArray(); std::set<int> visited_face_set; std::map<int, int> prev_chart_map; std::queue<int> q; q.push(to_chart_id); visited_face_set.insert(to_chart_id); prev_chart_map[to_chart_id] = -1; bool flag = false; while(!q.empty()) { int cur_chart_id = q.front(); q.pop(); if(cur_chart_id == from_chart_id) { flag = true; break;} const std::vector<int>& adj_charts = patch_array[cur_chart_id].m_nb_patch_index_array; for(size_t k=0; k<adj_charts.size(); ++k) { int chart_id = adj_charts[k]; if(visited_face_set.find(chart_id) == visited_face_set.end()) { q.push(chart_id); visited_face_set.insert(chart_id); prev_chart_map[chart_id] = cur_chart_id; } } } if(!flag) return false; trans_list.push_back(from_chart_id); int prev_chart = prev_chart_map[from_chart_id]; while(prev_chart != -1) { trans_list.push_back(prev_chart); prev_chart = prev_chart_map[prev_chart]; } return true; } zjucad::matrix::matrix<double> TransFunctor::GetTransMatrixInOneChart(int chart_id, std::pair<int,int> old_x_axis, std::pair<int,int> new_x_axis) const { const std::vector<ParamChart>& chart_array = p_chart_creator->GetChartArray(); const ParamChart& param_chart = chart_array[chart_id]; const std::vector<ParamCoord>& conner_param_coord_vec = param_chart.m_conner_param_coord_array; // std::cout << "Chart ID : " << chart_id << std::endl; // for(size_t k=0; k<conner_param_coord_vec.size(); ++k){ // std::cout << "( " << conner_param_coord_vec[k].s_coord <<" " << conner_param_coord_vec[k].t_coord << ")" << " "; // } // std::cout << std::endl; zjucad::matrix::matrix<double> t_mat(zjucad::matrix::eye<double>(3)); zjucad::matrix::matrix<double> r_mat(zjucad::matrix::eye<double>(3)); int old_origin = old_x_axis.first, new_origin = new_x_axis.first; if(old_origin != new_origin) { double tx = conner_param_coord_vec[old_origin].s_coord - conner_param_coord_vec[new_origin].s_coord; double ty = conner_param_coord_vec[old_origin].t_coord - conner_param_coord_vec[new_origin].t_coord; t_mat(0, 2) = tx; t_mat(1, 2) = ty; } if(old_x_axis != new_x_axis) { double x1, y1, x2, y2; x1 = conner_param_coord_vec[old_x_axis.second].s_coord - conner_param_coord_vec[old_x_axis.first].s_coord; y1 = conner_param_coord_vec[old_x_axis.second].t_coord - conner_param_coord_vec[old_x_axis.first].t_coord; x2 = conner_param_coord_vec[new_x_axis.second].s_coord - conner_param_coord_vec[new_x_axis.first].s_coord; y2 = conner_param_coord_vec[new_x_axis.second].t_coord - conner_param_coord_vec[new_x_axis.first].t_coord; double cross_v = x1*y2 - y1*x2; double dot_v = x1*x2 + y1*y2; double len1 = sqrt(x1*x1 + y1*y1); double len2 = sqrt(x2*x2 + y2*y2); // std::cout << x1 << " " << y1 <<" " << x2 <<" " << y2 << std::endl; // std::cout << cross_v << " " << dot_v << std::endl; double asin_angle = asin(cross_v/(len1*len2)); double acos_angle = acos(dot_v/(len1*len2)); double r_angle; if(fabs(dot_v) < LARGE_ZERO_EPSILON) { if(cross_v < 0) r_angle = PI*3/2; else r_angle = PI/2; }else if(fabs(cross_v) < LARGE_ZERO_EPSILON) { if(dot_v < 0) r_angle = PI; else r_angle = 0; }else { if(cross_v < 0 && dot_v > 0) r_angle = asin_angle + 2*PI; /// 4 else if( cross_v < 0 && dot_v < 0) r_angle = PI - asin_angle; /// 3 else if( cross_v > 0 && dot_v < 0) r_angle = acos_angle; /// 2 else if( cross_v > 0 && dot_v > 0) r_angle = asin_angle; /// 1 if(r_angle < 0) r_angle += 2*PI; } //std::cout << "Rotate angle : " << r_angle << std::endl; double cos_v = cos(r_angle), sin_v = sin(r_angle); r_mat(0, 0) = cos_v; r_mat(0, 1) = sin_v; r_mat(1, 0) = -sin_v; r_mat(1, 1) = cos_v; } return r_mat*t_mat; } zjucad::matrix::matrix<double> TransFunctor::GetTransMatrixOfAdjCharts(int from_chart_id, int to_chart_id, int vid) const { if(p_chart_creator->IsAmbiguityChartPair(from_chart_id, to_chart_id)){ return GetTransMatrixBetweenAmbiguityCharts(vid, from_chart_id, -1, to_chart_id); } const std::vector<ParamPatch>& patch_array = p_chart_creator->GetPatchArray(); const ParamPatch& from_patch = patch_array[from_chart_id]; const ParamPatch& to_patch = patch_array[to_chart_id]; const std::vector<PatchEdge>& patch_edge_array = p_chart_creator->GetPatchEdgeArray(); /// find the common edge of these two charts const std::vector<int>& from_patch_edge_array = from_patch.m_edge_index_array; const std::vector<int>& to_patch_edge_array = to_patch.m_edge_index_array; std::vector<int> common_edges; for(size_t k=0; k<from_patch_edge_array.size(); ++k){ if(find(to_patch_edge_array.begin(), to_patch_edge_array.end(), from_patch_edge_array[k]) != to_patch_edge_array.end()) common_edges.push_back(from_patch_edge_array[k]); } /// the common edges may be not only one, we choose the minimum index edge int com_edge = *(min_element(common_edges.begin(), common_edges.end())); int com_edge_idx_1(-1), com_edge_idx_2(-1); for(size_t k=0; k<from_patch_edge_array.size(); ++k){ if(from_patch_edge_array[k] == com_edge) { com_edge_idx_1 = (int)k; break; } } for(size_t k=0; k<to_patch_edge_array.size(); ++k){ if(to_patch_edge_array[k] == com_edge) { com_edge_idx_2 = (int) k; break; } } assert(com_edge_idx_1 != -1 && com_edge_idx_2 != -1); std::pair<int, int> old_x_axis_1, new_x_axis_1; /// find the from chart and to chart's origin and x-axis size_t edge_num = from_patch.m_edge_index_array.size(); old_x_axis_1 = std::make_pair(0, 1); new_x_axis_1 = std::make_pair(com_edge_idx_1, (com_edge_idx_1+1)%edge_num); std::pair<int, int> old_x_axis_2, new_x_axis_2; old_x_axis_2 = std::make_pair(0, 1); new_x_axis_2 = std::make_pair( (com_edge_idx_2+1)%edge_num, com_edge_idx_2); // std::cout << "Chart 1 : " << new_x_axis_1.first << " " << new_x_axis_1.second << std::endl; // std::cout << "Chart 2 : " << new_x_axis_2.first << " " << new_x_axis_2.second << std::endl; zjucad::matrix::matrix<double> trans_mat_1 = GetTransMatrixInOneChart(from_chart_id, old_x_axis_1, new_x_axis_1); zjucad::matrix::matrix<double> trans_mat_2 = GetTransMatrixInOneChart(to_chart_id, old_x_axis_2, new_x_axis_2); inv(trans_mat_2); return trans_mat_2 * trans_mat_1; } zjucad::matrix::matrix<double> TransFunctor::GetTransMatrixBetweenAmbiguityCharts(int from_vert, int from_chart_id, int to_vert, int to_chart_id) const { ///TODO: check these two charts is ambiguity charts or not const std::vector<ParamPatch>& patch_array = p_chart_creator->GetPatchArray(); const ParamPatch& from_patch = patch_array[from_chart_id]; const ParamPatch& to_patch = patch_array[to_chart_id]; const std::vector<PatchEdge>& patch_edge_array = p_chart_creator->GetPatchEdgeArray(); /// find the common edge of these two charts const std::vector<int>& from_patch_edge_array = from_patch.m_edge_index_array; const std::vector<int>& to_patch_edge_array = to_patch.m_edge_index_array; std::vector<int> common_edges; for(size_t k=0; k<from_patch_edge_array.size(); ++k){ if(find(to_patch_edge_array.begin(), to_patch_edge_array.end(), from_patch_edge_array[k]) != to_patch_edge_array.end()) common_edges.push_back(from_patch_edge_array[k]); } if(common_edges.size() == 0 ) { std::cerr << "Error: These two charts don't have common edges, so they are not ambiguity chart pair!" << std::endl; return zjucad::matrix::eye<double>(3); }else if(common_edges.size() == 1) { std::cerr << "Error: These two charts only have one common edge, so they are not ambiguity chart pair!" << std::endl; return GetTransMatrixOfAdjCharts(from_chart_id, to_chart_id, from_vert); } int com_edge = ChooseEdgeForAmbiguityChart(common_edges, from_vert, to_vert); int com_edge_idx_1(-1), com_edge_idx_2(-1); for(size_t k=0; k<from_patch_edge_array.size(); ++k){ if(from_patch_edge_array[k] == com_edge) { com_edge_idx_1 = (int)k; break; } } for(size_t k=0; k<to_patch_edge_array.size(); ++k){ if(to_patch_edge_array[k] == com_edge) { com_edge_idx_2 = (int) k; break; } } assert(com_edge_idx_1 != -1 && com_edge_idx_2 != -1); std::pair<int, int> old_x_axis_1, new_x_axis_1; /// find the from chart and to chart's origin and x-axis size_t edge_num = from_patch.m_edge_index_array.size(); old_x_axis_1 = std::make_pair(0, 1); new_x_axis_1 = std::make_pair(com_edge_idx_1, (com_edge_idx_1+1)%edge_num); std::pair<int, int> old_x_axis_2, new_x_axis_2; old_x_axis_2 = std::make_pair(0, 1); new_x_axis_2 = std::make_pair( (com_edge_idx_2+1)%edge_num, com_edge_idx_2); zjucad::matrix::matrix<double> trans_mat_1 = GetTransMatrixInOneChart(from_chart_id, old_x_axis_1, new_x_axis_1); zjucad::matrix::matrix<double> trans_mat_2 = GetTransMatrixInOneChart(to_chart_id, old_x_axis_2, new_x_axis_2); inv(trans_mat_2); return trans_mat_2 * trans_mat_1; } void TransFunctor::TransParamCoordBetweenAmbiguityCharts(int from_vert, int from_chart_id, int to_chart_id, const ParamCoord& from_coord, ParamCoord& to_coord) const { const std::vector<ParamPatch>& patch_array = p_chart_creator->GetPatchArray(); const ParamPatch& from_patch = patch_array[from_chart_id]; const ParamPatch& to_patch = patch_array[to_chart_id]; const std::vector<PatchEdge>& patch_edge_array = p_chart_creator->GetPatchEdgeArray(); /// find the common edge of these two charts const std::vector<int>& from_patch_edge_array = from_patch.m_edge_index_array; const std::vector<int>& to_patch_edge_array = to_patch.m_edge_index_array; std::vector<int> common_edges; for(size_t k=0; k<from_patch_edge_array.size(); ++k){ if(find(to_patch_edge_array.begin(), to_patch_edge_array.end(), from_patch_edge_array[k]) != to_patch_edge_array.end()) common_edges.push_back(from_patch_edge_array[k]); } if(common_edges.size() == 0 ) { std::cerr << "Error: These two charts don't have common edges, so they are not ambiguity chart pair!" << std::endl; return ; }else if(common_edges.size() == 1) { std::cerr << "Error: These two charts only have one common edge, so they are not ambiguity chart pair!" << std::endl; return ; } int com_edge = ChooseEdgeForAmbiguityChart(common_edges, from_vert); int com_edge_idx_1(-1), com_edge_idx_2(-1); for(size_t k=0; k<from_patch_edge_array.size(); ++k){ if(from_patch_edge_array[k] == com_edge) { com_edge_idx_1 = (int)k; break; } } for(size_t k=0; k<to_patch_edge_array.size(); ++k){ if(to_patch_edge_array[k] == com_edge) { com_edge_idx_2 = (int) k; break; } } assert(com_edge_idx_1 != -1 && com_edge_idx_2 != -1); std::pair<int, int> old_x_axis_1, new_x_axis_1; /// find the from chart and to chart's origin and x-axis size_t edge_num = from_patch.m_edge_index_array.size(); old_x_axis_1 = std::make_pair(0, 1); new_x_axis_1 = std::make_pair(com_edge_idx_1, (com_edge_idx_1+1)%edge_num); std::pair<int, int> old_x_axis_2, new_x_axis_2; old_x_axis_2 = std::make_pair(0, 1); new_x_axis_2 = std::make_pair( (com_edge_idx_2+1)%edge_num, com_edge_idx_2); zjucad::matrix::matrix<double> trans_mat_1 = GetTransMatrixInOneChart(from_chart_id, old_x_axis_1, new_x_axis_1); zjucad::matrix::matrix<double> trans_mat_2 = GetTransMatrixInOneChart(to_chart_id, old_x_axis_2, new_x_axis_2); inv(trans_mat_2); zjucad::matrix::matrix<double> trans_mat = trans_mat_2*trans_mat_1; to_coord.s_coord = trans_mat(0, 0)*from_coord.s_coord + trans_mat(0, 1)*from_coord.t_coord + trans_mat(0, 2); to_coord.t_coord = trans_mat(1, 0)*from_coord.s_coord + trans_mat(1, 1)*from_coord.t_coord + trans_mat(1, 2); } int TransFunctor::ChooseEdgeForAmbiguityChart(const std::vector<int>& common_edges, int from_vert, int to_vert/* =-1 */) const { const std::vector<PatchEdge>& patch_edge_array = p_chart_creator->GetPatchEdgeArray(); boost::shared_ptr<MeshModel> p_mesh = p_chart_creator->GetMeshModel(); double min_dist = std::numeric_limits<double>::infinity(); int com_edge(-1); for(size_t k=0; k<common_edges.size(); ++k) { const std::vector<int>& mesh_path = patch_edge_array[common_edges[k]].m_mesh_path; double cur_dist = 0.0; int nearest_vert; cur_dist += GetNearestVertexOnPath(p_mesh, from_vert, mesh_path, nearest_vert); if(to_vert!=-1) cur_dist += GetNearestVertexOnPath(p_mesh, to_vert, mesh_path, nearest_vert); if(cur_dist < min_dist) { min_dist = cur_dist; com_edge = common_edges[k]; } } return com_edge; } }
[ [ [ 1, 401 ] ] ]
c8bffd27b130d4b3fc990d1d020c6c84b57b7a30
335783c9e5837a1b626073d1288b492f9f6b057f
/source/fbxcmd/daolib/Model/MMH/MSHH.h
8b45fdc0bb434e792e7607a0fd003b39786b1db3
[ "BSD-3-Clause", "LicenseRef-scancode-warranty-disclaimer", "BSD-2-Clause" ]
permissive
code-google-com/fbx4eclipse
110766ee9760029d5017536847e9f3dc09e6ebd2
cc494db4261d7d636f8c4d0313db3953b781e295
refs/heads/master
2016-09-08T01:55:57.195874
2009-12-03T20:35:48
2009-12-03T20:35:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,318
h
/********************************************************************** *< FILE: MSHH.h DESCRIPTION: MMH File Format HISTORY: *> Copyright (c) 2009, All Rights Reserved. **********************************************************************/ #pragma once #include "MMH/MMHCommon.h" #include "GFF/GFFField.h" #include "GFF/GFFList.h" #include "GFF/GFFStruct.h" namespace DAO { using namespace GFF; namespace MMH { /////////////////////////////////////////////////////////////////// class MSHH { protected: GFFStructRef impl; static ShortString type; public: MSHH(GFFStructRef owner); static const ShortString& Type() { return type; } const ShortString& get_type() const { return type; } Text get_name() const; void set_name(const Text& value); Text get_materialObject() const; void set_materialObject(const Text& value); Text get_materialLibrary() const; void set_materialLibrary(const Text& value); Text get_id() const; void set_id(const Text& value); Text get_meshGroupName() const; void set_meshGroupName(const Text& value); unsigned char get_meshCastRuntimeShadow() const; void set_meshCastRuntimeShadow(unsigned char value); unsigned char get_meshCastBakedShadow() const; void set_meshCastBakedShadow(unsigned char value); unsigned char get_meshCutAway() const; void set_meshCutAway(unsigned char value); unsigned char get_meshPunchThrough() const; void set_meshPunchThrough(unsigned char value); GFFListRef get_meshBonesUsed() const; unsigned char get_meshReceiveBakedShadow() const; void set_meshReceiveBakedShadow(unsigned char value); unsigned char get_meshReceiveRuntimeShadow() const; void set_meshReceiveRuntimeShadow(unsigned char value); Text get_nodeMeshName() const; void set_nodeMeshName(const Text& value); unsigned char get_meshIsVfxMesh() const; void set_meshIsVfxMesh(unsigned char value); Color4 get_meshMaterialColor() const; void set_meshMaterialColor(Color4 value); unsigned char get_useVariationTint() const; void set_useVariationTint(unsigned char value); GFFListRef get_children() const; }; typedef ValuePtr<MSHH> MSHHPtr; typedef ValueRef<MSHH> MSHHRef; } //namespace MMH } //namespace DAO
[ "tazpn314@ccf8930c-dfc1-11de-9043-17b7bd24f792" ]
[ [ [ 1, 94 ] ] ]
91fce7a6440d520e12bfddde8a19d19b042c57a1
b7c505dcef43c0675fd89d428e45f3c2850b124f
/Src/SimulatorQt/Util/qt/Win32/include/Qt/qatomic.h
4fad65d9e10928955307e99564bc23ed80b06e6b
[ "BSD-2-Clause" ]
permissive
pranet/bhuman2009fork
14e473bd6e5d30af9f1745311d689723bfc5cfdb
82c1bd4485ae24043aa720a3aa7cb3e605b1a329
refs/heads/master
2021-01-15T17:55:37.058289
2010-02-28T13:52:56
2010-02-28T13:52:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,070
h
/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information ([email protected]) ** ** This file is part of the QtCore module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Commercial License Agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at [email protected]. ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QATOMIC_H #define QATOMIC_H #include <QtCore/qglobal.h> #include <QtCore/qbasicatomic.h> QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Core) // High-level atomic integer operations class Q_CORE_EXPORT QAtomicInt : public QBasicAtomicInt { public: inline QAtomicInt(int value = 0) { #ifdef QT_ARCH_PARISC this->_q_lock[0] = this->_q_lock[1] = this->_q_lock[2] = this->_q_lock[3] = -1; #endif _q_value = value; } inline QAtomicInt(const QAtomicInt &other) { #ifdef QT_ARCH_PARISC this->_q_lock[0] = this->_q_lock[1] = this->_q_lock[2] = this->_q_lock[3] = -1; #endif _q_value = other._q_value; } inline QAtomicInt &operator=(int value) { (void) QBasicAtomicInt::operator=(value); return *this; } inline QAtomicInt &operator=(const QAtomicInt &other) { (void) QBasicAtomicInt::operator=(other); return *this; } #ifdef qdoc bool operator==(int value) const; bool operator!=(int value) const; bool operator!() const; operator int() const; static bool isReferenceCountingNative(); static bool isReferenceCountingWaitFree(); bool ref(); bool deref(); static bool isTestAndSetNative(); static bool isTestAndSetWaitFree(); bool testAndSetRelaxed(int expectedValue, int newValue); bool testAndSetAcquire(int expectedValue, int newValue); bool testAndSetRelease(int expectedValue, int newValue); bool testAndSetOrdered(int expectedValue, int newValue); static bool isFetchAndStoreNative(); static bool isFetchAndStoreWaitFree(); int fetchAndStoreRelaxed(int newValue); int fetchAndStoreAcquire(int newValue); int fetchAndStoreRelease(int newValue); int fetchAndStoreOrdered(int newValue); static bool isFetchAndAddNative(); static bool isFetchAndAddWaitFree(); int fetchAndAddRelaxed(int valueToAdd); int fetchAndAddAcquire(int valueToAdd); int fetchAndAddRelease(int valueToAdd); int fetchAndAddOrdered(int valueToAdd); #endif }; // High-level atomic pointer operations template <typename T> class QAtomicPointer : public QBasicAtomicPointer<T> { public: inline QAtomicPointer(T *value = 0) { #ifdef QT_ARCH_PARISC this->_q_lock[0] = this->_q_lock[1] = this->_q_lock[2] = this->_q_lock[3] = -1; #endif QBasicAtomicPointer<T>::_q_value = value; } inline QAtomicPointer(const QAtomicPointer<T> &other) { #ifdef QT_ARCH_PARISC this->_q_lock[0] = this->_q_lock[1] = this->_q_lock[2] = this->_q_lock[3] = -1; #endif QBasicAtomicPointer<T>::_q_value = other._q_value; } inline QAtomicPointer<T> &operator=(T *value) { (void) QBasicAtomicPointer<T>::operator=(value); return *this; } inline QAtomicPointer<T> &operator=(const QAtomicPointer<T> &other) { (void) QBasicAtomicPointer<T>::operator=(other); return *this; } #ifdef qdoc bool operator==(T *value) const; bool operator!=(T *value) const; bool operator!() const; operator T *() const; T *operator->() const; static bool isTestAndSetNative(); static bool isTestAndSetWaitFree(); bool testAndSetRelaxed(T *expectedValue, T *newValue); bool testAndSetAcquire(T *expectedValue, T *newValue); bool testAndSetRelease(T *expectedValue, T *newValue); bool testAndSetOrdered(T *expectedValue, T *newValue); static bool isFetchAndStoreNative(); static bool isFetchAndStoreWaitFree(); T *fetchAndStoreRelaxed(T *newValue); T *fetchAndStoreAcquire(T *newValue); T *fetchAndStoreRelease(T *newValue); T *fetchAndStoreOrdered(T *newValue); static bool isFetchAndAddNative(); static bool isFetchAndAddWaitFree(); T *fetchAndAddRelaxed(qptrdiff valueToAdd); T *fetchAndAddAcquire(qptrdiff valueToAdd); T *fetchAndAddRelease(qptrdiff valueToAdd); T *fetchAndAddOrdered(qptrdiff valueToAdd); #endif }; /*! This is a helper for the assignment operators of implicitly shared classes. Your assignment operator should look like this: \snippet doc/src/snippets/code/src.corelib.thread.qatomic.h 0 */ template <typename T> inline void qAtomicAssign(T *&d, T *x) { if (d == x) return; x->ref.ref(); if (!d->ref.deref()) delete d; d = x; } /*! This is a helper for the detach method of implicitly shared classes. Your private class needs a copy constructor which copies the members and sets the refcount to 1. After that, your detach function should look like this: \snippet doc/src/snippets/code/src.corelib.thread.qatomic.h 1 */ template <typename T> inline void qAtomicDetach(T *&d) { if (d->ref == 1) return; T *x = d; d = new T(*d); if (!x->ref.deref()) delete x; } QT_END_NAMESPACE QT_END_HEADER #endif // QATOMIC_H
[ "alon@rogue.(none)" ]
[ [ [ 1, 227 ] ] ]
b9b8a3f0e3131a7c372f9785b7467ce1580e1637
95a3e8914ddc6be5098ff5bc380305f3c5bcecb2
/src/FusionForever_lib/PlayerAI.cpp
32dc1d1fb58064c7b77913a1943fcf0caa52db75
[]
no_license
danishcake/FusionForever
8fc3b1a33ac47177666e6ada9d9d19df9fc13784
186d1426fe6b3732a49dfc8b60eb946d62aa0e3b
refs/heads/master
2016-09-05T16:16:02.040635
2010-04-24T11:05:10
2010-04-24T11:05:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
15,773
cpp
#include "StdAfx.h" #include "PlayerAI.h" #include "TurningRoutines.h" #include "Core.h" #include "sdl.h" #include "Radar.h" std::vector<int> PlayerAI::core_ids_; std::map<int, std::vector<InputConfig> > PlayerAI::bindings; void PlayerAI::SaveBindings() { TiXmlDocument doc("Controls.xml"); TiXmlElement* root = new TiXmlElement("Controls"); doc.LinkEndChild(root); for(std::map<int, std::vector<InputConfig> >::iterator it = bindings.begin(); it != bindings.end(); ++it) { TiXmlElement* player = new TiXmlElement("PlayerBindings"); player->SetAttribute("id", it->first); for(std::vector<InputConfig>::iterator it2 = it->second.begin(); it2 != it->second.end(); it2++) { TiXmlElement* ic = new TiXmlElement("InputConfig"); ic->SetAttribute("Action", Action::ToStr[it2->action]); ic->SetAttribute("BindingType", BindingType::ToStr[it2->type]); switch(it2->type) { case BindingType::KeyboardBinding: { TiXmlElement* kb_el = new TiXmlElement("Binding"); kb_el->SetAttribute("Key", it2->binding.key); ic->LinkEndChild(kb_el); } break; case BindingType::JoystickButtonBinding: { TiXmlElement* jsb_el = new TiXmlElement("Binding"); jsb_el->SetAttribute("JoystickIndex", it2->binding.joystick_button.joystick_index); jsb_el->SetAttribute("JoystickButton", it2->binding.joystick_button.button_index); ic->LinkEndChild(jsb_el); } break; case BindingType::MouseButtonBinding: { TiXmlElement* mb_el = new TiXmlElement("Binding"); mb_el->SetAttribute("MouseButton", MouseButton::ToStr[it2->binding.mouse_button]); ic->LinkEndChild(mb_el); } break; case BindingType::JoystickAxisBinding: { TiXmlElement* jsa_el = new TiXmlElement("Binding"); jsa_el->SetAttribute("JoystickAxis", it2->binding.joystick_axis.axis_index); jsa_el->SetAttribute("JoystickIndex", it2->binding.joystick_axis.joystick_index); ic->LinkEndChild(jsa_el); } break; case BindingType::MouseAxisBinding: { TiXmlElement* ma_el = new TiXmlElement("Binding"); ma_el->SetAttribute("MouseAxis", MouseAxis::ToStr[it2->binding.mouse_axis]); ic->LinkEndChild(ma_el); } break; } player->LinkEndChild(ic); } root->LinkEndChild(player); } doc.SaveFile(); } void PlayerAI::LoadBindings() { TiXmlDocument doc("Controls.xml"); bool xml_error = false; if(doc.LoadFile()) { TiXmlElement* root = doc.FirstChildElement("Controls"); if(root) { TiXmlElement* player = root->FirstChildElement("PlayerBindings"); while(player) { int player_id = 0; if(player->QueryIntAttribute("id", &player_id) == TIXML_SUCCESS) { TiXmlElement* ic = player->FirstChildElement("InputConfig"); while(ic) { std::string action_string; if(ic->QueryValueAttribute("Action", &action_string) != TIXML_SUCCESS) { Logger::ErrorOut() << "Error reading action attribute, continuing\n"; continue; } std::string binding_type_string; if(ic->QueryValueAttribute("BindingType", &binding_type_string) != TIXML_SUCCESS) { Logger::ErrorOut() << "Error reading binding attribute, continuing\n"; continue; } Action::Enum action = Action::FromStr(action_string); BindingType::Enum binding_type = BindingType::FromStr(binding_type_string); TiXmlElement* binding = ic->FirstChildElement("Binding"); if(binding) { switch(binding_type) { case BindingType::KeyboardBinding: { int key = 0; if(binding->QueryValueAttribute("Key", &key) == TIXML_SUCCESS) { bindings[player_id].push_back(InputConfig(binding_type, Binding((SDLKey)key), action)); } else { Logger::ErrorOut() << "Missing Key attribute, continuing\n"; continue; } } break; case BindingType::JoystickButtonBinding: { int joystick_index = 0; int joystick_button_index = 0; if(binding->QueryValueAttribute("JoystickIndex", &joystick_index) == TIXML_SUCCESS && binding->QueryValueAttribute("JoystickButton", &joystick_button_index) == TIXML_SUCCESS) { bindings[player_id].push_back(InputConfig(binding_type, Binding(JoystickButton::Create(joystick_index, joystick_button_index)), action)); } else { Logger::ErrorOut() << "Missing JoystickIndex or JoystickButton atttribute, continuing\n"; } } break; case BindingType::JoystickAxisBinding: { int joystick_index = 0; int joystick_axis_index = 0; if(binding->QueryValueAttribute("JoystickIndex", &joystick_index) == TIXML_SUCCESS && binding->QueryValueAttribute("JoystickAxis", &joystick_axis_index) == TIXML_SUCCESS) { bindings[player_id].push_back(InputConfig(binding_type, Binding(JoystickAxis::Create(joystick_index, joystick_axis_index)), action)); } else { Logger::ErrorOut() << "Missing JoystickIndex or JoystickAxis atttribute, continuing\n"; } } break; case BindingType::MouseAxisBinding: { std::string axis; if(binding->QueryValueAttribute("MouseAxis", &axis) == TIXML_SUCCESS) { MouseAxis::Enum mouse_axis = MouseAxis::FromStr(axis); if(mouse_axis != MouseAxis::InvalidFirst && mouse_axis != MouseAxis::InvalidLast) { bindings[player_id].push_back(InputConfig(binding_type, Binding(mouse_axis), action)); } else { Logger::ErrorOut() << "MouseAxis attribute incorrect: " << axis << "\n"; } } else { Logger::ErrorOut() << "Missing MouseAxis attribute\n"; } } break; case BindingType::MouseButtonBinding: { std::string button; if(binding->QueryValueAttribute("MouseButton", &button) == TIXML_SUCCESS) { MouseButton::Enum mouse_button = MouseButton::FromStr(button); if(mouse_button != MouseButton::InvalidFirst && mouse_button != MouseButton::InvalidLast) { bindings[player_id].push_back(InputConfig(binding_type, Binding(mouse_button), action)); } else { Logger::ErrorOut() << "Missing MouseAxis attribute\n"; } } else { Logger::ErrorOut() << "Missing MouseButton attribute\n"; } } break; } } else { xml_error = true; Logger::ErrorOut() << "Missing Binding element\n"; } ic = ic->NextSiblingElement("InputConfig"); } } else xml_error = true; player = player->NextSiblingElement("PlayerBindings"); } } else xml_error = true; } else xml_error = true; if(xml_error) { ResetToDefault(); } } void PlayerAI::ResetToDefault() { bindings.clear(); std::vector<InputConfig> p1; std::vector<InputConfig> p2; p1.push_back(InputConfig(BindingType::KeyboardBinding, Binding(SDLK_a), Action::MoveLeft)); p1.push_back(InputConfig(BindingType::KeyboardBinding, Binding(SDLK_d), Action::MoveRight)); p1.push_back(InputConfig(BindingType::KeyboardBinding, Binding(SDLK_w), Action::MoveUp)); p1.push_back(InputConfig(BindingType::KeyboardBinding, Binding(SDLK_s), Action::MoveDown)); p1.push_back(InputConfig(BindingType::MouseAxisBinding, Binding(MouseAxis::MouseX), Action::LookXAxis)); p1.push_back(InputConfig(BindingType::MouseAxisBinding, Binding(MouseAxis::MouseY), Action::LookYAxis)); p1.push_back(InputConfig(BindingType::KeyboardBinding, Binding(SDLK_LCTRL), Action::Boost)); p1.push_back(InputConfig(BindingType::MouseButtonBinding, Binding(MouseButton::LeftMouseButton), Action::Fire)); p1.push_back(InputConfig(BindingType::MouseButtonBinding, Binding(MouseButton::RightMouseButton), Action::Boost)); p1.push_back(InputConfig(BindingType::MouseButtonBinding, Binding(MouseButton::MiddleMouseButton), Action::Target)); p2.push_back(InputConfig(BindingType::JoystickAxisBinding, Binding(JoystickAxis::Create(0,0)), Action::XMovement)); p2.push_back(InputConfig(BindingType::JoystickAxisBinding, Binding(JoystickAxis::Create(0,1)), Action::YMovement)); p2.push_back(InputConfig(BindingType::JoystickAxisBinding, Binding(JoystickAxis::Create(0,0)), Action::LookXAxis)); p2.push_back(InputConfig(BindingType::JoystickAxisBinding, Binding(JoystickAxis::Create(0,1)), Action::LookYAxis)); p2.push_back(InputConfig(BindingType::JoystickButtonBinding, Binding(JoystickButton::Create(0,0)), Action::Fire)); p2.push_back(InputConfig(BindingType::JoystickButtonBinding, Binding(JoystickButton::Create(0,1)), Action::Boost)); p2.push_back(InputConfig(BindingType::JoystickButtonBinding, Binding(JoystickButton::Create(0,2)), Action::LockAngle)); p2.push_back(InputConfig(BindingType::JoystickButtonBinding, Binding(JoystickButton::Create(0,3)), Action::LockMovement)); p2.push_back(InputConfig(BindingType::JoystickButtonBinding, Binding(JoystickButton::Create(0,5)), Action::LookBackwards)); bindings[0] = p1; bindings[1] = p2; } PlayerAI::PlayerAI(int _player_id) { player_id_ = _player_id; lock_angle_ = false; core_id_ = -1; } PlayerAI::~PlayerAI(void) { if(core_id_ != -1) { core_ids_.erase(std::remove(core_ids_.begin(), core_ids_.end(), core_id_), core_ids_.end()); } } AIAction PlayerAI::Tick(float _timespan, std::vector<Core*>& /*_allies*/, std::vector<Core*>& _enemies, Core* _self) { if(core_id_ == -1) { core_id_ = _self->GetSectionID(); if(core_id_ != -1) { core_ids_.push_back(core_id_); } else Logger::ErrorOut() << "Player ID of -1 encountered\n"; } if(core_ids_.size() == 1) { Radar::SetPlayerPosition(_self->GetGlobalPosition()); } AIAction action; Uint8* keystates = SDL_GetKeyState(0); int mx, my; int mb = SDL_GetMouseState(&mx, &my); Vector3f point_to_face; Vector3f peer_factor; bool lock_movement = false; bool lock_angle = false; bool look_backwards = false; if(SDL_NumJoysticks()) SDL_JoystickUpdate(); point_to_face = _self->GetGlobalPosition(); std::vector<InputConfig>& binds = bindings[player_id_]; for(std::vector<InputConfig>::iterator it = binds.begin(); it != binds.end(); ++it) { switch(it->type) { case BindingType::MouseAxisBinding: { float axis_value = 0; float ltv_axis_value = 0; switch(it->binding.mouse_axis) { case MouseAxis::MouseX: axis_value = static_cast<float>(mx); ltv_axis_value = ltv_mouse_position_.x; break; case MouseAxis::MouseY: axis_value = static_cast<float>(my); ltv_axis_value = ltv_mouse_position_.y; break; } switch(it->action) { case Action::LookXAxis: point_to_face.x = Camera::Instance().ScreenToWorld(Vector3f(axis_value, 0, 0)).x; peer_factor.x = (axis_value - (Camera::Instance().GetWindowWidth() / 2.0f)) * 2.0f / Camera::Instance().GetWindowWidth(); break; case Action::LookYAxis: point_to_face.y = Camera::Instance().ScreenToWorld(Vector3f(0, axis_value, 0)).y; peer_factor.y = -(axis_value - (Camera::Instance().GetWindowHeight() / 2.0f)) * 2.0f / Camera::Instance().GetWindowHeight(); break; case Action::XMovement: movement_integrator_.x *= (1.0f - 0.2f * _timespan); movement_integrator_.x += axis_value - ltv_axis_value; action.dx_ += movement_integrator_.x / (fabs(movement_integrator_.x) > 1.0f ? fabs(movement_integrator_.x) : 1.0f); break; case Action::YMovement: movement_integrator_.y *= (1.0f - 0.2f * _timespan); movement_integrator_.y += axis_value - ltv_axis_value; action.dx_ += movement_integrator_.y / (fabs(movement_integrator_.y) > 1.0f ? fabs(movement_integrator_.y) : 1.0f); break; } } break; case BindingType::JoystickAxisBinding: { float axis_value = 0; if(it->binding.joystick_axis.joystick) { Sint16 js_axis_val = SDL_JoystickGetAxis(it->binding.joystick_axis.joystick, it->binding.joystick_axis.axis_index); if(abs(js_axis_val) < MAXSHORT * 0.2f) js_axis_val = 0; axis_value = (float)js_axis_val / (float)MAXSHORT; } switch(it->action) { case Action::LookXAxis: point_to_face.x += axis_value; peer_factor.x = axis_value; break; case Action::LookYAxis: point_to_face.y -= axis_value; peer_factor.y = -axis_value; break; case Action::XMovement: action.dx_ += axis_value; break; case Action::YMovement: action.dy_ -= axis_value; break; } break; } case BindingType::KeyboardBinding: case BindingType::MouseButtonBinding: case BindingType::JoystickButtonBinding: if((it->type == BindingType::KeyboardBinding && keystates[it->binding.key]) || (it->type == BindingType::MouseButtonBinding && (mb & SDL_BUTTON(GetSDLCode(it->binding.mouse_button)))) || (it->type == BindingType::JoystickButtonBinding && it->binding.joystick_button.joystick && SDL_JoystickGetButton(it->binding.joystick_button.joystick, it->binding.joystick_button.button_index))) { switch(it->action) { case Action::Fire: action.firing_ = true; break; case Action::Boost: action.thrust_ = true; break; case Action::Target: break; case Action::MoveLeft: action.dx_--; break; case Action::MoveRight: action.dx_++; break; case Action::MoveUp: action.dy_++; break; case Action::MoveDown: action.dy_--; break; case Action::LockMovement: lock_movement = true; break; case Action::LockAngle: lock_angle = true; break; case Action::LookBackwards: look_backwards = true; break; } } break; } } if(look_backwards) { point_to_face *= -1; } if(lock_angle_) { point_to_face = lock_vector_ + _self->GetGlobalPosition();//+ _self->GetAngle(); } Vector3f point_to_face_relative = point_to_face - _self->GetGlobalPosition(); if(point_to_face_relative.lengthSq()!=0) { TurnData turn_data = GetTurnDirection(_self->GetAngle(), point_to_face_relative); float dotprod = turn_data.turn_factor; action.dtheta_ = ClampTurnDirection(dotprod, 0.4f); if(peer_factor.lengthSq() > 1) peer_factor.normalize(); Vector3f camera_centre = _self->GetGlobalPosition(); Camera::Instance().SetCentreTarget(camera_centre.x, camera_centre.y, peer_factor.x, peer_factor.y, CameraLevel::Human); Camera::Instance().SetFocus(_self->GetPosition().x, _self->GetPosition().y, CameraLevel::Human); } else { Camera::Instance().SetCentreTarget(_self->GetPosition().x, _self->GetPosition().y, 0, 0, CameraLevel::Human); Camera::Instance().SetFocus(_self->GetPosition().x, _self->GetPosition().y, CameraLevel::Human); } ltv_mouse_position_.x = static_cast<float>(mx); ltv_mouse_position_.y = static_cast<float>(my); if(lock_movement) { action.dx_ = 0; action.dy_ = 0; } if(lock_angle && !lock_angle_) { lock_vector_ = Vector3f(sinf(_self->GetAngle() * M_PI / 180.0f), cosf(_self->GetAngle() * M_PI / 180.0f), 0); } lock_angle_ = lock_angle; return action; }
[ [ [ 1, 456 ] ] ]
66925a8d8350b09fe5288597c5885d31ef748b72
c0c2acf1ee600d9e86a68828738130a6de9e6438
/src/Engines/Audio/AudioEngine.cpp
6f8e0d8f81b15da84dbb8cba79ffb9f3947e7fe8
[]
no_license
nekonyuu/bombersow-project2
bdc9bb46ddf3f3e3bdf4ab1a0f6fc54dc1e2fbc3
7420ae63189cd1e508463dc91921c60aa554378c
refs/heads/master
2021-01-22T14:40:02.181184
2010-11-16T18:17:54
2010-11-16T18:17:54
32,104,900
0
0
null
null
null
null
UTF-8
C++
false
false
2,033
cpp
/* GPL v3 Licence : Bombersow is a free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Bombersow is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Bombersow. If not, see <http://www.gnu.org/licenses/>. Creative Commons BY-NC-SA : This work is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA. */ #include "Engines/Audio/AudioEngine.hpp" AudioEngine::AudioEngine() { // Loading musics loadMusic(std::string("menu"), std::string("sounds/music/ParagonX9 - Metropolis [8-Bit].ogg")); } AudioEngine::~AudioEngine() { } void AudioEngine::Run() { // TODO : vidage du vector sounds. } void AudioEngine::loadSound(std::string name, std::string path) { buffers[name].LoadFromFile(path); } void AudioEngine::loadMusic(std::string name, std::string path) { sf::Music *music = new sf::Music(); music->OpenFromFile(path); musics[name] = music; } void AudioEngine::playSound(std::string name) { if(buffers.find(name) != buffers.end()) { sf::Sound sound(buffers[name]); sounds.push_back(sound); sounds.back().Play(); } } void AudioEngine::playMusic(std::string name) { if(musics.find(name) != musics.end()) musics[name]->Play(); } void AudioEngine::stopMusic(std::string name) { }
[ [ [ 1, 74 ] ] ]
85ecb001ee76d72da1a902bf8f5b2b1c5e88d921
7b4c786d4258ce4421b1e7bcca9011d4eeb50083
/_代码统计专用文件夹/C++Primer中文版(第4版)/第十一章 泛型算法/20090213_代码11.2.3_对容器元素重新排列的算法.cpp
1237839404688db237f398d878ccba60dffca9b5
[]
no_license
lzq123218/guoyishi-works
dbfa42a3e2d3bd4a984a5681e4335814657551ef
4e78c8f2e902589c3f06387374024225f52e5a92
refs/heads/master
2021-12-04T11:11:32.639076
2011-05-30T14:12:43
2011-05-30T14:12:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,094
cpp
#include <iostream> #include <algorithm> #include <vector> #include <string> using namespace std; bool isShorter(const string &s1, const string &s2) { return s1.size() < s2.size(); } bool GT6(const string &s) { return s.size() >= 6; } string make_plural(size_t ctr, const string &word, const string &ending) { return (ctr == 1) ? word : word + ending; } int main() { vector<string> words; string word; cout << "Enter some words(Ctrl+Z to end):" << endl; while (cin >> word) words.push_back(word); cin.clear(); sort(words.begin(), words.end()); vector<string>::iterator end_unique = unique(words.begin(), words.end()); words.erase(end_unique, words.end()); stable_sort(words.begin(), words.end(), isShorter); vector<string>::size_type wc = count_if(words.begin(), words.end(), GT6); cout << wc << " " << make_plural(wc, "word", "s") << " 6 characters or longer" << endl; for (vector<string>::iterator iter = words.begin(); iter != words.end(); ++iter) { cout << *iter << " "; } cout << endl; return 0; }
[ "baicaibang@70501136-4834-11de-8855-c187e5f49513" ]
[ [ [ 1, 52 ] ] ]
6173e429335ca2f5e13e6d3beb97fdb47c550b6f
c3531ade6396e9ea9c7c9a85f7da538149df2d09
/Param/include/hj_3rd/zjucad/matrix/iterator.h
24676cd0854fd2b6df95539bca118779e08a87e2
[]
no_license
feengg/MultiChart-Parameterization
ddbd680f3e1c2100e04c042f8f842256f82c5088
764824b7ebab9a3a5e8fa67e767785d2aec6ad0a
refs/heads/master
2020-03-28T16:43:51.242114
2011-04-19T17:18:44
2011-04-19T17:18:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,174
h
/* State Key Lab of CAD&CG Zhejiang Unv. Author: Jin Huang ([email protected]) Copyright (c) 2004-2010 <Jin Huang> All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. */ #ifndef _ZJUCAD_MATRIX_ITERATOR_H_ #define _ZJUCAD_MATRIX_ITERATOR_H_ #include <iterator> namespace zjucad { namespace matrix { template <typename T> struct default_matrix_iterator { typedef std::forward_iterator_tag iterator_category; typedef T value_type; typedef ptrdiff_t difference_type; typedef T* pointer; typedef T& reference; }; }} #endif
[ [ [ 1, 39 ] ] ]
e3d4d9b746683413a7984e498b57ae8ccc9cf200
0c1f669f3dfdab47085bf537348b0354f836abea
/ qtremotedroid/QtRemoteDroidClient/src/start.cpp
c7225a9d96e6e2f76012c719325f5b949fb7b372
[]
no_license
harlentan/qtremotedroid
fc5fc96d4374c39561aea73470a88d1f0a68b637
d07dd045213711538b38c7ced2fd6d5a8edcf241
refs/heads/master
2021-01-10T11:37:59.331004
2010-12-12T09:55:39
2010-12-12T09:55:39
54,114,402
0
0
null
null
null
null
UTF-8
C++
false
false
2,634
cpp
#include <QtGui> #include <QDesktopWidget> #include "start.h" #include "widget.h" start::start(QWidget *parent) : QWidget(parent) { QDesktopWidget* desktopWidget = QApplication::desktop(); //get client rect. QRect rect = desktopWidget->availableGeometry(); Widget *native = new Widget(&helper, this); nativeLabel = new QLabel(tr("Welcome to Teleca Qt!")); nativeLabel->setAlignment(Qt::AlignHCenter); stateLabel = new QLabel(tr("Starting...")); stateLabel->setAlignment(Qt::AlignHCenter); /*imageLabel = new QLabel(); imageLabel->resize(rect.width(),rect.height()*0.8); QPixmap pixmap(":/784.gif"); //pixmap = new QPixmap(":/784.gif"); imageLabel->setPixmap(pixmap.scaled(imageLabel->size()));*/ // QSplashScreen splash(pixmap); //Window window; createProgressBar(); QGridLayout *layout = new QGridLayout; layout->addWidget(nativeLabel, 0, 0); layout->addWidget(native, 1, 0); layout->addWidget(progressBar, 2, 0); layout->addWidget(stateLabel,3,0); setLayout(layout); QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), native, SLOT(animate())); timer->start(250); //timer->start(2); setWindowTitle(tr("start")); // setWindowIcon(QIcon(":/images/qt.png")); } start::~start() { delete(progressBar); //delete(pixmap); //delete(native); delete(nativeLabel); delete(stateLabel); } void start::createProgressBar() { progressBar = new QProgressBar; progressBar->setRange(0, 3000); progressBar->setValue(0); progressBar->setTextVisible(0); QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(advanceProgressBar())); timer->start(0); } void start::advanceProgressBar() { int curVal = progressBar->value(); // int maxVal = progressBar->maximum(); if (curVal < progressBar->maximum()) { progressBar->setValue(curVal + 1 ); } else { //timer->stop(); //delete timer; //this->close(); QTimer *tmpTm = qobject_cast<QTimer *>(sender()); tmpTm->stop();//stop the Timer exitStart(); } } void start::exitStart() { //this->close(); this->hide(); pConfig = new ClientConfig; pConfig->show(); pConfig->showFullScreen(); //a.actions(); } /* void start::closeEvent(QCloseEvent *) { this->hide(); pConfig = new ClientConfig; pConfig->show(); } */
[ [ [ 1, 134 ] ] ]
4d83b86f11d995b3db7c1b81f42675b122c5e768
b23a27888195014aa5bc123d7910515e9a75959c
/Main/V1.0/Srcs/opcspot/DAServer.h
6bac37b4105f21d0882c8cda2f499a1c915423b7
[]
no_license
fostrock/connectspot
c54bb5484538e8dd7c96b76d3096dad011279774
1197a196d9762942c0d61e2438c4a3bca513c4c8
refs/heads/master
2021-01-10T11:39:56.096336
2010-08-17T05:46:51
2010-08-17T05:46:51
50,015,788
1
0
null
null
null
null
UTF-8
C++
false
false
1,775
h
//------------------------------------------------------------------------------------------ // File: <DAServer.h> // Purpose: declare <OPC da class object> // // @author <Yun Hua> // @version 1.0 2010/01/04 // // Copyright (C) 2010, Yun Hua //-----------------------------------------------------------------------------------------// #pragma once #include "resource.h" // main symbols #include "opcspot_i.h" class MyClassFactory; // {63D5F432-CFE4-11d1-B2C8-0060083BA1FB} static const GUID CATID_OPCDAServer20 = {0x63D5F432, 0xCFE4, 0x11d1, {0xB2, 0xC8, 0x00, 0x60, 0x08, 0x3B, 0xA1, 0xFB}}; // {63D5F430-CFE4-11d1-B2C8-0060083BA1FB} static const GUID CATID_OPCDAServer10 = {0x63D5F430, 0xCFE4, 0x11d1, {0xB2, 0xC8, 0x00, 0x60, 0x08, 0x3B, 0xA1, 0xFB}}; // DAServer class ATL_NO_VTABLE DAServer : public CComObjectRootEx<CComMultiThreadModel>, public CComCoClass<DAServer, &CLSID_DAServer>, public IDispatchImpl<IDAServer, &IID_IDAServer, &LIBID_opcspotLib, /*wMajor =*/ 1, /*wMinor =*/ 0> { public: DAServer() { } DECLARE_REGISTRY_RESOURCEID(IDR_DASERVER) DECLARE_CLASSFACTORY_EX(MyClassFactory) BEGIN_COM_MAP(DAServer) COM_INTERFACE_ENTRY(IDAServer) COM_INTERFACE_ENTRY(IDispatch) END_COM_MAP() // Register OPC DA 2.0 category, so // 'Implemented Categories' // { // {63D5F432-CFE4-11D1-B2C8-0060083BA1FB} // } // in DAServer.rgs is redundant. BEGIN_CATEGORY_MAP(DAServer) IMPLEMENTED_CATEGORY(CATID_OPCDAServer10) IMPLEMENTED_CATEGORY(CATID_OPCDAServer20) END_CATEGORY_MAP() DECLARE_PROTECT_FINAL_CONSTRUCT() HRESULT FinalConstruct() { return S_OK; } void FinalRelease() { } public: }; OBJECT_ENTRY_AUTO(__uuidof(DAServer), DAServer)
[ [ [ 1, 73 ] ] ]
21128459ff3cabf3b3ff074e2a311474d2a25a30
fd0221edcf44c190efadd6d8b13763ef5bcbc6f6
/fer_h264/fer_h264/fer_h264.h
bdb858178fdc61b1ffee45ac6c91d7b7fa58bbe6
[]
no_license
zoltanmaric/h264-fer
2ddb8ac5af293dd1a30d9ca37c8508377745d025
695c712a74a75ad96330613e5dd24938e29f96e6
refs/heads/master
2021-01-01T15:31:42.218179
2010-06-17T21:09:11
2010-06-17T21:09:11
32,142,996
0
0
null
null
null
null
UTF-8
C++
false
false
814
h
#pragma once #include <string> // .Net System Namespaces using namespace System; using namespace System::Runtime::InteropServices; inline String ^ ToManagedString(const char * pString); inline const std::string ToStdString(String ^ strString); namespace fer_h264 { public ref class Starter { public: void PokreniKoder(); public: void NastaviKoder(); public: void PokreniDekoder(); public: void DohvatiStatistiku(int % brojTipova1, int % brojTipova2, int % brojTipova3, int % brojTipova4, int % brojTipova5, int % velicina, int % trajanje); public: void PostaviParametre(int FrameStart, int FrameEnd, int qp, int OsnovnoPredvidanje, int VelicinaProzora, int ToleriranaGreska, int IntraSvakih); public: void PostaviUlazIzlaz(String ^% ulaz, String ^% izlaz); }; }
[ "davor.prugovecki@9f3bdf0a-daf3-11de-b590-7f2b5bfbe1fd" ]
[ [ [ 1, 26 ] ] ]
c929d9f43f9374e00f48c7039f2ce917dfd4a3dc
3920e5fc5cbc2512701a3d2f52e072fd50debb83
/Source/Common/itkManagedImageBase.cxx
aa6cb8015e91695a11fcb96a6dd846f56f89106a
[ "MIT" ]
permissive
amirsalah/manageditk
4063a37d7370dcbcd08bfe9d24d22015d226ceaf
1ca3a8ea7db221a3b6a578d3c75e3ed941ef8761
refs/heads/master
2016-08-12T05:38:03.377086
2010-08-02T08:17:32
2010-08-02T08:17:32
52,595,294
0
0
null
null
null
null
UTF-8
C++
false
false
18,333
cxx
/*============================================================================= NOTE: THIS FILE IS A HANDMADE WRAPPER FOR THE ManagedITK PROJECT. Project: ManagedITK Program: Insight Segmentation & Registration Toolkit Module: itkManagedImageBase.cxx Language: C++/CLI Author: Dan Mueller Date: $Date: 2008-03-09 19:29:02 +0100 (Sun, 09 Mar 2008) $ Revision: $Revision: 8 $ Portions of this code are covered under the ITK and VTK copyright. See http://www.itk.org/HTML/Copyright.htm for details. See http://www.vtk.org/copyright.php for details. Copyright (c) 2007-2008 Daniel Mueller Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =============================================================================*/ #pragma once #pragma warning( disable : 4635 ) // Disable warnings about XML doc comments #ifndef __itkManagedImageBase_cxx #define __itkManagedImageBase_cxx // Include some useful ITK headers #pragma unmanaged #include "itkImageIOFactory.h" // Include some useful ManagedITK files #pragma managed #include "itkManagedDataObject.cxx" #include "itkManagedDataObjectWithReadWrite.cxx" #include "itkManagedIndex.cxx" #include "itkManagedContinuousIndex.cxx" #include "itkManagedPoint.cxx" #include "itkManagedOffset.cxx" #include "itkManagedPixelType.cxx" #include "itkManagedPixel.cxx" #include "itkManagedSize.cxx" #include "itkManagedSpacing.cxx" #include "itkManagedMatrix.cxx" #include "itkManagedImageRegion.cxx" #include "itkManagedExceptionObject.cxx" #include "itkManagedImageInformation.cxx" // Use some managed namespaces #using <mscorlib.dll> #using <System.dll> using namespace System; using namespace System::IO; using namespace System::Reflection; using namespace System::Diagnostics; using namespace System::Collections::Generic; namespace itk { ///<summary> ///This class is a managed wrapper for itk::ImageBase. ///</summary> public ref class itkImageBase abstract : itkDataObjectWithReadWrite { protected: itkPixelType^ m_PixelType; unsigned int m_Dimension; ///<summary>Protected constructor.</summary> itkImageBase ( ) : itkDataObjectWithReadWrite( ) { } public: ///<summary>Dispose of the managed object.</summary> ~itkImageBase ( ) { } ///<summary>Get the type of pixel this image contains.</summary> ///<remarks> ///In native itk, images are templated over the pixel type: TPixel (eg. unsigned ///char, float, etc). In ManagedITK, to allow for the specification of image types ///at runtime, the itkPixelType and itkPixel classes were introduced. ///</remarks> property itkPixelType^ PixelType { itkPixelType^ get( ) { return this->m_PixelType; } } ///<summary>Get the number of dimensions this image contains.</summary> ///<remarks> ///In native itk, images are templated over the number of dimensions: VDimension. ///In ManagedITK, to allow for the specification of image types at runtime, ///this property was introduced. ///</remarks> property unsigned int Dimension { unsigned int get( ) { return this->m_Dimension; } } ///<summary>Get the size of the image (from the LargestPossibleRegion).</summary> ///<remarks>This method was added in ManagedITK for simplicity.</remarks> property itkSize^ Size { virtual itkSize^ get()=0; } ///<summary> ///Get the physical size of the image of the image (element-wise multiplication ///of Size and Spacing). ///</summary> ///<remarks>This method was added in ManagedITK for simplicity.</remarks> property itkArray<double>^ PhysicalSize { virtual itkArray<double>^ get() { itkArray<double>^ result = gcnew itkArray<double>(this->Dimension); for (unsigned int i=0; i<this->Dimension; i++) result[i] = this->Size[i] * this->Spacing[i]; return result; } } ///<summary>Get/set the spacing between pixels of the image.</summary> property itkSpacing^ Spacing { virtual itkSpacing^ get()=0; virtual void set( itkSpacing^ spacing )=0; } ///<summary>Get/set the origin of the image in physical space.</summary> property itkPoint^ Origin { virtual itkPoint^ get()=0; virtual void set( itkPoint^ origin )=0; } ///<summary> ///Get the region object that defines the size and starting index ///for the largest possible region this image could represent. ///</summary> property itkImageRegion^ LargestPossibleRegion { virtual itkImageRegion^ get()=0; virtual void set ( itkImageRegion^ region )=0; } ///<summary> ///Get/set the region object that defines the size and starting index ///for the region of the image requested (i.e., the region of the ///image to be operated on by a filter). Setting the RequestedRegion ///does not cause the object to be modified. ///</summary> property itkImageRegion^ RequestedRegion { virtual itkImageRegion^ get()=0; virtual void set ( itkImageRegion^ region )=0; } ///<summary> ///Get/set the region object that defines the size and starting index ///of the region of the image currently loaded in memory. ///</summary> property itkImageRegion^ BufferedRegion { virtual itkImageRegion^ get()=0; virtual void set ( itkImageRegion^ region )=0; } ///<summary>Get the pointer to the underlying image data array.</summary> property IntPtr Buffer { virtual IntPtr get()=0; } ///<summary>Get the direction cosines of the image. The direction cosines are vectors that point from one pixel to the next.</summary> property itkMatrix^ Direction { virtual itkMatrix^ get()=0; virtual void set ( itkMatrix^ direction )=0; } ///<summary> ///Allocates the memory for an empty image. ///This is the method to use to create an image from scratch (ie. not from IO). ///The regions MUST have been set: call SetRegions() before calling this method. ///The buffer is NOT initialised: call FillBuffer() after calling this method. ///</summary> ///<remarks>This method finalises the creation of the underlying native itk::Image.</remarks> virtual void Allocate ( )=0; ///<summary> ///Convenience method to set the LargestPossibleRegion, BufferedRegion and RequestedRegion. ///</summary> ///<param name="regions">The image region specifying the largest, requested, and buffered size.</param> ///<remarks> ///This method does not allocate the image, use Allocate for that purpose. ///</remarks> virtual void SetRegions ( itkImageRegion^ regions )=0; ///<summary> ///Fills the image data with the given value. ///The image regions must be set before calling this method and ///the image must have been allocated. ///</summary> ///<param name="value">The pixel value to fill the image.</param> virtual void FillBuffer ( itkPixel^ value )=0; ///<summary>Read and return the image information.</summary> ///<param name="filename">The relative or absolute file path and name.</param> ///<returns>An itkImageInformation structure containing the dimensions, pixeltype, ///size, spacing, etc. of the given image.</returns> ///<remarks>This method was added in ManagedITK for simplicity.</remarks> static itkImageInformation^ ReadInformation ( System::String^ filename ) { try { // Marshal string to std::string std::string stdFilename; itkObject::MarshalString( filename, stdFilename ); // Read the image information itk::ImageIOBase::Pointer imageIO = itk::ImageIOFactory::CreateImageIO( stdFilename.c_str(), itk::ImageIOFactory::ReadMode ); if ( imageIO.IsNull() ) { throw gcnew NotSupportedException( "The given file type is not supported." ); return nullptr; } imageIO->SetFileName( stdFilename.c_str() ); imageIO->ReadImageInformation(); // Get the dim, size, spacing and origin unsigned int dim = imageIO->GetNumberOfDimensions(); itkSize^ size = gcnew itkSize( dim ); itkSpacing^ spacing = gcnew itkSpacing( dim ); itkPoint^ origin = gcnew itkPoint( dim ); for (unsigned int i=0; i<dim; i++) { spacing[i] = imageIO->GetSpacing( i ); origin[i] = imageIO->GetOrigin( i ); size[i] = imageIO->GetDimensions( i ); } // Get the pixel type itkPixelTypeEnum componentType = itkPixelTypeEnum::UnsignedChar; itkPixelArrayEnum arrayType = itkPixelArrayEnum::Scalar; switch (imageIO->GetComponentType()) { case itk::ImageIOBase::UCHAR: componentType = itkPixelTypeEnum::UnsignedChar; break; case itk::ImageIOBase::CHAR: componentType = itkPixelTypeEnum::SignedChar; break; case itk::ImageIOBase::USHORT: componentType = itkPixelTypeEnum::UnsignedShort; break; case itk::ImageIOBase::SHORT: componentType = itkPixelTypeEnum::SignedShort; break; case itk::ImageIOBase::ULONG: componentType = itkPixelTypeEnum::UnsignedLong; break; case itk::ImageIOBase::LONG: componentType = itkPixelTypeEnum::SignedLong; break; case itk::ImageIOBase::FLOAT: componentType = itkPixelTypeEnum::Float; break; case itk::ImageIOBase::DOUBLE: componentType = itkPixelTypeEnum::Double; break; default: throw gcnew NotSupportedException( "Unsupported pixel component type: " + ((int)imageIO->GetComponentType()).ToString() ); return nullptr; } switch (imageIO->GetPixelType()) { case itk::ImageIOBase::SCALAR: arrayType = itkPixelArrayEnum::Scalar; break; case itk::ImageIOBase::RGB: arrayType = itkPixelArrayEnum::ArrayRGB; break; case itk::ImageIOBase::RGBA: arrayType = itkPixelArrayEnum::ArrayRGBA; break; case itk::ImageIOBase::VECTOR: arrayType = itkPixelArrayEnum::ArrayVector; break; case itk::ImageIOBase::COVARIANTVECTOR: arrayType = itkPixelArrayEnum::ArrayCovariantVector; break; default: throw gcnew ApplicationException( "Unsupported pixel array type: " + ((int)imageIO->GetPixelType()).ToString() ); return nullptr; } itkPixelType^ pixeltype = gcnew itkPixelType( componentType, arrayType, imageIO->GetNumberOfComponents() ); // Return the information structure return gcnew itkImageInformation( pixeltype, dim, size, spacing, origin ); } catch ( itk::ExceptionObject& ex ) { throw gcnew itkExceptionObject( ex ); } catch ( Exception^ ex ) { System::String^ message = "Unable to read '" + System::IO::Path::GetFileName(filename) + "'."; throw gcnew ApplicationException(message, ex); } } ///<summary>Read an image series from the given filenames.</summary> ///<param name="filenames">An array of absolute file paths.</param> ///<remarks>This method was added in ManagedITK for simplicity.</remarks> virtual void ReadSeries ( array<System::String^>^ filenames )=0; ///<summary>Read an image series from the files matching the given pattern.</summary> ///<param name="path">An absolute path to search for the files comprising the series.</param> ///<param name="pattern">A pattern with wildcard character '*'.</param> ///<example>path="C:/temp/", pattern="test_*.png".</example> ///<remarks>This method was added in ManagedITK for simplicity.</remarks> virtual void ReadSeries ( System::String^ path, System::String^ pattern ) { this->ReadSeries( System::IO::Directory::GetFiles(path, pattern) ); } ///<summary> ///Read an image from the given DICOM directory using GDCM. ///This method uses the first found series identifier. ///</summary> ///<param name="directory">The directory containing the DICOM series.</param> ///<remarks>This method was added in ManagedITK for simplicity.</remarks> virtual void ReadDicomDirectory( System::String^ directory ) = 0; ///<summary>Read an image from the given DICOM directory using GDCM.</summary> ///<param name="directory">The directory containing the DICOM series.</param> ///<param name="seriesid">The identifier of the series to read.</param> ///<remarks>This method was added in ManagedITK for simplicity.</remarks> virtual void ReadDicomDirectory( System::String^ directory, System::String^ seriesid ) = 0; ///<summary>Read an image from the given DICOM directory using GDCM.</summary> ///<param name="directory">The directory containing the DICOM series.</param> ///<param name="seriesid">The identifier of the series to read.</param> ///<param name="restrictions">Specifies additional DICOM information to distinguish unique volumes within the directory. Eg. "0008|0021" distinguishes series based on date.</param> ///<remarks>This method was added in ManagedITK for simplicity.</remarks> virtual void ReadDicomDirectory( System::String^ directory, System::String^ seriesid, ... array<System::String^>^ restrictions) = 0; ///<summary>Write an image series to the files matching the given format. The seriesFormat is "000".</summary> ///<param name="filenameFormat">The absolute path and filename format for the images. Eg. C:/temp/test_{0}.png.</param> ///<example>filenameFormat="C:/temp/test_{0}.png".</example> ///<remarks>This method was added in ManagedITK for simplicity.</remarks> virtual void WriteSeries ( System::String^ filenameFormat ) { this->WriteSeries( filenameFormat, "000" ); } ///<summary>Write an image series to the files matching the given format.</summary> ///<param name="filenameFormat">The absolute path and filename format for the images. Eg. C:/temp/test_{0}.png.</param> ///<param name="seriesFormat">A format string for the series numbers. Eg. "000".</param> ///<example>filenameFormat="C:/temp/test_{0}.png" and seriesFormat="000".</example> ///<remarks>This method was added in ManagedITK for simplicity.</remarks> virtual void WriteSeries ( System::String^ filenameFormat, System::String^ seriesFormat )=0; ///<summary>Returns the pixel value at the given discrete location.</summary> ///<param name="index">The discrete location in image space.</param> ///<returns>The pixel value at the given discrete location.</returns> virtual itkPixel^ GetPixel ( itkIndex^ index )=0; ///<summary>Set the pixel value at the given discrete location.</summary> ///<param name="index">The discrete location in image space.</param> ///<param name="value">The new value to set.</param> virtual void SetPixel ( itkIndex^ index, itkPixel^ value )=0; ///<summary>Convert a physical point to a continuous index.</summary> ///<param name="point">The geometric location in physical space.</param> ///<param name="cindex">The resultant continuous location in image space.</param> ///<returns>true if the resulting index is within the image, false otherwise.</returns> virtual bool TransformPhysicalPointToContinuousIndex( itkPoint^ point, [System::Runtime::InteropServices::Out] itkContinuousIndex^% cindex )=0; ///<summary>Convert a physical point to a discrete index.</summary> ///<param name="point">The geometric location in physical space.</param> ///<param name="index">The resultant discrete location in image space.</param> ///<returns>true if the resulting index is within the image, false otherwise.</returns> virtual bool TransformPhysicalPointToIndex( itkPoint^ point, [System::Runtime::InteropServices::Out] itkIndex^% index )=0; ///<summary>Convert a continuous index to a physical point.</summary> ///<param name="cindex">The continuous location in image space.</param> ///<param name="point">The resultant geometric location in physical space.</param> virtual void TransformContinuousIndexToPhysicalPoint( itkContinuousIndex^ cindex, [System::Runtime::InteropServices::Out] itkPoint^% point )=0; ///<summary>Convert a discrete index to a physical point.</summary> ///<param name="index">The discrete location in image space.</param> ///<param name="point">The resultant geometric location in physical space.</param> virtual void TransformIndexToPhysicalPoint( itkIndex^ index, [System::Runtime::InteropServices::Out] itkPoint^% point )=0; ///<summary> ///Create a string representation of the image in the following format: /// "Size=[XX, XX, ..] Spacing=[XX, XX, ..] PixelType=ThePixelType" ///</summary> ///<returns>A string representation of the image including Size, Spacing, and PixelType.</returns> virtual String^ ToString() override { // Construct string String^ result = String::Empty; if (this->Size != nullptr) result += "Size=" + this->Size->ToString() + " "; if (this->Spacing != nullptr) result += "Spacing=" + this->Spacing->ToString() + " "; result += "PixelType=" + this->PixelType->LongTypeString; // Return return result; } }; // end ref class } // end namespace itk #endif
[ "dan.muel@a4e08166-d753-0410-af4e-431cb8890a25" ]
[ [ [ 1, 413 ] ] ]
076dd86223284366df80b71aafa9e3306bb84bb0
61e4e71a9ad4ac3fdce3c1595c627b9c79a68c29
/src/Todo.h
c90f420b61669313943799e505f4866f328e62c5
[]
no_license
oot/signpost
c2ff81bdb3ab75a5511eedd18798d637cd080526
8a8e5c6c693217daf56398e6bb59f89563f9689b
refs/heads/master
2016-09-05T19:52:41.876837
2010-11-19T08:07:48
2010-11-19T08:07:48
32,301,199
0
0
null
null
null
null
UTF-8
C++
false
false
1,141
h
#ifndef __TODO_H__ #define __TODO_H__ #include "Item.h" class Todo : public Item { public: Todo(void); ~Todo(void); enum StateType { StateInProgress, StateNotStarted, StateCanceled, StateCompleted, StateHolding, StateWaiting, StatePledge }; virtual Item::Type getType() { return Item::Todo; } virtual DateTimeType getDateForDisplay() { return completedDate_; } virtual std::string getTitle() { return title_; } virtual std::string getContents() { return description_; } void setTitle(const std::string& title) { title_ = title; } void setContents(const std::string& contents) { description_ = contents; } void setState(StateType status) { status_ = status; } StateType getState() { return status_; } int getProgress() { return progress_; } void setProgress(int progress) { progress_ = progress; } private: std::string title_; std::string description_; int progress_; StateType status_; DateTimeType completedDate_; DateTimeType startDate_; DateTimeType plannedDate_; std::vector<int> dependency_; int parentIdx_; }; #endif // __TODO_H__
[ "oot.xxxix@067241ac-f43e-11dd-9d1a-b59b2e1864b6", "[email protected]@067241ac-f43e-11dd-9d1a-b59b2e1864b6" ]
[ [ [ 1, 2 ], [ 48, 49 ] ], [ [ 3, 47 ] ] ]
2d969dd2888e8107861a9c4a069caef5b05d7843
012df7e7841bd12bfdf57d1f3372e24a8470b3e1
/Src/VCDParser/VCDParser/main.cpp
3efe61b3869be2aceaaae61c3f68bdd264ca04c3
[]
no_license
chetandeep/vcdparser
ed0dead176ad8627b5f271eaf337d1e323d90c10
fe10cade559b1b636c6292b1ee55f9737cb6b072
refs/heads/master
2021-01-10T20:06:35.175257
2010-03-08T07:21:40
2010-03-08T07:21:40
39,216,382
0
0
null
null
null
null
UTF-8
C++
false
false
651
cpp
#include "Tokenizer.h" #include <iostream> #include <fstream> using namespace std; int main() { // test for scanner // char* path = "test2.vcd"; // ofstream out("out.txt"); // ofstream out2("out2.txt"); // signed char ch; // CScanner s( path ); // // while ( (ch = s.get_char()) != -1 ) // out << ch; // // s.reopen( "test2.vcd"); // while ( (ch = s.get_char()) != -1 ) // out2 << ch; // test for tokenizer char* path = "test.vcd"; ofstream out("out.txt"); CTokenizer t(path); int tok; while ( (tok = t.next_var_token()) != TT_EOF ) out << t.get_word() << " " << tok << endl; return 0; }
[ "GavinGEY@7c0e9aa8-cadc-11de-aa3c-17c1778f147b" ]
[ [ [ 1, 34 ] ] ]
fa9c24e68a32a788519b9531e8881970b6bf9e23
d6e0f648d63055d6576de917de8d6f0f3fcb2989
/dac/win/src/qtservice_p.h
3b225ac8d6c5e34ea916523e0be2e6895c52233c
[]
no_license
lgosha/ssd
9b4a0ade234dd192ef30274377787edf1244b365
0b97a39fd7edabca44c4ac19178a5c626d1efea3
refs/heads/master
2020-05-19T12:41:32.060017
2011-09-27T12:43:06
2011-09-27T12:43:06
2,428,803
0
0
null
null
null
null
UTF-8
C++
false
false
3,347
h
/**************************************************************************** ** ** This file is part of a Qt Solutions component. ** ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). ** ** Contact: Qt Software Information ([email protected]) ** ** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Solutions Commercial License Agreement provided ** with the Software or, alternatively, in accordance with the terms ** contained in a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** Please note Third Party Software included with Qt Solutions may impose ** additional restrictions and it is the user's responsibility to ensure ** that they have met the licensing requirements of the GPL, LGPL, or Qt ** Solutions Commercial license and the relevant license of the Third ** Party Software they are using. ** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at [email protected]. ** ****************************************************************************/ #ifndef QTSERVICE_P_H #define QTSERVICE_P_H #include <QtCore/QStringList> #include "qtservice.h" class QtServiceControllerPrivate { Q_DECLARE_PUBLIC(QtServiceController) public: QString serviceName; QtServiceController *q_ptr; }; class QtServiceBasePrivate { Q_DECLARE_PUBLIC(QtServiceBase) public: QtServiceBasePrivate(const QString &name); ~QtServiceBasePrivate(); QtServiceBase *q_ptr; QString serviceDescription; QtServiceController::StartupType startupType; QtServiceBase::ServiceFlags serviceFlags; QStringList args; static class QtServiceBase *instance; QtServiceController controller; void startService(); int run(bool asService, const QStringList &argList); bool install(const QString &account, const QString &password, const QString &dir, const QString &conf); bool start(); QString filePath() const; bool sysInit(); void sysSetPath(); void sysCleanup(); class QtServiceSysPrivate *sysd; }; #endif
[ [ [ 1, 93 ] ] ]
7180b1484c5fc09753ed91d7e720865ba7cdb65e
e0edf5efb199a25f74bb0cba5168dda0c4203a36
/cachesim/src/Memory.cpp
7154e3a038b65e874039636525fc9b1ceb1ee4a4
[]
no_license
wangxinalex/cachesim
905c5e70646d4f64ff00c076f26e2e1dd450acc3
3526e5a3212287c2e7209bf8cb91beeb3161b229
refs/heads/master
2020-05-18T12:42:35.036992
2008-05-18T20:52:59
2008-05-18T20:52:59
33,253,613
0
0
null
null
null
null
UTF-8
C++
false
false
611
cpp
#include "Memory.h" using namespace std; Memory::Memory() { for(int i=0;i<= 0x1fffff;i++) contents.push_back(0); } Memory::~Memory() { } vector<uint> Memory::read(uint address, uint blockSize) { vector<uint> result; uint startPos = (address/blockSize); startPos *=blockSize; if(address <= 0xffffffff) { for(int i=0;i<blockSize;i++) { result.push_back(contents[startPos+i]); } } return result; } bool Memory::write(uint address, uint content) { if(address <= 0xffffffff) { contents[address]=content; return true; } else return false; }
[ "arthur.almeida.rodrigues@23a22076-5c4d-0410-b9f2-21d8122b860c" ]
[ [ [ 1, 39 ] ] ]
e5c1b0c52ee0b1f61d9f47bc5c4d3c073f87fb8b
50f94444677eb6363f2965bc2a29c09f8da7e20d
/Src/EmptyProject/EpCamera.cpp
b76eb18d0c0ddbae38c86d452d018e4371227bbd
[]
no_license
gasbank/poolg
efd426db847150536eaa176d17dcddcf35e74e5d
e73221494c4a9fd29c3d75fb823c6fb1983d30e5
refs/heads/master
2020-04-10T11:56:52.033568
2010-11-04T19:31:00
2010-11-04T19:31:00
1,051,621
1
0
null
null
null
null
UHC
C++
false
false
13,124
cpp
#include "EmptyProjectPCH.h" #include "EpCamera.h" #include "Utility.h" #include "WorldManager.h" #include "World.h" #include "ArnNode.h" #include "ShaderWrapper.h" extern PostRadialBlurShader* g_postRadialBlurShader; EpCamera::EpCamera(void) { m_fSmoothCameraTimer = 99999.0f; m_fSmoothCameraDuration = 1.0f; m_bViewParamsDirty = false; m_bCamManualMovement = false; m_bShake = false; m_nextShakeTime = 0; m_minPullDist = 5.0f; m_vEyeShake = m_vUpShake = m_vLookAtShake = ArnConsts::ARNVEC3_ZERO; } void EpCamera::frameMove( FLOAT fElapsedTime ) { CModelViewerCamera::FrameMove( fElapsedTime ); switch ( m_runningCamera ) { case CAMERA_NORMAL: // 위치가 일정하므로 Update해줄 것이 없다. break; case CAMERA_SMOOTH: updateSmoothCamera( fElapsedTime ); break; case CAMERA_EXTERNAL: updateExternalCamera( m_pArnCam ); break; case CAMERA_SMOOTH_ATTACH: updateSmoothAttachCamera( fElapsedTime ); break; case CAMERA_ATTACH: updateAttachCamera(); break; } //printf("Eye, At %f %f %f, %f %f %f \n", m_vEye.x, m_vEye.y, m_vEye.z, m_vLookAt.x, m_vLookAt.y, m_vLookAt.z ); processShake( fElapsedTime ); if ( ( m_bViewParamsDirty && !m_bCamManualMovement ) || m_bShake ) { ArnVec3 eye, lookAt, up; if ( m_bShake ) { eye = m_vEyeShake + m_vEye; lookAt = m_vLookAtShake + m_vLookAt; up = m_vUpShake + m_vUp; setViewParamsWithUp( &eye, &lookAt, &up ); } else { eye = m_vEye; lookAt = m_vLookAt; up = m_vUp; setViewParamsWithUp( &eye, &lookAt, &up ); } m_bViewParamsDirty = false; } } D3DUtil_CameraKeys EpCamera::MapKey( UINT nKey ) { // This could be upgraded to a method that's user-definable but for // simplicity, we'll use a hardcoded mapping. switch( nKey ) { case VK_CONTROL: return CAM_CONTROLDOWN; case VK_LEFT: return CAM_STRAFE_LEFT; case VK_RIGHT: return CAM_STRAFE_RIGHT; case VK_UP: return CAM_MOVE_FORWARD; case VK_DOWN: return CAM_MOVE_BACKWARD; case VK_PRIOR: return CAM_MOVE_UP; // pgup case VK_NEXT: return CAM_MOVE_DOWN; // pgdn case VK_HOME: return CAM_RESET; } return CAM_UNKNOWN; } void EpCamera::setViewParamsWithUp( ArnVec3* pvEyePt, ArnVec3* pvLookatPt, const ArnVec3& vUp ) { if( NULL == pvEyePt || NULL == pvLookatPt ) return; m_vEye.x = pvEyePt->x; m_vEye.y = pvEyePt->y; m_vEye.z = pvEyePt->z; m_vDefaultEye.x = pvEyePt->x; m_vDefaultEye.y = pvEyePt->y; m_vDefaultEye.z = pvEyePt->z; m_vLookAt.x = pvLookatPt->x; m_vLookAt.y = pvLookatPt->y; m_vLookAt.z = pvLookatPt->z; m_vDefaultLookAt.x = pvLookatPt->x; m_vDefaultLookAt.y = pvLookatPt->y; m_vDefaultLookAt.z = pvLookatPt->z; m_vUp = vUp; // TODO: Should be verified... // Calc the view matrix ArnMatrix view; ArnMatrixLookAtLH( &view, pvEyePt, pvLookatPt, &vUp ); view = view.transpose(); memcpy(&m_mView, &view, sizeof(float)*4*4); ArnMatrix mInvView; ArnMatrixInverse( &mInvView, NULL, reinterpret_cast<ArnMatrix*>(&m_mView) ); // The axis basis vectors and camera position are stored inside the // position matrix in the 4 rows of the camera's world matrix. // To figure out the yaw/pitch of the camera, we just need the Z basis vector ArnVec3* pZBasis = ( ArnVec3* )&mInvView.m[3][1]; m_fCameraYawAngle = atan2f( pZBasis->x, pZBasis->z ); float fLen = sqrtf( pZBasis->z * pZBasis->z + pZBasis->x * pZBasis->x ); m_fCameraPitchAngle = -atan2f( pZBasis->y, fLen ); // Propogate changes to the member arcball ArnQuat quat; ArnMatrix mRotation; ArnMatrixLookAtLH( &mRotation, pvEyePt, pvLookatPt, &vUp ); ArnQuaternionRotationMatrix( &quat, &mRotation ); D3DXQUATERNION d3dxQ(quat.x, quat.y, quat.z, quat.w); m_ViewArcBall.SetQuatNow( d3dxQ ); // Set the radius according to the distance ArnVec3 vEyeToPoint; vEyeToPoint = *pvLookatPt - *pvEyePt; SetRadius( ArnVec3Length( &vEyeToPoint ) ); // View information changed. FrameMove should be called. m_bDragSinceLastUpdate = true; } void EpCamera::setViewParamsWithUp( ArnVec3* pvEyePt, ArnVec3* pvLookatPt, ArnVec3* pvUp ) { setViewParamsWithUp( pvEyePt, pvLookatPt, *pvUp ); } ArnVec3* EpCamera::GetUpPt() { return &m_vUp; } // arnCam로부터 정보를 얻어서 카메라의 view parameter를 지정한다. // arnCam이 변할 수 있으므로 프레임마다 호출해아 한다. void EpCamera::updateExternalCamera( ArnCamera* arnCam ) { // // Content of local transform ( 4 * 4) // // [ Right ] // [ Up ] // [ Look ] // [Position] // // Transpose of this is view transform matrix // assert( arnCam ); const ARN_NDD_CAMERA_CHUNK& arnCamData = arnCam->getCameraData(); // Extract information from localXfrom ArnMatrix arnCamLocalXfrom(m_pArnCam->computeWorldXform()); // Calculate up and lookAt vectors based on local xform mat ArnVec3 pos = *(ArnVec3*)&arnCamLocalXfrom.m[3][0]; // Camera position stored in 4th row of mat ArnVec3 up = ArnConsts::ARNVEC3_Y; // Up vector basis (+Y axis) ArnVec3 look = ArnConsts::ARNVEC3_Z; // LookAt vector basis (+Z axis) ArnVec3TransformCoord( &look, &look, &arnCamLocalXfrom ); // Transform LookAt vector // Clear translation part of camera xform mat since Up vector is relative to // camera position, not absolute. arnCamLocalXfrom.m[3][0] = arnCamLocalXfrom.m[3][1] = arnCamLocalXfrom.m[3][2] = 0; ArnVec3TransformCoord( &up, &up, &arnCamLocalXfrom ); // Transform Up vector m_vUp = up; ArnVec3Assign(m_vLookAt, look); ArnVec3Assign(m_vEye, pos); m_bViewParamsDirty = true; } void EpCamera::setDesViewParams( ArnVec3* pvEyePt, ArnVec3* pvLookAtPt, ArnVec3* vUp ) { m_vDesEye = *pvEyePt; m_vDesLookAt = *pvLookAtPt; m_vDesUp = *vUp; } void EpCamera::updateSmoothCamera( float fElapsedTime ) { // 지정된 시간 동안 이전 위치로부터 목적 위치까지 linear interpolation 하여 현재 카메라 위치를 // 구한다. if ( m_fSmoothCameraTimer < m_fSmoothCameraDuration ) { float s = m_fSmoothCameraTimer / m_fSmoothCameraDuration; ArnVec3Lerp( &m_vEye, &m_vPrevEye, &m_vDesEye, s ); ArnVec3Lerp( &m_vLookAt, &m_vPrevLookAt, &m_vDesLookAt, s ); ArnVec3Lerp( &m_vUp, &m_vPrevUp, &m_vDesUp, s ); m_fSmoothCameraTimer += fElapsedTime; m_bViewParamsDirty = true; const float blurWidth = 0.1f; if ( s < 0.5f ) g_postRadialBlurShader->setBlurWidth( (s * 2) * blurWidth ); else g_postRadialBlurShader->setBlurWidth( (2.0f + (-s * 2)) * blurWidth ); } else if ( m_bUpdateContinue ) { // 마지막으로 최종 위치에 정확히 카메라를 놓는다. ArnVec3Assign(m_vEye, m_vDesEye); ArnVec3Assign(m_vLookAt, m_vDesLookAt); m_vUp = m_vDesUp; m_bUpdateContinue = false; m_bViewParamsDirty = true; g_postRadialBlurShader->setBlurWidth( 0 ); } } void EpCamera::begin( RunningCamera rc ) { m_runningCamera = rc; // CAMERA_SMOOTH는 카메라가 이전 위치에서 목적 위치까지 서서히 움직이는 카메라이다. // 따라서 이전 위치를 미리 저장해 두고, timer도 초기화한다. switch ( rc ) { case CAMERA_SMOOTH: case CAMERA_SMOOTH_ATTACH: m_vPrevEye = m_vEye; m_vPrevLookAt = m_vLookAt; m_vPrevUp = m_vUp; m_fSmoothCameraTimer = 0.0f; break; } m_bUpdateContinue = true; } // 쓸모 없는 함수가 된듯 하나 아까워서 남겨둠. void EpCamera::lerpViewParams( ArnVec3* pvEyeOut, ArnVec3* pvLookAtOut, ArnVec3* pvUpOut, ArnVec3* pvEye1, ArnVec3* pvLookAt1, ArnVec3* pvUp1, ArnVec3* pvEye2, ArnVec3* pvLookAt2, ArnVec3* pvUp2, float s ) { ArnVec3Lerp( pvEyeOut, pvEye1, pvEye2, s ); ArnVec3Lerp( pvLookAtOut, pvLookAt1, pvLookAt2, s ); ArnVec3Lerp( pvUpOut, pvUp1, pvUp2, s ); } LRESULT EpCamera::handleMessages( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { if ( uMsg == WM_KEYDOWN ) if ( wParam == VK_F6 ) m_bCamManualMovement = !m_bCamManualMovement; return CModelViewerCamera::HandleMessages( hWnd, uMsg, wParam, lParam ); } void EpCamera::updateSmoothAttachCamera( float fElapsedTime ) { // 기존의 Smooth moving camera를 활용한다. // At first, attach destination of camera to object's position. // So camera gradually attached. // If attaching is finished, just float over the object and follow object. if ( m_bUpdateContinue ) { m_vDesEye.x = m_vPos->x; m_vDesEye.y = m_vPos->y; m_vDesEye.z = m_vPos->z - 30.0f; m_vDesLookAt.x = m_vPos->x; m_vDesLookAt.y = m_vPos->y; m_vDesLookAt.z = m_vPos->z - 1.0f; m_vDesUp.x = 0.0f; m_vDesUp.y = 1.0f; m_vDesUp.z = 0.0f; pulledEye( &m_vDesEye, &m_vDesLookAt, &m_vDesEye, 1 ); } else { m_vEye.x = m_vPos->x; m_vEye.y = m_vPos->y; m_vEye.z = m_vPos->z - 30.0f; m_vLookAt.x = m_vPos->x; m_vLookAt.y = m_vPos->y; m_vLookAt.z = m_vPos->z - 1.0f; m_vUp.x = 0.0f; m_vUp.y = 1.0f; m_vUp.z = 0.0f; pulledEye( reinterpret_cast<ArnVec3*>(&m_vEye), reinterpret_cast<ArnVec3*>(&m_vLookAt), reinterpret_cast<ArnVec3*>(&m_vEye), 1 ); } // And move to the destination gradually updateSmoothCamera( fElapsedTime ); // After moving to destination, always follow object. m_bViewParamsDirty = true; } void EpCamera::beginShoulderLookCamera( const ArnVec3* pvMePos, const ArnVec3* pvOppPos ) { ArnVec3 vEnemyPos = *pvOppPos; ArnVec3 vHeroPos = *pvMePos; // 전투가 일어나는 위치를 구한다. 적의 위치와 주인공 위치의 중간임. ArnVec3 vBattlePos; vBattlePos.x = (vEnemyPos.x + vHeroPos.x) / 2.0f; vBattlePos.y = (vEnemyPos.y + vHeroPos.y) / 2.0f; vBattlePos.z = (vEnemyPos.z + vHeroPos.z) / 2.0f; // 최종 카메라 상태. ArnVec3 vDesEye( 0.0f, 0.0f, -15.0f ); ArnVec3 vDesLookAt( vBattlePos.x, vBattlePos.y, vBattlePos.z - 2.0f ); ArnVec3 vDesUp( 0.0f, 0.0f, -1.0f ); // 주인공으로부터 적으로 이어지는 축을 구한다. ArnVec3 vBattleAxis; vBattleAxis.x = (vEnemyPos.x - vHeroPos.x); vBattleAxis.y = (vEnemyPos.y - vHeroPos.y); vBattleAxis.z = (vEnemyPos.z - vHeroPos.z); // z 축에 대고 vBattleAxis를 -45도 돌린다. ArnVec3 zAxis( 0.0f, 0.0f, 1.0f ); Utility::rotateAboutAxis( &vBattleAxis, &zAxis, D3DXToRadian( -30.0f ) ); // vDesEye를 vBattleAxis에 대고 -60도 만큼 돌린다. Utility::rotateAboutAxis( &vDesEye, &vBattleAxis, D3DXToRadian( -45.0f ) ); // vDesEye를 주인공 위로 옮긴다. vDesEye.x += vBattlePos.x; vDesEye.y += vBattlePos.y; vDesLookAt.z -= 1.0f; // 장애물에 가리지 않도록 한다. pulledEye( &vDesEye, &vDesLookAt, &vDesEye, 1 ); // 자, 이제 카메라의 목적 위치를 구하였다. 이동시켜보자. setDesViewParams( &vDesEye, &vDesLookAt, &vDesUp ); setSmoothCameraDuration( 1.0f ); begin( CAMERA_SMOOTH ); } void EpCamera::updateAttachCamera() { m_vEye.x = m_vPos->x; m_vEye.y = m_vPos->y; m_vEye.z = m_vPos->z - 30.0f; m_vLookAt.x = m_vPos->x; m_vLookAt.y = m_vPos->y; m_vLookAt.z = m_vPos->z; m_vUp.x = 0.0f; m_vUp.y = 1.0f; m_vUp.z = 0.0f; m_bViewParamsDirty = true; } void EpCamera::pulledEye( ArnVec3* vPulledEye, ArnVec3* vLookAt, ArnVec3* vEye, int nth ) { ArnNode* arnNode = GetWorldManager().getCurWorld()->getArnSceneGraphPt()->getSceneRoot(); ArnVec3 vRayDir = *vEye - *vLookAt; ArnVec3 vNormRayDir; ArnVec3Normalize( &vNormRayDir, &vRayDir ); float camDist = ArnVec3Length( &vRayDir ); float obsDist = Utility::FullTraverseExhaustiveRayTesting( arnNode, *vLookAt, vNormRayDir, nth ); if ( camDist <= obsDist ) *vPulledEye = *vEye; else { if ( obsDist <= m_minPullDist ) pulledEye( vPulledEye, vLookAt, vEye, ++nth ); else { vNormRayDir *= obsDist; *vPulledEye = *vLookAt + vNormRayDir; } } //printf( "camDist, obsDist %f %f \n", camDist, obsDist ); } void EpCamera::processShake( float fElapsedTime ) { if ( m_bShake ) { const float shakeIntervalMax = 0.075f; const float eyeShakeAmount = 0.5f; const float lookAtShakeAmount = 0.2f; const float upShakeAmount = 0.075f; if ( m_nextShakeTime <= 0 ) { m_vEyeShake = ArnVec3( ( (float)rand()/RAND_MAX - 0.5f ) * eyeShakeAmount, ( (float)rand()/RAND_MAX - 0.5f ) * eyeShakeAmount, ( (float)rand()/RAND_MAX - 0.5f ) * eyeShakeAmount ); m_vLookAtShake = ArnVec3( ( (float)rand()/RAND_MAX - 0.5f ) * lookAtShakeAmount, ( (float)rand()/RAND_MAX - 0.5f ) * lookAtShakeAmount, ( (float)rand()/RAND_MAX - 0.5f ) * lookAtShakeAmount ); m_vUpShake = ArnVec3( ( (float)rand()/RAND_MAX - 0.5f ) * upShakeAmount, ( (float)rand()/RAND_MAX - 0.5f ) * upShakeAmount, ( (float)rand()/RAND_MAX - 0.5f ) * upShakeAmount ); m_bViewParamsDirty = true; m_nextShakeTime = (float)rand()/RAND_MAX * shakeIntervalMax; } else { m_nextShakeTime -= fElapsedTime; } } }
[ [ [ 1, 2 ], [ 4, 4 ], [ 8, 8 ], [ 10, 10 ], [ 12, 13 ], [ 18, 20 ], [ 22, 25 ], [ 51, 53 ], [ 55, 71 ], [ 76, 101 ], [ 104, 123 ], [ 126, 163 ], [ 165, 165 ], [ 170, 170 ], [ 189, 189 ], [ 194, 209 ], [ 214, 214 ], [ 229, 229 ], [ 231, 232 ], [ 237, 242 ], [ 247, 248 ], [ 253, 254 ], [ 280, 282 ], [ 285, 287 ], [ 335, 335 ], [ 345, 345 ], [ 347, 348 ], [ 351, 351 ], [ 357, 359 ], [ 362, 362 ], [ 368, 368 ], [ 404, 404 ], [ 407, 410 ], [ 426, 462 ] ], [ [ 3, 3 ], [ 5, 7 ], [ 9, 9 ], [ 11, 11 ], [ 14, 17 ], [ 21, 21 ], [ 26, 50 ], [ 54, 54 ], [ 72, 75 ], [ 102, 103 ], [ 124, 125 ], [ 164, 164 ], [ 166, 169 ], [ 171, 188 ], [ 190, 193 ], [ 210, 213 ], [ 215, 228 ], [ 230, 230 ], [ 233, 236 ], [ 243, 246 ], [ 249, 252 ], [ 255, 279 ], [ 283, 284 ], [ 288, 334 ], [ 336, 344 ], [ 346, 346 ], [ 349, 350 ], [ 352, 356 ], [ 360, 361 ], [ 363, 367 ], [ 369, 403 ], [ 405, 406 ], [ 411, 425 ], [ 463, 463 ] ] ]
504965595e1b71a1e1e3e742a8ef484c7fc6e78e
f8b364974573f652d7916c3a830e1d8773751277
/emulator/allegrex/instructions/MADDU.h
7aa5e2bf2971f10f17f11e6c0e609566f0066ea8
[]
no_license
lemmore22/pspe4all
7a234aece25340c99f49eac280780e08e4f8ef49
77ad0acf0fcb7eda137fdfcb1e93a36428badfd0
refs/heads/master
2021-01-10T08:39:45.222505
2009-08-02T11:58:07
2009-08-02T11:58:07
55,047,469
0
0
null
null
null
null
UTF-8
C++
false
false
1,042
h
template< > struct AllegrexInstructionTemplate< 0x0000001d, 0xfc00ffff > : AllegrexInstructionUnknown { static AllegrexInstructionTemplate &self() { static AllegrexInstructionTemplate insn; return insn; } static AllegrexInstruction *get_instance() { return &AllegrexInstructionTemplate::self(); } virtual AllegrexInstruction *instruction(u32 opcode) { return this; } virtual char const *opcode_name() { return "MADDU"; } virtual void interpret(Processor &processor, u32 opcode); virtual void disassemble(u32 address, u32 opcode, char *opcode_name, char *operands, char *comment); protected: AllegrexInstructionTemplate() {} }; typedef AllegrexInstructionTemplate< 0x0000001d, 0xfc00ffff > AllegrexInstruction_MADDU; namespace Allegrex { extern AllegrexInstruction_MADDU &MADDU; } #ifdef IMPLEMENT_INSTRUCTION AllegrexInstruction_MADDU &Allegrex::MADDU = AllegrexInstruction_MADDU::self(); #endif
[ [ [ 1, 41 ] ] ]
ccbc2e137b416dce45c96bb2fbe182fc5337b884
c2c93fc3fd90bd77764ac3016d816a59b2370891
/Incomplited/Useful functions 0.1/plugin/callbacks.h
bcf3e8a15e7bf8ac1a9498f111055c0c4aeaab1d
[]
no_license
MsEmiNeko/samp-alex009-projects
a1d880ee3116de95c189ef3f79ce43b163b91603
9b9517486b28411c8b747fae460266a88d462e51
refs/heads/master
2021-01-10T16:22:34.863725
2011-04-30T04:01:15
2011-04-30T04:01:15
43,719,520
0
1
null
2018-01-19T16:55:45
2015-10-05T23:23:37
SourcePawn
UTF-8
C++
false
false
418
h
/* * Copyright (C) 2011 Alex009 * License read in license.txt * Description: callbacks */ // SDK #include "SDK/amx/amx.h" #include "SDK/plugincommon.h" class CCallbacks { public: CCallbacks() ; ~CCallbacks(); void OnPlayerSetPointOnMap(int playerid,float x,float y,float z); void CallbacksOnAMXLoad(AMX* amx); void CallbacksOnAMXUnLoad(AMX* amx); // vars AMX* SampObjects[17]; };
[ [ [ 1, 24 ] ] ]
a0b566374b1a68f2b0480c96f1342ad1788ff294
a37df219b4a30e684db85b00dd76d4c36140f3c2
/1.7.1/run/Catl0.h
c4bc49a374aa8fac5241474a003ee65513e187f3
[]
no_license
BlackMoon/bm-net
0f79278f8709cd5d0738a6c3a27369726b0bb793
eb6414bc412a8cfc5c24622977e7fa7203618269
refs/heads/master
2020-12-25T20:20:44.843483
2011-11-29T10:33:17
2011-11-29T10:33:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
699
h
// Machine generated IDispatch wrapper class(es) created with Add Class from Typelib Wizard #import "D:\\Geology\\atl\\Debug\\atl.tlb" no_namespace // Catl0 wrapper class class Catl0 : public COleDispatchDriver { public: Catl0(){} // Calls COleDispatchDriver default constructor Catl0(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) {} Catl0(const Catl0& dispatchSrc) : COleDispatchDriver(dispatchSrc) {} // Attributes public: // Operations public: // Iatl methods public: void m1(long p1, BOOL p2) { static BYTE parms[] = VTS_I4 VTS_BOOL ; InvokeHelper(0x1, DISPATCH_METHOD, VT_EMPTY, NULL, parms, p1, p2); } // Iatl properties public: };
[ "[email protected]@b6168ec3-97fc-df6f-cbe5-288b4f99fbbd" ]
[ [ [ 1, 31 ] ] ]
0025ebd49732ad7fa69fd193c3fc7b36295f0128
516b78edbad95d6fb76b6a51c5353eaeb81b56d6
/engine2/src/events/eventhandler.cpp
7aae5655e75793ea7bb26c9bb3702b9900abd894
[]
no_license
BackupTheBerlios/lutaprakct
73d9fb2898e0a1a019d8ea7870774dd68778793e
fee62fa093fa560e51a26598619b97926ea9cb6b
refs/heads/master
2021-01-18T14:05:20.313781
2008-06-16T21:51:13
2008-06-16T21:51:13
40,252,766
0
0
null
null
null
null
UTF-8
C++
false
false
372
cpp
#include "eventhandler.h" #include "eventdispatcher.h" /**contrutor ja adiciona o eventhandler na lista de handlers no dispatcher */ EventHandler::EventHandler(){ EVENTDISPATCHER::getInstance().addHandler(this); } void EventHandler::sendEvent(int eventType, int arg1, int arg2){ EVENTDISPATCHER::getInstance().sendEvent(eventType, arg1, arg2); }
[ "gha" ]
[ [ [ 1, 16 ] ] ]
79659661d6572b352c94e49b6c22f91be14f3be6
f9351a01f0e2dec478e5b60c6ec6445dcd1421ec
/itl/boost/itl/type_traits/neutron.hpp
a2810b02c88e160f8dcd8cab6fcfa7afb1cd93f8
[ "BSL-1.0" ]
permissive
WolfgangSt/itl
e43ed68933f554c952ddfadefef0e466612f542c
6609324171a96565cabcf755154ed81943f07d36
refs/heads/master
2016-09-05T20:35:36.628316
2008-11-04T11:44:44
2008-11-04T11:44:44
327,076
0
1
null
null
null
null
UTF-8
C++
false
false
2,151
hpp
/*----------------------------------------------------------------------------+ Copyright (c) 2008-2008: Joachim Faulhaber +-----------------------------------------------------------------------------+ Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENCE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +----------------------------------------------------------------------------*/ #ifndef __itl_type_traits_neutron_JOFA_080912_H__ #define __itl_type_traits_neutron_JOFA_080912_H__ #include <boost/itl/type_traits/type_to_string.hpp> // I DO NOT #include boost/itl/itl_<date_time_adapter>.hpp here, because it // HAS TO be included by client code prior to this location. namespace boost{ namespace itl { template <class Type> struct neutron { static Type value(); inline Type operator()()const { return value(); } //JODO everything static?? }; #ifdef ITL_NEEDS_GREGORIAN_DATE_NEUTRON_VALUE #define ITL_HAS_GREGORIAN_DATE_NEUTRON_VALUE template<> inline boost::gregorian::date neutron<boost::gregorian::date>::value() { return boost::gregorian::date(boost::gregorian::min_date_time); } template<> struct neutron<boost::gregorian::date_duration> { static boost::gregorian::date_duration value() { return boost::gregorian::date(boost::gregorian::min_date_time) - boost::gregorian::date(boost::gregorian::min_date_time); } }; #endif #ifdef ITL_NEEDS_POSIX_TIME_PTIME_NEUTRON_VALUE #define ITL_HAS_POSIX_TIME_PTIME_NEUTRON_VALUE template<> inline boost::posix_time::ptime neutron<boost::posix_time::ptime>::value() { return boost::posix_time::ptime(boost::posix_time::min_date_time); } #endif template <class Type> inline Type neutron<Type>::value() { return Type(); } template<> inline std::string unary_template_to_string<neutron>::apply() { return "0"; } }} // namespace boost itl #define ITL_NEUTRONS_PROVIDED #endif
[ "jofaber@6b8beb3d-354a-0410-8f2b-82c74c7fef9a" ]
[ [ [ 1, 67 ] ] ]
f1dc3a4aba0d178baf4908fc9ee2456173d0bcc7
74c8da5b29163992a08a376c7819785998afb588
/NetAnimal/addons/pa/dependencies/include/ParticleUniverse/ParticleAffectors/ParticleUniverseScaleAffectorFactory.h
c6eea9492419a147463475f62f1b1c5e851bdd91
[]
no_license
dbabox/aomi
dbfb46c1c9417a8078ec9a516cc9c90fe3773b78
4cffc8e59368e82aed997fe0f4dcbd7df626d1d0
refs/heads/master
2021-01-13T14:05:10.813348
2011-06-07T09:36:41
2011-06-07T09:36:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,070
h
/* ----------------------------------------------------------------------------------------------- This source file is part of the Particle Universe product. Copyright (c) 2010 Henry van Merode Usage of this program is licensed under the terms of the Particle Universe Commercial License. You can find a copy of the Commercial License in the Particle Universe package. ----------------------------------------------------------------------------------------------- */ #ifndef __PU_SCALE_AFFECTOR_FACTORY_H__ #define __PU_SCALE_AFFECTOR_FACTORY_H__ #include "ParticleUniversePrerequisites.h" #include "ParticleUniverseScaleAffectorTokens.h" #include "ParticleUniverseScaleAffector.h" #include "ParticleUniverseAffectorFactory.h" namespace ParticleUniverse { /** Factory class responsible for creating the ScaleAffector. */ class _ParticleUniverseExport ScaleAffectorFactory : public ParticleAffectorFactory { public: ScaleAffectorFactory(void) {}; virtual ~ScaleAffectorFactory(void) {}; /** See ParticleAffectorFactory */ Ogre::String getAffectorType(void) const { return "Scale"; } /** See ParticleAffectorFactory */ ParticleAffector* createAffector(void) { return _createAffector<ScaleAffector>(); } /** See ScriptReader */ virtual bool translateChildProperty(Ogre::ScriptCompiler* compiler, const Ogre::AbstractNodePtr &node) { return mScaleAffectorTranslator.translateChildProperty(compiler, node); }; /** See ScriptReader */ virtual bool translateChildObject(Ogre::ScriptCompiler* compiler, const Ogre::AbstractNodePtr &node) { return mScaleAffectorTranslator.translateChildObject(compiler, node); }; /* */ virtual void write(ParticleScriptSerializer* serializer , const IElement* element) { // Delegate mScaleAffectorWriter.write(serializer, element); } protected: ScaleAffectorWriter mScaleAffectorWriter; ScaleAffectorTranslator mScaleAffectorTranslator; }; } #endif
[ [ [ 1, 67 ] ] ]
25a531873f0c74b846f9810a8f3dd2d6b18b6cb3
b14d5833a79518a40d302e5eb40ed5da193cf1b2
/cpp/extern/xercesc++/2.6.0/src/xercesc/dom/impl/DOMNamedNodeMapImpl.cpp
0954c268c03ff372a85efe14ba30056e31305096
[ "Apache-2.0" ]
permissive
andyburke/bitflood
dcb3fb62dad7fa5e20cf9f1d58aaa94be30e82bf
fca6c0b635d07da4e6c7fbfa032921c827a981d6
refs/heads/master
2016-09-10T02:14:35.564530
2011-11-17T09:51:49
2011-11-17T09:51:49
2,794,411
1
0
null
null
null
null
UTF-8
C++
false
false
12,092
cpp
/* * Copyright 2001-2002,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * $Id: DOMNamedNodeMapImpl.cpp,v 1.14 2004/09/08 13:55:51 peiyongz Exp $ */ #include <xercesc/dom/DOMAttr.hpp> #include <xercesc/dom/DOMException.hpp> #include <xercesc/framework/XMLBuffer.hpp> #include <xercesc/util/XMLUniDefs.hpp> #include "DOMNodeVector.hpp" #include "DOMNamedNodeMapImpl.hpp" #include "DOMCasts.hpp" #include "DOMDocumentImpl.hpp" #include "DOMNodeImpl.hpp" XERCES_CPP_NAMESPACE_BEGIN DOMNamedNodeMapImpl::DOMNamedNodeMapImpl(DOMNode *ownerNod) { fOwnerNode=ownerNod; memset(fBuckets,0,MAP_SIZE*sizeof(DOMNodeVector*)); } DOMNamedNodeMapImpl::~DOMNamedNodeMapImpl() { } bool DOMNamedNodeMapImpl::readOnly() { return castToNodeImpl(fOwnerNode)->isReadOnly(); } DOMNamedNodeMapImpl *DOMNamedNodeMapImpl::cloneMap(DOMNode *ownerNod) { DOMDocumentImpl *doc = (DOMDocumentImpl *)(castToNodeImpl(ownerNod)->getOwnerDocument()); DOMNamedNodeMapImpl *newmap = new (doc) DOMNamedNodeMapImpl(ownerNod); for(int index=0;index<MAP_SIZE;index++) if (fBuckets[index] != 0) { XMLSize_t size=fBuckets[index]->size(); newmap->fBuckets[index] = new (doc) DOMNodeVector(doc, size); for (XMLSize_t i = 0; i < size; ++i) { DOMNode *s = fBuckets[index]->elementAt(i); DOMNode *n = s->cloneNode(true); castToNodeImpl(n)->isSpecified(castToNodeImpl(s)->isSpecified()); castToNodeImpl(n)->fOwnerNode = ownerNod; castToNodeImpl(n)->isOwned(true); newmap->fBuckets[index]->addElement(n); } } return newmap; } XMLSize_t DOMNamedNodeMapImpl::getLength() const { XMLSize_t count=0; for(int index=0;index<MAP_SIZE;index++) count+=(fBuckets[index]==0?0:fBuckets[index]->size()); return count; } DOMNode * DOMNamedNodeMapImpl::item(XMLSize_t index) const { XMLSize_t count=0; for(XMLSize_t i=0;i<MAP_SIZE;i++) { if(fBuckets[i]==0) continue; XMLSize_t thisBucket=fBuckets[i]->size(); if(index>=count && index<(count+thisBucket)) return fBuckets[i]->elementAt(index-count); count+=thisBucket; } return NULL; } DOMNode * DOMNamedNodeMapImpl::getNamedItem(const XMLCh *name) const { unsigned int hash=XMLString::hash(name,MAP_SIZE); if(fBuckets[hash]==0) return 0; int i = 0; int size = fBuckets[hash]->size(); for (i = 0; i < size; ++i) { DOMNode *n=fBuckets[hash]->elementAt(i); if(XMLString::equals(name,n->getNodeName())) return n; } return 0; } // // removeNamedItem() - Remove the named item, and return it. // The caller can release the // returned item if it's not used // we can't do it here because the caller would // never see the returned node. // DOMNode * DOMNamedNodeMapImpl::removeNamedItem(const XMLCh *name) { if (this->readOnly()) throw DOMException( DOMException::NO_MODIFICATION_ALLOWED_ERR, 0, GetDOMNamedNodeMapMemoryManager); unsigned int hash=XMLString::hash(name,MAP_SIZE); if(fBuckets[hash]==0) throw DOMException(DOMException::NOT_FOUND_ERR, 0, GetDOMNamedNodeMapMemoryManager); int i = 0; int size = fBuckets[hash]->size(); for (i = 0; i < size; ++i) { DOMNode *n=fBuckets[hash]->elementAt(i); if(XMLString::equals(name,n->getNodeName())) { fBuckets[hash]->removeElementAt(i); castToNodeImpl(n)->fOwnerNode = fOwnerNode->getOwnerDocument(); castToNodeImpl(n)->isOwned(false); return n; } } throw DOMException(DOMException::NOT_FOUND_ERR, 0, GetDOMNamedNodeMapMemoryManager); return 0; } // // setNamedItem() Put the item into the NamedNodeList by name. // If an item with the same name already was // in the list, replace it. Return the old // item, if there was one. // Caller is responsible for arranging for // deletion of the old item if its ref count is // zero. // DOMNode * DOMNamedNodeMapImpl::setNamedItem(DOMNode * arg) { DOMDocument *doc = fOwnerNode->getOwnerDocument(); DOMNodeImpl *argImpl = castToNodeImpl(arg); if(argImpl->getOwnerDocument() != doc) throw DOMException(DOMException::WRONG_DOCUMENT_ERR,0, GetDOMNamedNodeMapMemoryManager); if (this->readOnly()) throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR, 0, GetDOMNamedNodeMapMemoryManager); if ((arg->getNodeType() == DOMNode::ATTRIBUTE_NODE) && argImpl->isOwned() && (argImpl->fOwnerNode != fOwnerNode)) throw DOMException(DOMException::INUSE_ATTRIBUTE_ERR,0, GetDOMNamedNodeMapMemoryManager); argImpl->fOwnerNode = fOwnerNode; argImpl->isOwned(true); const XMLCh* name=arg->getNodeName(); unsigned int hash=XMLString::hash(name,MAP_SIZE); if(fBuckets[hash]==0) fBuckets[hash] = new (doc) DOMNodeVector(doc, 3); int i = 0; int size = fBuckets[hash]->size(); for (i = 0; i < size; ++i) { DOMNode *n=fBuckets[hash]->elementAt(i); if(XMLString::equals(name,n->getNodeName())) { fBuckets[hash]->setElementAt(arg,i); castToNodeImpl(n)->fOwnerNode = fOwnerNode->getOwnerDocument(); castToNodeImpl(n)->isOwned(false); return n; } } fBuckets[hash]->addElement(arg); return 0; } void DOMNamedNodeMapImpl::setReadOnly(bool readOnl, bool deep) { // this->fReadOnly=readOnl; if(deep) { for (int index = 0; index < MAP_SIZE; index++) { if(fBuckets[index]==0) continue; int sz = fBuckets[index]->size(); for (int i=0; i<sz; ++i) castToNodeImpl(fBuckets[index]->elementAt(i))->setReadOnly(readOnl, deep); } } } //Introduced in DOM Level 2 DOMNode *DOMNamedNodeMapImpl::getNamedItemNS(const XMLCh *namespaceURI, const XMLCh *localName) const { // the map is indexed using the full name of nodes; to search given a namespace and a local name // we have to do a linear search for (int index = 0; index < MAP_SIZE; index++) { if(fBuckets[index]==0) continue; int i = 0; int size = fBuckets[index]->size(); for (i = 0; i < size; ++i) { DOMNode *n=fBuckets[index]->elementAt(i); const XMLCh * nNamespaceURI = n->getNamespaceURI(); const XMLCh * nLocalName = n->getLocalName(); if (!XMLString::equals(nNamespaceURI, namespaceURI)) //URI not match continue; else { if (XMLString::equals(localName, nLocalName) || (nLocalName == 0 && XMLString::equals(localName, n->getNodeName()))) return n; } } } return 0; } // // setNamedItemNS() Put the item into the NamedNodeList by name. // If an item with the same name already was // in the list, replace it. Return the old // item, if there was one. // Caller is responsible for arranging for // deletion of the old item if its ref count is // zero. // DOMNode * DOMNamedNodeMapImpl::setNamedItemNS(DOMNode *arg) { DOMDocument *doc = fOwnerNode->getOwnerDocument(); DOMNodeImpl *argImpl = castToNodeImpl(arg); if (argImpl->getOwnerDocument() != doc) throw DOMException(DOMException::WRONG_DOCUMENT_ERR,0, GetDOMNamedNodeMapMemoryManager); if (this->readOnly()) throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR, 0, GetDOMNamedNodeMapMemoryManager); if (argImpl->isOwned()) throw DOMException(DOMException::INUSE_ATTRIBUTE_ERR,0, GetDOMNamedNodeMapMemoryManager); argImpl->fOwnerNode = fOwnerNode; argImpl->isOwned(true); const XMLCh* namespaceURI=arg->getNamespaceURI(); const XMLCh* localName=arg->getLocalName(); // the map is indexed using the full name of nodes; to search given a namespace and a local name // we have to do a linear search for (int index = 0; index < MAP_SIZE; index++) { if(fBuckets[index]==0) continue; int i = 0; int size = fBuckets[index]->size(); for (i = 0; i < size; ++i) { DOMNode *n=fBuckets[index]->elementAt(i); const XMLCh * nNamespaceURI = n->getNamespaceURI(); const XMLCh * nLocalName = n->getLocalName(); if (!XMLString::equals(nNamespaceURI, namespaceURI)) //URI not match continue; else { if (XMLString::equals(localName, nLocalName) || (nLocalName == 0 && XMLString::equals(localName, n->getNodeName()))) { fBuckets[index]->setElementAt(arg,i); castToNodeImpl(n)->fOwnerNode = fOwnerNode->getOwnerDocument(); castToNodeImpl(n)->isOwned(false); return n; } } } } // if not found, add it using the full name as key return setNamedItem(arg); } // removeNamedItemNS() - Remove the named item, and return it. // The caller can release the // returned item if it's not used // we can't do it here because the caller would // never see the returned node. DOMNode *DOMNamedNodeMapImpl::removeNamedItemNS(const XMLCh *namespaceURI, const XMLCh *localName) { if (this->readOnly()) throw DOMException( DOMException::NO_MODIFICATION_ALLOWED_ERR, 0, GetDOMNamedNodeMapMemoryManager); // the map is indexed using the full name of nodes; to search given a namespace and a local name // we have to do a linear search for (int index = 0; index < MAP_SIZE; index++) { if(fBuckets[index]==0) continue; int i = 0; int size = fBuckets[index]->size(); for (i = 0; i < size; ++i) { DOMNode *n=fBuckets[index]->elementAt(i); const XMLCh * nNamespaceURI = n->getNamespaceURI(); const XMLCh * nLocalName = n->getLocalName(); if (!XMLString::equals(nNamespaceURI, namespaceURI)) //URI not match continue; else { if (XMLString::equals(localName, nLocalName) || (nLocalName == 0 && XMLString::equals(localName, n->getNodeName()))) { fBuckets[index]->removeElementAt(i); castToNodeImpl(n)->fOwnerNode = fOwnerNode->getOwnerDocument(); castToNodeImpl(n)->isOwned(false); return n; } } } } throw DOMException(DOMException::NOT_FOUND_ERR, 0, GetDOMNamedNodeMapMemoryManager); return 0; } XERCES_CPP_NAMESPACE_END
[ [ [ 1, 337 ] ] ]
9100e4836d0192d2b74bd2c228ad27bc143ca39a
87cfed8101402f0991cd2b2412a5f69da90a955e
/daq/daq/src/mwwinsound/StdAfx.cpp
683f710176a9addd8ff76282decf4f9a4e132f72
[]
no_license
dedan/clock_stimulus
d94a52c650e9ccd95dae4fef7c61bb13fdcbd027
890ec4f7a205c8f7088c1ebe0de55e035998df9d
refs/heads/master
2020-05-20T03:21:23.873840
2010-06-22T12:13:39
2010-06-22T12:13:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
417
cpp
// stdafx.cpp : source file that includes just the standard includes // stdafx.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information // Copyright 1998-2003 The MathWorks, Inc. // $Revision: 1.1.6.1 $ $Date: 2003/10/15 18:33:44 $ #include "stdafx.h" #ifdef _ATL_STATIC_REGISTRY #include <statreg.h> #include <statreg.cpp> #endif #include <atlimpl.cpp>
[ [ [ 1, 15 ] ] ]
b701a974da69c5f693966d9a7589b498d824422e
d01196cdfc4451c4e1c88343bdb1eb4db9c5ac18
/source/server/global/globals.cpp
f25d5d9d3064892ce6a581cb82b7d2945f8efa8c
[]
no_license
ferhan66h/Xash3D_ancient
7491cd4ff1c7d0b48300029db24d7e08ba96e88a
075e0a6dae12a0952065eb9b2954be4a8827c72f
refs/heads/master
2021-12-10T07:55:29.592432
2010-05-09T00:00:00
2016-07-30T17:37:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,793
cpp
/*** * * Copyright (c) 1996-2002, Valve LLC. All rights reserved. * * This product contains software technology licensed from Id * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * All Rights Reserved. * * Use, distribution, and modification of this source code and/or resulting * object code is restricted to non-commercial enhancements to products from * Valve LLC. All other use, distribution, or modification is prohibited * without written permission from Valve LLC. * ****/ /* ===== globals.cpp ======================================================== DLL-wide global variable definitions. They're all defined here, for convenient centralization. Source files that need them should "extern ..." declare each variable, to better document what globals they care about. */ #include "extdll.h" #include "utils.h" #include "cbase.h" #include "baseweapon.h" #include "soundent.h" DLL_GLOBAL unsigned short m_usPlayEmptySound; DLL_GLOBAL unsigned short m_usEjectBrass; DLL_GLOBAL unsigned short m_usPlayTexSound; DLL_GLOBAL ULONG g_ulFrameCount; DLL_GLOBAL ULONG g_ulModelIndexEyes; DLL_GLOBAL ULONG g_ulModelIndexPlayer; DLL_GLOBAL Vector g_vecAttackDir; DLL_GLOBAL int g_iSkillLevel; DLL_GLOBAL int gDisplayTitle; DLL_GLOBAL BOOL g_fGameOver; DLL_GLOBAL BOOL g_startSuit; DLL_GLOBAL const Vector g_vecZero = Vector(0,0,0); DLL_GLOBAL int g_Language; DLL_GLOBAL short g_sModelIndexLaser; DLL_GLOBAL int g_sModelIndexLaserDot; DLL_GLOBAL short g_sModelIndexFireball; DLL_GLOBAL short g_sModelIndexSmoke; DLL_GLOBAL short g_sModelIndexWExplosion; DLL_GLOBAL short g_sModelIndexBubbles; DLL_GLOBAL short g_sModelIndexBloodDrop; DLL_GLOBAL short g_sModelIndexBloodSpray; DLL_GLOBAL int g_sModelIndexErrorSprite; DLL_GLOBAL int g_sModelIndexErrorModel; DLL_GLOBAL int g_sModelIndexNullModel; DLL_GLOBAL int g_sModelIndexNullSprite; int GetStdLightStyle (int iStyle) { switch (iStyle) { case 0: return MAKE_STRING("m"); // 0 normal case 1: return MAKE_STRING("mmnmmommommnonmmonqnmmo"); // 1 FLICKER (first variety) case 2: return MAKE_STRING("abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba"); // 2 SLOW STRONG PULSE case 3: return MAKE_STRING("mmmmmaaaaammmmmaaaaaabcdefgabcdefg"); // 3 CANDLE (first variety) case 4: return MAKE_STRING("mamamamamama"); // 4 FAST STROBE case 5: return MAKE_STRING("jklmnopqrstuvwxyzyxwvutsrqponmlkj"); // 5 GENTLE PULSE 1 case 6: return MAKE_STRING("nmonqnmomnmomomno"); // 6 FLICKER (second variety) case 7: return MAKE_STRING("mmmaaaabcdefgmmmmaaaammmaamm"); // 7 CANDLE (second variety) case 8: return MAKE_STRING("mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa"); // 8 CANDLE (third variety) case 9: return MAKE_STRING("aaaaaaaazzzzzzzz"); // 9 SLOW STROBE (fourth variety) case 10: return MAKE_STRING("mmamammmmammamamaaamammma"); // 10 FLUORESCENT FLICKER case 11: return MAKE_STRING("abcdefghijklmnopqrrqponmlkjihgfedcba"); // 11 SLOW PULSE NOT FADE TO BLACK case 12: return MAKE_STRING("mmnnmmnnnmmnn"); // 12 UNDERWATER LIGHT MUTATION case 13: return MAKE_STRING("a"); // 13 OFF case 14: return MAKE_STRING("aabbccddeeffgghhiijjkkllmmmmmmmmmmmmmm"); // 14 SLOW FADE IN case 15: return MAKE_STRING("abcdefghijklmmmmmmmmmmmmmmmmmmmmmmmmmm"); // 15 MED FADE IN case 16: return MAKE_STRING("acegikmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm"); // 16 FAST FADE IN case 17: return MAKE_STRING("llkkjjiihhggffeeddccbbaaaaaaaaaaaaaaaa"); // 17 SLOW FADE OUT case 18: return MAKE_STRING("lkjihgfedcbaaaaaaaaaaaaaaaaaaaaaaaaaaa"); // 18 MED FADE OUT case 19: return MAKE_STRING("kigecaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); // 19 FAST FADE OUT default: return MAKE_STRING("m"); } }
[ [ [ 1, 84 ] ] ]
e47a7161c824907fe88c11a6eab0cf01ee3c716c
fe122f81ca7d6dff899945987f69305ada995cd7
/DB/dbAx/CardFile/CardFile.h
1b3093ef3d7fb74f09241eddd7cace65c2597d6b
[]
no_license
myeverytime/chtdependstoreroom
ddb9f4f98a6a403521aaf403d0b5f2dc5213f346
64a4d1e2d32abffaab0376f6377e10448b3c5bc3
refs/heads/master
2021-01-10T06:53:35.455736
2010-06-23T10:21:44
2010-06-23T10:21:44
50,168,936
0
0
null
null
null
null
UTF-8
C++
false
false
516
h
// CardFile.h : main header file for the PROJECT_NAME application // #pragma once #ifndef __AFXWIN_H__ #error "include 'stdafx.h' before including this file for PCH" #endif #include "resource.h" // main symbols // CCardFileApp: // See CardFile.cpp for the implementation of this class // class CCardFileApp : public CWinApp { public: CCardFileApp(); // Overrides public: virtual BOOL InitInstance(); // Implementation DECLARE_MESSAGE_MAP() }; extern CCardFileApp theApp;
[ "robustwell@bd7e636a-136b-06c9-ecb0-b59307166256" ]
[ [ [ 1, 31 ] ] ]
077b43b9c4d8fd46983e4a0062fd9f806caf9caa
c54f5a7cf6de3ed02d2e02cf867470ea48bd9258
/pyobjc/PyOpenGL-2.0.2.01/src/interface/GL.KTX._buffer_region.0100.inc
c48f6958ea5c61ec156d9c7a476a3f2f2927473a
[]
no_license
orestis/pyobjc
01ad0e731fbbe0413c2f5ac2f3e91016749146c6
c30bf50ba29cb562d530e71a9d6c3d8ad75aa230
refs/heads/master
2021-01-22T06:54:35.401551
2009-09-01T09:24:47
2009-09-01T09:24:47
16,895
8
5
null
null
null
null
UTF-8
C++
false
false
64,075
inc
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 1.3.23 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make * changes to this file unless you know what you are doing--modify the SWIG * interface file instead. * ----------------------------------------------------------------------------- */ #define SWIGPYTHON #ifndef SWIG_TEMPLATE_DISAMBIGUATOR # if defined(__SUNPRO_CC) # define SWIG_TEMPLATE_DISAMBIGUATOR template # else # define SWIG_TEMPLATE_DISAMBIGUATOR # endif #endif #include <Python.h> /*********************************************************************** * common.swg * * This file contains generic SWIG runtime support for pointer * type checking as well as a few commonly used macros to control * external linkage. * * Author : David Beazley ([email protected]) * * Copyright (c) 1999-2000, The University of Chicago * * This file may be freely redistributed without license or fee provided * this copyright message remains intact. ************************************************************************/ #include <string.h> #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # if !defined(STATIC_LINKED) # define SWIGEXPORT(a) __declspec(dllexport) a # else # define SWIGEXPORT(a) a # endif #else # define SWIGEXPORT(a) a #endif #define SWIGRUNTIME(x) static x #ifndef SWIGINLINE #if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) # define SWIGINLINE inline #else # define SWIGINLINE #endif #endif /* This should only be incremented when either the layout of swig_type_info changes, or for whatever reason, the runtime changes incompatibly */ #define SWIG_RUNTIME_VERSION "1" /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ #ifdef SWIG_TYPE_TABLE #define SWIG_QUOTE_STRING(x) #x #define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) #define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) #else #define SWIG_TYPE_TABLE_NAME #endif #ifdef __cplusplus extern "C" { #endif typedef void *(*swig_converter_func)(void *); typedef struct swig_type_info *(*swig_dycast_func)(void **); typedef struct swig_type_info { const char *name; swig_converter_func converter; const char *str; void *clientdata; swig_dycast_func dcast; struct swig_type_info *next; struct swig_type_info *prev; } swig_type_info; static swig_type_info *swig_type_list = 0; static swig_type_info **swig_type_list_handle = &swig_type_list; /* Compare two type names skipping the space characters, therefore "char*" == "char *" and "Class<int>" == "Class<int >", etc. Return 0 when the two name types are equivalent, as in strncmp, but skipping ' '. */ static int SWIG_TypeNameComp(const char *f1, const char *l1, const char *f2, const char *l2) { for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { while ((*f1 == ' ') && (f1 != l1)) ++f1; while ((*f2 == ' ') && (f2 != l2)) ++f2; if (*f1 != *f2) return *f1 - *f2; } return (l1 - f1) - (l2 - f2); } /* Check type equivalence in a name list like <name1>|<name2>|... */ static int SWIG_TypeEquiv(const char *nb, const char *tb) { int equiv = 0; const char* te = tb + strlen(tb); const char* ne = nb; while (!equiv && *ne) { for (nb = ne; *ne; ++ne) { if (*ne == '|') break; } equiv = SWIG_TypeNameComp(nb, ne, tb, te) == 0; if (*ne) ++ne; } return equiv; } /* Register a type mapping with the type-checking */ static swig_type_info * SWIG_TypeRegister(swig_type_info *ti) { swig_type_info *tc, *head, *ret, *next; /* Check to see if this type has already been registered */ tc = *swig_type_list_handle; while (tc) { /* check simple type equivalence */ int typeequiv = (strcmp(tc->name, ti->name) == 0); /* check full type equivalence, resolving typedefs */ if (!typeequiv) { /* only if tc is not a typedef (no '|' on it) */ if (tc->str && ti->str && !strstr(tc->str,"|")) { typeequiv = SWIG_TypeEquiv(ti->str,tc->str); } } if (typeequiv) { /* Already exists in the table. Just add additional types to the list */ if (ti->clientdata) tc->clientdata = ti->clientdata; head = tc; next = tc->next; goto l1; } tc = tc->prev; } head = ti; next = 0; /* Place in list */ ti->prev = *swig_type_list_handle; *swig_type_list_handle = ti; /* Build linked lists */ l1: ret = head; tc = ti + 1; /* Patch up the rest of the links */ while (tc->name) { head->next = tc; tc->prev = head; head = tc; tc++; } if (next) next->prev = head; head->next = next; return ret; } /* Check the typename */ static swig_type_info * SWIG_TypeCheck(char *c, swig_type_info *ty) { swig_type_info *s; if (!ty) return 0; /* Void pointer */ s = ty->next; /* First element always just a name */ do { if (strcmp(s->name,c) == 0) { if (s == ty->next) return s; /* Move s to the top of the linked list */ s->prev->next = s->next; if (s->next) { s->next->prev = s->prev; } /* Insert s as second element in the list */ s->next = ty->next; if (ty->next) ty->next->prev = s; ty->next = s; s->prev = ty; return s; } s = s->next; } while (s && (s != ty->next)); return 0; } /* Cast a pointer up an inheritance hierarchy */ static SWIGINLINE void * SWIG_TypeCast(swig_type_info *ty, void *ptr) { if ((!ty) || (!ty->converter)) return ptr; return (*ty->converter)(ptr); } /* Dynamic pointer casting. Down an inheritance hierarchy */ static swig_type_info * SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { swig_type_info *lastty = ty; if (!ty || !ty->dcast) return ty; while (ty && (ty->dcast)) { ty = (*ty->dcast)(ptr); if (ty) lastty = ty; } return lastty; } /* Return the name associated with this type */ static SWIGINLINE const char * SWIG_TypeName(const swig_type_info *ty) { return ty->name; } /* Return the pretty name associated with this type, that is an unmangled type name in a form presentable to the user. */ static const char * SWIG_TypePrettyName(const swig_type_info *type) { /* The "str" field contains the equivalent pretty names of the type, separated by vertical-bar characters. We choose to print the last name, as it is often (?) the most specific. */ if (type->str != NULL) { const char *last_name = type->str; const char *s; for (s = type->str; *s; s++) if (*s == '|') last_name = s+1; return last_name; } else return type->name; } /* Search for a swig_type_info structure */ static swig_type_info * SWIG_TypeQuery(const char *name) { swig_type_info *ty = *swig_type_list_handle; while (ty) { if (ty->str && (SWIG_TypeEquiv(ty->str,name))) return ty; if (ty->name && (strcmp(name,ty->name) == 0)) return ty; ty = ty->prev; } return 0; } /* Set the clientdata field for a type */ static void SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { swig_type_info *tc, *equiv; if (ti->clientdata) return; /* if (ti->clientdata == clientdata) return; */ ti->clientdata = clientdata; equiv = ti->next; while (equiv) { if (!equiv->converter) { tc = *swig_type_list_handle; while (tc) { if ((strcmp(tc->name, equiv->name) == 0)) SWIG_TypeClientData(tc,clientdata); tc = tc->prev; } } equiv = equiv->next; } } /* Pack binary data into a string */ static char * SWIG_PackData(char *c, void *ptr, size_t sz) { static char hex[17] = "0123456789abcdef"; unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; register unsigned char uu; for (; u != eu; ++u) { uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; } return c; } /* Unpack binary data from a string */ static char * SWIG_UnpackData(char *c, void *ptr, size_t sz) { register unsigned char uu = 0; register int d; unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; for (; u != eu; ++u) { d = *(c++); if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); *u = uu; } return c; } /* This function will propagate the clientdata field of type to * any new swig_type_info structures that have been added into the list * of equivalent types. It is like calling * SWIG_TypeClientData(type, clientdata) a second time. */ static void SWIG_PropagateClientData(swig_type_info *type) { swig_type_info *equiv = type->next; swig_type_info *tc; if (!type->clientdata) return; while (equiv) { if (!equiv->converter) { tc = *swig_type_list_handle; while (tc) { if ((strcmp(tc->name, equiv->name) == 0) && !tc->clientdata) SWIG_TypeClientData(tc, type->clientdata); tc = tc->prev; } } equiv = equiv->next; } } #ifdef __cplusplus } #endif /* ----------------------------------------------------------------------------- * SWIG API. Portion that goes into the runtime * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif /* ----------------------------------------------------------------------------- * for internal method declarations * ----------------------------------------------------------------------------- */ #ifndef SWIGINTERN #define SWIGINTERN static #endif #ifndef SWIGINTERNSHORT #ifdef __cplusplus #define SWIGINTERNSHORT static inline #else /* C case */ #define SWIGINTERNSHORT static #endif /* __cplusplus */ #endif /* Common SWIG API */ #define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Python_ConvertPtr(obj, pp, type, flags) #define SWIG_NewPointerObj(p, type, flags) SWIG_Python_NewPointerObj(p, type, flags) #define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) /* Python-specific SWIG API */ #define SWIG_newvarlink() SWIG_Python_newvarlink() #define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) #define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags) #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) #define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) /* Exception handling in wrappers */ #define SWIG_fail goto fail #define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) #define SWIG_append_errmsg(msg) SWIG_Python_AddErrMesg(msg,0) #define SWIG_preppend_errmsg(msg) SWIG_Python_AddErrMesg(msg,1) #define SWIG_type_error(type,obj) SWIG_Python_TypeError(type,obj) #define SWIG_null_ref(type) SWIG_Python_NullRef(type) /* Contract support */ #define SWIG_contract_assert(expr, msg) \ if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg ); goto fail; } else /* ----------------------------------------------------------------------------- * Constant declarations * ----------------------------------------------------------------------------- */ /* Constant Types */ #define SWIG_PY_INT 1 #define SWIG_PY_FLOAT 2 #define SWIG_PY_STRING 3 #define SWIG_PY_POINTER 4 #define SWIG_PY_BINARY 5 /* Constant information structure */ typedef struct swig_const_info { int type; char *name; long lvalue; double dvalue; void *pvalue; swig_type_info **ptype; } swig_const_info; /* ----------------------------------------------------------------------------- * Pointer declarations * ----------------------------------------------------------------------------- */ /* Use SWIG_NO_COBJECT_TYPES to force the use of strings to represent C/C++ pointers in the python side. Very useful for debugging, but not always safe. */ #if !defined(SWIG_NO_COBJECT_TYPES) && !defined(SWIG_COBJECT_TYPES) # define SWIG_COBJECT_TYPES #endif /* Flags for pointer conversion */ #define SWIG_POINTER_EXCEPTION 0x1 #define SWIG_POINTER_DISOWN 0x2 /* ----------------------------------------------------------------------------- * Alloc. memory flags * ----------------------------------------------------------------------------- */ #define SWIG_OLDOBJ 1 #define SWIG_NEWOBJ SWIG_OLDOBJ + 1 #define SWIG_PYSTR SWIG_NEWOBJ + 1 #ifdef __cplusplus } #endif /*********************************************************************** * pyrun.swg * * This file contains the runtime support for Python modules * and includes code for managing global variables and pointer * type checking. * * Author : David Beazley ([email protected]) ************************************************************************/ #ifdef __cplusplus extern "C" { #endif /* ----------------------------------------------------------------------------- * global variable support code. * ----------------------------------------------------------------------------- */ typedef struct swig_globalvar { char *name; /* Name of global variable */ PyObject *(*get_attr)(); /* Return the current value */ int (*set_attr)(PyObject *); /* Set the value */ struct swig_globalvar *next; } swig_globalvar; typedef struct swig_varlinkobject { PyObject_HEAD swig_globalvar *vars; } swig_varlinkobject; static PyObject * swig_varlink_repr(swig_varlinkobject *v) { v = v; return PyString_FromString("<Global variables>"); } static int swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) { swig_globalvar *var; flags = flags; fprintf(fp,"Global variables { "); for (var = v->vars; var; var=var->next) { fprintf(fp,"%s", var->name); if (var->next) fprintf(fp,", "); } fprintf(fp," }\n"); return 0; } static PyObject * swig_varlink_getattr(swig_varlinkobject *v, char *n) { swig_globalvar *var = v->vars; while (var) { if (strcmp(var->name,n) == 0) { return (*var->get_attr)(); } var = var->next; } PyErr_SetString(PyExc_NameError,"Unknown C global variable"); return NULL; } static int swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { swig_globalvar *var = v->vars; while (var) { if (strcmp(var->name,n) == 0) { return (*var->set_attr)(p); } var = var->next; } PyErr_SetString(PyExc_NameError,"Unknown C global variable"); return 1; } static PyTypeObject varlinktype = { PyObject_HEAD_INIT(0) 0, /* Number of items in variable part (ob_size) */ (char *)"swigvarlink", /* Type name (tp_name) */ sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */ 0, /* Itemsize (tp_itemsize) */ 0, /* Deallocator (tp_dealloc) */ (printfunc) swig_varlink_print, /* Print (tp_print) */ (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */ (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */ 0, /* tp_compare */ (reprfunc) swig_varlink_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ 0, /* tp_flags */ 0, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #ifdef COUNT_ALLOCS /* these must be last */ 0, /* tp_alloc */ 0, /* tp_free */ 0, /* tp_maxalloc */ 0, /* tp_next */ #endif }; /* Create a variable linking object for use later */ static PyObject * SWIG_Python_newvarlink(void) { swig_varlinkobject *result = 0; result = PyMem_NEW(swig_varlinkobject,1); varlinktype.ob_type = &PyType_Type; /* Patch varlinktype into a PyType */ result->ob_type = &varlinktype; result->vars = 0; result->ob_refcnt = 0; Py_XINCREF((PyObject *) result); return ((PyObject*) result); } static void SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { swig_varlinkobject *v; swig_globalvar *gv; v= (swig_varlinkobject *) p; gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); gv->name = (char *) malloc(strlen(name)+1); strcpy(gv->name,name); gv->get_attr = get_attr; gv->set_attr = set_attr; gv->next = v->vars; v->vars = gv; } /* ----------------------------------------------------------------------------- * errors manipulation * ----------------------------------------------------------------------------- */ static void SWIG_Python_TypeError(const char *type, PyObject *obj) { if (type) { if (!PyCObject_Check(obj)) { const char *otype = (obj ? obj->ob_type->tp_name : 0); if (otype) { PyObject *str = PyObject_Str(obj); const char *cstr = str ? PyString_AsString(str) : 0; if (cstr) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", type, otype, cstr); } else { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", type, otype); } Py_DECREF(str); return; } } else { const char *otype = (char *) PyCObject_GetDesc(obj); if (otype) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PyCObject(%s)' is received", type, otype); return; } } PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); } else { PyErr_Format(PyExc_TypeError, "unexpected type is received"); } } static SWIGINLINE void SWIG_Python_NullRef(const char *type) { if (type) { PyErr_Format(PyExc_TypeError, "null reference of type '%s' was received",type); } else { PyErr_Format(PyExc_TypeError, "null reference was received"); } } static int SWIG_Python_AddErrMesg(const char* mesg, int infront) { if (PyErr_Occurred()) { PyObject *type = 0; PyObject *value = 0; PyObject *traceback = 0; PyErr_Fetch(&type, &value, &traceback); if (value) { PyObject *old_str = PyObject_Str(value); Py_XINCREF(type); PyErr_Clear(); if (infront) { PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str)); } else { PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); } Py_DECREF(old_str); } return 1; } else { return 0; } } static int SWIG_Python_ArgFail(int argnum) { if (PyErr_Occurred()) { /* add information about failing argument */ char mesg[256]; sprintf(mesg, "argument number %d:", argnum); return SWIG_Python_AddErrMesg(mesg, 1); } else { return 0; } } /* ----------------------------------------------------------------------------- * pointers/data manipulation * ----------------------------------------------------------------------------- */ /* Convert a pointer value */ static int SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) { swig_type_info *tc; char *c = 0; static PyObject *SWIG_this = 0; int newref = 0; PyObject *pyobj = 0; void *vptr; if (!obj) return 0; if (obj == Py_None) { *ptr = 0; return 0; } #ifdef SWIG_COBJECT_TYPES if (!(PyCObject_Check(obj))) { if (!SWIG_this) SWIG_this = PyString_FromString("this"); pyobj = obj; obj = PyObject_GetAttr(obj,SWIG_this); newref = 1; if (!obj) goto type_error; if (!PyCObject_Check(obj)) { Py_DECREF(obj); goto type_error; } } vptr = PyCObject_AsVoidPtr(obj); c = (char *) PyCObject_GetDesc(obj); if (newref) Py_DECREF(obj); goto type_check; #else if (!(PyString_Check(obj))) { if (!SWIG_this) SWIG_this = PyString_FromString("this"); pyobj = obj; obj = PyObject_GetAttr(obj,SWIG_this); newref = 1; if (!obj) goto type_error; if (!PyString_Check(obj)) { Py_DECREF(obj); goto type_error; } } c = PyString_AS_STRING(obj); /* Pointer values must start with leading underscore */ if (*c != '_') { if (strcmp(c,"NULL") == 0) { if (newref) { Py_DECREF(obj); } *ptr = (void *) 0; return 0; } else { if (newref) { Py_DECREF(obj); } goto type_error; } } c++; c = SWIG_UnpackData(c,&vptr,sizeof(void *)); if (newref) { Py_DECREF(obj); } #endif type_check: if (ty) { tc = SWIG_TypeCheck(c,ty); if (!tc) goto type_error; *ptr = SWIG_TypeCast(tc,vptr); } if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) { PyObject_SetAttrString(pyobj,(char*)"thisown",Py_False); } return 0; type_error: PyErr_Clear(); if (pyobj && !obj) { obj = pyobj; if (PyCFunction_Check(obj)) { /* here we get the method pointer for callbacks */ char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); c = doc ? strstr(doc, "swig_ptr: ") : 0; if (c) { c += 10; if (*c == '_') { c++; c = SWIG_UnpackData(c,&vptr,sizeof(void *)); goto type_check; } } } } if (flags & SWIG_POINTER_EXCEPTION) { if (ty) { SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); } else { SWIG_Python_TypeError("C/C++ pointer", obj); } } return -1; } /* Convert a pointer value, signal an exception on a type mismatch */ static void * SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { void *result; if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { PyErr_Clear(); if (flags & SWIG_POINTER_EXCEPTION) { SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); SWIG_Python_ArgFail(argnum); } } return result; } /* Convert a packed value value */ static int SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty, int flags) { swig_type_info *tc; char *c = 0; if ((!obj) || (!PyString_Check(obj))) goto type_error; c = PyString_AS_STRING(obj); /* Pointer values must start with leading underscore */ if (*c != '_') goto type_error; c++; c = SWIG_UnpackData(c,ptr,sz); if (ty) { tc = SWIG_TypeCheck(c,ty); if (!tc) goto type_error; } return 0; type_error: PyErr_Clear(); if (flags & SWIG_POINTER_EXCEPTION) { if (ty) { SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); } else { SWIG_Python_TypeError("C/C++ packed data", obj); } } return -1; } /* Create a new pointer string */ static char * SWIG_Python_PointerStr(char *buff, void *ptr, const char *name, size_t bsz) { char *r = buff; if ((2*sizeof(void *) + 2) > bsz) return 0; *(r++) = '_'; r = SWIG_PackData(r,&ptr,sizeof(void *)); if (strlen(name) + 1 > (bsz - (r - buff))) return 0; strcpy(r,name); return buff; } /* Create a new pointer object */ static PyObject * SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) { PyObject *robj; if (!ptr) { Py_INCREF(Py_None); return Py_None; } #ifdef SWIG_COBJECT_TYPES robj = PyCObject_FromVoidPtrAndDesc((void *) ptr, (char *) type->name, NULL); #else { char result[1024]; SWIG_Python_PointerStr(result, ptr, type->name, 1024); robj = PyString_FromString(result); } #endif if (!robj || (robj == Py_None)) return robj; if (type->clientdata) { PyObject *inst; PyObject *args = Py_BuildValue((char*)"(O)", robj); Py_DECREF(robj); inst = PyObject_CallObject((PyObject *) type->clientdata, args); Py_DECREF(args); if (inst) { if (own) { PyObject_SetAttrString(inst,(char*)"thisown",Py_True); } robj = inst; } } return robj; } static PyObject * SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { char result[1024]; char *r = result; if ((2*sz + 2 + strlen(type->name)) > 1024) return 0; *(r++) = '_'; r = SWIG_PackData(r,ptr,sz); strcpy(r,type->name); return PyString_FromString(result); } /* ----------------------------------------------------------------------------- * constants/methods manipulation * ----------------------------------------------------------------------------- */ /* Install Constants */ static void SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { int i; PyObject *obj; for (i = 0; constants[i].type; i++) { switch(constants[i].type) { case SWIG_PY_INT: obj = PyInt_FromLong(constants[i].lvalue); break; case SWIG_PY_FLOAT: obj = PyFloat_FromDouble(constants[i].dvalue); break; case SWIG_PY_STRING: if (constants[i].pvalue) { obj = PyString_FromString((char *) constants[i].pvalue); } else { Py_INCREF(Py_None); obj = Py_None; } break; case SWIG_PY_POINTER: obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); break; case SWIG_PY_BINARY: obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); break; default: obj = 0; break; } if (obj) { PyDict_SetItemString(d,constants[i].name,obj); Py_DECREF(obj); } } } /* Fix SwigMethods to carry the callback ptrs when needed */ static void SWIG_Python_FixMethods(PyMethodDef *methods, swig_const_info *const_table, swig_type_info **types, swig_type_info **types_initial) { int i; for (i = 0; methods[i].ml_name; ++i) { char *c = methods[i].ml_doc; if (c && (c = strstr(c, "swig_ptr: "))) { int j; swig_const_info *ci = 0; char *name = c + 10; for (j = 0; const_table[j].type; j++) { if (strncmp(const_table[j].name, name, strlen(const_table[j].name)) == 0) { ci = &(const_table[j]); break; } } if (ci) { size_t shift = (ci->ptype) - types; swig_type_info *ty = types_initial[shift]; size_t ldoc = (c - methods[i].ml_doc); size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; char *ndoc = (char*)malloc(ldoc + lptr + 10); char *buff = ndoc; void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue: (void *)(ci->lvalue); strncpy(buff, methods[i].ml_doc, ldoc); buff += ldoc; strncpy(buff, "swig_ptr: ", 10); buff += 10; SWIG_Python_PointerStr(buff, ptr, ty->name, lptr); methods[i].ml_doc = ndoc; } } } } /* ----------------------------------------------------------------------------- * Lookup type pointer * ----------------------------------------------------------------------------- */ #if PY_MAJOR_VERSION < 2 /* PyModule_AddObject function was introduced in Python 2.0. The following function is copied out of Python/modsupport.c in python version 2.3.4 */ static int PyModule_AddObject(PyObject *m, char *name, PyObject *o) { PyObject *dict; if (!PyModule_Check(m)) { PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg"); return -1; } if (!o) { PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value"); return -1; } dict = PyModule_GetDict(m); if (dict == NULL) { /* Internal error -- modules must have a dict! */ PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", PyModule_GetName(m)); return -1; } if (PyDict_SetItemString(dict, name, o)) return -1; Py_DECREF(o); return 0; } #endif static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} /* Sentinel */ }; static void SWIG_Python_LookupTypePointer(swig_type_info ***type_list_handle) { PyObject *module, *pointer; void *type_pointer; /* first check if module already created */ type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); if (type_pointer) { *type_list_handle = (swig_type_info **) type_pointer; } else { PyErr_Clear(); /* create a new module and variable */ module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); pointer = PyCObject_FromVoidPtr((void *) (*type_list_handle), NULL); if (pointer && module) { PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); } } } #ifdef __cplusplus } #endif /* -------- TYPES TABLE (BEGIN) -------- */ #define SWIGTYPE_p_GLsizei swig_types[0] #define SWIGTYPE_p_GLshort swig_types[1] #define SWIGTYPE_p_GLboolean swig_types[2] #define SWIGTYPE_size_t swig_types[3] #define SWIGTYPE_p_GLushort swig_types[4] #define SWIGTYPE_p_GLenum swig_types[5] #define SWIGTYPE_p_GLvoid swig_types[6] #define SWIGTYPE_p_GLint swig_types[7] #define SWIGTYPE_p_char swig_types[8] #define SWIGTYPE_p_GLclampd swig_types[9] #define SWIGTYPE_p_GLclampf swig_types[10] #define SWIGTYPE_p_GLuint swig_types[11] #define SWIGTYPE_ptrdiff_t swig_types[12] #define SWIGTYPE_p_GLbyte swig_types[13] #define SWIGTYPE_p_GLbitfield swig_types[14] #define SWIGTYPE_p_GLfloat swig_types[15] #define SWIGTYPE_p_GLubyte swig_types[16] #define SWIGTYPE_p_GLdouble swig_types[17] static swig_type_info *swig_types[19]; /* -------- TYPES TABLE (END) -------- */ /*----------------------------------------------- @(target):= _buffer_region.so ------------------------------------------------*/ #define SWIG_init init_buffer_region #define SWIG_name "_buffer_region" SWIGINTERN PyObject * SWIG_FromCharPtr(const char* cptr) { if (cptr) { size_t size = strlen(cptr); if (size > INT_MAX) { return SWIG_NewPointerObj((char*)(cptr), SWIG_TypeQuery("char *"), 0); } else { if (size != 0) { return PyString_FromStringAndSize(cptr, size); } else { return PyString_FromString(cptr); } } } Py_INCREF(Py_None); return Py_None; } /*@C:\\bin\\SWIG-1.3.23\\Lib\\python\\pymacros.swg,66,SWIG_define@*/ #define SWIG_From_int PyInt_FromLong /*@@*/ /** * * GL.KTX.buffer_region Module for PyOpenGL * * Date: May 2001 * * Authors: Tarn Weisner Burton <[email protected]> * ***/ GLint PyOpenGL_round(double x) { if (x >= 0) { return (GLint) (x+0.5); } else { return (GLint) (x-0.5); } } int __PyObject_AsArray_Size(PyObject* x); #ifdef NUMERIC #define _PyObject_AsArray_Size(x) ((x == Py_None) ? 0 : ((PyArray_Check(x)) ? PyArray_Size(x) : __PyObject_AsArray_Size(x))) #else /* NUMERIC */ #define _PyObject_AsArray_Size(x) ((x == Py_None) ? 0 : __PyObject_AsArray_Size(x)) #endif /* NUMERIC */ #define _PyObject_As(NAME, BASE) BASE* _PyObject_As##NAME(PyObject* source, PyObject** temp, int* len); #define _PyObject_AsArray_Cleanup(target, temp) if (temp) Py_XDECREF(temp); else PyMem_Del(target) _PyObject_As(FloatArray, float) _PyObject_As(DoubleArray, double) _PyObject_As(CharArray, signed char) _PyObject_As(UnsignedCharArray, unsigned char) _PyObject_As(ShortArray, short) _PyObject_As(UnsignedShortArray, unsigned short) _PyObject_As(IntArray, int) _PyObject_As(UnsignedIntArray, unsigned int) void* _PyObject_AsArray(GLenum type, PyObject* source, PyObject** temp, int* len); #define PyErr_XPrint() if (PyErr_Occurred()) PyErr_Print() #if HAS_DYNAMIC_EXT #define DECLARE_EXT(PROC_NAME, RET, ERROR_RET, PROTO, CALL)\ RET PROC_NAME PROTO\ {\ typedef RET (APIENTRY *proc_##PROC_NAME) PROTO;\ proc_##PROC_NAME proc = (proc_##PROC_NAME)GL_GetProcAddress(#PROC_NAME);\ if (proc) return proc CALL;\ PyErr_SetGLErrorMessage( GL_INVALID_OPERATION, "Dynamic function loading not implemented/supported on this platform" );\ return ERROR_RET;\ } #define DECLARE_VOID_EXT(PROC_NAME, PROTO, CALL)\ void PROC_NAME PROTO\ {\ typedef void (APIENTRY *proc_##PROC_NAME) PROTO;\ proc_##PROC_NAME proc = (proc_##PROC_NAME)GL_GetProcAddress(#PROC_NAME);\ if (proc) proc CALL;\ else {\ PyErr_SetGLErrorMessage( GL_INVALID_OPERATION, "Dynamic function loading not implemented/supported on this platform" );\ }\ } #else #define DECLARE_EXT(PROC_NAME, RET, ERROR_RET, PROTO, CALL)\ RET PROC_NAME PROTO\ {\ PyErr_SetGLErrorMessage( GL_INVALID_OPERATION, "Dynamic function loading not implemented/supported on this platform" );\ return ERROR_RET;\ } #define DECLARE_VOID_EXT(PROC_NAME, PROTO, CALL)\ void PROC_NAME PROTO\ {\ PyErr_SetGLErrorMessage( GL_INVALID_OPERATION, "Dynamic function loading not implemented/supported on this platform" );\ } #endif #define _PyTuple_From(NAME, BASE) PyObject* _PyTuple_From##NAME(int len, BASE* data); _PyTuple_From(UnsignedCharArray, unsigned char) _PyTuple_From(CharArray, signed char) _PyTuple_From(UnsignedShortArray, unsigned short) _PyTuple_From(ShortArray, short) _PyTuple_From(UnsignedIntArray, unsigned int) _PyTuple_From(IntArray, int) _PyTuple_From(FloatArray, float) _PyTuple_From(DoubleArray, double) #define _PyObject_From(NAME, BASE) PyObject* _PyObject_From##NAME(int nd, int* dims, BASE* data, int own); _PyObject_From(UnsignedCharArray, unsigned char) _PyObject_From(CharArray, signed char) _PyObject_From(UnsignedShortArray, unsigned short) _PyObject_From(ShortArray, short) _PyObject_From(UnsignedIntArray, unsigned int) _PyObject_From(IntArray, int) _PyObject_From(FloatArray, float) _PyObject_From(DoubleArray, double) PyObject* _PyObject_FromArray(GLenum type, int nd, int *dims, void* data, int own); void* SetupPixelRead(int rank, GLenum format, GLenum type, int *dims); void SetupPixelWrite(int rank); void* SetupRawPixelRead(GLenum format, GLenum type, int n, const int *dims, int* size); void* _PyObject_AsPointer(PyObject* x); /* The following line causes a warning on linux and cygwin The function is defined in interface_utils.c, which is linked to each extension module. For some reason, though, this declaration doesn't get recognised as a declaration prototype for that function. */ void init_util(); typedef void *PTR; typedef struct { void (*_decrement)(void* pointer); void (*_decrementPointer)(GLenum pname); int (*_incrementLock)(void *pointer); int (*_incrementPointerLock)(GLenum pname); void (*_acquire)(void* pointer); void (*_acquirePointer)(GLenum pname); #if HAS_DYNAMIC_EXT PTR (*GL_GetProcAddress)(const char* name); #endif int (*InitExtension)(const char *name, const char** procs); PyObject *_GLerror; PyObject *_GLUerror; } util_API; static util_API *_util_API = NULL; #define decrementLock(x) (*_util_API)._decrement(x) #define decrementPointerLock(x) (*_util_API)._decrementPointer(x) #define incrementLock(x) (*_util_API)._incrementLock(x) #define incrementPointerLock(x) (*_util_API)._incrementPointerLock(x) #define acquire(x) (*_util_API)._acquire(x) #define acquirePointer(x) (*_util_API)._acquirePointer(x) #define GLerror (*_util_API)._GLerror #define GLUerror (*_util_API)._GLUerror #if HAS_DYNAMIC_EXT #define GL_GetProcAddress(x) (*_util_API).GL_GetProcAddress(x) #endif #define InitExtension(x, y) (*_util_API).InitExtension(x, (const char**)y) #define PyErr_SetGLerror(code) PyErr_SetObject(GLerror, Py_BuildValue("is", code, gluErrorString(code))); #define PyErr_SetGLUerror(code) PyErr_SetObject(GLUerror, Py_BuildValue("is", code, gluErrorString(code))); int _PyObject_Dimension(PyObject* x, int rank); #define ERROR_MSG_SEP ", " #define ERROR_MSG_SEP_LEN 2 int GLErrOccurred() { if (PyErr_Occurred()) return 1; if (CurrentContextIsValid()) { GLenum error, *errors = NULL; char *msg = NULL; const char *this_msg; int count = 0; error = glGetError(); while (error != GL_NO_ERROR) { this_msg = gluErrorString(error); if (count) { msg = realloc(msg, (strlen(msg) + strlen(this_msg) + ERROR_MSG_SEP_LEN + 1)*sizeof(char)); strcat(msg, ERROR_MSG_SEP); strcat(msg, this_msg); errors = realloc(errors, (count + 1)*sizeof(GLenum)); } else { msg = malloc((strlen(this_msg) + 1)*sizeof(char)); strcpy(msg, this_msg); errors = malloc(sizeof(GLenum)); } errors[count++] = error; error = glGetError(); } if (count) { PyErr_SetObject(GLerror, Py_BuildValue("Os", _PyTuple_FromIntArray(count, (int*)errors), msg)); free(errors); free(msg); return 1; } } return 0; } void PyErr_SetGLErrorMessage( int id, char * message ) { /* set a GLerror with an ID and string message This tries pretty hard to look just like a regular error as produced by GLErrOccurred()'s formatter, save that there's only the single error being reported. Using id 0 is probably best for any future use where there isn't a good match for the exception description in the error-enumeration set. */ PyObject * args = NULL; args = Py_BuildValue( "(i)s", id, message ); if (args) { PyErr_SetObject( GLerror, args ); Py_XDECREF( args ); } else { PyErr_SetGLerror(id); } } #if !EXT_DEFINES_PROTO || !defined(GL_KTX_buffer_region) DECLARE_EXT(glBufferRegionEnabled, GLuint, -1, (), ()) DECLARE_EXT(glNewBufferRegion, GLuint, -1, (GLenum type), (type)) DECLARE_VOID_EXT(glDeleteBufferRegion, (GLuint region), (region)) DECLARE_VOID_EXT(glReadBufferRegion, (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height), (region, x, y, width, height)) DECLARE_VOID_EXT(glDrawBufferRegion, (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height, GLint xDest, GLint yDest), (region, x, y, width, height, xDest, yDest)) #endif /*@C:\\bin\\SWIG-1.3.23\\Lib\\python\\pymacros.swg,66,SWIG_define@*/ #define SWIG_From_long PyInt_FromLong /*@@*/ SWIGINTERNSHORT PyObject* SWIG_From_unsigned_SS_long(unsigned long value) { return (value > LONG_MAX) ? PyLong_FromUnsignedLong(value) : PyInt_FromLong((long)(value)); } #if UINT_MAX < LONG_MAX /*@C:\\bin\\SWIG-1.3.23\\Lib\\python\\pymacros.swg,66,SWIG_define@*/ #define SWIG_From_unsigned_SS_int SWIG_From_long /*@@*/ #else /*@C:\\bin\\SWIG-1.3.23\\Lib\\python\\pymacros.swg,66,SWIG_define@*/ #define SWIG_From_unsigned_SS_int SWIG_From_unsigned_SS_long /*@@*/ #endif static char _doc_glBufferRegionEnabled[] = "glBufferRegionEnabled() -> bool"; #include <limits.h> SWIGINTERNSHORT int SWIG_CheckUnsignedLongInRange(unsigned long value, unsigned long max_value, const char *errmsg) { if (value > max_value) { if (errmsg) { PyErr_Format(PyExc_OverflowError, "value %lu is greater than '%s' minimum %lu", value, errmsg, max_value); } return 0; } return 1; } SWIGINTERN int SWIG_AsVal_unsigned_SS_long(PyObject *obj, unsigned long *val) { if (PyInt_Check(obj)) { long v = PyInt_AS_LONG(obj); if (v >= 0) { if (val) *val = v; return 1; } } if (PyLong_Check(obj)) { unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return 1; } else { if (!val) PyErr_Clear(); return 0; } } if (val) { SWIG_type_error("unsigned long", obj); } return 0; } #if UINT_MAX != ULONG_MAX SWIGINTERN int SWIG_AsVal_unsigned_SS_int(PyObject *obj, unsigned int *val) { const char* errmsg = val ? "unsigned int" : (char*)0; unsigned long v; if (SWIG_AsVal_unsigned_SS_long(obj, &v)) { if (SWIG_CheckUnsignedLongInRange(v, INT_MAX, errmsg)) { if (val) *val = (unsigned int)(v); return 1; } } else { PyErr_Clear(); } if (val) { SWIG_type_error(errmsg, obj); } return 0; } #else SWIGINTERNSHORT unsigned int SWIG_AsVal_unsigned_SS_int(PyObject *obj, unsigned int *val) { return SWIG_AsVal_unsigned_SS_long(obj,(unsigned long *)val); } #endif SWIGINTERNSHORT unsigned int SWIG_As_unsigned_SS_int(PyObject* obj) { unsigned int v; if (!SWIG_AsVal_unsigned_SS_int(obj, &v)) { /* this is needed to make valgrind/purify happier. */ memset((void*)&v, 0, sizeof(unsigned int)); } return v; } SWIGINTERNSHORT int SWIG_Check_unsigned_SS_int(PyObject* obj) { return SWIG_AsVal_unsigned_SS_int(obj, (unsigned int*)0); } static char _doc_glNewBufferRegion[] = "glNewBufferRegion(type) -> handle"; static char _doc_glDeleteBufferRegion[] = "glDeleteBufferRegion(region) -> None"; SWIGINTERN int SWIG_CheckLongInRange(long value, long min_value, long max_value, const char *errmsg) { if (value < min_value) { if (errmsg) { PyErr_Format(PyExc_OverflowError, "value %ld is less than '%s' minimum %ld", value, errmsg, min_value); } return 0; } else if (value > max_value) { if (errmsg) { PyErr_Format(PyExc_OverflowError, "value %ld is greater than '%s' maximum %ld", value, errmsg, max_value); } return 0; } return 1; } SWIGINTERN int SWIG_AsVal_long(PyObject * obj, long* val) { if (PyInt_Check(obj)) { if (val) *val = PyInt_AS_LONG(obj); return 1; } if (PyLong_Check(obj)) { long v = PyLong_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return 1; } else { if (!val) PyErr_Clear(); return 0; } } if (val) { SWIG_type_error("long", obj); } return 0; } #if INT_MAX != LONG_MAX SWIGINTERN int SWIG_AsVal_int(PyObject *obj, int *val) { const char* errmsg = val ? "int" : (char*)0; long v; if (SWIG_AsVal_long(obj, &v)) { if (SWIG_CheckLongInRange(v, INT_MIN,INT_MAX, errmsg)) { if (val) *val = (int)(v); return 1; } else { return 0; } } else { PyErr_Clear(); } if (val) { SWIG_type_error(errmsg, obj); } return 0; } #else SWIGINTERNSHORT int SWIG_AsVal_int(PyObject *obj, int *val) { return SWIG_AsVal_long(obj,(long*)val); } #endif SWIGINTERNSHORT int SWIG_Check_int(PyObject* obj) { return SWIG_AsVal_int(obj, (int*)0); } static char _doc_glReadBufferRegion[] = "glReadBufferRegion(region, x, y, width, height) -> None"; SWIGINTERNSHORT int SWIG_As_int(PyObject* obj) { int v; if (!SWIG_AsVal_int(obj, &v)) { /* this is needed to make valgrind/purify happier. */ memset((void*)&v, 0, sizeof(int)); } return v; } static char _doc_glDrawBufferRegion[] = "glDrawBufferRegion(region, x, y, width, height, xDest, yDest) -> None"; static char *proc_names[] = { #if !EXT_DEFINES_PROTO || !defined(GL_KTX_buffer_region) "glBufferRegionEnabled", "glNewBufferRegion", "glDeleteBufferRegion", "glReadBufferRegion", "glDrawBufferRegion", #endif NULL }; #define glInitBufferRegionKTX() InitExtension("GL_KTX_buffer_region", proc_names) static char _doc_glInitBufferRegionKTX[] = "glInitBufferRegionKTX() -> bool"; PyObject *__info() { if (glInitBufferRegionKTX()) { PyObject *info = PyList_New(0); return info; } Py_INCREF(Py_None); return Py_None; } #ifdef __cplusplus extern "C" { #endif static PyObject *_wrap_glBufferRegionEnabled(PyObject *self, PyObject *args) { PyObject *resultobj; GLuint result; if(!PyArg_ParseTuple(args,(char *)":glBufferRegionEnabled")) goto fail; { result = (GLuint)glBufferRegionEnabled(); if (GLErrOccurred()) { return NULL; } } { resultobj = SWIG_From_unsigned_SS_int((unsigned int)(result)); } return resultobj; fail: return NULL; } static PyObject *_wrap_glNewBufferRegion(PyObject *self, PyObject *args) { PyObject *resultobj; GLenum arg1 ; GLuint result; PyObject * obj0 = 0 ; if(!PyArg_ParseTuple(args,(char *)"O:glNewBufferRegion",&obj0)) goto fail; { arg1 = (GLenum)(SWIG_As_unsigned_SS_int(obj0)); if (SWIG_arg_fail(1)) SWIG_fail; } { result = (GLuint)glNewBufferRegion(arg1); if (GLErrOccurred()) { return NULL; } } { resultobj = SWIG_From_unsigned_SS_int((unsigned int)(result)); } return resultobj; fail: return NULL; } static PyObject *_wrap_glDeleteBufferRegion(PyObject *self, PyObject *args) { PyObject *resultobj; GLuint arg1 ; PyObject * obj0 = 0 ; if(!PyArg_ParseTuple(args,(char *)"O:glDeleteBufferRegion",&obj0)) goto fail; { arg1 = (GLuint)(SWIG_As_unsigned_SS_int(obj0)); if (SWIG_arg_fail(1)) SWIG_fail; } { glDeleteBufferRegion(arg1); if (GLErrOccurred()) { return NULL; } } Py_INCREF(Py_None); resultobj = Py_None; return resultobj; fail: return NULL; } static PyObject *_wrap_glReadBufferRegion(PyObject *self, PyObject *args) { PyObject *resultobj; GLuint arg1 ; GLint arg2 ; GLint arg3 ; GLsizei arg4 ; GLsizei arg5 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; if(!PyArg_ParseTuple(args,(char *)"OOOOO:glReadBufferRegion",&obj0,&obj1,&obj2,&obj3,&obj4)) goto fail; { arg1 = (GLuint)(SWIG_As_unsigned_SS_int(obj0)); if (SWIG_arg_fail(1)) SWIG_fail; } { if (PyInt_Check(obj1) || PyLong_Check(obj1)) { arg2= (GLint)(PyInt_AsLong( obj1 )); } else if (PyFloat_Check(obj1)) { double arg2_temp_float; arg2_temp_float = PyFloat_AsDouble(obj1); if ((arg2_temp_float <= INT_MIN-0.5) || (arg2_temp_float >= INT_MAX+0.5)) { PyErr_SetString(PyExc_ValueError, "GLint value too large to convert"); return NULL; } arg2 = PyOpenGL_round( arg2_temp_float ); } } { if (PyInt_Check(obj2) || PyLong_Check(obj2)) { arg3= (GLint)(PyInt_AsLong( obj2 )); } else if (PyFloat_Check(obj2)) { double arg3_temp_float; arg3_temp_float = PyFloat_AsDouble(obj2); if ((arg3_temp_float <= INT_MIN-0.5) || (arg3_temp_float >= INT_MAX+0.5)) { PyErr_SetString(PyExc_ValueError, "GLint value too large to convert"); return NULL; } arg3 = PyOpenGL_round( arg3_temp_float ); } } { if (PyInt_Check(obj3) || PyLong_Check(obj3)) { arg4= (GLsizei)(PyInt_AsLong( obj3 )); } else if (PyFloat_Check(obj3)) { double arg4_temp_float; arg4_temp_float = PyFloat_AsDouble(obj3); if (arg4_temp_float >= (INT_MAX-0.5)) { PyErr_SetString(PyExc_ValueError, "Value too large to be converted to a size measurement"); return NULL; } else if (arg4_temp_float <= -0.5) { PyErr_SetString(PyExc_ValueError, "Value less than 0, cannot be converted to a size measurement"); return NULL; } arg4 = (GLsizei) PyOpenGL_round( arg4_temp_float ); } } { if (PyInt_Check(obj4) || PyLong_Check(obj4)) { arg5= (GLsizei)(PyInt_AsLong( obj4 )); } else if (PyFloat_Check(obj4)) { double arg5_temp_float; arg5_temp_float = PyFloat_AsDouble(obj4); if (arg5_temp_float >= (INT_MAX-0.5)) { PyErr_SetString(PyExc_ValueError, "Value too large to be converted to a size measurement"); return NULL; } else if (arg5_temp_float <= -0.5) { PyErr_SetString(PyExc_ValueError, "Value less than 0, cannot be converted to a size measurement"); return NULL; } arg5 = (GLsizei) PyOpenGL_round( arg5_temp_float ); } } { glReadBufferRegion(arg1,arg2,arg3,arg4,arg5); if (GLErrOccurred()) { return NULL; } } Py_INCREF(Py_None); resultobj = Py_None; return resultobj; fail: return NULL; } static PyObject *_wrap_glDrawBufferRegion(PyObject *self, PyObject *args) { PyObject *resultobj; GLuint arg1 ; GLint arg2 ; GLint arg3 ; GLsizei arg4 ; GLsizei arg5 ; GLint arg6 ; GLint arg7 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; PyObject * obj6 = 0 ; if(!PyArg_ParseTuple(args,(char *)"OOOOOOO:glDrawBufferRegion",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) goto fail; { arg1 = (GLuint)(SWIG_As_unsigned_SS_int(obj0)); if (SWIG_arg_fail(1)) SWIG_fail; } { if (PyInt_Check(obj1) || PyLong_Check(obj1)) { arg2= (GLint)(PyInt_AsLong( obj1 )); } else if (PyFloat_Check(obj1)) { double arg2_temp_float; arg2_temp_float = PyFloat_AsDouble(obj1); if ((arg2_temp_float <= INT_MIN-0.5) || (arg2_temp_float >= INT_MAX+0.5)) { PyErr_SetString(PyExc_ValueError, "GLint value too large to convert"); return NULL; } arg2 = PyOpenGL_round( arg2_temp_float ); } } { if (PyInt_Check(obj2) || PyLong_Check(obj2)) { arg3= (GLint)(PyInt_AsLong( obj2 )); } else if (PyFloat_Check(obj2)) { double arg3_temp_float; arg3_temp_float = PyFloat_AsDouble(obj2); if ((arg3_temp_float <= INT_MIN-0.5) || (arg3_temp_float >= INT_MAX+0.5)) { PyErr_SetString(PyExc_ValueError, "GLint value too large to convert"); return NULL; } arg3 = PyOpenGL_round( arg3_temp_float ); } } { if (PyInt_Check(obj3) || PyLong_Check(obj3)) { arg4= (GLsizei)(PyInt_AsLong( obj3 )); } else if (PyFloat_Check(obj3)) { double arg4_temp_float; arg4_temp_float = PyFloat_AsDouble(obj3); if (arg4_temp_float >= (INT_MAX-0.5)) { PyErr_SetString(PyExc_ValueError, "Value too large to be converted to a size measurement"); return NULL; } else if (arg4_temp_float <= -0.5) { PyErr_SetString(PyExc_ValueError, "Value less than 0, cannot be converted to a size measurement"); return NULL; } arg4 = (GLsizei) PyOpenGL_round( arg4_temp_float ); } } { if (PyInt_Check(obj4) || PyLong_Check(obj4)) { arg5= (GLsizei)(PyInt_AsLong( obj4 )); } else if (PyFloat_Check(obj4)) { double arg5_temp_float; arg5_temp_float = PyFloat_AsDouble(obj4); if (arg5_temp_float >= (INT_MAX-0.5)) { PyErr_SetString(PyExc_ValueError, "Value too large to be converted to a size measurement"); return NULL; } else if (arg5_temp_float <= -0.5) { PyErr_SetString(PyExc_ValueError, "Value less than 0, cannot be converted to a size measurement"); return NULL; } arg5 = (GLsizei) PyOpenGL_round( arg5_temp_float ); } } { arg6 = (GLint)(SWIG_As_int(obj5)); if (SWIG_arg_fail(6)) SWIG_fail; } { arg7 = (GLint)(SWIG_As_int(obj6)); if (SWIG_arg_fail(7)) SWIG_fail; } { glDrawBufferRegion(arg1,arg2,arg3,arg4,arg5,arg6,arg7); if (GLErrOccurred()) { return NULL; } } Py_INCREF(Py_None); resultobj = Py_None; return resultobj; fail: return NULL; } static PyObject *_wrap_glInitBufferRegionKTX(PyObject *self, PyObject *args) { PyObject *resultobj; int result; if(!PyArg_ParseTuple(args,(char *)":glInitBufferRegionKTX")) goto fail; { result = (int)glInitBufferRegionKTX(); if (GLErrOccurred()) { return NULL; } } { resultobj = SWIG_From_int((int)(result)); } return resultobj; fail: return NULL; } static PyObject *_wrap___info(PyObject *self, PyObject *args) { PyObject *resultobj; PyObject *result; if(!PyArg_ParseTuple(args,(char *)":__info")) goto fail; { result = (PyObject *)__info(); if (GLErrOccurred()) { return NULL; } } { resultobj= result; } return resultobj; fail: return NULL; } static PyMethodDef SwigMethods[] = { { (char *)"glBufferRegionEnabled", _wrap_glBufferRegionEnabled, METH_VARARGS, NULL}, { (char *)"glNewBufferRegion", _wrap_glNewBufferRegion, METH_VARARGS, NULL}, { (char *)"glDeleteBufferRegion", _wrap_glDeleteBufferRegion, METH_VARARGS, NULL}, { (char *)"glReadBufferRegion", _wrap_glReadBufferRegion, METH_VARARGS, NULL}, { (char *)"glDrawBufferRegion", _wrap_glDrawBufferRegion, METH_VARARGS, NULL}, { (char *)"glInitBufferRegionKTX", _wrap_glInitBufferRegionKTX, METH_VARARGS, NULL}, { (char *)"__info", _wrap___info, METH_VARARGS, NULL}, { NULL, NULL, 0, NULL } }; /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ static swig_type_info _swigt__p_GLsizei[] = {{"_p_GLsizei", 0, "int *|GLsizei *", 0, 0, 0, 0},{"_p_GLint", 0, 0, 0, 0, 0, 0},{"_p_GLsizei", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLshort[] = {{"_p_GLshort", 0, "short *|GLshort *", 0, 0, 0, 0},{"_p_GLshort", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLboolean[] = {{"_p_GLboolean", 0, "unsigned char *|GLboolean *", 0, 0, 0, 0},{"_p_GLboolean", 0, 0, 0, 0, 0, 0},{"_p_GLubyte", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__size_t[] = {{"_size_t", 0, "size_t", 0, 0, 0, 0},{"_size_t", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLushort[] = {{"_p_GLushort", 0, "unsigned short *|GLushort *", 0, 0, 0, 0},{"_p_GLushort", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLenum[] = {{"_p_GLenum", 0, "unsigned int *|GLenum *", 0, 0, 0, 0},{"_p_GLuint", 0, 0, 0, 0, 0, 0},{"_p_GLenum", 0, 0, 0, 0, 0, 0},{"_p_GLbitfield", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLvoid[] = {{"_p_GLvoid", 0, "void *|GLvoid *", 0, 0, 0, 0},{"_p_GLvoid", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLint[] = {{"_p_GLint", 0, "int *|GLint *", 0, 0, 0, 0},{"_p_GLint", 0, 0, 0, 0, 0, 0},{"_p_GLsizei", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_char[] = {{"_p_char", 0, "char *", 0, 0, 0, 0},{"_p_char", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLclampd[] = {{"_p_GLclampd", 0, "double *|GLclampd *", 0, 0, 0, 0},{"_p_GLclampd", 0, 0, 0, 0, 0, 0},{"_p_GLdouble", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLclampf[] = {{"_p_GLclampf", 0, "float *|GLclampf *", 0, 0, 0, 0},{"_p_GLfloat", 0, 0, 0, 0, 0, 0},{"_p_GLclampf", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLuint[] = {{"_p_GLuint", 0, "unsigned int *|GLuint *", 0, 0, 0, 0},{"_p_GLuint", 0, 0, 0, 0, 0, 0},{"_p_GLenum", 0, 0, 0, 0, 0, 0},{"_p_GLbitfield", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__ptrdiff_t[] = {{"_ptrdiff_t", 0, "ptrdiff_t", 0, 0, 0, 0},{"_ptrdiff_t", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLbyte[] = {{"_p_GLbyte", 0, "signed char *|GLbyte *", 0, 0, 0, 0},{"_p_GLbyte", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLbitfield[] = {{"_p_GLbitfield", 0, "unsigned int *|GLbitfield *", 0, 0, 0, 0},{"_p_GLuint", 0, 0, 0, 0, 0, 0},{"_p_GLbitfield", 0, 0, 0, 0, 0, 0},{"_p_GLenum", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLfloat[] = {{"_p_GLfloat", 0, "float *|GLfloat *", 0, 0, 0, 0},{"_p_GLfloat", 0, 0, 0, 0, 0, 0},{"_p_GLclampf", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLubyte[] = {{"_p_GLubyte", 0, "unsigned char *|GLubyte *", 0, 0, 0, 0},{"_p_GLboolean", 0, 0, 0, 0, 0, 0},{"_p_GLubyte", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLdouble[] = {{"_p_GLdouble", 0, "double *|GLdouble *", 0, 0, 0, 0},{"_p_GLclampd", 0, 0, 0, 0, 0, 0},{"_p_GLdouble", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info *swig_types_initial[] = { _swigt__p_GLsizei, _swigt__p_GLshort, _swigt__p_GLboolean, _swigt__size_t, _swigt__p_GLushort, _swigt__p_GLenum, _swigt__p_GLvoid, _swigt__p_GLint, _swigt__p_char, _swigt__p_GLclampd, _swigt__p_GLclampf, _swigt__p_GLuint, _swigt__ptrdiff_t, _swigt__p_GLbyte, _swigt__p_GLbitfield, _swigt__p_GLfloat, _swigt__p_GLubyte, _swigt__p_GLdouble, 0 }; /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ static swig_const_info swig_const_table[] = { { SWIG_PY_POINTER, (char*)"__version__", 0, 0, (void *)"1.29.6.1", &SWIGTYPE_p_char}, { SWIG_PY_POINTER, (char*)"__date__", 0, 0, (void *)"2004/11/14 23:19:04", &SWIGTYPE_p_char}, { SWIG_PY_POINTER, (char*)"__author__", 0, 0, (void *)"Tarn Weisner Burton <[email protected]>", &SWIGTYPE_p_char}, { SWIG_PY_POINTER, (char*)"__doc__", 0, 0, (void *)"http://www.autodesk.com/develop/devres/heidi/oglspecs.htm", &SWIGTYPE_p_char}, {0, 0, 0, 0.0, 0, 0}}; #ifdef __cplusplus } #endif #ifdef SWIG_LINK_RUNTIME #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # if defined(_MSC_VER) || defined(__GNUC__) # define SWIGIMPORT(a) extern a # else # if defined(__BORLANDC__) # define SWIGIMPORT(a) a _export # else # define SWIGIMPORT(a) a # endif # endif #else # define SWIGIMPORT(a) a #endif #ifdef __cplusplus extern "C" #endif SWIGEXPORT(void *) SWIG_ReturnGlobalTypeList(void *); #endif #ifdef __cplusplus extern "C" #endif SWIGEXPORT(void) SWIG_init(void) { static PyObject *SWIG_globals = 0; static int typeinit = 0; PyObject *m, *d; int i; if (!SWIG_globals) SWIG_globals = SWIG_newvarlink(); /* Fix SwigMethods to carry the callback ptrs when needed */ SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_types_initial); m = Py_InitModule((char *) SWIG_name, SwigMethods); d = PyModule_GetDict(m); if (!typeinit) { #ifdef SWIG_LINK_RUNTIME swig_type_list_handle = (swig_type_info **) SWIG_ReturnGlobalTypeList(swig_type_list_handle); #else # ifndef SWIG_STATIC_RUNTIME SWIG_Python_LookupTypePointer(&swig_type_list_handle); # endif #endif for (i = 0; swig_types_initial[i]; i++) { swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]); } typeinit = 1; } SWIG_InstallConstants(d,swig_const_table); PyDict_SetItemString(d,"__version__", SWIG_FromCharPtr("1.29.6.1")); PyDict_SetItemString(d,"__date__", SWIG_FromCharPtr("2004/11/14 23:19:04")); { PyDict_SetItemString(d,"__api_version__", SWIG_From_int((int)(256))); } PyDict_SetItemString(d,"__author__", SWIG_FromCharPtr("Tarn Weisner Burton <[email protected]>")); PyDict_SetItemString(d,"__doc__", SWIG_FromCharPtr("http://www.autodesk.com/develop/devres/heidi/oglspecs.htm")); #ifdef NUMERIC PyArray_API = NULL; import_array(); init_util(); PyErr_Clear(); #endif { PyObject *util = PyImport_ImportModule("OpenGL.GL._GL__init__"); if (util) { PyObject *api_object = PyDict_GetItemString(PyModule_GetDict(util), "_util_API"); if (PyCObject_Check(api_object)) _util_API = (util_API*)PyCObject_AsVoidPtr(api_object); } } { PyDict_SetItemString(d,"GL_KTX_FRONT_REGION", SWIG_From_int((int)(0x0000))); } { PyDict_SetItemString(d,"GL_KTX_BACK_REGION", SWIG_From_int((int)(0x0001))); } { PyDict_SetItemString(d,"GL_KTX_Z_REGION", SWIG_From_int((int)(0x0002))); } { PyDict_SetItemString(d,"GL_KTX_STENCIL_REGION", SWIG_From_int((int)(0x0003))); } }
[ "ronaldoussoren@f55f28a5-9edb-0310-a011-a803cfcd5d25" ]
[ [ [ 1, 2124 ] ] ]
f354c3309d08dac24a2da6b30b90756399274af4
11da90929ba1488c59d25c57a5fb0899396b3bb2
/Src/WindowsCE/WinTextRenderer.hpp
1e91672bc4b7ce63d4b7d18aa617e34fb8fe22b1
[]
no_license
danste/ars-framework
5e7864630fd8dbf7f498f58cf6f9a62f8e1d95c6
90f99d43804d3892432acbe622b15ded6066ea5d
refs/heads/master
2022-11-11T15:31:02.271791
2005-10-17T15:37:36
2005-10-17T15:37:36
263,623,421
0
0
null
2020-05-13T12:28:22
2020-05-13T12:28:21
null
UTF-8
C++
false
false
2,352
hpp
#ifndef ARSLEXIS_WIN_TEXT_RENDERER_HPP__ #define ARSLEXIS_WIN_TEXT_RENDERER_HPP__ #include <WindowsCE/Controls.hpp> #include <Definition.hpp> class TextRenderer: public Widget { ScrollBar scrollBar_; bool scrollbarVisible_; bool leftButtonDown_; UINT scrollTimer_; ulong_t actionDown_; enum ScrollDirection { scrollNone, scrollDown, scrollUp }; enum {timerId = 1}; ScrollDirection scrollDirection_; //HDC offscreenDC_; //HGDIOBJ origBitmap_; void verifyScrollbarVisible(); void updateScroller(RepaintOption repaint); void prepareTestData(); enum ScrollType { scrollHome, scrollLine, scrollPage, scrollEnd, scrollPosition }; bool scroll(int units, ScrollType type, const Point* p = NULL); void paintDefinition(HDC dc, int scroll = 0, const Point* p = NULL, bool erase = false); void definitionBounds(Rect& r); struct DC_Helper { HDC orig; HDC offscreen; HGDIOBJ origBmp; DC_Helper(HDC org): orig(org), offscreen(NULL), origBmp(NULL) {} }; bool prepareOffscreenDC(DC_Helper& h, Rect& rect, bool erase = false); void updateOrigDC(DC_Helper& h, Rect& rect); void destroyOffscreenDC(DC_Helper& h); public: explicit TextRenderer(AutoDeleteOption ad = autoDeleteNot); ~TextRenderer(); bool create(DWORD style, int x, int y, int w, int h, HWND parent, HINSTANCE instance = NULL); bool create(DWORD style, const RECT& r, HWND parent, HINSTANCE instance = NULL); Definition definition; void setModel(DefinitionModel* model, Definition::ModelOwnerFlag own = Definition::ownModelNot); protected: virtual LRESULT callback(UINT uMsg, WPARAM wParam, LPARAM lParam); long handleCreate(const CREATESTRUCT& cs); long handleResize(UINT sizeType, ushort width, ushort height); long handlePaint(HDC dc, PAINTSTRUCT* ps); private: bool mouseAction(int x, int y, UINT clickCount); LRESULT handleVScroll(UINT msg, WPARAM wParam, LPARAM lParam); LRESULT handleKeyDown(UINT msg, WPARAM wParam, LPARAM lParam); LRESULT handleTimer(UINT msg, WPARAM wParam, LPARAM lParam); }; #endif // ARSLEXIS_WIN_TEXT_RENDERER_HPP__
[ "andrzejc@10a9aba9-86da-0310-ac04-a2df2cc00fd9" ]
[ [ [ 1, 87 ] ] ]
ffc20b04e3baa37acee59f7570e39b81b7a35849
1d0aaab36740e9117022b3cf03029cede9f558ab
/Boat.cpp
90d9138285334ebfbe3404ee35665ed6cb553288
[]
no_license
mikeqcp/superseaman
76ac7c4b4a19a705880a078ca66cfd8976fc07d1
bebeb48e90270dd94bb1c85090f12c4123002815
refs/heads/master
2021-01-25T12:09:29.096901
2011-09-13T21:44:33
2011-09-13T21:44:33
32,287,575
0
0
null
null
null
null
WINDOWS-1250
C++
false
false
2,318
cpp
#include "Boat.h" Boat::Boat(Model *boat, Cloth *sail): boat(boat), sail(sail){ // sail->BuildCloth(); //wyznaczenie końca bomu, wg którego będzie obracany on i żagiel int length; glm::vec4 *ms = boat->GetSegment("bom", "bomend", &length); bomEnd = glm::vec4(0); for(int i = 0; i < length; i++) bomEnd += ms[i]; bomEnd /= length; //stworzenie macierzy, która przesuwa bom z początku układu współrzędnych (punkt O) do jego pierwotnego miejsca //jej odwrotność oczywiście przesuwa bom z pierwotnego miejsca do punktu O translateBomMatrix = glm::translate(glm::mat4(1), glm::vec3(bomEnd.x, bomEnd.y, bomEnd.z)); } Boat::~Boat(void) { } void Boat::Draw(){ boat -> Draw(); sail -> Draw(); sailAngle = 0; } void Boat::Update(glm::mat4 P, glm::mat4 V, glm::mat4 M, glm::vec4 lightPos){ //aktualizacja macierzy kadlubu przed wykonaniem pozostalych operacji - zanim macierz M zostanie zmieniona dla zagla i bomu boat ->Update(P, V, M, lightPos); //stworz macierz rotacji, która obróci żagiel o kąt sailAngle glm::mat4 rotMat = glm::rotate(glm::mat4(1), sailAngle, glm::vec3(0, 1, 0)); //przesun bom do początku układu współrzędnych, obróc o kąt sailAngle, przesuń z powrotem i przenieś do układu świata M = M*translateBomMatrix*rotMat*glm::inverse(translateBomMatrix); //Aktualizacja kadlubu i żagla boat->UpdateMesh("bom", P, V, M, lightPos); sail ->Update(P, V, M, lightPos); sail ->RotateWind(-sailAngle); //Krok czasowy dla metody całkowania verleta i funkcji spełniania ograniczeń sail->TimeStep(); } void Boat::RotateSail(GLfloat angle){ sailAngle = angle; //oganiczenie obrotu zagla od -60 do 60 stopni if(sailAngle > 60) sailAngle = 60; else if(sailAngle < -60) sailAngle = -60; } void Boat::DrawReflection(){ boat -> DrawReflection(); sail -> DrawReflection(); } void Boat::SetClipPlane(glm::vec4 clipPlane){ boat->SetClipPlane(clipPlane); sail->SetClipPlane(clipPlane); } void Boat::SetTextures(Texture *textures, int texCount){ boat ->SetTextures(textures, texCount); sail ->SetTextures(textures, texCount); } void Boat::SetLookAtPos(glm::vec3 lookAtPos){ boat ->SetLookAt(lookAtPos); sail ->SetLookAt(lookAtPos); }
[ "[email protected]@a54423c0-632b-0463-fc5f-a1ef5643ace0" ]
[ [ [ 1, 93 ] ] ]
e2e87922e3ef0c11a96c5a980826f2c6362d2f03
38664d844d9fad34e88160f6ebf86c043db9f1c5
/branches/initialize/skin/src/libcoolsb/custdraw.cpp
3995e98fc2954743724a64cfb53179da2c962413
[]
no_license
cnsuhao/jezzitest
84074b938b3e06ae820842dac62dae116d5fdaba
9b5f6cf40750511350e5456349ead8346cabb56e
refs/heads/master
2021-05-28T23:08:59.663581
2010-11-25T13:44:57
2010-11-25T13:44:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
13,572
cpp
#include <windows.h> #include <commctrl.h> #include "coolscroll.h" #include "../skinitf.h" #include <atlcomcli.h> #include <tmschema.h> UINT CALLBACK CoolSB_DrawProc(HDC hdc, UINT uCmdId, UINT uButflags, RECT *rect); extern BOOL fCustomDraw ; //extern HDC hdcSkin; HPEN hpen, oldpen; HPEN whitepen; HFONT hfont; HENHMETAFILE hemf=0; typedef struct { int x, y; int width, height; } CustomDrawTable; // // Define a set of structures which describe // where-abouts the source "textures" are in the // custom draw bitmap. We need to know x, y, width and height // for each scrollbar segment. // CustomDrawTable cdt_horz_normal[] = { { 0, 0, 15, 15 }, //left arrow NORMAL { 0, 15, 15, 15 }, //right arrow NORMAL { 0, 35, 1, 15 }, //page left NORMAL { 0, 35, 1, 15 }, //page right NORMAL { -1, -1, -1, -1 }, //padding { 14, 35, 4, 15 }, //horz thumb (left) { 18, 35, 8, 15 }, //horz thumb (middle) { 26, 35, 4, 15 }, //horz thumb (right) }; CustomDrawTable cdt_horz_hot[] = { { 15, 0, 15, 15 }, //left arrow ACTIVE { 15, 15, 15, 15 }, //right arrow ACTIVE { 6, 35, 1, 15 }, //page left ACTIVE { 6, 35, 1, 15 }, //page right ACTIVE { -1, -1, -1, -1 }, //padding { 14, 35, 4, 15 }, //horz thumb (left) { 18, 35, 8, 15 }, //horz thumb (middle) { 26, 35, 4, 15 }, //horz thumb (right) }; CustomDrawTable cdt_horz_active[] = { { 30, 0, 15, 15 }, //left arrow ACTIVE { 30, 15, 15, 15 }, //right arrow ACTIVE { 4, 35, 1, 15 }, //page left ACTIVE { 4, 35, 1, 15 }, //page right ACTIVE { -1, -1, -1, -1 }, //padding { 14, 35, 4, 15 }, //horz thumb (left) { 18, 35, 8, 15 }, //horz thumb (middle) { 26, 35, 4, 15 }, //horz thumb (right) }; // vertical CustomDrawTable cdt_vert_normal[] = { { 60, 0, 15, 15 }, //up arrow NORMAL { 60, 15, 15, 15 }, //down arrow NORMAL { 60, 35, 15, 1 }, //page up NORMAL { 60, 35, 15, 1 }, //page down NORMAL { -1, -1, -1, -1 }, //padding { 80, 35, 15, 4 }, //vert thumb (left) { 80, 39, 15, 8 }, //vert thumb (middle) { 80, 47, 15, 4 }, //vert thumb (right) }; CustomDrawTable cdt_vert_hot[] = { { 75, 0, 15, 15 }, //up arrow ACTIVE { 75, 15, 15, 15 }, //down arrow ACTIVE { 60, 41, 15, 1 }, //page up ACTIVE { 60, 41, 15, 1 }, //page down ACTIVE { -1, -1, -1, -1 }, //padding { 80, 35, 15, 4 }, //vert thumb (left) { 80, 39, 15, 8 }, //vert thumb (middle) { 80, 47, 15, 4 }, //vert thumb (right) }; CustomDrawTable cdt_vert_active[] = { { 90, 0, 15, 15 }, //up arrow ACTIVE { 90, 15, 15, 15 }, //down arrow ACTIVE { 60, 35, 15, 1 }, //page up ACTIVE { 60, 35, 15, 1 }, //page down ACTIVE { -1, -1, -1, -1 }, //padding { 80, 35, 15, 4 }, //vert thumb (left) { 80, 39, 15, 8 }, //vert thumb (middle) { 80, 47, 15, 4 }, //vert thumb (right) }; CustomDrawTable cdt_box = { 35, 35, 15, 15 }; LRESULT WINAPI HandleCustomDraw(UINT ctrlid, NMCSBCUSTOMDRAW *nm) { using namespace Skin; RECT *rc; CustomDrawTable *cdt; UINT code = NM_CUSTOMDRAW; int temp = 0; int thumblen = 0; int nPart; int nState; CComPtr<ISkinScheme> pss; GetCurrentScheme(&pss); UNREFERENCED_PARAMETER(ctrlid); // inserted buttons do not use PREPAINT etc.. if(nm->nBar == SB_INSBUT) { CoolSB_DrawProc(nm->hdc, nm->uItem, nm->uState, &nm->rect); return CDRF_SKIPDEFAULT; } if(!fCustomDraw) return CDRF_DODEFAULT; if(nm->dwDrawStage == CDDS_PREPAINT) { if(fCustomDraw) return CDRF_SKIPDEFAULT; else return CDRF_DODEFAULT; } if(nm->dwDrawStage == CDDS_POSTPAINT) { } //the sizing gripper in the bottom-right corner if(nm->nBar == SB_BOTH) { RECT *rc = &nm->rect; if ( pss ) { pss->DrawBackground( nm->hdc, SCROLLBAR, SBP_SIZEBOX, SZB_RIGHTALIGN, rc, NULL); } /* StretchBlt(nm->hdc, rc->left, rc->top, rc->right-rc->left, rc->bottom-rc->top, hdcSkin, cdt_box.x, cdt_box.y, cdt_box.width, cdt_box.height, SRCCOPY); */ return CDRF_SKIPDEFAULT; } else if(nm->nBar == SB_HORZ) //ˮƽ { rc = &nm->rect; if ( nm->uItem == HTSCROLL_LEFT || nm->uItem == HTSCROLL_RIGHT ) { if(nm->uState == CDIS_DISABLED) nState = nm->uItem == HTSCROLL_LEFT ? ABS_LEFTDISABLED : ABS_RIGHTDISABLED ; else if(nm->uState == CDIS_HOT) nState = nm->uItem == HTSCROLL_LEFT ? ABS_LEFTHOT : ABS_RIGHTHOT ; else if(nm->uState == CDIS_SELECTED) nState = nm->uItem == HTSCROLL_LEFT ? ABS_LEFTPRESSED : ABS_RIGHTPRESSED ; else nState = nm->uItem == HTSCROLL_LEFT ? ABS_LEFTNORMAL : ABS_RIGHTNORMAL ; nPart = SBP_ARROWBTN; if ( pss ) { if ( rc->left == 0 && rc->top == 0 ) return CDRF_SKIPDEFAULT; pss->DrawBackground( nm->hdc, SCROLLBAR, nPart, nState, rc, NULL); } return CDRF_SKIPDEFAULT; } else if ( nm->uItem == HTSCROLL_THUMB ) { if(nm->uState == CDIS_DISABLED) nState = SCRBS_DISABLED ; else if(nm->uState == CDIS_HOT) nState = SCRBS_HOT ; else if(nm->uState == CDIS_SELECTED) nState = SCRBS_PRESSED ; else nState = SCRBS_NORMAL ; // first draw thumb nPart = SBP_THUMBBTNHORZ; if ( pss ) { pss->DrawBackground( nm->hdc, SCROLLBAR, nPart, nState, rc, NULL); } // second draw gripper RECT rcGripper; BOOL bRet = pss->GetRect( SCROLLBAR, 11, nState, &rcGripper); if ( bRet ) { if ( rc->right - rc->left > rcGripper.right - rcGripper.left + 4 ) { RECT rcClient = *rc; rcClient.left = rcClient.left + ( rc->right - rc->left - rcGripper.right + rcGripper.left ) / 2; rcClient.right = rcClient.left + rcGripper.right - rcGripper.left; if ( pss ) { pss->DrawBackground( nm->hdc, SCROLLBAR, 11, nState, &rcClient, NULL); } } } return CDRF_SKIPDEFAULT; } else if ( nm->uItem == HTSCROLL_PAGELEFT ) { nPart = SBP_LOWERTRACKHORZ; if ( pss ) { pss->DrawBackground( nm->hdc, SCROLLBAR, nPart, 1, rc, NULL); } return CDRF_SKIPDEFAULT; } else if ( nm->uItem == HTSCROLL_PAGERIGHT ) { nPart = SBP_UPPERTRACKHORZ; if ( pss && rc->left != rc->right ) { pss->DrawBackground( nm->hdc, SCROLLBAR, nPart, 1, rc, NULL); } return CDRF_SKIPDEFAULT; } } else if(nm->nBar == SB_VERT) { rc = &nm->rect; if ( nm->uItem == HTSCROLL_UP || nm->uItem == HTSCROLL_DOWN ) { if(nm->uState == CDIS_DISABLED) nState = nm->uItem == HTSCROLL_UP ? ABS_UPDISABLED : ABS_DOWNDISABLED ; else if(nm->uState == CDIS_HOT) nState = nm->uItem == HTSCROLL_UP ? ABS_UPHOT : ABS_DOWNHOT ; else if(nm->uState == CDIS_SELECTED) nState = nm->uItem == HTSCROLL_UP ? ABS_UPPRESSED : ABS_DOWNPRESSED ; else nState = nm->uItem == HTSCROLL_UP ? ABS_UPNORMAL : ABS_DOWNNORMAL ; nPart = SBP_ARROWBTN; if ( pss ) { if ( rc->left == 0 && rc->top == 0 ) return CDRF_SKIPDEFAULT; pss->DrawBackground( nm->hdc, SCROLLBAR, nPart, nState, rc, NULL); } return CDRF_SKIPDEFAULT; } else if ( nm->uItem == HTSCROLL_THUMB ) { if(nm->uState == CDIS_DISABLED) nState = SCRBS_DISABLED ; else if(nm->uState == CDIS_HOT) nState = SCRBS_HOT ; else if(nm->uState == CDIS_SELECTED) nState = SCRBS_PRESSED ; else nState = SCRBS_NORMAL ; // first draw thumb nPart = SBP_THUMBBTNVERT; if ( pss ) { pss->DrawBackground( nm->hdc, SCROLLBAR, nPart, nState, rc, NULL); } // second draw gripper RECT rcGripper; BOOL bRet = pss->GetRect( SCROLLBAR, 12, nState, &rcGripper); if ( bRet ) { if ( rc->bottom - rc->top > rcGripper.bottom - rcGripper.top + 4 ) { RECT rcClient = *rc; rcClient.top = rcClient.top + ( rc->bottom - rc->top - rcGripper.bottom + rcGripper.top ) / 2 ; rcClient.bottom = rcClient.top + rcGripper.bottom - rcGripper.top; if ( pss ) { pss->DrawBackground( nm->hdc, SCROLLBAR, 12, nState, &rcClient, NULL); } } } return CDRF_SKIPDEFAULT; } else if ( nm->uItem == HTSCROLL_PAGEGUP ) { nPart = SBP_LOWERTRACKVERT; if ( pss ) { if ( pss && rc->top != rc->bottom ) { ATLTRACE("scroll bar %d:%d \r\n", rc->top, rc->bottom); IntersectClipRect( nm->hdc, rc->left, rc->top, rc->right, rc->bottom ); pss->DrawBackground( nm->hdc, SCROLLBAR, nPart, 1, rc, NULL); SelectClipRgn( nm->hdc, NULL); } } return CDRF_SKIPDEFAULT; } else if ( nm->uItem == HTSCROLL_PAGEGDOWN ) { nPart = SBP_UPPERTRACKVERT; if ( pss && rc->top != rc->bottom ) { IntersectClipRect( nm->hdc, rc->left, rc->top, rc->right, rc->bottom ); pss->DrawBackground( nm->hdc, SCROLLBAR, nPart, 1, rc, NULL); SelectClipRgn( nm->hdc, NULL); } return CDRF_SKIPDEFAULT; } } //INSERTED BUTTONS are handled here... else if(nm->nBar == SB_INSBUT) { CoolSB_DrawProc(nm->hdc, nm->uItem, nm->uState, &nm->rect); return CDRF_SKIPDEFAULT; } else { return CDRF_DODEFAULT; } //normal bitmaps, use same code for HORZ and VERT //StretchBlt(nm->hdc, rc->left, rc->top, rc->right-rc->left, rc->bottom-rc->top, // hdcSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY); return CDRF_SKIPDEFAULT; } void DrawTab(HDC hdcEMF, int x, int tabwidth, int tabheight, int xslope, BOOL active) { POINT pts[4]; pts[0].x = x + 0; pts[0].y = 0; pts[1].x = x + xslope; pts[1].y = tabheight; pts[2].x = x + tabwidth - xslope; pts[2].y = tabheight; pts[3].x = x + tabwidth; pts[3].y = 0; if(active) SelectObject(hdcEMF, GetStockObject(WHITE_BRUSH)); else SelectObject(hdcEMF, GetSysColorBrush(COLOR_3DFACE)); Polygon(hdcEMF, pts, 4); oldpen = (HPEN) SelectObject(hdcEMF, hpen); MoveToEx(hdcEMF, pts[1].x+1, pts[1].y, 0); LineTo(hdcEMF, pts[2].x, pts[2].y); if(active) SelectObject(hdcEMF, whitepen); MoveToEx(hdcEMF, pts[3].x - 1, pts[3].y, 0); LineTo(hdcEMF, pts[0].x, pts[0].y); SelectObject(hdcEMF, oldpen); } // // Draw a series of "tabs" into a meta-file, // which we will use to custom-draw one of the inserted // scrollbar buttons // void InitMetaFile(void) { HDC hdcEMF; RECT rect; int totalwidth = 120; int width = 110, height = GetSystemMetrics(SM_CYHSCROLL); LOGFONT lf; POINT pts[4]; int tabwidth = 40, tabxslope = 5; pts[0].x = 0; pts[0].y = 0; pts[1].x = tabxslope; pts[1].y = height - 1; pts[2].x = tabwidth - tabxslope; pts[2].y = height - 1; pts[3].x = tabwidth; pts[3].y = 0; hpen = CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DSHADOW)); whitepen = CreatePen(PS_INSIDEFRAME,0,RGB(0xff,0xff,0xff)); SetRect(&rect, 0, 0, totalwidth, height+1); hdcEMF = CreateEnhMetaFile(NULL, NULL, NULL, NULL); ZeroMemory(&lf, sizeof(lf)); lf.lfHeight = -MulDiv(7, GetDeviceCaps(hdcEMF, LOGPIXELSY), 72); lf.lfPitchAndFamily = DEFAULT_PITCH; lf.lfCharSet = ANSI_CHARSET; lstrcpy(lf.lfFaceName, "Arial");//Small fonts"); hfont = CreateFontIndirect(&lf); pts[0].x = 0; pts[0].y = 0; pts[1].x = tabxslope; pts[1].y = height - 1; pts[2].x = tabwidth - tabxslope; pts[2].y = height - 1; pts[3].x = tabwidth; pts[3].y = 0; FillRect (hdcEMF, &rect, GetSysColorBrush(COLOR_3DFACE));//GetStockObject(WHITE_BRUSH); //fit as many lines in as space permits SelectObject(hdcEMF, GetSysColorBrush(COLOR_3DFACE)); DrawTab(hdcEMF, width-tabwidth, tabwidth, height - 1, tabxslope, FALSE); DrawTab(hdcEMF, width-tabwidth-tabwidth+tabxslope, tabwidth, height - 1, tabxslope, FALSE); DrawTab(hdcEMF, 0, tabwidth, height - 1, tabxslope, TRUE); SelectObject(hdcEMF, hpen); MoveToEx(hdcEMF, 110, 0, 0); LineTo(hdcEMF, totalwidth, 0); SelectObject(hdcEMF, hfont); SetBkMode(hdcEMF, TRANSPARENT); TextOut(hdcEMF, 10,1, "Build", 5); TextOut(hdcEMF, 42,1, "Debug", 5); TextOut(hdcEMF, 78,1, "Result", 6); SelectObject(hdcEMF, oldpen); DeleteObject(hpen); DeleteObject(whitepen); hemf = CloseEnhMetaFile(hdcEMF); } // // function for drawing the custom-draw inserted buttons // Called from the WM_NOTIFY handler (HandleCustomDraw) // UINT CALLBACK CoolSB_DrawProc(HDC hdc, UINT uCmdId, UINT uButflags, RECT *rect) { RECT rc; POINT pt; HPEN hpen, hold; HBITMAP hbm, oldbm; HDC hdcmem; if(hemf == 0) InitMetaFile(); SetRect(&rc, 0, 0, 120, rect->bottom-rect->top); hdcmem = CreateCompatibleDC(hdc); hbm = CreateCompatibleBitmap(hdc, rc.right, rc.bottom); oldbm = (HBITMAP) SelectObject(hdcmem, hbm); SetWindowOrgEx(hdc, -rect->left, -rect->top, &pt); PlayEnhMetaFile(hdcmem, hemf, &rc); BitBlt(hdc, 0, 0, rc.right, rc.bottom, hdcmem, 0, 0, SRCCOPY); SetRect(&rc, 120, 0, rect->right-rect->left, rect->bottom-rect->top); FillRect(hdc, &rc, GetSysColorBrush(COLOR_3DFACE)); hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DSHADOW)); hold = (HPEN) SelectObject(hdc, hpen); MoveToEx(hdc, 120, 0, 0); LineTo(hdc, rect->right-rect->left, 0); SetWindowOrgEx(hdc, pt.x, pt.y, 0); SelectObject(hdc, hold); SelectObject(hdcmem, oldbm); DeleteObject(hbm); DeleteDC(hdcmem); DeleteObject(hpen); UNREFERENCED_PARAMETER(uButflags); UNREFERENCED_PARAMETER(uCmdId); return 0; }
[ "zhongzeng@ba8f1dc9-3c1c-0410-9eed-0f8a660c14bd" ]
[ [ [ 1, 530 ] ] ]
64fcbf90328304504f4515c39bb38dbe41716663
ba200ae9f30b89d1e32aee6a6e5ef2c991cee157
/trunk/GosuImpl/TextInputX.cpp
d5bdd845f45402791c9368b1ff7f44dad177829a
[ "MIT" ]
permissive
clebertavares/gosu
1d5fd08d22825d18f2840dfe1c53c96f700b665f
e534e0454648a4ef16c7934d3b59b80ac9ec7a44
refs/heads/master
2020-04-08T15:36:38.697104
2010-02-20T16:57:25
2010-02-20T16:57:25
537,484
1
0
null
null
null
null
UTF-8
C++
false
false
5,094
cpp
#include <Gosu/TextInput.hpp> #include <Gosu/Input.hpp> #include <algorithm> #include <vector> #include <wctype.h> struct Gosu::TextInput::Impl { std::wstring text; unsigned caretPos, selectionStart; Impl() : caretPos(0), selectionStart(0) {} }; Gosu::TextInput::TextInput() : pimpl(new Impl) { } Gosu::TextInput::~TextInput() { } std::wstring Gosu::TextInput::text() const { return pimpl->text; } void Gosu::TextInput::setText(const std::wstring& text) { pimpl->text = text; pimpl->caretPos = pimpl->selectionStart = text.length(); } unsigned Gosu::TextInput::caretPos() const { return pimpl->caretPos; } unsigned Gosu::TextInput::selectionStart() const { return pimpl->selectionStart; } #define CARET_POS (pimpl->caretPos) #define SEL_START (pimpl->selectionStart) bool Gosu::TextInput::feedXEvent(void* display, void* event) { XEvent* ev = static_cast<XEvent*>(event); if (ev->type != KeyPress) return false; bool ctrlDown = (ev->xkey.state & ControlMask); bool shiftDown = (ev->xkey.state & ShiftMask); KeySym lower, upper; XConvertCase(XKeycodeToKeysym((Display*)display, ev->xkey.keycode, 0), &lower, &upper); wchar_t ch = static_cast<wchar_t>(shiftDown ? upper : lower); if (ch >= 32 && ch != 127 && ch <= 255) { // Delete (overwrite) previous selection. if (CARET_POS != SEL_START) { unsigned min = std::min(CARET_POS, SEL_START); unsigned max = std::max(CARET_POS, SEL_START); pimpl->text.erase(pimpl->text.begin() + min, pimpl->text.begin() + max); CARET_POS = SEL_START = min; } wchar_t text[] = { ch, 0 }; std::wstring filteredText = filter(text); pimpl->text.insert(pimpl->text.begin() + CARET_POS, filteredText.begin(), filteredText.end()); CARET_POS += filteredText.length(); SEL_START = CARET_POS; return true; } // Char left if (ch == kbLeft && !ctrlDown) { if (CARET_POS > 0) CARET_POS -= 1; if (!shiftDown) SEL_START = CARET_POS; return true; } // Char right if (ch == kbRight && !ctrlDown) { if (CARET_POS < pimpl->text.length()) CARET_POS += 1; if (!shiftDown) SEL_START = CARET_POS; return true; } // Home if (ch == kbHome) { CARET_POS = 0; if (!shiftDown) SEL_START = CARET_POS; return true; } // End if (ch == kbEnd) { CARET_POS = pimpl->text.length(); if (!shiftDown) SEL_START = CARET_POS; return true; } // Word left if (ch == kbLeft && ctrlDown) { if (CARET_POS == pimpl->text.length()) --CARET_POS; while (CARET_POS > 0 && iswspace(pimpl->text.at(CARET_POS - 1))) --CARET_POS; while (CARET_POS > 0 && !iswspace(pimpl->text.at(CARET_POS - 1))) --CARET_POS; if (!shiftDown) SEL_START = CARET_POS; return true; } // Word right if (ch == kbRight && ctrlDown) { while (CARET_POS < pimpl->text.length() && iswspace(pimpl->text.at(CARET_POS))) ++CARET_POS; while (CARET_POS < pimpl->text.length() && !iswspace(pimpl->text.at(CARET_POS))) ++CARET_POS; if (!shiftDown) SEL_START = CARET_POS; return true; } // Delete existant selection if (ch == kbBackspace) { if (SEL_START != CARET_POS) { unsigned min = std::min(CARET_POS, SEL_START); unsigned max = std::max(CARET_POS, SEL_START); pimpl->text.erase(pimpl->text.begin() + min, pimpl->text.begin() + max); SEL_START = CARET_POS = min; } else if (CARET_POS > 0) { unsigned oldCaret = CARET_POS; CARET_POS -= 1; pimpl->text.erase(pimpl->text.begin() + CARET_POS, pimpl->text.begin() + oldCaret); SEL_START = CARET_POS; } return true; } // Delete existant selection if (ch == kbDelete) { if (SEL_START != CARET_POS) { unsigned min = std::min(CARET_POS, SEL_START); unsigned max = std::max(CARET_POS, SEL_START); pimpl->text.erase(pimpl->text.begin() + min, pimpl->text.begin() + max); SEL_START = CARET_POS = min; } else if (CARET_POS < pimpl->text.length()) { unsigned oldCaret = CARET_POS; CARET_POS += 1; pimpl->text.erase(pimpl->text.begin() + oldCaret, pimpl->text.begin() + CARET_POS); SEL_START = CARET_POS = oldCaret; } return true; } return false; }
[ [ [ 1, 203 ] ] ]
f4a8503a5dccb73d5e839a825f93588df74cd297
df4928511778393732aa2f1560f204826f05fe10
/gamestate.h
2dc858a72a52491a48ff0d991705168b0e3508d1
[]
no_license
ViktorNordgren/sword-of-kings
ad88769671eb5a1134e3909bd25310d429fede81
4d16f69dca6f0d1f82aac393fa79d96632903f49
refs/heads/master
2018-01-08T10:26:29.012309
2007-11-29T06:57:45
2007-11-29T06:57:45
49,721,358
0
0
null
null
null
null
UTF-8
C++
false
false
443
h
#ifndef _DEFINED_game_state #define _DEFINED_game_state #include <string> /* * GameState.h */ #include "character.h" #include "common_game.h" class GameState { public: GameState(void*); bool isConditionTrue(string cond); void performAction(string action); protected: bool sword_found; bool talked_to_geoffery; void * engine; }; #endif
[ "mhousser@5b9ac4b1-7c3f-0410-9070-89a53124ee38", "[email protected]" ]
[ [ [ 1, 2 ], [ 15, 15 ], [ 23, 23 ] ], [ [ 3, 14 ], [ 16, 22 ], [ 24, 27 ] ] ]
c506bd097e3ce0b7f8eb4fc93ca73af2488d2d77
b14d5833a79518a40d302e5eb40ed5da193cf1b2
/cpp/extern/xercesc++/2.6.0/src/xercesc/validators/schema/XercesElementWildcard.hpp
520a3ffe75abd6cd1715bcf78179643ec5da06ce
[ "Apache-2.0" ]
permissive
andyburke/bitflood
dcb3fb62dad7fa5e20cf9f1d58aaa94be30e82bf
fca6c0b635d07da4e6c7fbfa032921c827a981d6
refs/heads/master
2016-09-10T02:14:35.564530
2011-11-17T09:51:49
2011-11-17T09:51:49
2,794,411
1
0
null
null
null
null
UTF-8
C++
false
false
3,442
hpp
/* * Copyright 2001,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * $Log: XercesElementWildcard.hpp,v $ * Revision 1.3 2004/09/08 13:56:58 peiyongz * Apache License Version 2.0 * * Revision 1.2 2002/11/04 14:49:42 tng * C++ Namespace Support. * * Revision 1.1.1.1 2002/02/01 22:22:50 peiyongz * sane_include * * Revision 1.2 2001/11/21 14:30:13 knoaman * Fix for UPA checking. * * Revision 1.1 2001/08/21 15:58:42 tng * Schema: New files XercesElementWildCard. * */ #if !defined(XERCESELEMENTWILDCARD_HPP) #define XERCESELEMENTWILDCARD_HPP #include <xercesc/util/QName.hpp> #include <xercesc/validators/common/ContentSpecNode.hpp> #include <xercesc/validators/schema/SubstitutionGroupComparator.hpp> XERCES_CPP_NAMESPACE_BEGIN // --------------------------------------------------------------------------- // Forward declarations // --------------------------------------------------------------------------- class SchemaGrammar; class VALIDATORS_EXPORT XercesElementWildcard { public : // ----------------------------------------------------------------------- // Class static methods // ----------------------------------------------------------------------- /* * check whether two elements are in conflict */ static bool conflict(SchemaGrammar* const pGrammar, ContentSpecNode::NodeTypes type1, QName* q1, ContentSpecNode::NodeTypes type2, QName* q2, SubstitutionGroupComparator* comparator); private: // ----------------------------------------------------------------------- // private helper methods // ----------------------------------------------------------------------- static bool uriInWildcard(SchemaGrammar* const pGrammar, QName* qname, unsigned int wildcard, ContentSpecNode::NodeTypes wtype, SubstitutionGroupComparator* comparator); static bool wildcardIntersect(ContentSpecNode::NodeTypes t1, unsigned int w1, ContentSpecNode::NodeTypes t2, unsigned int w2); // ----------------------------------------------------------------------- // Unimplemented constructors and operators // ----------------------------------------------------------------------- XercesElementWildcard(); ~XercesElementWildcard(); }; XERCES_CPP_NAMESPACE_END #endif // XERCESELEMENTWILDCARD_HPP
[ [ [ 1, 97 ] ] ]
fa01e21df16242bf4f0d11d9df11a906ae032761
b8c3d2d67e983bd996b76825f174bae1ba5741f2
/RTMP/utils/gil_2/libs/gil/opencv/test.cpp
29ece9a678523bebd0a2e42f563e5612c029ded6
[]
no_license
wangscript007/rtmp-cpp
02172f7a209790afec4c00b8855d7a66b7834f23
3ec35590675560ac4fa9557ca7a5917c617d9999
refs/heads/master
2021-05-30T04:43:19.321113
2008-12-24T20:16:15
2008-12-24T20:16:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
36
cpp
int main() { return 0; }
[ "fpelliccioni@71ea4c15-5055-0410-b3ce-cda77bae7b57" ]
[ [ [ 1, 7 ] ] ]
435509af78f6b6c83eb8076471c56888cb68adff
fec97339b4f90ddcc8d49d39c048140f05b2db6e
/mainwindow.h
f4d62a91e418b84449b6db6b6601a3d2ae8b80d5
[]
no_license
SirEOF/geomdef
55ea012b898029baaf60fae8fc236ca8ab855cfb
0e9508539703b697882df82c84fb92d34a3e3dff
refs/heads/master
2021-05-29T06:43:54.986200
2010-02-01T11:24:21
2010-02-01T11:24:21
null
0
0
null
null
null
null
WINDOWS-1250
C++
false
false
11,226
h
////////////////////////////////////////////////////////////////////////////////// /// \file mainwindow.h /// \author Grzegorz Kurek /// \author [email protected] /// \version 1.0.1 /// \date 20-01-2010 /// \brief Deklaracja klasy mainwindow, glownego okna programu. Plik naglowkowy. /////////////////////////////////////////////////////////////////////////////////// #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QtGui> #include <QMainWindow> #include "interpolation.h" #include <QColor> ///////////////////////////////////////////////////////////////////////// /// \namespace Ui /// \brief Przestrzen nazw Ui ///////////////////////////////////////////////////////////////////////// namespace Ui { class MainWindow; } class QGraphicsScene; class rotate; class rotateo; class skewdialog; class about; class barreldialog; //////////////////////////////////////////////////////////////////////////////// /// \class MainWindow /// \brief Klasa oodpowiedzialna za glowne okno programu. Dziedzicy po QMainWindow. /////////////////////////////////////////////////////////////////////////////// class MainWindow : public QMainWindow { Q_OBJECT public: ////////////////////////////////////////////////////////////////////////// /// MainWindow /// \brief Konstruktor przyjmujacy jako parmetr rodzica QWidget. /// \param parent Parametr domniemany. Wskaźnik do rodzica typu QWidget. ///////////////////////////////////////////////////////////////////////// MainWindow(QWidget *parent = 0); ///////////////////////////////////////////////////////////////////////// /// Destruktor. ///////////////////////////////////////////////////////////////////////// ~MainWindow(); ///////////////////////////////////////////////////////////////////////// /// image /// \brief Obiekt typu QImage, obraz wczytywany do modyfikacji. ///////////////////////////////////////////////////////////////////////// QImage image; protected: //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void changeEvent(QEvent *e); private: //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// QGraphicsScene *scene; //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// Ui::MainWindow *ui; //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// int angle; //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void resizeEvent( QResizeEvent * ); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// bool isImageLoaded; //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// QString currentFileName; //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// QString currentFileType; //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void clearScene(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// bool isModifed; //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// rotate *rotateWindow; //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// rotateo *axisRotateWindow; //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// skewdialog *skewWindow; //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// about *aboutWindow; //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// barreldialog * bdialog; //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// Interpolation * interp; //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// QRgb rgb; private slots: //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void on_actionBarrel_correction_activated(); void loadFile(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void barelCorrectionSlot(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void zoomIn(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void zoomOut(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void rotateDialog(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void rotateoDialog(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void skewd(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void rotateImageCloseOK(int angle); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void rotateImageCloseCancel(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void axisRotateImageCloseOK(int xp, int yp, int zp); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void axisRotateImageCloseCancel(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void skewCloseOK(int angleX, int angleY); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void barrelSignalCancel(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void barrelSignalOK(qreal a1, qreal b1, qreal c1, qreal d1); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void skewCloseCancel(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void saveFile(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void saveFileAs(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void clearImage(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void print(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void exit(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void loadImage(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void activateMenu(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void openHelp(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void openWeb(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void aboutInfo(); //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// void closeEvent(QCloseEvent *); }; #endif // MAINWINDOW_H
[ "grzesiek.kurek@e2a736ec-deac-11de-b357-fb893c5a43fa", "lukasz.madon@e2a736ec-deac-11de-b357-fb893c5a43fa" ]
[ [ [ 1, 6 ], [ 8, 11 ], [ 13, 14 ], [ 17, 19 ], [ 21, 32 ], [ 34, 34 ], [ 36, 36 ], [ 39, 41 ], [ 48, 49 ], [ 53, 54 ], [ 59, 61 ], [ 65, 67 ], [ 71, 71 ], [ 76, 76 ], [ 81, 81 ], [ 86, 86 ], [ 91, 91 ], [ 96, 96 ], [ 101, 101 ], [ 106, 106 ], [ 111, 111 ], [ 116, 116 ], [ 121, 121 ], [ 126, 126 ], [ 131, 132 ], [ 147, 147 ], [ 152, 152 ], [ 162, 162 ], [ 167, 167 ], [ 172, 172 ], [ 177, 177 ], [ 182, 182 ], [ 187, 187 ], [ 192, 192 ], [ 197, 197 ], [ 202, 202 ], [ 207, 207 ], [ 222, 222 ], [ 227, 227 ], [ 232, 232 ], [ 237, 237 ], [ 242, 242 ], [ 247, 247 ], [ 252, 252 ], [ 257, 257 ], [ 262, 262 ], [ 267, 267 ], [ 272, 272 ], [ 277, 281 ] ], [ [ 7, 7 ], [ 12, 12 ], [ 15, 16 ], [ 20, 20 ], [ 33, 33 ], [ 35, 35 ], [ 37, 38 ], [ 42, 47 ], [ 50, 52 ], [ 55, 58 ], [ 62, 64 ], [ 68, 70 ], [ 72, 75 ], [ 77, 80 ], [ 82, 85 ], [ 87, 90 ], [ 92, 95 ], [ 97, 100 ], [ 102, 105 ], [ 107, 110 ], [ 112, 115 ], [ 117, 120 ], [ 122, 125 ], [ 127, 130 ], [ 133, 146 ], [ 148, 151 ], [ 153, 161 ], [ 163, 166 ], [ 168, 171 ], [ 173, 176 ], [ 178, 181 ], [ 183, 186 ], [ 188, 191 ], [ 193, 196 ], [ 198, 201 ], [ 203, 206 ], [ 208, 221 ], [ 223, 226 ], [ 228, 231 ], [ 233, 236 ], [ 238, 241 ], [ 243, 246 ], [ 248, 251 ], [ 253, 256 ], [ 258, 261 ], [ 263, 266 ], [ 268, 271 ], [ 273, 276 ] ] ]
6326578bbdf58b7dd5e6e4da30b08f9d34238f0f
12ea67a9bd20cbeed3ed839e036187e3d5437504
/winxgui/WTLHelper/Dialog/WtlHelperDlg.h
01d55cf1de8d13a91e2759b3a18f6e91795e48f3
[]
no_license
cnsuhao/winxgui
e0025edec44b9c93e13a6c2884692da3773f9103
348bb48994f56bf55e96e040d561ec25642d0e46
refs/heads/master
2021-05-28T21:33:54.407837
2008-09-13T19:43:38
2008-09-13T19:43:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,915
h
//////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2004 Sergey Solozhentsev // Author: Sergey Solozhentsev e-mail: [email protected] // Product: WTL Helper // File: WtlHelperDlg.h // Created: 12.01.2005 13:54 // // Using this software in commercial applications requires an author // permission. The permission will be granted to everyone excluding the cases // when someone simply tries to resell the code. // This file may be redistributed by any means PROVIDING it is not sold for // profit without the authors written consent, and providing that this notice // and the authors name is included. // This file is provided "as is" with no expressed or implied warranty. The // author accepts no liability if it causes any damage to you or your computer // whatsoever. // //////////////////////////////////////////////////////////////////////////////// // This file was generated by WTL Dialog wizard // WtlHelperDlg.h : Declaration of the CWtlHelperDlg #pragma once #pragma warning (disable: 4267) #include "../atlgdix.h" #include "../CustomTabCtrl.h" #include "../DotNetTabCtrl.h" #include <atlframe.h> #include "../TabbedFrame.h" #pragma warning (default: 4267) #include "VariablePage.h" #include "FunctionPage.h" struct WtlDlgWindowSettings : public CSettings<WtlDlgWindowSettings> { CRect m_WindowRect; int m_ActiveTab; BEGIN_SETTINGS_MAP() SETTINGS_VARIABLE_OPT(m_ActiveTab) SETTINGS_BINARY_OPT(&m_WindowRect, sizeof(CRect)) END_SETTINGS_MAP() WtlDlgWindowSettings() : m_ActiveTab(0), m_WindowRect(0, 0, 450, 300) { } }; // CWtlHelperDlg #define IDC_PAGESTAB 1023 class CWtlHelperDlg : public CDialogImpl<CWtlHelperDlg>, public CDialogResize<CWtlHelperDlg>, public CSettings<CWtlHelperDlg> { CToolBarCtrl m_ToolBar; CTabbedChildWindow< CDotNetTabCtrl<CTabViewTabItem> > m_tabbedChildWindow; CFunctionPage m_FunctionPage; CVariablePage m_VariablePage; WtlDlgWindowSettings m_DlgSettings; bool m_bSavePreviousPane; void SetCommonPointers(); void LoadSettings(); void SaveSettings(); public: CWtlHelperDlg(); ~CWtlHelperDlg(); enum { IDD = IDD_WTLHELPERDLG }; int* m_piCurrentClass; ClassVector* m_pClassVector; CSmartAtlArray<InsDelPoints>* m_pModifications; CResourceManager* m_pResManager; int m_iActivePage; BEGIN_MSG_MAP(CWtlHelperDlg) MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) MESSAGE_HANDLER(WM_SIZE, OnSize) MESSAGE_HANDLER(WM_DESTROY, OnDestroy) MESSAGE_HANDLER(WM_GETMINMAXINFO, OnGetMinMaxInfo) COMMAND_HANDLER(IDOK, BN_CLICKED, OnClickedOK) COMMAND_HANDLER(IDCANCEL, BN_CLICKED, OnClickedCancel) COMMAND_HANDLER(IDC_BUTTON_APPLY, BN_CLICKED, OnApply) NOTIFY_CODE_HANDLER(CTCN_SELCHANGE, OnTabSelectChange) MESSAGE_HANDLER(WTLH_SETMODIFIED, OnSetModified) NOTIFY_CODE_HANDLER(TTN_GETDISPINFO, OnTtnGetDispInfo) if (uMsg == WM_COMMAND) { if (lParam == (LPARAM)m_ToolBar.m_hWnd) { ::SendMessage(m_tabbedChildWindow.GetActiveView(), uMsg, wParam, lParam); } } if (uMsg == WM_NOTIFY) { if (((LPNMHDR)lParam)->hwndFrom == m_ToolBar.m_hWnd) { ::SendMessage(m_tabbedChildWindow.GetActiveView(), uMsg, wParam, lParam); } } CHAIN_MSG_MAP(CDialogResize<CWtlHelperDlg>) END_MSG_MAP() BEGIN_DLGRESIZE_MAP(CWtlHelperDlg) DLGRESIZE_CONTROL(IDOK, DLSZ_MOVE_X | DLSZ_MOVE_Y) DLGRESIZE_CONTROL(IDCANCEL, DLSZ_MOVE_X | DLSZ_MOVE_Y) DLGRESIZE_CONTROL(IDC_BUTTON_APPLY, DLSZ_MOVE_X | DLSZ_MOVE_Y) DLGRESIZE_CONTROL(IDC_PAGESTAB, DLSZ_SIZE_X | DLSZ_SIZE_Y) END_DLGRESIZE_MAP() BEGIN_SETTINGS_MAP() SETTINGS_VARIABLE_OPT_RO(m_bSavePreviousPane) SETTINGS_CHILD_OPT_USE_PARENT(m_DlgSettings) END_SETTINGS_MAP() // Handler prototypes: // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnClickedOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnClickedCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnApply(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnTabSelectChange(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); LRESULT OnTtnGetDispInfo(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); LRESULT OnSetModified(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); };
[ "xushiweizh@86f14454-5125-0410-a45d-e989635d7e98" ]
[ [ [ 1, 143 ] ] ]
5bcdf8295f83638a5c7e96503bc7335006f1dd91
636990a23a0f702e3c82fa3fc422f7304b0d7b9e
/ocx/AnvizOcx/AnvizOcx/MutilQueue.cpp
b0d91dbb3193444a36b9f485326132c8f5396641
[]
no_license
ak869/armcontroller
09599d2c145e6457aa8c55c8018514578d897de9
da68e180cacce06479158e7b31374e7ec81c3ebf
refs/heads/master
2021-01-13T01:17:25.501840
2009-02-09T18:03:20
2009-02-09T18:03:20
40,271,726
0
1
null
null
null
null
UTF-8
C++
false
false
1,201
cpp
#include "StdAfx.h" #include "MutilQueue.h" CMutilQueue::CMutilQueue(void) { m_header = NULL; m_NData = 0; m_end = NULL; } CMutilQueue::~CMutilQueue(void) { Clear(); } void CMutilQueue::In(CMutilQData *Val) { if( m_NData == 0 ) { m_header = Val; m_end = Val; Val->m_next = NULL; Val->m_prev = NULL; }else { m_end->m_next = Val; Val->m_prev = m_end; Val->m_next = NULL; m_end = Val; } m_NData++; } void CMutilQueue::Out(CMutilQData *pVal) { if( m_NData != 0 ) { CMutilQData *t; t = m_header; while( t ) { if( pVal->EqualOut(t) ) {// pVal->Clone(t); if( t->m_prev ) t->m_prev->m_next = t->m_next; else m_header = t->m_next; delete t; m_NData--; break; } t = t->m_next; } if( (t = pVal->Out()) != NULL ) { pVal->Clone(t); if( t->m_prev ) t->m_prev->m_next = t->m_next; else m_header = t->m_next; delete t; m_NData--; } } } void CMutilQueue::Clear() { if( m_NData ) { CMutilQData *t; t = m_header; while( t ) { m_header = t->next; delete t; m_NData--; } m_header = NULL; } }
[ "leon.b.dong@41cf9b94-d0c3-11dd-86c2-0f8696b7b6f9" ]
[ [ [ 1, 82 ] ] ]
9ae7fc8642f5609ff4612a71fd246e64af3b7d39
84a2f4764b007ba21c451d005cf530c0c06a2aab
/objects/object_template.cpp
87a84bea5a9d237ea55972c27272a0089c36a841
[]
no_license
zzhhb/gps-sdr
32a035cd834940db51ea78d2242eb165cef4beda
13cd490dd5f61df4169f9494b3d07f214181f3e6
refs/heads/master
2020-12-14T20:19:18.420012
2008-10-01T10:59:36
2008-10-01T10:59:36
69,079
1
0
null
null
null
null
UTF-8
C++
false
false
3,273
cpp
/*! \file OBJECT.cpp Implements member functions of OBJECT class. */ /************************************************************************************************ Copyright 2008 Gregory W Heckler This file is part of the GPS Software Defined Radio (GPS-SDR) The GPS-SDR is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GPS-SDR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GPS-SDR; if not, write to the: Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ************************************************************************************************/ #include "OBJECT.h" /*----------------------------------------------------------------------------------------------*/ void *OBJECT_Thread(void *_arg) { OBJECT *aOBJECT = pOBJECT; while(grun) { aOBJECT->Inport(); aOBJECT->Export(); } pthread_exit(0); } /*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/ void OBJECT::Start() { pthread_create(&thread, NULL, OBJECT_Thread, NULL); printf("OBJECT thread started\n"); } /*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/ void OBJECT::Stop() { pthread_join(thread, NULL); printf("OBJECT thread stopped\n"); } /*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/ OBJECT::OBJECT() { temp = 0; } /*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/ OBJECT::~OBJECT() { printf("Destructing OBJECT\n"); } /*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/ void OBJECT::Inport() { } /*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/ void OBJECT::Parse() { } /*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/ void OBJECT::Export() { } /*----------------------------------------------------------------------------------------------*/
[ "gheckler@core2duo.(none)" ]
[ [ [ 1, 98 ] ] ]
9ab5781ff7120e68e6ce325a01a2b95431349e15
d6a28d9d845a20463704afe8ebe644a241dc1a46
/source/Irrlicht/CColorConverter.cpp
97315af9426ae48da9403c8a2e1cf48399ab10e6
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-other-permissive", "Zlib" ]
permissive
marky0720/irrlicht-android
6932058563bf4150cd7090d1dc09466132df5448
86512d871eeb55dfaae2d2bf327299348cc5202c
refs/heads/master
2021-04-30T08:19:25.297407
2010-10-08T08:27:33
2010-10-08T08:27:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
13,538
cpp
// Copyright (C) 2002-2009 Nikolaus Gebhardt // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h #include "CColorConverter.h" #include "SColor.h" #include "os.h" #include "irrString.h" namespace irr { namespace video { //! converts a monochrome bitmap to A1R5G5B5 data void CColorConverter::convert1BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, s32 linepad, bool flip) { if (!in || !out) return; if (flip) out += width * height; for (s32 y=0; y<height; ++y) { s32 shift = 7; if (flip) out -= width; for (s32 x=0; x<width; ++x) { out[x] = *in>>shift & 0x01 ? (s16)0xffff : (s16)0x8000; if ((--shift)<0) // 8 pixel done { shift=7; ++in; } } if (shift != 7) // width did not fill last byte ++in; if (!flip) out += width; in += linepad; } } //! converts a 4 bit palettized image to A1R5G5B5 void CColorConverter::convert4BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad, bool flip) { if (!in || !out || !palette) return; if (flip) out += width*height; for (s32 y=0; y<height; ++y) { s32 shift = 4; if (flip) out -= width; for (s32 x=0; x<width; ++x) { out[x] = X8R8G8B8toA1R5G5B5(palette[(u8)((*in >> shift) & 0xf)]); if (shift==0) { shift = 4; ++in; } else shift = 0; } if (shift == 0) // odd width ++in; if (!flip) out += width; in += linepad; } } //! converts a 8 bit palettized image into A1R5G5B5 void CColorConverter::convert8BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad, bool flip) { if (!in || !out || !palette) return; if (flip) out += width * height; for (s32 y=0; y<height; ++y) { if (flip) out -= width; // one line back for (s32 x=0; x<width; ++x) { out[x] = X8R8G8B8toA1R5G5B5(palette[(u8)(*in)]); ++in; } if (!flip) out += width; in += linepad; } } //! converts a 8 bit palettized or non palettized image (A8) into R8G8B8 void CColorConverter::convert8BitTo24Bit(const u8* in, u8* out, s32 width, s32 height, const u8* palette, s32 linepad, bool flip) { if (!in || !out ) return; const s32 lineWidth = 3 * width; if (flip) out += lineWidth * height; for (s32 y=0; y<height; ++y) { if (flip) out -= lineWidth; // one line back for (s32 x=0; x< lineWidth; x += 3) { if ( palette ) { #ifdef __BIG_ENDIAN__ out[x+0] = palette[ (in[0] << 2 ) + 0]; out[x+1] = palette[ (in[0] << 2 ) + 1]; out[x+2] = palette[ (in[0] << 2 ) + 2]; #else out[x+0] = palette[ (in[0] << 2 ) + 2]; out[x+1] = palette[ (in[0] << 2 ) + 1]; out[x+2] = palette[ (in[0] << 2 ) + 0]; #endif } else { out[x+0] = in[0]; out[x+1] = in[0]; out[x+2] = in[0]; } ++in; } if (!flip) out += lineWidth; in += linepad; } } //! converts a 8 bit palettized or non palettized image (A8) into R8G8B8 void CColorConverter::convert8BitTo32Bit(const u8* in, u8* out, s32 width, s32 height, const u8* palette, s32 linepad, bool flip) { if (!in || !out ) return; const u32 lineWidth = 4 * width; if (flip) out += lineWidth * height; u32 x; register u32 c; for (u32 y=0; y < (u32) height; ++y) { if (flip) out -= lineWidth; // one line back if ( palette ) { for (x=0; x < (u32) width; x += 1) { c = in[x]; ((u32*)out)[x] = ((u32*)palette)[ c ]; } } else { for (x=0; x < (u32) width; x += 1) { c = in[x]; #ifdef __BIG_ENDIAN__ ((u32*)out)[x] = c << 24 | c << 16 | c << 8 | 0x000000FF; #else ((u32*)out)[x] = 0xFF000000 | c << 16 | c << 8 | c; #endif } } if (!flip) out += lineWidth; in += width + linepad; } } //! converts 16bit data to 16bit data void CColorConverter::convert16BitTo16Bit(const s16* in, s16* out, s32 width, s32 height, s32 linepad, bool flip) { if (!in || !out) return; if (flip) out += width * height; for (s32 y=0; y<height; ++y) { if (flip) out -= width; #ifdef __BIG_ENDIAN__ for (s32 x=0; x<width; ++x) out[x]=os::Byteswap::byteswap(in[x]); #else memcpy(out, in, width*sizeof(s16)); #endif if (!flip) out += width; in += width; in += linepad; } } //! copies R8G8B8 24bit data to 24bit data void CColorConverter::convert24BitTo24Bit(const u8* in, u8* out, s32 width, s32 height, s32 linepad, bool flip, bool bgr) { if (!in || !out) return; const s32 lineWidth = 3 * width; if (flip) out += lineWidth * height; for (s32 y=0; y<height; ++y) { if (flip) out -= lineWidth; if (bgr) { for (s32 x=0; x<lineWidth; x+=3) { out[x+0] = in[x+2]; out[x+1] = in[x+1]; out[x+2] = in[x+0]; } } else { memcpy(out,in,lineWidth); } if (!flip) out += lineWidth; in += lineWidth; in += linepad; } } //! Resizes the surface to a new size and converts it at the same time //! to an A8R8G8B8 format, returning the pointer to the new buffer. void CColorConverter::convert16bitToA8R8G8B8andResize(const s16* in, s32* out, s32 newWidth, s32 newHeight, s32 currentWidth, s32 currentHeight) { if (!newWidth || !newHeight) return; // note: this is very very slow. (i didn't want to write a fast version. // but hopefully, nobody wants to convert surfaces every frame. f32 sourceXStep = (f32)currentWidth / (f32)newWidth; f32 sourceYStep = (f32)currentHeight / (f32)newHeight; f32 sy; s32 t; for (s32 x=0; x<newWidth; ++x) { sy = 0.0f; for (s32 y=0; y<newHeight; ++y) { t = in[(s32)(((s32)sy)*currentWidth + x*sourceXStep)]; t = (((t >> 15)&0x1)<<31) | (((t >> 10)&0x1F)<<19) | (((t >> 5)&0x1F)<<11) | (t&0x1F)<<3; out[(s32)(y*newWidth + x)] = t; sy+=sourceYStep; } } } //! copies X8R8G8B8 32 bit data void CColorConverter::convert32BitTo32Bit(const s32* in, s32* out, s32 width, s32 height, s32 linepad, bool flip) { if (!in || !out) return; if (flip) out += width * height; for (s32 y=0; y<height; ++y) { if (flip) out -= width; #ifdef __BIG_ENDIAN__ for (s32 x=0; x<width; ++x) out[x]=os::Byteswap::byteswap(in[x]); #else memcpy(out, in, width*sizeof(s32)); #endif if (!flip) out += width; in += width; in += linepad; } } void CColorConverter::convert_A1R5G5B5toR8G8B8(const void* sP, s32 sN, void* dP) { u16* sB = (u16*)sP; u8 * dB = (u8 *)dP; for (s32 x = 0; x < sN; ++x) { dB[2] = (*sB & 0x7c00) >> 7; dB[1] = (*sB & 0x03e0) >> 2; dB[0] = (*sB & 0x1f) << 3; sB += 1; dB += 3; } } void CColorConverter::convert_A1R5G5B5toB8G8R8(const void* sP, s32 sN, void* dP) { u16* sB = (u16*)sP; u8 * dB = (u8 *)dP; for (s32 x = 0; x < sN; ++x) { dB[0] = (*sB & 0x7c00) >> 7; dB[1] = (*sB & 0x03e0) >> 2; dB[2] = (*sB & 0x1f) << 3; sB += 1; dB += 3; } } void CColorConverter::convert_A1R5G5B5toA8R8G8B8(const void* sP, s32 sN, void* dP) { u16* sB = (u16*)sP; u32* dB = (u32*)dP; for (s32 x = 0; x < sN; ++x) *dB++ = A1R5G5B5toA8R8G8B8(*sB++); } void CColorConverter::convert_A1R5G5B5toA1R5G5B5(const void* sP, s32 sN, void* dP) { memcpy(dP, sP, sN * 2); } void CColorConverter::convert_A1R5G5B5toR5G6B5(const void* sP, s32 sN, void* dP) { u16* sB = (u16*)sP; u16* dB = (u16*)dP; for (s32 x = 0; x < sN; ++x) *dB++ = A1R5G5B5toR5G6B5(*sB++); } void CColorConverter::convert_A8R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP) { u8* sB = (u8*)sP; u8* dB = (u8*)dP; for (s32 x = 0; x < sN; ++x) { // sB[3] is alpha dB[0] = sB[2]; dB[1] = sB[1]; dB[2] = sB[0]; sB += 4; dB += 3; } } void CColorConverter::convert_A8R8G8B8toB8G8R8(const void* sP, s32 sN, void* dP) { u8* sB = (u8*)sP; u8* dB = (u8*)dP; for (s32 x = 0; x < sN; ++x) { // sB[3] is alpha dB[0] = sB[0]; dB[1] = sB[1]; dB[2] = sB[2]; sB += 4; dB += 3; } } void CColorConverter::convert_A8R8G8B8toA8R8G8B8(const void* sP, s32 sN, void* dP) { memcpy(dP, sP, sN * 4); } void CColorConverter::convert_A8R8G8B8toA1R5G5B5(const void* sP, s32 sN, void* dP) { u32* sB = (u32*)sP; u16* dB = (u16*)dP; for (s32 x = 0; x < sN; ++x) *dB++ = A8R8G8B8toA1R5G5B5(*sB++); } void CColorConverter::convert_A8R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP) { u8 * sB = (u8 *)sP; u16* dB = (u16*)dP; for (s32 x = 0; x < sN; ++x) { s32 r = sB[2] >> 3; s32 g = sB[1] >> 2; s32 b = sB[0] >> 3; dB[0] = (r << 11) | (g << 5) | (b); sB += 4; dB += 1; } } void CColorConverter::convert_A8R8G8B8toR3G3B2(const void* sP, s32 sN, void* dP) { u8* sB = (u8*)sP; u8* dB = (u8*)dP; for (s32 x = 0; x < sN; ++x) { u8 r = sB[2] & 0xe0; u8 g = (sB[1] & 0xe0) >> 3; u8 b = (sB[0] & 0xc0) >> 6; dB[0] = (r | g | b); sB += 4; dB += 1; } } void CColorConverter::convert_R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP) { memcpy(dP, sP, sN * 3); } void CColorConverter::convert_R8G8B8toA8R8G8B8(const void* sP, s32 sN, void* dP) { u8* sB = (u8* )sP; u32* dB = (u32*)dP; for (s32 x = 0; x < sN; ++x) { *dB = 0xff000000 | (sB[0]<<16) | (sB[1]<<8) | sB[2]; sB += 3; ++dB; } } void CColorConverter::convert_R8G8B8toA1R5G5B5(const void* sP, s32 sN, void* dP) { u8 * sB = (u8 *)sP; u16* dB = (u16*)dP; for (s32 x = 0; x < sN; ++x) { s32 r = sB[0] >> 3; s32 g = sB[1] >> 3; s32 b = sB[2] >> 3; dB[0] = (0x8000) | (r << 10) | (g << 5) | (b); sB += 3; dB += 1; } } void CColorConverter::convert_B8G8R8toA8R8G8B8(const void* sP, s32 sN, void* dP) { u8* sB = (u8* )sP; u32* dB = (u32*)dP; for (s32 x = 0; x < sN; ++x) { *dB = 0xff000000 | (sB[2]<<16) | (sB[1]<<8) | sB[0]; sB += 3; ++dB; } } void CColorConverter::convert_B8G8R8A8toA8R8G8B8(const void* sP, s32 sN, void* dP) { u8* sB = (u8*)sP; u8* dB = (u8*)dP; for (s32 x = 0; x < sN; ++x) { dB[0] = sB[3]; dB[1] = sB[2]; dB[2] = sB[1]; dB[3] = sB[0]; sB += 4; dB += 4; } } void CColorConverter::convert_R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP) { u8 * sB = (u8 *)sP; u16* dB = (u16*)dP; for (s32 x = 0; x < sN; ++x) { s32 r = sB[0] >> 3; s32 g = sB[1] >> 2; s32 b = sB[2] >> 3; dB[0] = (r << 11) | (g << 5) | (b); sB += 3; dB += 1; } } void CColorConverter::convert_R5G6B5toR5G6B5(const void* sP, s32 sN, void* dP) { memcpy(dP, sP, sN * 2); } void CColorConverter::convert_R5G6B5toR8G8B8(const void* sP, s32 sN, void* dP) { u16* sB = (u16*)sP; u8 * dB = (u8 *)dP; for (s32 x = 0; x < sN; ++x) { dB[0] = (*sB & 0xf800) << 8; dB[1] = (*sB & 0x07e0) << 2; dB[2] = (*sB & 0x001f) << 3; sB += 4; dB += 3; } } void CColorConverter::convert_R5G6B5toB8G8R8(const void* sP, s32 sN, void* dP) { u16* sB = (u16*)sP; u8 * dB = (u8 *)dP; for (s32 x = 0; x < sN; ++x) { dB[2] = (*sB & 0xf800) << 8; dB[1] = (*sB & 0x07e0) << 2; dB[0] = (*sB & 0x001f) << 3; sB += 4; dB += 3; } } void CColorConverter::convert_R5G6B5toA8R8G8B8(const void* sP, s32 sN, void* dP) { u16* sB = (u16*)sP; u32* dB = (u32*)dP; for (s32 x = 0; x < sN; ++x) *dB++ = R5G6B5toA8R8G8B8(*sB++); } void CColorConverter::convert_R5G6B5toA1R5G5B5(const void* sP, s32 sN, void* dP) { u16* sB = (u16*)sP; u16* dB = (u16*)dP; for (s32 x = 0; x < sN; ++x) *dB++ = R5G6B5toA1R5G5B5(*sB++); } void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN, void* dP, ECOLOR_FORMAT dF) { switch (sF) { case ECF_A1R5G5B5: switch (dF) { case ECF_A1R5G5B5: convert_A1R5G5B5toA1R5G5B5(sP, sN, dP); break; case ECF_R5G6B5: convert_A1R5G5B5toR5G6B5(sP, sN, dP); break; case ECF_A8R8G8B8: convert_A1R5G5B5toA8R8G8B8(sP, sN, dP); break; case ECF_R8G8B8: convert_A1R5G5B5toR8G8B8(sP, sN, dP); break; } break; case ECF_R5G6B5: switch (dF) { case ECF_A1R5G5B5: convert_R5G6B5toA1R5G5B5(sP, sN, dP); break; case ECF_R5G6B5: convert_R5G6B5toR5G6B5(sP, sN, dP); break; case ECF_A8R8G8B8: convert_R5G6B5toA8R8G8B8(sP, sN, dP); break; case ECF_R8G8B8: convert_R5G6B5toR8G8B8(sP, sN, dP); break; } break; case ECF_A8R8G8B8: switch (dF) { case ECF_A1R5G5B5: convert_A8R8G8B8toA1R5G5B5(sP, sN, dP); break; case ECF_R5G6B5: convert_A8R8G8B8toR5G6B5(sP, sN, dP); break; case ECF_A8R8G8B8: convert_A8R8G8B8toA8R8G8B8(sP, sN, dP); break; case ECF_R8G8B8: convert_A8R8G8B8toR8G8B8(sP, sN, dP); break; } break; case ECF_R8G8B8: switch (dF) { case ECF_A1R5G5B5: convert_R8G8B8toA1R5G5B5(sP, sN, dP); break; case ECF_R5G6B5: convert_R8G8B8toR5G6B5(sP, sN, dP); break; case ECF_A8R8G8B8: convert_R8G8B8toA8R8G8B8(sP, sN, dP); break; case ECF_R8G8B8: convert_R8G8B8toR8G8B8(sP, sN, dP); break; } break; } } } // end namespace video } // end namespace irr
[ "hybrid@dfc29bdd-3216-0410-991c-e03cc46cb475", "bitplane@dfc29bdd-3216-0410-991c-e03cc46cb475", "engineer_apple@dfc29bdd-3216-0410-991c-e03cc46cb475" ]
[ [ [ 1, 1 ], [ 32, 32 ], [ 336, 337 ], [ 352, 353 ], [ 392, 392 ], [ 394, 394 ], [ 409, 409 ], [ 411, 411 ] ], [ [ 2, 31 ], [ 33, 114 ], [ 202, 335 ], [ 338, 351 ], [ 354, 391 ], [ 393, 393 ], [ 395, 408 ], [ 410, 410 ], [ 412, 504 ], [ 537, 690 ] ], [ [ 115, 201 ], [ 505, 536 ] ] ]
addf9fec4e664af4c6345f8caf948d57850ce83c
15f5ea95f75eebb643a9fa4d31592b2537a33030
/src/re167/GLRenderContext.cpp
fdc27a116060ab90131f3d3caeb87698f4992189
[]
no_license
festus-onboard/graphics
90aaf323e188b205661889db2c9ac59ed43bfaa7
fdd195cd758ef95147d2d02160062d2014e50e04
refs/heads/master
2021-05-26T14:38:54.088062
2009-05-10T16:59:28
2009-05-10T16:59:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,408
cpp
#include "GLRenderContext.h" using namespace RE167; GLRenderContext* GLRenderContext::getSingletonPtr(void) { return static_cast<GLRenderContext *>(ms_Singleton); } GLRenderContext& GLRenderContext::getSingleton(void) { assert( ms_Singleton ); return ( *(static_cast<GLRenderContext *>(ms_Singleton)) ); } void GLRenderContext::init() { assert(glewInit() == GLEW_OK); assert(GL_VERSION_2_0); wireframe = false; // Ensures that normal vectores will be scaled to unit length glEnable(GL_NORMALIZE); glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } void GLRenderContext::toggleWireframe() { wireframe = !wireframe; if (wireframe) { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } else { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } endFrame(); } void GLRenderContext::setViewport(int width, int height) { glViewport(0,0, width, height); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } void GLRenderContext::beginFrame() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } void GLRenderContext::endFrame() { glFlush(); } void GLRenderContext::setModelViewMatrix(const Matrix4 &m) { glMatrixMode(GL_MODELVIEW); glLoadMatrixf(m.transpose().getElementPointer()); } void GLRenderContext::setProjectionMatrix(const Matrix4 &m) { glMatrixMode(GL_PROJECTION); glLoadMatrixf(m.transpose().getElementPointer()); } void GLRenderContext::render(Object *object) { setMaterial(object->getMaterial()); VertexData& vertexData = object->vertexData; VertexDeclaration& vertexDeclaration = vertexData.vertexDeclaration; VertexBufferBinding& vertexBufferBinding = vertexData.vertexBufferBinding; // The basic way to draw triangles in OpenGL is to use glBegin(GL_TRIANGLES), // then specify vertices, colors, etc. using glVertex(), glColor(), etc., and finish // with glEnd(). However, we are using a more advanced technique here that is based // on so-called vertex arrays. Vertex arrays are more efficient because they need // fewer function calls to OpenGL. Read more about vertex arrays in Chapter 2 of the // OpenGL book. // Set up vertex arrays for(int j=0; j<vertexDeclaration.getElementCount(); j++) { const VertexElement *element = vertexDeclaration.getElement(j); const VertexBuffer& vertexBuffer = vertexBufferBinding.getBuffer(element->getBufferIndex()); unsigned char* buf = vertexBuffer.getBuffer(); GLsizei vertexStride = static_cast<GLsizei>(element->getStride()); GLint vertexSize = static_cast<GLint>(element->getSize()); int offset = element->getOffset(); switch(element->getSemantic()) { case VES_POSITION : glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(vertexSize, GL_FLOAT, vertexStride, buf+offset); break; case VES_NORMAL : glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(GL_FLOAT, vertexStride, buf+offset); break; case VES_DIFFUSE : glEnableClientState(GL_COLOR_ARRAY); glColorPointer(vertexSize, GL_FLOAT, vertexStride, buf+offset); glEnable(GL_COLOR_MATERIAL); break; case VES_TEXTURE_COORDINATES : glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(vertexSize, GL_FLOAT, vertexStride, buf+offset); break; } } // Draw glDrawElements(GL_TRIANGLES, vertexData.getIndexCount(), GL_UNSIGNED_INT, vertexData.getIndexBuffer()); // Disable the arrays we used for(int j=0; j<vertexDeclaration.getElementCount(); j++) { const VertexElement *element = vertexDeclaration.getElement(j); switch(element->getSemantic()) { case VES_POSITION : glDisableClientState(GL_VERTEX_ARRAY); break; case VES_NORMAL : glDisableClientState(GL_NORMAL_ARRAY); break; case VES_DIFFUSE : glDisableClientState(GL_COLOR_ARRAY); break; case VES_TEXTURE_COORDINATES : glDisableClientState(GL_TEXTURE_COORD_ARRAY); break; } } assert(glGetError()==GL_NO_ERROR); } // Add the following to GLRenderContext.cpp void GLRenderContext::setLights(const std::list<Light*> &lightList) { GLint lightIndex[] = {GL_LIGHT0, GL_LIGHT1, GL_LIGHT2, GL_LIGHT3, GL_LIGHT4, GL_LIGHT5, GL_LIGHT6, GL_LIGHT7}; glMatrixMode(GL_MODELVIEW); glLoadIdentity(); std::list<Light*>::const_iterator iter; if(lightList.begin()!=lightList.end()) { // Lighting glEnable(GL_LIGHTING); int i=0; for (iter=lightList.begin(); iter!=lightList.end() && i<8; iter++) { Light *l = (*iter); glEnable(lightIndex[i]); if(l->getType() == Light::DIRECTIONAL) { float direction[4]; direction[0] = l->getDirection().getX(); direction[1] = l->getDirection().getY(); direction[2] = l->getDirection().getZ(); direction[3] = 0.f; glLightfv(lightIndex[i], GL_POSITION, direction); } if(l->getType() == Light::POINT || l->getType() == Light::SPOT) { float position[4]; position[0] = l->getPosition().getX(); position[1] = l->getPosition().getY(); position[2] = l->getPosition().getZ(); position[3] = 1.f; glLightfv(lightIndex[i], GL_POSITION, position); } if(l->getType() == Light::SPOT) { float spotDirection[3]; spotDirection[0] = l->getSpotDirection().getX(); spotDirection[1] = l->getSpotDirection().getY(); spotDirection[2] = l->getSpotDirection().getZ(); glLightfv(lightIndex[i], GL_SPOT_DIRECTION, spotDirection); glLightf(lightIndex[i], GL_SPOT_EXPONENT, l->getSpotExponent()); glLightf(lightIndex[i], GL_SPOT_CUTOFF, l->getSpotCutoff()); } float diffuse[4]; diffuse[0] = l->getDiffuseColor().getX(); diffuse[1] = l->getDiffuseColor().getY(); diffuse[2] = l->getDiffuseColor().getZ(); diffuse[3] = 1.f; glLightfv(lightIndex[i], GL_DIFFUSE, diffuse); float ambient[4]; ambient[0] = l->getAmbientColor().getX(); ambient[1] = l->getAmbientColor().getY(); ambient[2] = l->getAmbientColor().getZ(); ambient[3] = 0; glLightfv(lightIndex[i], GL_AMBIENT, ambient); float specular[4]; specular[0] = l->getSpecularColor().getX(); specular[1] = l->getSpecularColor().getY(); specular[2] = l->getSpecularColor().getZ(); specular[3] = 0; glLightfv(lightIndex[i], GL_SPECULAR, specular); i++; } } } void GLRenderContext::setMaterial(const Material *m) { // If there's no material, we need to ensure that // material, texture, and shaders are all at default // Do this by passing in the Default material if (m==NULL) { setMaterial(&Material::OPEN_GL_DEFAULT); } else { // Just in case they had used regular coloring previously. glDisable(GL_COLOR_MATERIAL); float diffuse[4]; diffuse[0] = m->getDiffuse().getX(); diffuse[1] = m->getDiffuse().getY(); diffuse[2] = m->getDiffuse().getZ(); diffuse[3] = 1.f; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse); float ambient[4]; ambient[0] = m->getAmbient().getX(); ambient[1] = m->getAmbient().getY(); ambient[2] = m->getAmbient().getZ(); ambient[3] = 1.f; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient); float specular[4]; specular[0] = m->getSpecular().getX(); specular[1] = m->getSpecular().getY(); specular[2] = m->getSpecular().getZ(); specular[3] = 1.f; glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, m->getShininess()); Texture *tex = m->getTexture(); if(tex!=0) { glEnable(GL_TEXTURE_2D); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBindTexture(GL_TEXTURE_2D, tex->getId()); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } // No texture else { glDisable(GL_TEXTURE_2D); } // If the material does not include a texture, use the default OpenGL // shader if (m->getShader() == NULL) { Shader::restoreDefaultShader(); } else { m->getShader()->use(); } } }
[ [ [ 1, 293 ] ] ]
058960e4b8f7e94f9805f26c29884aed2f954733
1960e1ee431d2cfd2f8ed5715a1112f665b258e3
/inc/com/cocollection.h
5cc156e08e7794f7119b8be5f42254087148b46b
[]
no_license
BackupTheBerlios/bvr20983
c26a1379b0a62e1c09d1428525f3b4940d5bb1a7
b32e92c866c294637785862e0ff9c491705c62a5
refs/heads/master
2021-01-01T16:12:42.021350
2009-11-01T22:38:40
2009-11-01T22:38:40
39,518,214
0
0
null
null
null
null
UTF-8
C++
false
false
2,495
h
/* * $Id$ * * Copyright (C) 2008 Dorothea Wachmann * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. */ #if !defined(COCOLLECTION_H) #define COCOLLECTION_H #include "com/collection.h" #include "com/counknown.h" #define DISPID_LISTITEM 0 #define DISPID_LISTCOUNT (-531) namespace bvr20983 { namespace COM { class COMServer; // // handmade dual interface for ICollection // without dependency to typelibrary // struct ICollectionInternal : public IDispatch { public: virtual HRESULT STDMETHODCALLTYPE get_Item(long Index,VARIANT *retval) = 0; virtual HRESULT STDMETHODCALLTYPE get_Count(long *retval) = 0; virtual HRESULT STDMETHODCALLTYPE get__NewEnum(IUnknown **retval) = 0; }; class CoCollection : public COUnknown,public ICollectionInternal { public: CoCollection(IUnknown* pUnkOuter=NULL); DECLARE_UNKNOWN // IDispatch members STDMETHODIMP GetTypeInfoCount(UINT *); STDMETHODIMP GetTypeInfo(UINT, LCID, ITypeInfo **); STDMETHODIMP GetIDsOfNames(REFIID, OLECHAR **, UINT, LCID, DISPID *); STDMETHODIMP Invoke(DISPID, REFIID, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *); // ICollectionInternal members STDMETHODIMP get_Item(long Index,VARIANT *retval); STDMETHODIMP get_Count(long *retval); STDMETHODIMP get__NewEnum(IUnknown **retval); virtual HRESULT InternalQueryInterface(REFIID riid,PPVOID ppv); bool Add(IDispatch* pUnk); bool Add(LPCTSTR pStr); private: Collection m_collection; static LPCTSTR dispNames[]; static DISPID dispIds[]; }; // of class CoCollection } // of namespace COM } // of namespace bvr20983 #endif // COCOLLECTION_H
[ "dwachmann@01137330-e44e-0410-aa50-acf51430b3d2" ]
[ [ [ 1, 77 ] ] ]
4f3a4d91ec0f282fbcb26ea5eb9de070421f9c5c
105cc69f4207a288be06fd7af7633787c3f3efb5
/HovercraftUniverse/CoreEngine/EntityMapping.h
982edaaccb0f8b1c0622227090444f8ea9f1899b
[]
no_license
allenjacksonmaxplayio/uhasseltaacgua
330a6f2751e1d6675d1cf484ea2db0a923c9cdd0
ad54e9aa3ad841b8fc30682bd281c790a997478d
refs/heads/master
2020-12-24T21:21:28.075897
2010-06-09T18:05:23
2010-06-09T18:05:23
56,725,792
0
0
null
null
null
null
UTF-8
C++
false
false
2,063
h
#ifndef ENTITIYMAPPING_H #define ENTITIYMAPPING_H #include <map> #include "OgreString.h" namespace HovUni { class Config; /** * This class represents the Entities.ini file but in memory * It is read only */ class EntityMapping { private: /** Name of the ini file */ static Ogre::String mEntityIniFile; /** The map with all info about entities */ std::map<Ogre::String,std::map<unsigned int,Ogre::String>> mEntityIniMap; /** An empty map used somewhere */ const std::map<unsigned int,Ogre::String> mEmpty; bool mLoaded; static EntityMapping mInstance; private: void addMapping( Config& config, const Ogre::String& Key ); void load(); protected: /** * Constructor */ EntityMapping(void); public: /** Default keys for the map */ static const Ogre::String CHARACTER; // "Character" static const Ogre::String HOVERCRAFT; // = "Hovercraft" static const Ogre::String MAPS; // = "Maps" /** * Set the entity ini file * @param file */ static void setEntityIniFile( const Ogre::String& file ); /** * Get the instance to the EntityMapping * @return instance */ static EntityMapping& getInstance(); ~EntityMapping(void); /** * Get the name of an entity given his type and id * @param type, the type of the entity * @param id, the id of the entity * @return the name of the entity together with the success value */ std::pair<Ogre::String,bool> getName( const Ogre::String& type, unsigned int id ) const; /** * Get the id of an entity given his type and name * @param name, the name of the entity * @param id, the id of the entity * @return the id of the entity together with succes value */ std::pair<unsigned int,bool> getId( const Ogre::String& type, const Ogre::String& name ) const; /** * Get the id-name map for a given type * @param type, the type * @return the map for given type */ const std::map<unsigned int,Ogre::String>& getMap(const Ogre::String& type) const; }; } #endif
[ "pintens.pieterjan@2d55a33c-0a8f-11df-aac0-2d4c26e34a4c" ]
[ [ [ 1, 92 ] ] ]
44b4ff1eb2e7080f60081f887e05b1c89fd50730
ce0622a0f49dd0ca172db04efdd9484064f20973
/tools/GameList/Common/AtgAnimation.cpp
2fa4db7f25e8debc9932c0879fdd1f14d1b90595
[]
no_license
maninha22crazy/xboxplayer
a78b0699d4002058e12c8f2b8c83b1cbc3316500
e9ff96899ad8e8c93deb3b2fe9168239f6a61fe1
refs/heads/master
2020-12-24T18:42:28.174670
2010-03-14T13:57:37
2010-03-14T13:57:37
56,190,024
1
0
null
null
null
null
UTF-8
C++
false
false
15,906
cpp
//----------------------------------------------------------------------------- // AtgAnimation.cpp // // Xbox Advanced Technology Group. // Copyright (C) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- #include "stdafx.h" #include <vector> #include <algorithm> #include "AtgAnimation.h" #include "AtgScene.h" namespace ATG { const StringID AnimationTransformTrack::TypeID( L"AnimationTransformTrack" ); const StringID Animation::TypeID( L"Animation" ); #define KEY_SEARCH_DISTANCE 4 //---------------------------------------------------------------------------------- // Name: AnimationKeyArray constructor // Desc: Initializes an AnimationKeyArray class to null values, and verifies the // dimension is valid. //---------------------------------------------------------------------------------- AnimationKeyArray::AnimationKeyArray( DWORD dwValueDimension ) : m_dwValueDimension( dwValueDimension ), m_pFloatData( NULL ), m_dwSize( 0 ), m_dwCapacity( 0 ) { assert( m_dwValueDimension > 0 ); } //---------------------------------------------------------------------------------- // Name: AnimationKeyArray destructor // Desc: Cleans up the memory allocations. //---------------------------------------------------------------------------------- AnimationKeyArray::~AnimationKeyArray() { delete[] m_pFloatData; m_pFloatData = NULL; m_dwCapacity = 0; m_dwSize = 0; m_dwValueDimension = 0; } //---------------------------------------------------------------------------------- // Name: Resize() // Desc: Increases the size of the key storage buffer. Ideally, your initialization // code should call this method once with the total number of keys, so no // further resizes will be necessary. //---------------------------------------------------------------------------------- VOID AnimationKeyArray::Resize( DWORD dwNewCapacity ) { assert( dwNewCapacity > m_dwCapacity ); assert( m_dwValueDimension > 0 ); // Allocate and clear new buffer. DWORD dwFloatCount = ( m_dwValueDimension + 1 ) * dwNewCapacity; FLOAT* pNewBuffer = new FLOAT[ dwFloatCount ]; ZeroMemory( pNewBuffer, dwFloatCount * sizeof( FLOAT ) ); // Copy existing contents to new buffer. if( m_pFloatData != NULL ) { DWORD dwExistingSize = m_dwSize * ( m_dwValueDimension + 1 ) * sizeof( FLOAT ); XMemCpy( pNewBuffer, m_pFloatData, dwExistingSize ); delete[] m_pFloatData; m_pFloatData = NULL; } // Update buffer pointer and capacity. m_pFloatData = pNewBuffer; m_dwCapacity = dwNewCapacity; } //---------------------------------------------------------------------------------- // Name: PointToBuffer() // Desc: Initializes the key array with a pointer to a pre-allocated key array. // This is the most preferred method of initialization if you already have the // key data in memory, such as from a resource loader. //---------------------------------------------------------------------------------- VOID AnimationKeyArray::PointToBuffer( FLOAT* pBuffer, DWORD dwBufferSizeBytes, DWORD dwKeyCount, DWORD dwValueDimension ) { // Sanity checks. assert( pBuffer != NULL ); assert( dwBufferSizeBytes == ( dwKeyCount * ( dwValueDimension + 1 ) * sizeof( FLOAT ) ) ); // Destroy any existing buffer. if( m_pFloatData != NULL ) delete[] m_pFloatData; // Initialize with new buffer. m_pFloatData = pBuffer; m_dwCapacity = dwKeyCount; m_dwSize = dwKeyCount; m_dwValueDimension = dwValueDimension; } //---------------------------------------------------------------------------------- // Name: AddKey() // Desc: Increases the size member by one. If there is not enough capacity to // accomodate the new key, the capacity is increased. // The index of the new key is returned. // This is not an optimal way to fill this structure, but it is convenient // for serialized loading. //---------------------------------------------------------------------------------- DWORD AnimationKeyArray::AddKey() { assert( m_dwSize <= m_dwCapacity ); if( m_dwSize == m_dwCapacity ) { DWORD dwNewSize = m_dwCapacity + ( m_dwCapacity >> 1 ); dwNewSize = max( 4, dwNewSize ); Resize( dwNewSize ); } DWORD dwResult = m_dwSize; ++m_dwSize; return dwResult; } //---------------------------------------------------------------------------------- // Name: SetKeyValue() // Desc: Changes a key's value vector to a new value. //---------------------------------------------------------------------------------- VOID AnimationKeyArray::SetKeyValue( DWORD dwKeyIndex, XMVECTOR vValue ) { FLOAT* pValueData = GetKeyValue( dwKeyIndex ); switch( m_dwValueDimension ) { case 3: XMStoreFloat3( (XMFLOAT3*)pValueData, vValue ); return; case 4: XMStoreFloat4( (XMFLOAT4*)pValueData, vValue ); return; case 2: XMStoreFloat2( (XMFLOAT2*)pValueData, vValue ); return; } } struct KeyTempStruct { FLOAT fTime; DWORD dwOriginalIndex; }; //---------------------------------------------------------------------------------- // Name: KeyTimeSortFunction // Desc: Helper function for the SortKeys() method, used with a STL sort. //---------------------------------------------------------------------------------- BOOL KeyTimeSortFunction( const KeyTempStruct& A, const KeyTempStruct& B ) { return A.fTime <= B.fTime; } //---------------------------------------------------------------------------------- // Name: SortKeys() // Desc: Sorts the keys by time, in ascending order. This should not be used // unless the keys were loaded in a serial fashion, and sort order is not // guaranteed. If this class is initialized using PointToBuffer(), and the // data is already sorted, you do not need to sort again. //---------------------------------------------------------------------------------- VOID AnimationKeyArray::SortKeys() { if( m_dwSize == 0 ) return; typedef std::vector<KeyTempStruct> KeyTempList; KeyTempList SortingList; SortingList.reserve( m_dwSize ); for( DWORD i = 0; i < m_dwSize; i++ ) { KeyTempStruct ts; ts.fTime = GetKeyTime( i ); ts.dwOriginalIndex = i; SortingList.push_back( ts ); } std::sort( SortingList.begin(), SortingList.end(), KeyTimeSortFunction ); DWORD dwKeySizeBytes = ( m_dwValueDimension + 1 ) * sizeof( FLOAT ); DWORD dwTotalSizeBytes = dwKeySizeBytes * m_dwSize; BYTE* pSortedKeys = new BYTE[ dwTotalSizeBytes ]; BYTE* pCurrentSortedKey = pSortedKeys; for( DWORD i = 0; i < SortingList.size(); i++ ) { KeyTempStruct& ts = SortingList[i]; BYTE* pOriginalKey = (BYTE*)m_pFloatData + dwKeySizeBytes * ts.dwOriginalIndex; XMemCpy( pCurrentSortedKey, pOriginalKey, dwKeySizeBytes ); pCurrentSortedKey += dwKeySizeBytes; } XMemCpy( m_pFloatData, pSortedKeys, dwTotalSizeBytes ); delete[] pSortedKeys; } //---------------------------------------------------------------------------------- // Name: FindKey() // Desc: Finds the key corresponding to the given time, using a starting hint and // a preferred search direction. This method is optimized to avoid float // branches, by using a "time code" for each key and the search parameter. // The time code is nothing more than a non-negative float treated as a DWORD. // Non-negative floats treated as ints can be compared and sorted like ints. //---------------------------------------------------------------------------------- DWORD AnimationKeyArray::FindKey( FLOAT fTime, DWORD dwKeyIndexHint, BOOL bPlayForward ) const { // Input checking. assert( fTime >= 0.0f ); assert( m_dwSize > 0 ); assert( dwKeyIndexHint < m_dwSize ); // Timecode is an integer re-expression of the float time, used to compare times // faster. Branching and comparing on float values is expensive on Xbox 360. DWORD dwTimeCode = *(DWORD*)&fTime; // Check if the time is less than the first key. if( dwTimeCode < GetKeyTimeCode( 0 ) ) return 0; // Quick search a few keys, in a linear fashion with wraparound. INT iIncrement = -1 + ( (INT)( bPlayForward & 1 ) << 1 ); for( INT i = 0; i < KEY_SEARCH_DISTANCE; i++ ) { DWORD dwIndex = (DWORD)( (INT)( dwKeyIndexHint + m_dwSize ) + ( iIncrement * i ) ) % m_dwSize; DWORD dwTimeCodeTest = GetKeyTimeCode( dwIndex ); // Check if we're looking at the last key. if( dwIndex == ( m_dwSize - 1 ) ) { // If the time code is after the last key, the last key is the right key. if( dwTimeCode >= dwTimeCodeTest ) return dwIndex; } else { // If the time code comes before the key we're looking at, go to the next // key. if( dwTimeCode < dwTimeCodeTest ) continue; // If the time code comes before the next key, then we are on the right key. DWORD dwTimeCodeTestNext = GetKeyTimeCode( dwIndex + 1 ); if( dwTimeCode < dwTimeCodeTestNext ) return dwIndex; } } // We didn't find the right key in the quick search. // Perform a binary search. DWORD dwStartIndex = 0; DWORD dwEndIndex = m_dwSize - 1; while( dwEndIndex > dwStartIndex ) { // Get the middle index in the range, biased upwards. DWORD dwTestIndex = ( dwStartIndex + dwEndIndex + 1 ) >> 1; DWORD dwTestTimeCode = GetKeyTimeCode( dwTestIndex ); if( dwTestTimeCode < dwTimeCode ) dwStartIndex = dwTestIndex; else if( dwTestTimeCode > dwTimeCode ) dwEndIndex = dwTestIndex - 1; else return dwTestIndex; } return dwStartIndex; } //---------------------------------------------------------------------------------- // Name: SampleVector() // Desc: Linearly interpolates between neighboring keys using a time parameter. // The user of this method should store a DWORD key index hint, which will be // updated each time a search is performed. The hint reduces most searches // to O(1), and when the hint fails, the performance of the search is // O(log n). // If the search time falls outside the key times, the result will be either // the first key's value or the last key's value. //---------------------------------------------------------------------------------- XMVECTOR AnimationKeyArray::SampleVector( FLOAT fTime, DWORD* pKeyIndexHint, BOOL bPlayForward ) const { // If we were given a hint, use it. DWORD dwKeyIndexHint = 0; if( pKeyIndexHint != NULL ) dwKeyIndexHint = *pKeyIndexHint; // Find the key. DWORD dwKeyIndex = FindKey( fTime, dwKeyIndexHint, bPlayForward ); // Update the hint so it can be used next time. if( pKeyIndexHint != NULL ) *pKeyIndexHint = dwKeyIndex; // Check if the time is before the first key or after the last key. // In this case, we do not need to lerp. DWORD dwTimeCode = *(DWORD*)&fTime; if( ( dwKeyIndex == m_dwSize - 1 ) || ( dwKeyIndex == 0 && dwTimeCode < GetKeyTimeCode( dwKeyIndex ) ) ) { return GetKeyVector( dwKeyIndex ); } // Extract the start and end times and values. FLOAT fStartTime = GetKeyTime( dwKeyIndex ); XMVECTOR vStart = GetKeyVector( dwKeyIndex ); FLOAT fEndTime = GetKeyTime( dwKeyIndex + 1 ); XMVECTOR vEnd = GetKeyVector( dwKeyIndex + 1 ); // Perform the lerp. FLOAT fParam = ( fTime - fStartTime ) / ( fEndTime - fStartTime ); return XMVectorLerp( vStart, vEnd, fParam ); } //---------------------------------------------------------------------------------- // Name: SampleVectorLooping() // Desc: Linearly interpolates between neighboring keys using a time parameter. // The user of this method should store a DWORD key index hint, which will be // updated each time a search is performed. The hint reduces most searches // to O(1), and when the hint fails, the performance of the search is // O(log n). // If the search time falls outside the key times, the result will be either // the first key's value or the last key's value. //---------------------------------------------------------------------------------- XMVECTOR AnimationKeyArray::SampleVectorLooping( FLOAT fTime, FLOAT fDuration, DWORD* pKeyIndexHint, BOOL bPlayForward ) const { // If we were given a hint, use it. DWORD dwKeyIndexHint = 0; if( pKeyIndexHint != NULL ) dwKeyIndexHint = *pKeyIndexHint; // Find the key. DWORD dwKeyIndex = FindKey( fTime, dwKeyIndexHint, bPlayForward ); // Update the hint so it can be used next time. if( pKeyIndexHint != NULL ) *pKeyIndexHint = dwKeyIndex; // Check if the time is before the first key or after the last key. // In this case, we do not need to lerp. DWORD dwTimeCode = *(DWORD*)&fTime; FLOAT fStartTime, fEndTime; XMVECTOR vStart, vEnd; if( dwKeyIndex == 0 && dwTimeCode < GetKeyTimeCode( dwKeyIndex ) ) { fStartTime = GetKeyTime( m_dwSize - 1 ) - fDuration; vStart = GetKeyVector( m_dwSize - 1 ); fEndTime = GetKeyTime( dwKeyIndex ); vEnd = GetKeyVector( dwKeyIndex ); } else if( dwKeyIndex == m_dwSize - 1 ) { fStartTime = GetKeyTime( dwKeyIndex ); vStart = GetKeyVector( dwKeyIndex ); fEndTime = GetKeyTime( 0 ) + fDuration; vEnd = GetKeyVector( 0 ); } else { // Extract the start and end times and values. fStartTime = GetKeyTime( dwKeyIndex ); vStart = GetKeyVector( dwKeyIndex ); fEndTime = GetKeyTime( dwKeyIndex + 1 ); vEnd = GetKeyVector( dwKeyIndex + 1 ); } // Perform the lerp. FLOAT fParam = ( fTime - fStartTime ) / ( fEndTime - fStartTime ); return XMVectorLerp( vStart, vEnd, fParam ); } } // namespace ATG
[ "goohome@343f5ee6-a13e-11de-ba2c-3b65426ee844" ]
[ [ [ 1, 378 ] ] ]
d901825222dac08b6731d1c05720f802ecb344db
6846783418c3a6e9376ea2d9ccb71088eb8cfcdb
/mexc_TemplateAffineTransform.cpp
0687e2b966f89e9c4006c4c70b88250c1bec1598
[]
no_license
zzsi/EMClusterSupression_building
b43804439681975c9238a656f06f80cf55e21781
364f9e9271de757da9d48b32c1fd5f082cd84080
refs/heads/master
2021-05-27T00:02:16.618167
2011-11-17T02:53:13
2011-11-17T02:53:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,114
cpp
/* * Affine transform of a list of "edgelets". An edgelet is a 2D point with its orientation and scale (length). * * Usage: * [outRow, outCol, outO, outS] = c_TemplateAffineTransform(tScale,rScale,cScale,rotation,inRow,inCol,inO,inS,nOri) * * */ # include <stdio.h> # include <stdlib.h> # include <string.h> # include "mex.h" # include "math.h" # define PI 3.1415926 # define ABS(x) ((x)>0? (x):(-(x))) # define MAX(x, y) ((x)>(y)? (x):(y)) # define MIN(x, y) ((x)<(y)? (x):(y)) # define ROUND(x) (floor((x)+.5)) float **A1, **A2; /* transformation matrices */ int nElement; /* number of edgelet elements to be transformed */ float *outRow, *outCol, *outO, *outS; float *inRow, *inCol, *inO, *inS; float rotation, tScale, rScale, cScale; int nOri; void matrixMultiplication(int mA, int nA, float **inA, int nB, float **inB, float **outC) { int c, r, k; float s; for( c = 0; c < nB; ++c ) for( r = 0; r < mA; ++r ) { s = 0; for( k = 0; k < nA; ++k ) { s += inA[r][k] * inB[k][c]; } outC[r][c] = s; } } void compute() { int i, j; float angle; float **pt, **tmp; /* pt is 1 by 3 */ pt = (float**)mxCalloc(1,sizeof(*pt)); for( i = 0; i < 1; ++i ) { pt[i] = (float*)mxCalloc(3,sizeof(**pt)); } /* tmp is 1 by 3 */ tmp = (float**)mxCalloc(1,sizeof(*tmp)); for( i = 0; i < 1; ++i ) { tmp[i] = (float*)mxCalloc(3,sizeof(**tmp)); } /* set the transformation matrix */ A1 = (float**)mxCalloc(3,sizeof(*A1)); for( i = 0; i < 3; ++i ) { A1[i] = (float*)mxCalloc(3,sizeof(**A1)); } A2 = (float**)mxCalloc(3,sizeof(*A2)); for( i = 0; i < 3; ++i ) { A2[i] = (float*)mxCalloc(3,sizeof(**A2)); } for( i = 0; i < 3; ++i ) for( j = 0; j < 3; ++j ) { A1[i][j] = 0; A2[i][j] = 0; } A1[0][0] = cScale * pow( (double)2, (double)(tScale/2) ); A1[1][1] = rScale * pow( (double)2, (double)(tScale/2) ); angle = rotation * PI/nOri; A2[0][0] = cos(angle); A2[0][1] = sin(angle); A2[1][0] = -A2[0][1]; A2[1][1] = A2[0][0]; for( i = 0; i < nElement; ++i ) { tmp[0][0] = inCol[i]; tmp[0][1] = -inRow[i]; tmp[0][2] = 1; matrixMultiplication(1,3,tmp,3,A1,pt); tmp[0][0] = pt[0][0]; tmp[0][1] = pt[0][1]; tmp[0][2] = pt[0][2]; matrixMultiplication(1,3,tmp,3,A2,pt); outCol[i] = ROUND( pt[0][0] ); outRow[i] = ROUND( -pt[0][1] ); outO[i] = inO[i] + rotation; outS[i] = inS[i] + tScale; while( outO[i] < 0 ) outO[i] = outO[i] + nOri; while( outO[i] >= nOri ) outO[i] = outO[i] - nOri; } } /* entry point: load input variables and run the algorithm */ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { mxArray *pA; mwSize dimsOutput[2]; void* start_of_pr; mxClassID datatype; int bytes_to_copy; /* ============================================= * Handle input variables. * ============================================= */ /* * input variable 0: tScale */ tScale = (float)mxGetScalar(prhs[0]); /* * input variable 1: rScale */ rScale = (float)mxGetScalar(prhs[1]); /* * input variable 2: cScale */ cScale = (float)mxGetScalar(prhs[2]); /* * input variable 3: rotation */ rotation = (float)mxGetScalar(prhs[3]); /* * input variable 4: inRow */ inRow = (float*)mxGetPr(prhs[4]); nElement = mxGetM(prhs[4]) * mxGetN(prhs[4]); datatype = mxGetClassID(prhs[4]); if (datatype != mxSINGLE_CLASS) mexErrMsgTxt("warning !! single precision required."); /* * input variable 5: inCol */ inCol = (float*)mxGetPr(prhs[5]); datatype = mxGetClassID(prhs[5]); if (datatype != mxSINGLE_CLASS) mexErrMsgTxt("warning !! single precision required."); /* * input variable 6: inO */ inO = (float*)mxGetPr(prhs[6]); datatype = mxGetClassID(prhs[6]); if (datatype != mxSINGLE_CLASS) mexErrMsgTxt("warning !! single precision required."); /* * input variable 7: inS */ inS = (float*)mxGetPr(prhs[7]); datatype = mxGetClassID(prhs[7]); if (datatype != mxSINGLE_CLASS) mexErrMsgTxt("warning !! single precision required."); /* * input variable 8: nOri (number of orientation levels within 0 ~ pi) */ nOri = (float)mxGetScalar(prhs[8]); /* ============================================= * Computation. * ============================================= */ outRow = (float*)mxCalloc( nElement, sizeof(*outRow) ); outCol = (float*)mxCalloc( nElement, sizeof(*outCol) ); outO = (float*)mxCalloc( nElement, sizeof(*outO) ); outS = (float*)mxCalloc( nElement, sizeof(*outS) ); compute(); /* ============================================= * Handle output variables. * ============================================= */ /* * output variable 0: outRow */ dimsOutput[0] = nElement; dimsOutput[1] = 1; pA = mxCreateNumericArray( 2, dimsOutput, mxSINGLE_CLASS, mxREAL ); /* populate the real part of the created array */ start_of_pr = (float*)mxGetData(pA); bytes_to_copy = dimsOutput[0] * dimsOutput[1] * mxGetElementSize(pA); memcpy( start_of_pr, outRow, bytes_to_copy ); plhs[0] = pA; /* * output variable 1: outCol */ dimsOutput[0] = nElement; dimsOutput[1] = 1; pA = mxCreateNumericArray( 2, dimsOutput, mxSINGLE_CLASS, mxREAL ); /* populate the real part of the created array */ start_of_pr = (float*)mxGetData(pA); bytes_to_copy = dimsOutput[0] * dimsOutput[1] * mxGetElementSize(pA); memcpy( start_of_pr, outCol, bytes_to_copy ); plhs[1] = pA; /* * output variable 2: outO */ dimsOutput[0] = nElement; dimsOutput[1] = 1; pA = mxCreateNumericArray( 2, dimsOutput, mxSINGLE_CLASS, mxREAL ); /* populate the real part of the created array */ start_of_pr = (float*)mxGetData(pA); bytes_to_copy = dimsOutput[0] * dimsOutput[1] * mxGetElementSize(pA); memcpy( start_of_pr, outO, bytes_to_copy ); plhs[2] = pA; /* * output variable 3: outS */ dimsOutput[0] = nElement; dimsOutput[1] = 1; pA = mxCreateNumericArray( 2, dimsOutput, mxSINGLE_CLASS, mxREAL ); /* populate the real part of the created array */ start_of_pr = (float*)mxGetData(pA); bytes_to_copy = dimsOutput[0] * dimsOutput[1] * mxGetElementSize(pA); memcpy( start_of_pr, outS, bytes_to_copy ); plhs[3] = pA; }
[ [ [ 1, 241 ] ] ]
3caae7e3c8823788c29d7a3359deee0cf9df9e1f
cd0987589d3815de1dea8529a7705caac479e7e9
/webkit/WebKit2/Shared/ImmutableArray.h
990306bead525372cfae96bf0e4c4345f9860d3c
[]
no_license
azrul2202/WebKit-Smartphone
0aab1ff641d74f15c0623f00c56806dbc9b59fc1
023d6fe819445369134dee793b69de36748e71d7
refs/heads/master
2021-01-15T09:24:31.288774
2011-07-11T11:12:44
2011-07-11T11:12:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,802
h
/* * Copyright (C) 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef ImmutableArray_h #define ImmutableArray_h #include "APIObject.h" #include <wtf/PassOwnArrayPtr.h> #include <wtf/PassRefPtr.h> #include <wtf/Vector.h> namespace WebKit { // ImmutableArray - An immutable array type suitable for vending to an API. class ImmutableArray : public APIObject { public: static const Type APIType = TypeArray; static PassRefPtr<ImmutableArray> create() { return adoptRef(new ImmutableArray); } static PassRefPtr<ImmutableArray> create(APIObject** entries, size_t size) { return adoptRef(new ImmutableArray(entries, size)); } static PassRefPtr<ImmutableArray> adopt(Vector<RefPtr<APIObject> >& entries) { return adoptRef(new ImmutableArray(entries)); } ~ImmutableArray(); template<typename T> T* at(size_t i) { if (m_entries[i]->type() != T::APIType) return 0; return static_cast<T*>(m_entries[i].get()); } APIObject* at(size_t i) { return m_entries[i].get(); } size_t size() { return m_entries.size(); } virtual bool isMutable() { return false; } protected: ImmutableArray(); ImmutableArray(APIObject** entries, size_t size); ImmutableArray(Vector<RefPtr<APIObject> >& entries); virtual Type type() const { return APIType; } Vector<RefPtr<APIObject> > m_entries; }; } // namespace WebKit #endif // ImmutableArray_h
[ [ [ 1, 77 ] ] ]
8d3b6ea354e6add0fe29590ae784f83457fc17a5
842997c28ef03f8deb3422d0bb123c707732a252
/src/moaicore/MOAITransform.cpp
2c42f80b753b7d878415f029f5eab2d41ec1a343
[]
no_license
bjorn/moai-beta
e31f600a3456c20fba683b8e39b11804ac88d202
2f06a454d4d94939dc3937367208222735dd164f
refs/heads/master
2021-01-17T11:46:46.018377
2011-06-10T07:33:55
2011-06-10T07:33:55
1,837,561
2
1
null
null
null
null
UTF-8
C++
false
false
23,428
cpp
// Copyright (c) 2010-2011 Zipline Games, Inc. All Rights Reserved. // http://getmoai.com #include "pch.h" #include <moaicore/MOAILogMessages.h> #include <moaicore/MOAITransform.h> //================================================================// // local //================================================================// //----------------------------------------------------------------// /** @name addLoc @text Adds a delta to the transform's location. @in MOAITransform self @in number xDelta @in number yDelta @out nil */ int MOAITransform::_addLoc ( lua_State* L ) { MOAI_LUA_SETUP ( MOAITransform, "UNN" ) USVec2D loc = self->GetLoc (); loc.mX += state.GetValue < float >( 2, 0.0f ); loc.mY += state.GetValue < float >( 3, 0.0f ); self->SetLoc ( loc ); self->ScheduleUpdate (); return 0; } //----------------------------------------------------------------// /** @name addRot @text Adds a delta to the transform's rotation @in MOAITransform self @in number rDelta In degrees. @out nil */ int MOAITransform::_addRot ( lua_State* L ) { MOAI_LUA_SETUP ( MOAITransform, "UN" ) float d = self->GetRot (); d += state.GetValue < float >( 2, 0.0f ); self->SetRot ( d ); self->ScheduleUpdate (); return 0; } //----------------------------------------------------------------// /** @name addScl @text Adds a delta to the transform's scale @in MOAITransform self @in number xSclDelta @in number ySclDelta @out nil */ int MOAITransform::_addScl ( lua_State* L ) { MOAI_LUA_SETUP ( MOAITransform, "UNN" ) USVec2D scl = self->GetScl (); scl.mX += state.GetValue < float >( 2, 0.0f ); scl.mY += state.GetValue < float >( 3, 0.0f ); self->SetScl ( scl ); self->ScheduleUpdate (); return 0; } //----------------------------------------------------------------// /** @name getLoc @text Returns the transform's current location. @in MOAITransform self @out number xLoc @out number yLoc */ int MOAITransform::_getLoc ( lua_State* L ) { MOAI_LUA_SETUP ( MOAITransform, "U" ) lua_pushnumber ( state, self->mLoc.mX ); lua_pushnumber ( state, self->mLoc.mY ); return 2; } //----------------------------------------------------------------// /** @name getRot @text Returns the transform's current rotation. @in MOAITransform self @out number rot Rotation in degrees. */ int MOAITransform::_getRot ( lua_State* L ) { MOAI_LUA_SETUP ( MOAITransform, "U" ) lua_pushnumber ( state, self->mDegrees ); return 1; } //----------------------------------------------------------------// /** @name getScl @text Returns the transform's current scale. @in MOAITransform self @out number xScl @out number yScl */ int MOAITransform::_getScl ( lua_State* L ) { MOAI_LUA_SETUP ( MOAITransform, "U" ) lua_pushnumber ( state, self->mScale.mX ); lua_pushnumber ( state, self->mScale.mY ); return 2; } //----------------------------------------------------------------// /** @name modelToWorld @text Transform a point in model space to world space. @in MOAITransform self @in number x @in number y @out number x @out number y */ int MOAITransform::_modelToWorld ( lua_State* L ) { MOAI_LUA_SETUP ( MOAITransform, "UNN" ) USVec2D loc; loc.mX = state.GetValue < float >( 2, 0.0f ); loc.mY = state.GetValue < float >( 3, 0.0f ); USAffine2D modelToWorld = self->GetLocalToWorldMtx (); modelToWorld.Transform ( loc ); lua_pushnumber ( state, loc.mX ); lua_pushnumber ( state, loc.mY ); return 2; } //----------------------------------------------------------------// /** @name move @text Animate the transform by applying a delta. Creates and returns a MOAIEaseDriver initialized to apply the delta. @in MOAITransform self @in number xDelta Delta to be added to x. @in number yDelta Delta to be added to y. @in number rDelta Delta to be added to r (in degrees). @in number xSclDelta Delta to be added to x scale. @in number ySclDelta Delta to be added to y scale. @in number length Length of animation in seconds. @opt number mode The ease mode. One of MOAIEaseType.EASE_IN, MOAIEaseType.EASE_OUT, MOAIEaseType.FLAT MOAIEaseType.LINEAR, MOAIEaseType.SMOOTH, MOAIEaseType.SOFT_EASE_IN, MOAIEaseType.SOFT_EASE_OUT, MOAIEaseType.SOFT_SMOOTH. Defaults to MOAIEaseType.SMOOTH. @out MOAIEaseDriver easeDriver */ int MOAITransform::_move ( lua_State* L ) { MOAI_LUA_SETUP ( MOAITransform, "UNNNNNN" ) MOAIEaseDriver* action = new MOAIEaseDriver (); action->ReserveLinks ( 5 ); float xLoc = state.GetValue < float >( 2, 0.0f ); float yLoc = state.GetValue < float >( 3, 0.0f ); float zRot = state.GetValue < float >( 4, 0.0f ); float xScl = state.GetValue < float >( 5, 0.0f ); float yScl = state.GetValue < float >( 6, 0.0f ); float delay = state.GetValue < float >( 7, 0.0f ); u32 mode = state.GetValue < u32 >( 8, USInterpolate::kSmooth ); action->SetLink ( 0, self, MOAITransformAttr::Pack ( ATTR_X_LOC ), xLoc, mode ); action->SetLink ( 1, self, MOAITransformAttr::Pack ( ATTR_Y_LOC ), yLoc, mode ); action->SetLink ( 2, self, MOAITransformAttr::Pack ( ATTR_Z_ROT ), zRot, mode ); action->SetLink ( 3, self, MOAITransformAttr::Pack ( ATTR_X_SCL ), xScl, mode ); action->SetLink ( 4, self, MOAITransformAttr::Pack ( ATTR_Y_SCL ), yScl, mode ); action->SetLength ( delay ); action->Start (); action->PushLuaUserdata ( state ); return 1; } //----------------------------------------------------------------// /** @name moveLoc @text Animate the transform by applying a delta. Creates and returns a MOAIEaseDriver initialized to apply the delta. @in MOAITransform self @in number xDelta Delta to be added to x. @in number yDelta Delta to be added to y. @in number length Length of animation in seconds. @opt number mode The ease mode. One of MOAIEaseType.EASE_IN, MOAIEaseType.EASE_OUT, MOAIEaseType.FLAT MOAIEaseType.LINEAR, MOAIEaseType.SMOOTH, MOAIEaseType.SOFT_EASE_IN, MOAIEaseType.SOFT_EASE_OUT, MOAIEaseType.SOFT_SMOOTH. Defaults to MOAIEaseType.SMOOTH. @out MOAIEaseDriver easeDriver */ int MOAITransform::_moveLoc ( lua_State* L ) { MOAI_LUA_SETUP ( MOAITransform, "UNNN" ) MOAIEaseDriver* action = new MOAIEaseDriver (); action->ReserveLinks ( 2 ); float xLoc = state.GetValue < float >( 2, 0.0f ); float yLoc = state.GetValue < float >( 3, 0.0f ); float delay = state.GetValue < float >( 4, 0.0f ); u32 mode = state.GetValue < u32 >( 5, USInterpolate::kSmooth ); action->SetLink ( 0, self, MOAITransformAttr::Pack ( ATTR_X_LOC ), xLoc, mode ); action->SetLink ( 1, self, MOAITransformAttr::Pack ( ATTR_Y_LOC ), yLoc, mode ); action->SetLength ( delay ); action->Start (); action->PushLuaUserdata ( state ); return 1; } //----------------------------------------------------------------// /** @name moveRot @text Animate the transform by applying a delta. Creates and returns a MOAIEaseDriver initialized to apply the delta. @in MOAITransform self @in number rDelta Delta to be added to r (in degrees). @in number length Length of animation in seconds. @opt number mode The ease mode. One of MOAIEaseType.EASE_IN, MOAIEaseType.EASE_OUT, MOAIEaseType.FLAT MOAIEaseType.LINEAR, MOAIEaseType.SMOOTH, MOAIEaseType.SOFT_EASE_IN, MOAIEaseType.SOFT_EASE_OUT, MOAIEaseType.SOFT_SMOOTH. Defaults to MOAIEaseType.SMOOTH. @out MOAIEaseDriver easeDriver */ int MOAITransform::_moveRot ( lua_State* L ) { MOAI_LUA_SETUP ( MOAITransform, "UNN" ) MOAIEaseDriver* action = new MOAIEaseDriver (); action->ReserveLinks ( 1 ); float zRot = state.GetValue < float >( 2, 0.0f ); float delay = state.GetValue < float >( 3, 0.0f ); u32 mode = state.GetValue < u32 >( 4, USInterpolate::kSmooth ); action->SetLink ( 0, self, MOAITransformAttr::Pack ( ATTR_Z_ROT ), zRot, mode ); action->SetLength ( delay ); action->Start (); action->PushLuaUserdata ( state ); return 1; } //----------------------------------------------------------------// /** @name moveScl @text Animate the transform by applying a delta. Creates and returns a MOAIEaseDriver initialized to apply the delta. @in MOAITransform self @in number xSclDelta Delta to be added to x scale. @in number ySclDelta Delta to be added to y scale. @in number length Length of animation in seconds. @opt number mode The ease mode. One of MOAIEaseType.EASE_IN, MOAIEaseType.EASE_OUT, MOAIEaseType.FLAT MOAIEaseType.LINEAR, MOAIEaseType.SMOOTH, MOAIEaseType.SOFT_EASE_IN, MOAIEaseType.SOFT_EASE_OUT, MOAIEaseType.SOFT_SMOOTH. Defaults to MOAIEaseType.SMOOTH. @out MOAIEaseDriver easeDriver */ int MOAITransform::_moveScl ( lua_State* L ) { MOAI_LUA_SETUP ( MOAITransform, "UNNN" ) MOAIEaseDriver* action = new MOAIEaseDriver (); action->ReserveLinks ( 2 ); float xScl = state.GetValue < float >( 2, 0.0f ); float yScl = state.GetValue < float >( 3, 0.0f ); float delay = state.GetValue < float >( 4, 0.0f ); u32 mode = state.GetValue < u32 >( 5, USInterpolate::kSmooth ); action->SetLink ( 0, self, MOAITransformAttr::Pack ( ATTR_X_SCL ), xScl, mode ); action->SetLink ( 1, self, MOAITransformAttr::Pack ( ATTR_Y_SCL ), yScl, mode ); action->SetLength ( delay ); action->Start (); action->PushLuaUserdata ( state ); return 1; } //----------------------------------------------------------------// /** @name seek @text Animate the transform by applying a delta. Delta is computed given a target value. Creates and returns a MOAIEaseDriver initialized to apply the delta. @in MOAITransform self @in number xGoal Desired resulting value for x. @in number yGoal Desired resulting value for y. @in number rGoal Desired resulting value for r (in degrees). @in number xSclGoal Desired resulting value for x scale. @in number ySclGoal Desired resulting value for y scale. @in number length Length of animation in seconds. @opt number mode The ease mode. One of MOAIEaseType.EASE_IN, MOAIEaseType.EASE_OUT, MOAIEaseType.FLAT MOAIEaseType.LINEAR, MOAIEaseType.SMOOTH, MOAIEaseType.SOFT_EASE_IN, MOAIEaseType.SOFT_EASE_OUT, MOAIEaseType.SOFT_SMOOTH. Defaults to MOAIEaseType.SMOOTH. @out MOAIEaseDriver easeDriver */ int MOAITransform::_seek ( lua_State* L ) { MOAI_LUA_SETUP ( MOAITransform, "UNNNNNN" ) MOAIEaseDriver* action = new MOAIEaseDriver (); action->ReserveLinks ( 5 ); float xLoc = state.GetValue < float >( 2, 0.0f ); float yLoc = state.GetValue < float >( 3, 0.0f ); float zRot = state.GetValue < float >( 4, 0.0f ); float xScl = state.GetValue < float >( 5, 0.0f ); float yScl = state.GetValue < float >( 6, 0.0f ); float delay = state.GetValue < float >( 7, 0.0f ); u32 mode = state.GetValue < u32 >( 8, USInterpolate::kSmooth ); action->SetLink ( 0, self, MOAITransformAttr::Pack ( ATTR_X_LOC ), xLoc - self->mLoc.mX, mode ); action->SetLink ( 1, self, MOAITransformAttr::Pack ( ATTR_Y_LOC ), yLoc - self->mLoc.mY, mode ); action->SetLink ( 2, self, MOAITransformAttr::Pack ( ATTR_Z_ROT ), zRot - self->mDegrees, mode ); action->SetLink ( 3, self, MOAITransformAttr::Pack ( ATTR_X_SCL ), xScl - self->mScale.mX, mode ); action->SetLink ( 4, self, MOAITransformAttr::Pack ( ATTR_Y_SCL ), yScl - self->mScale.mY, mode ); action->SetLength ( delay ); action->Start (); action->PushLuaUserdata ( state ); return 1; } //----------------------------------------------------------------// /** @name seekLoc @text Animate the transform by applying a delta. Delta is computed given a target value. Creates and returns a MOAIEaseDriver initialized to apply the delta. @in MOAITransform self @in number xGoal Desired resulting value for x. @in number yGoal Desired resulting value for y. @in number length Length of animation in seconds. @opt number mode The ease mode. One of MOAIEaseType.EASE_IN, MOAIEaseType.EASE_OUT, MOAIEaseType.FLAT MOAIEaseType.LINEAR, MOAIEaseType.SMOOTH, MOAIEaseType.SOFT_EASE_IN, MOAIEaseType.SOFT_EASE_OUT, MOAIEaseType.SOFT_SMOOTH. Defaults to MOAIEaseType.SMOOTH. @out MOAIEaseDriver easeDriver */ int MOAITransform::_seekLoc ( lua_State* L ) { MOAI_LUA_SETUP ( MOAITransform, "UNNN" ) MOAIEaseDriver* action = new MOAIEaseDriver (); action->ReserveLinks ( 2 ); float xLoc = state.GetValue < float >( 2, 0.0f ); float yLoc = state.GetValue < float >( 3, 0.0f ); float delay = state.GetValue < float >( 4, 0.0f ); u32 mode = state.GetValue < u32 >( 5, USInterpolate::kSmooth ); action->SetLink ( 0, self, MOAITransformAttr::Pack ( ATTR_X_LOC ), xLoc - self->mLoc.mX, mode ); action->SetLink ( 1, self, MOAITransformAttr::Pack ( ATTR_Y_LOC ), yLoc - self->mLoc.mY, mode ); action->SetLength ( delay ); action->Start (); action->PushLuaUserdata ( state ); return 1; } //----------------------------------------------------------------// /** @name seekRot @text Animate the transform by applying a delta. Delta is computed given a target value. Creates and returns a MOAIEaseDriver initialized to apply the delta. @in MOAITransform self @in number rGoal Desired resulting value for r (in degrees). @in number length Length of animation in seconds. @opt number mode The ease mode. One of MOAIEaseType.EASE_IN, MOAIEaseType.EASE_OUT, MOAIEaseType.FLAT MOAIEaseType.LINEAR, MOAIEaseType.SMOOTH, MOAIEaseType.SOFT_EASE_IN, MOAIEaseType.SOFT_EASE_OUT, MOAIEaseType.SOFT_SMOOTH. Defaults to MOAIEaseType.SMOOTH. @out MOAIEaseDriver easeDriver */ int MOAITransform::_seekRot ( lua_State* L ) { MOAI_LUA_SETUP ( MOAITransform, "UNN" ) MOAIEaseDriver* action = new MOAIEaseDriver (); action->ReserveLinks ( 1 ); float zRot = state.GetValue < float >( 2, 0.0f ); float delay = state.GetValue < float >( 3, 0.0f ); u32 mode = state.GetValue < u32 >( 4, USInterpolate::kSmooth ); action->SetLink ( 0, self, MOAITransformAttr::Pack ( ATTR_Z_ROT ), zRot - self->mDegrees, mode ); action->SetLength ( delay ); action->Start (); action->PushLuaUserdata ( state ); return 1; } //----------------------------------------------------------------// /** @name seekScl @text Animate the transform by applying a delta. Delta is computed given a target value. Creates and returns a MOAIEaseDriver initialized to apply the delta. @in MOAITransform self @in number xSclGoal Desired resulting value for x scale. @in number ySclGoal Desired resulting value for y scale. @in number length Length of animation in seconds. @opt number mode The ease mode. One of MOAIEaseType.EASE_IN, MOAIEaseType.EASE_OUT, MOAIEaseType.FLAT MOAIEaseType.LINEAR, MOAIEaseType.SMOOTH, MOAIEaseType.SOFT_EASE_IN, MOAIEaseType.SOFT_EASE_OUT, MOAIEaseType.SOFT_SMOOTH. Defaults to MOAIEaseType.SMOOTH. @out MOAIEaseDriver easeDriver */ int MOAITransform::_seekScl ( lua_State* L ) { MOAI_LUA_SETUP ( MOAITransform, "UNNN" ) MOAIEaseDriver* action = new MOAIEaseDriver (); action->ReserveLinks ( 2 ); float xScl = state.GetValue < float >( 2, 0.0f ); float yScl = state.GetValue < float >( 3, 0.0f ); float delay = state.GetValue < float >( 4, 0.0f ); u32 mode = state.GetValue < u32 >( 5, USInterpolate::kSmooth ); action->SetLink ( 0, self, MOAITransformAttr::Pack ( ATTR_X_SCL ), xScl - self->mScale.mX, mode ); action->SetLink ( 1, self, MOAITransformAttr::Pack ( ATTR_Y_SCL ), yScl - self->mScale.mY, mode ); action->SetLength ( delay ); action->Start (); action->PushLuaUserdata ( state ); return 1; } //----------------------------------------------------------------// /** @name setLoc @text Sets the transform's location. @in MOAITransform self @in number x @in number y @out nil */ int MOAITransform::_setLoc ( lua_State* L ) { MOAI_LUA_SETUP ( MOAITransform, "UNN" ) USVec2D loc; loc.mX = state.GetValue < float >( 2, 0.0f ); loc.mY = state.GetValue < float >( 3, 0.0f ); self->SetLoc ( loc ); self->ScheduleUpdate (); return 0; } //----------------------------------------------------------------// /** @name setParent @text Sets or clears the prop's parent transform. @in MOAITransform self @opt MOAITransformBase parent Default value is nil. @out nil */ int MOAITransform::_setParent ( lua_State* L ) { MOAI_LUA_SETUP ( MOAITransform, "U" ) MOAITransformBase* parent = state.GetLuaObject < MOAITransformBase >( 2 ); self->SetParent ( parent ); return 0; } //----------------------------------------------------------------// /** @name setRot @text Sets the transform's rotation. @in MOAITransform self @in number rot Rotation in degrees. @out nil */ int MOAITransform::_setRot ( lua_State* L ) { MOAI_LUA_SETUP ( MOAITransform, "UN" ) float d = state.GetValue < float >( 2, 0.0f ); self->SetRot ( d ); self->ScheduleUpdate (); return 0; } //----------------------------------------------------------------// /** @name setScl @text Sets the transform's scale. @in MOAITransform self @in number xScl @in number yScl @out nil */ int MOAITransform::_setScl ( lua_State* L ) { MOAI_LUA_SETUP ( MOAITransform, "UNN" ) USVec2D scl; scl.mX = state.GetValue < float >( 2, 0.0f ); scl.mY = state.GetValue < float >( 3, 0.0f ); self->SetScl ( scl ); self->ScheduleUpdate (); return 0; } //----------------------------------------------------------------// /** @name worldToModel @text Transform a point in world space to model space. @in MOAITransform self @in number x @in number y @out number x @out number y */ int MOAITransform::_worldToModel ( lua_State* L ) { MOAI_LUA_SETUP ( MOAITransform, "UNN" ) USVec2D loc; loc.mX = state.GetValue < float >( 2, 0.0f ); loc.mY = state.GetValue < float >( 3, 0.0f ); USAffine2D worldToModel = self->GetWorldToLocalMtx (); worldToModel.Transform ( loc ); lua_pushnumber ( state, loc.mX ); lua_pushnumber ( state, loc.mY ); return 2; } //================================================================// // MOAITransform //================================================================// //----------------------------------------------------------------// bool MOAITransform::ApplyAttrOp ( u32 attrID, USAttrOp& attrOp ) { if ( MOAITransformAttr::Check ( attrID )) { switch ( UNPACK_ATTR ( attrID )) { case ATTR_X_LOC: this->mLoc.mX = attrOp.Op ( this->mLoc.mX ); return true; case ATTR_Y_LOC: this->mLoc.mY = attrOp.Op ( this->mLoc.mY ); return true; case ATTR_Z_ROT: this->mDegrees = attrOp.Op ( this->mDegrees ); return true; case ATTR_X_SCL: this->mScale.mX = attrOp.Op ( this->mScale.mX ); return true; case ATTR_Y_SCL: this->mScale.mY = attrOp.Op ( this->mScale.mY ); return true; } } return false; } //----------------------------------------------------------------// void MOAITransform::BuildTransforms ( float xOff, float yOff, float xStretch, float yStretch ) { this->mLocalToWorldMtx.ScRoTr ( this->mScale.mX * xStretch, this->mScale.mY * yStretch, ( float )D2R * this->mDegrees, this->mLoc.mX + xOff, this->mLoc.mY + yOff ); if ( this->mTraitSource ) { const USAffine2D* inherit = this->mTraitSource->GetTransformTrait (); if ( inherit ) { if ( this->mTraitMask & INHERIT_TRANSFORM ) { this->mLocalToWorldMtx.Append ( *inherit ); } else if ( this->mTraitMask & INHERIT_LOC ) { USVec2D loc = this->mLoc; inherit->Transform ( loc ); this->mLocalToWorldMtx.m [ USAffine2D::C2_R0 ] = loc.mX; this->mLocalToWorldMtx.m [ USAffine2D::C2_R1 ] = loc.mY; } } } this->mWorldToLocalMtx.Inverse ( this->mLocalToWorldMtx ); } //----------------------------------------------------------------// const USAffine2D& MOAITransform::GetLocalToWorldMtx () { return this->mLocalToWorldMtx; } //----------------------------------------------------------------// const USAffine2D& MOAITransform::GetWorldToLocalMtx () { return this->mWorldToLocalMtx; } //----------------------------------------------------------------// MOAITransform::MOAITransform () : mLoc ( 0.0f, 0.0f ), mScale ( 1.0f, 1.0f ), mDegrees ( 0.0f ) { RTTI_BEGIN RTTI_EXTEND ( MOAITraits ) RTTI_EXTEND ( MOAITransformBase ) RTTI_END this->mLocalToWorldMtx.Ident (); this->mWorldToLocalMtx.Ident (); } //----------------------------------------------------------------// MOAITransform::~MOAITransform () { } //----------------------------------------------------------------// void MOAITransform::OnDepNodeUpdate () { this->BuildTransforms ( 0.0f, 0.0f, 1.0f, 1.0f ); } //----------------------------------------------------------------// void MOAITransform::RegisterLuaClass ( USLuaState& state ) { MOAITraits::RegisterLuaClass ( state ); state.SetField ( -1, "ATTR_X_LOC", MOAITransformAttr::Pack ( ATTR_X_LOC )); state.SetField ( -1, "ATTR_Y_LOC", MOAITransformAttr::Pack ( ATTR_Y_LOC )); state.SetField ( -1, "ATTR_Z_ROT", MOAITransformAttr::Pack ( ATTR_Z_ROT )); state.SetField ( -1, "ATTR_X_SCL", MOAITransformAttr::Pack ( ATTR_X_SCL )); state.SetField ( -1, "ATTR_Y_SCL", MOAITransformAttr::Pack ( ATTR_Y_SCL )); } //----------------------------------------------------------------// void MOAITransform::RegisterLuaFuncs ( USLuaState& state ) { MOAITraits::RegisterLuaFuncs ( state ); luaL_Reg regTable [] = { { "addLoc", _addLoc }, { "addRot", _addRot }, { "addScl", _addScl }, { "getLoc", _getLoc }, { "getRot", _getRot }, { "getScl", _getScl }, { "modelToWorld", _modelToWorld }, { "move", _move }, { "moveLoc", _moveLoc }, { "moveRot", _moveRot }, { "moveScl", _moveScl }, { "seek", _seek }, { "seekLoc", _seekLoc }, { "seekRot", _seekRot }, { "seekScl", _seekScl }, { "setLoc", _setLoc }, { "setParent", _setParent }, { "setRot", _setRot }, { "setScl", _setScl }, { "worldToModel", _worldToModel }, { NULL, NULL } }; luaL_register ( state, 0, regTable ); } //----------------------------------------------------------------// void MOAITransform::SetLoc ( float x, float y ) { this->mLoc.mX = x; this->mLoc.mY = y; } //----------------------------------------------------------------// void MOAITransform::SetParent ( MOAITransformBase* parent ) { this->SetTraitSource ( parent ); } //----------------------------------------------------------------// void MOAITransform::SetScl ( float x, float y ) { this->mScale.mX = x; this->mScale.mY = y; } //----------------------------------------------------------------// STLString MOAITransform::ToString () { STLString repr; PRETTY_PRINT ( repr, mLoc ) PRETTY_PRINT ( repr, mScale ) PRETTY_PRINT ( repr, mDegrees ) return repr; }
[ "Patrick@agile.(none)" ]
[ [ [ 1, 732 ] ] ]
dd0cf3b83b4285fe7764f665a76aa15899f26f29
01fadae9f2a6d3f19bc843841a7faa9c40fc4a20
/CG/code_CG/EX04_04.CPP
369ba3900ab6b180fe72c96e05f4460dd4f1506a
[]
no_license
passzenith/passzenithproject
9999da29ac8df269c41d280137113e1e2638542d
67dd08f4c3a046889319170a89b45478bfd662d2
refs/heads/master
2020-12-24T14:36:46.389657
2010-09-05T02:34:42
2010-09-05T02:34:42
32,310,266
0
0
null
null
null
null
UTF-8
C++
false
false
957
cpp
#include <GL/glut.h> void init (void) { glClearColor (1.0, 1.0, 1.0, 0.0); glMatrixMode (GL_PROJECTION); gluOrtho2D (0.0, 200.0, 0.0, 150.0); } void myDisplay (void) { GLint y; GLfloat Size; glClear (GL_COLOR_BUFFER_BIT); glColor3f (0.0, 0.0, 1.0); Size = 1.0; for (y=10; y<=140; y+=15) { glLineWidth (Size); glBegin (GL_LINES); glVertex2i (20, y); // Set line-segment geometry glVertex2i (180, y); glEnd ( ); Size += 1.0f; } glFlush ( ); } int main (int argc, char** argv) { glutInit (&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowPosition (50, 100); glutInitWindowSize (400, 300); glutCreateWindow ("Set Line Width in OpenGL Program"); init ( ); glutDisplayFunc (myDisplay); glutMainLoop ( ); return 0; }
[ "passzenith@00fadc5f-a3f2-dbaa-0561-d91942954633" ]
[ [ [ 1, 41 ] ] ]
85944423000eff7273aea6753e2ab99d608c1f2e
b14d5833a79518a40d302e5eb40ed5da193cf1b2
/cpp/extern/xercesc++/2.6.0/src/xercesc/dom/DOMRange.hpp
18e9e4630fc96efc4eed589e1ac993cde0dd37f1
[ "Apache-2.0" ]
permissive
andyburke/bitflood
dcb3fb62dad7fa5e20cf9f1d58aaa94be30e82bf
fca6c0b635d07da4e6c7fbfa032921c827a981d6
refs/heads/master
2016-09-10T02:14:35.564530
2011-11-17T09:51:49
2011-11-17T09:51:49
2,794,411
1
0
null
null
null
null
UTF-8
C++
false
false
21,926
hpp
#ifndef DOMRange_HEADER_GUARD_ #define DOMRange_HEADER_GUARD_ /* * Copyright 2001-2002,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * $Id: DOMRange.hpp,v 1.9 2004/09/08 13:55:39 peiyongz Exp $ */ #include <xercesc/util/XercesDefs.hpp> XERCES_CPP_NAMESPACE_BEGIN class DOMNode; class DOMDocumentFragment; /** * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113'>Document Object Model (DOM) Level 2 Traversal and Range Specification</a>. * @since DOM Level 2 */ class CDOM_EXPORT DOMRange { protected: // ----------------------------------------------------------------------- // Hidden constructors // ----------------------------------------------------------------------- /** @name Hidden constructors */ //@{ DOMRange() {}; //@} private: // ----------------------------------------------------------------------- // Unimplemented constructors and operators // ----------------------------------------------------------------------- /** @name Unimplemented constructors and operators */ //@{ DOMRange(const DOMRange &); DOMRange & operator = (const DOMRange &); //@} public: // ----------------------------------------------------------------------- // All constructors are hidden, just the destructor is available // ----------------------------------------------------------------------- /** @name Destructor */ //@{ /** * Destructor * */ virtual ~DOMRange() {}; //@} // ----------------------------------------------------------------------- // Class Types // ----------------------------------------------------------------------- /** @name Public Contants */ //@{ /** * Constants CompareHow. * * <p><code>START_TO_START:</code> * Compare start boundary-point of <code>sourceRange</code> to start * boundary-point of Range on which <code>compareBoundaryPoints</code> * is invoked.</p> * * <p><code>START_TO_END:</code> * Compare start boundary-point of <code>sourceRange</code> to end * boundary-point of Range on which <code>compareBoundaryPoints</code> * is invoked.</p> * * <p><code>END_TO_END:</code> * Compare end boundary-point of <code>sourceRange</code> to end * boundary-point of Range on which <code>compareBoundaryPoints</code> * is invoked.</p> * * <p><code>END_TO_START:</code> * Compare end boundary-point of <code>sourceRange</code> to start * boundary-point of Range on which <code>compareBoundaryPoints</code> * is invoked.</p> * * @since DOM Level 2 */ enum CompareHow { START_TO_START = 0, START_TO_END = 1, END_TO_END = 2, END_TO_START = 3 }; //@} // ----------------------------------------------------------------------- // Virtual DOMRange interface // ----------------------------------------------------------------------- /** @name Functions introduced in DOM Level 2 */ //@{ // ----------------------------------------------------------------------- // Getter methods // ----------------------------------------------------------------------- /** * DOMNode within which the Range begins * @exception DOMException * INVALID_STATE_ERR: Raised if <code>detach()</code> has already been * invoked on this object. * * @since DOM Level 2 */ virtual DOMNode* getStartContainer() const = 0; /** * Offset within the starting node of the Range. * @exception DOMException * INVALID_STATE_ERR: Raised if <code>detach()</code> has already been * invoked on this object. * * @since DOM Level 2 */ virtual XMLSize_t getStartOffset() const = 0; /** * DOMNode within which the Range ends * @exception DOMException * INVALID_STATE_ERR: Raised if <code>detach()</code> has already been * invoked on this object. * * @since DOM Level 2 */ virtual DOMNode* getEndContainer() const = 0; /** * Offset within the ending node of the Range. * @exception DOMException * INVALID_STATE_ERR: Raised if <code>detach()</code> has already been * invoked on this object. * * @since DOM Level 2 */ virtual XMLSize_t getEndOffset() const = 0; /** * TRUE if the Range is collapsed * @exception DOMException * INVALID_STATE_ERR: Raised if <code>detach()</code> has already been * invoked on this object. * * @since DOM Level 2 */ virtual bool getCollapsed() const = 0; /** * The deepest common ancestor container of the Range's two * boundary-points. * @exception DOMException * INVALID_STATE_ERR: Raised if <code>detach()</code> has already been * invoked on this object. * * @since DOM Level 2 */ virtual const DOMNode* getCommonAncestorContainer() const = 0; // ----------------------------------------------------------------------- // Setter methods // ----------------------------------------------------------------------- /** * Sets the attributes describing the start of the Range. * @param refNode The <code>refNode</code> value. This parameter must be * different from <code>null</code>. * @param offset The <code>startOffset</code> value. * @exception DOMRangeException * INVALID_NODE_TYPE_ERR: Raised if <code>refNode</code> or an ancestor * of <code>refNode</code> is an DOMEntity, DOMNotation, or DOMDocumentType * node. * @exception DOMException * INDEX_SIZE_ERR: Raised if <code>offset</code> is negative or greater * than the number of child units in <code>refNode</code>. Child units * are 16-bit units if <code>refNode</code> is a type of DOMCharacterData * node (e.g., a DOMText or DOMComment node) or a DOMProcessingInstruction * node. Child units are Nodes in all other cases. * <br>INVALID_STATE_ERR: Raised if <code>detach()</code> has already * been invoked on this object. * <br>WRONG_DOCUMENT_ERR: Raised if <code>refNode</code> was created * from a different document than the one that created this range. * * @since DOM Level 2 */ virtual void setStart(const DOMNode *refNode, XMLSize_t offset) = 0; /** * Sets the attributes describing the end of a Range. * @param refNode The <code>refNode</code> value. This parameter must be * different from <code>null</code>. * @param offset The <code>endOffset</code> value. * @exception DOMRangeException * INVALID_NODE_TYPE_ERR: Raised if <code>refNode</code> or an ancestor * of <code>refNode</code> is an DOMEntity, DOMNotation, or DOMDocumentType * node. * @exception DOMException * INDEX_SIZE_ERR: Raised if <code>offset</code> is negative or greater * than the number of child units in <code>refNode</code>. Child units * are 16-bit units if <code>refNode</code> is a type of DOMCharacterData * node (e.g., a DOMText or DOMComment node) or a DOMProcessingInstruction * node. Child units are Nodes in all other cases. * <br>INVALID_STATE_ERR: Raised if <code>detach()</code> has already * been invoked on this object. * <br>WRONG_DOCUMENT_ERR: Raised if <code>refNode</code> was created * from a different document than the one that created this range. * * @since DOM Level 2 */ virtual void setEnd(const DOMNode *refNode, XMLSize_t offset) = 0; /** * Sets the start position to be before a node * @param refNode Range starts before <code>refNode</code> * @exception DOMRangeException * INVALID_NODE_TYPE_ERR: Raised if the root container of * <code>refNode</code> is not an DOMAttr, DOMDocument, or DOMDocumentFragment * node or if <code>refNode</code> is a DOMDocument, DOMDocumentFragment, * DOMAttr, DOMEntity, or DOMNotation node. * @exception DOMException * INVALID_STATE_ERR: Raised if <code>detach()</code> has already been * invoked on this object. * <br>WRONG_DOCUMENT_ERR: Raised if <code>refNode</code> was created * from a different document than the one that created this range. * * @since DOM Level 2 */ virtual void setStartBefore(const DOMNode *refNode) = 0; /** * Sets the start position to be after a node * @param refNode Range starts after <code>refNode</code> * @exception DOMRangeException * INVALID_NODE_TYPE_ERR: Raised if the root container of * <code>refNode</code> is not an DOMAttr, DOMDocument, or DOMDocumentFragment * node or if <code>refNode</code> is a DOMDocument, DOMDocumentFragment, * DOMAttr, DOMEntity, or DOMNotation node. * @exception DOMException * INVALID_STATE_ERR: Raised if <code>detach()</code> has already been * invoked on this object. * <br>WRONG_DOCUMENT_ERR: Raised if <code>refNode</code> was created * from a different document than the one that created this range. * * @since DOM Level 2 */ virtual void setStartAfter(const DOMNode *refNode) = 0; /** * Sets the end position to be before a node. * @param refNode Range ends before <code>refNode</code> * @exception DOMRangeException * INVALID_NODE_TYPE_ERR: Raised if the root container of * <code>refNode</code> is not an DOMAttr, DOMDocument, or DOMDocumentFragment * node or if <code>refNode</code> is a DOMDocument, DOMDocumentFragment, * DOMAttr, DOMEntity, or DOMNotation node. * @exception DOMException * INVALID_STATE_ERR: Raised if <code>detach()</code> has already been * invoked on this object. * <br>WRONG_DOCUMENT_ERR: Raised if <code>refNode</code> was created * from a different document than the one that created this range. * * @since DOM Level 2 */ virtual void setEndBefore(const DOMNode *refNode) = 0; /** * Sets the end of a Range to be after a node * @param refNode Range ends after <code>refNode</code>. * @exception DOMRangeException * INVALID_NODE_TYPE_ERR: Raised if the root container of * <code>refNode</code> is not a DOMAttr, DOMDocument or DOMDocumentFragment * node or if <code>refNode</code> is a DOMDocument, DOMDocumentFragment, * DOMAttr, DOMEntity, or DOMNotation node. * @exception DOMException * INVALID_STATE_ERR: Raised if <code>detach()</code> has already been * invoked on this object. * <br>WRONG_DOCUMENT_ERR: Raised if <code>refNode</code> was created * from a different document than the one that created this range. * * @since DOM Level 2 */ virtual void setEndAfter(const DOMNode *refNode) = 0; // ----------------------------------------------------------------------- // Misc methods // ----------------------------------------------------------------------- /** * Collapse a Range onto one of its boundary-points * @param toStart If TRUE, collapses the Range onto its start; if FALSE, * collapses it onto its end. * @exception DOMException * INVALID_STATE_ERR: Raised if <code>detach()</code> has already been * invoked on this object. * * @since DOM Level 2 */ virtual void collapse(bool toStart) = 0; /** * Select a node and its contents * @param refNode The node to select. * @exception DOMRangeException * INVALID_NODE_TYPE_ERR: Raised if an ancestor of <code>refNode</code> * is an DOMEntity, DOMNotation or DOMDocumentType node or if * <code>refNode</code> is a DOMDocument, DOMDocumentFragment, DOMAttr, DOMEntity, * or DOMNotation node. * @exception DOMException * INVALID_STATE_ERR: Raised if <code>detach()</code> has already been * invoked on this object. * <br>WRONG_DOCUMENT_ERR: Raised if <code>refNode</code> was created * from a different document than the one that created this range. * * @since DOM Level 2 */ virtual void selectNode(const DOMNode *refNode) = 0; /** * Select the contents within a node * @param refNode DOMNode to select from * @exception DOMRangeException * INVALID_NODE_TYPE_ERR: Raised if <code>refNode</code> or an ancestor * of <code>refNode</code> is an DOMEntity, DOMNotation or DOMDocumentType node. * @exception DOMException * INVALID_STATE_ERR: Raised if <code>detach()</code> has already been * invoked on this object. * <br>WRONG_DOCUMENT_ERR: Raised if <code>refNode</code> was created * from a different document than the one that created this range. * * @since DOM Level 2 */ virtual void selectNodeContents(const DOMNode *refNode) = 0; /** * Compare the boundary-points of two Ranges in a document. * @param how A code representing the type of comparison, as defined * above. * @param sourceRange The <code>Range</code> on which this current * <code>Range</code> is compared to. * @return -1, 0 or 1 depending on whether the corresponding * boundary-point of the Range is respectively before, equal to, or * after the corresponding boundary-point of <code>sourceRange</code>. * @exception DOMException * WRONG_DOCUMENT_ERR: Raised if the two Ranges are not in the same * DOMDocument or DOMDocumentFragment. * <br>INVALID_STATE_ERR: Raised if <code>detach()</code> has already * been invoked on this object. * * @since DOM Level 2 */ virtual short compareBoundaryPoints(CompareHow how, const DOMRange* sourceRange) const = 0; /** * Removes the contents of a Range from the containing document or * document fragment without returning a reference to the removed * content. * @exception DOMException * NO_MODIFICATION_ALLOWED_ERR: Raised if any portion of the content of * the Range is read-only or any of the nodes that contain any of the * content of the Range are read-only. * <br>INVALID_STATE_ERR: Raised if <code>detach()</code> has already * been invoked on this object. * * @since DOM Level 2 */ virtual void deleteContents() = 0; /** * Moves the contents of a Range from the containing document or document * fragment to a new DOMDocumentFragment. * @return A DOMDocumentFragment containing the extracted contents. * @exception DOMException * NO_MODIFICATION_ALLOWED_ERR: Raised if any portion of the content of * the Range is read-only or any of the nodes which contain any of the * content of the Range are read-only. * <br>HIERARCHY_REQUEST_ERR: Raised if a DOMDocumentType node would be * extracted into the new DOMDocumentFragment. * <br>INVALID_STATE_ERR: Raised if <code>detach()</code> has already * been invoked on this object. * * @since DOM Level 2 */ virtual DOMDocumentFragment* extractContents() = 0; /** * Duplicates the contents of a Range * @return A DOMDocumentFragment that contains content equivalent to this * Range. * @exception DOMException * HIERARCHY_REQUEST_ERR: Raised if a DOMDocumentType node would be * extracted into the new DOMDocumentFragment. * <br>INVALID_STATE_ERR: Raised if <code>detach()</code> has already * been invoked on this object. * * @since DOM Level 2 */ virtual DOMDocumentFragment* cloneContents() const = 0; /** * Inserts a node into the DOMDocument or DOMDocumentFragment at the start of * the Range. If the container is a DOMText node, this will be split at the * start of the Range (as if the DOMText node's splitText method was * performed at the insertion point) and the insertion will occur * between the two resulting DOMText nodes. Adjacent DOMText nodes will not be * automatically merged. If the node to be inserted is a * DOMDocumentFragment node, the children will be inserted rather than the * DOMDocumentFragment node itself. * @param newNode The node to insert at the start of the Range * @exception DOMException * NO_MODIFICATION_ALLOWED_ERR: Raised if an ancestor container of the * start of the Range is read-only. * <br>WRONG_DOCUMENT_ERR: Raised if <code>newNode</code> and the * container of the start of the Range were not created from the same * document. * <br>HIERARCHY_REQUEST_ERR: Raised if the container of the start of * the Range is of a type that does not allow children of the type of * <code>newNode</code> or if <code>newNode</code> is an ancestor of * the container. * <br>INVALID_STATE_ERR: Raised if <code>detach()</code> has already * been invoked on this object. * @exception DOMRangeException * INVALID_NODE_TYPE_ERR: Raised if <code>newNode</code> is an DOMAttr, * DOMEntity, DOMNotation, or DOMDocument node. * * @since DOM Level 2 */ virtual void insertNode(DOMNode *newNode) = 0; /** * Reparents the contents of the Range to the given node and inserts the * node at the position of the start of the Range. * @param newParent The node to surround the contents with. * @exception DOMException * NO_MODIFICATION_ALLOWED_ERR: Raised if an ancestor container of * either boundary-point of the Range is read-only. * <br>WRONG_DOCUMENT_ERR: Raised if <code> newParent</code> and the * container of the start of the Range were not created from the same * document. * <br>HIERARCHY_REQUEST_ERR: Raised if the container of the start of * the Range is of a type that does not allow children of the type of * <code>newParent</code> or if <code>newParent</code> is an ancestor * of the container or if <code>node</code> would end up with a child * node of a type not allowed by the type of <code>node</code>. * <br>INVALID_STATE_ERR: Raised if <code>detach()</code> has already * been invoked on this object. * @exception DOMRangeException * BAD_BOUNDARYPOINTS_ERR: Raised if the Range partially selects a * non-text node. * <br>INVALID_NODE_TYPE_ERR: Raised if <code> node</code> is an DOMAttr, * DOMEntity, DOMDocumentType, DOMNotation, DOMDocument, or DOMDocumentFragment node. * * @since DOM Level 2 */ virtual void surroundContents(DOMNode *newParent) = 0; /** * Produces a new Range whose boundary-points are equal to the * boundary-points of the Range. * @return The duplicated Range. * @exception DOMException * INVALID_STATE_ERR: Raised if <code>detach()</code> has already been * invoked on this object. * * @since DOM Level 2 */ virtual DOMRange* cloneRange() const = 0; /** * Returns the contents of a Range as a string. This string contains only * the data characters, not any markup. * @return The contents of the Range. * @exception DOMException * INVALID_STATE_ERR: Raised if <code>detach()</code> has already been * invoked on this object. * * @since DOM Level 2 */ virtual const XMLCh* toString() const = 0; /** * Called to indicate that the Range is no longer in use and that the * implementation may relinquish any resources associated with this * Range. Subsequent calls to any methods or attribute getters on this * Range will result in a <code>DOMException</code> being thrown with an * error code of <code>INVALID_STATE_ERR</code>. * @exception DOMException * INVALID_STATE_ERR: Raised if <code>detach()</code> has already been * invoked on this object. * * @since DOM Level 2 */ virtual void detach() = 0; //@} // ----------------------------------------------------------------------- // Non-standard Extension // ----------------------------------------------------------------------- /** @name Non-standard Extension */ //@{ /** * Called to indicate that this Range is no longer in use * and that the implementation may relinquish any resources associated with it. * (release() will call detach() where appropriate) * * Access to a released object will lead to unexpected result. */ virtual void release() = 0; //@} }; XERCES_CPP_NAMESPACE_END #endif
[ [ [ 1, 529 ] ] ]
67aa302bf6e1c6e5a22220d5c536a0f0fcc03bd5
c95a83e1a741b8c0eb810dd018d91060e5872dd8
/Game/ClientShellDLL/ClientShellShared/WeaponChooser.cpp
11d9811779a92cf10b4e94b270986e88a3cf89b9
[]
no_license
rickyharis39/nolf2
ba0b56e2abb076e60d97fc7a2a8ee7be4394266c
0da0603dc961e73ac734ff365bfbfb8abb9b9b04
refs/heads/master
2021-01-01T17:21:00.678517
2011-07-23T12:11:19
2011-07-23T12:11:19
38,495,312
1
0
null
null
null
null
UTF-8
C++
false
false
7,503
cpp
// ----------------------------------------------------------------------- // // // MODULE : WeaponChooser.cpp // // PURPOSE : In-game popup for choosing weapons // // (c) 1997-2001 Monolith Productions, Inc. All Rights Reserved // // ----------------------------------------------------------------------- // #include "stdafx.h" #include "WeaponChooser.h" #include "InterfaceMgr.h" #include "GameClientShell.h" #include "WinUtil.h" #include "SoundMgr.h" #include "LayoutMgr.h" #include "ClientWeaponBase.h" #include "ClientWeaponMgr.h" extern CGameClientShell* g_pGameClientShell; namespace { const int kLastAmmo = 1; const int kCurrWeapon = 1; const int kCurrAmmo = 0; const float kfDelayTime = 15.0f; VarTrack g_vtChooserAutoSwitchTime; VarTrack g_vtChooserAutoSwitchFreq; } ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CWeaponChooser::CWeaponChooser() { m_nWeapon = -1; m_nClass = 0; m_bIsOpen = false; } CWeaponChooser::~CWeaponChooser() { } void CWeaponChooser::Init() { g_vtChooserAutoSwitchTime.Init(g_pLTClient, "ChooserAutoSwitchTime", NULL, 0.175f); g_vtChooserAutoSwitchFreq.Init(g_pLTClient, "ChooserAutoSwitchFreq", NULL, 0.1f); } void CWeaponChooser::Term() { if (m_bIsOpen) Close(); } bool CWeaponChooser::Open(uint8 nClass) { if (m_bIsOpen && nClass == m_nClass) return true; CClientWeaponMgr const *pClientWeaponMgr = g_pPlayerMgr->GetClientWeaponMgr(); IClientWeaponBase const *pClientWeapon = pClientWeaponMgr->GetCurrentClientWeapon(); if( !pClientWeapon ) return false; if (!m_bIsOpen) m_nWeapon = pClientWeapon->GetWeaponId(); uint8 nWeapon = pClientWeaponMgr->GetNextWeaponId( m_nWeapon, nClass ); if (!g_pWeaponMgr->IsValidWeaponId(nWeapon) && g_pWeaponMgr->GetWeaponClass(m_nWeapon) != nClass ) { if (!m_bIsOpen) m_nWeapon = -1; g_pHUDMgr->QueueUpdate(kHUDChooser); return false; } m_bIsOpen = true; m_nClass = nClass; m_AutoCloseTimer.Start(kfDelayTime); g_pHUDMgr->QueueUpdate(kHUDChooser); return true; } void CWeaponChooser::Close() { if (!m_bIsOpen) return; m_bIsOpen = false; m_nClass = 0; m_AutoCloseTimer.Stop(); m_AutoSwitchTimer.Stop(); m_NextWeaponKeyDownTimer.Stop(); m_PrevWeaponKeyDownTimer.Stop(); if (g_pHUDMgr) g_pHUDMgr->QueueUpdate(kHUDChooser); } void CWeaponChooser::NextWeapon(uint8 nClass) { if (nClass > g_pWeaponMgr->GetNumWeaponClasses()) nClass = m_nClass; // get the next avail weapon uint8 nWeapon = g_pPlayerMgr->GetClientWeaponMgr()->GetNextWeaponId( m_nWeapon, nClass ); if (g_pWeaponMgr->IsValidWeaponId(nWeapon) ) m_nWeapon = nWeapon; g_pClientSoundMgr->PlayInterfaceSound((char*)g_pInterfaceResMgr->GetSoundSelect()); m_AutoCloseTimer.Start(kfDelayTime); m_NextWeaponKeyDownTimer.Start(g_vtChooserAutoSwitchTime.GetFloat()); g_pHUDMgr->QueueUpdate(kHUDChooser); } void CWeaponChooser::PrevWeapon() { // get the prev avail weapon uint8 nWeapon = g_pPlayerMgr->GetClientWeaponMgr()->GetPrevWeaponId( m_nWeapon, m_nClass ); if (g_pWeaponMgr->IsValidWeaponId(nWeapon) ) m_nWeapon = nWeapon; g_pClientSoundMgr->PlayInterfaceSound((char*)g_pInterfaceResMgr->GetSoundSelect()); m_AutoCloseTimer.Start(kfDelayTime); m_PrevWeaponKeyDownTimer.Start(g_vtChooserAutoSwitchTime.GetFloat()); g_pHUDMgr->QueueUpdate(kHUDChooser); } void CWeaponChooser::EndAutoSwitch(bool bNextWeaponKey) { if (bNextWeaponKey) m_NextWeaponKeyDownTimer.Stop(); else m_PrevWeaponKeyDownTimer.Stop(); m_AutoSwitchTimer.Stop(); } void CWeaponChooser::Update() { // If Weapon chooser is being drawn, see if we want to change weapons... if (!IsOpen()) return; // See if we should close ourselves... if (m_AutoCloseTimer.On() && m_AutoCloseTimer.Stopped()) { g_pClientSoundMgr->PlayInterfaceSound((char*)g_pInterfaceResMgr->GetSoundSelect()); Close(); } else if (m_NextWeaponKeyDownTimer.On() && m_NextWeaponKeyDownTimer.Stopped()) { // See if we should switch to the next weapon... if (m_AutoSwitchTimer.On()) { if (m_AutoSwitchTimer.Stopped()) { NextWeapon(-1); m_AutoSwitchTimer.Start(g_vtChooserAutoSwitchFreq.GetFloat()); } } else { m_AutoSwitchTimer.Start(g_vtChooserAutoSwitchFreq.GetFloat()); } } else if (m_PrevWeaponKeyDownTimer.On() && m_PrevWeaponKeyDownTimer.Stopped()) { if (m_PrevWeaponKeyDownTimer.On()) { if (m_AutoSwitchTimer.Stopped()) { PrevWeapon(); m_AutoSwitchTimer.Start(g_vtChooserAutoSwitchFreq.GetFloat()); } } else { m_AutoSwitchTimer.Start(g_vtChooserAutoSwitchFreq.GetFloat()); } } } ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CAmmoChooser::CAmmoChooser() { m_nAmmo = -1; m_bIsOpen = false; } CAmmoChooser::~CAmmoChooser() { } void CAmmoChooser::Init() { } void CAmmoChooser::Term() { if (m_bIsOpen) Close(); } bool CAmmoChooser::Open() { // Don't allow the chooser to be opened if we're selecting/deselecting a // weapon... IClientWeaponBase *pClientWeapon = g_pPlayerMgr->GetCurrentClientWeapon(); WeaponState eState = pClientWeapon->GetState(); if (W_DESELECT == eState || W_SELECT == eState) return false; if (m_bIsOpen) return true; m_nAmmo = pClientWeapon->GetAmmoId(); if (m_nAmmo == pClientWeapon->GetNextAvailableAmmo()) { m_nAmmo = -1; m_bIsOpen = false; return false; } m_bIsOpen = true; m_AutoCloseTimer.Start(kfDelayTime); g_pHUDMgr->QueueUpdate(kHUDChooser); return true; } void CAmmoChooser::Close() { if (!m_bIsOpen) return; m_bIsOpen = false; m_AutoCloseTimer.Stop(); m_AutoSwitchTimer.Stop(); m_NextAmmoKeyDownTimer.Stop(); if (g_pHUDMgr) g_pHUDMgr->QueueUpdate(kHUDChooser); } void CAmmoChooser::NextAmmo() { IClientWeaponBase *pClientWeapon = g_pPlayerMgr->GetCurrentClientWeapon(); if ( !pClientWeapon ) { return; } m_nAmmo = pClientWeapon->GetNextAvailableAmmo(m_nAmmo); g_pClientSoundMgr->PlayInterfaceSound((char*)g_pInterfaceResMgr->GetSoundSelect()); m_AutoCloseTimer.Start(kfDelayTime); m_NextAmmoKeyDownTimer.Start(g_vtChooserAutoSwitchTime.GetFloat()); g_pHUDMgr->QueueUpdate(kHUDChooser); } void CAmmoChooser::EndAutoSwitch() { m_NextAmmoKeyDownTimer.Stop(); m_AutoSwitchTimer.Stop(); } void CAmmoChooser::Update() { // If Weapon chooser is being drawn, see if we want to change weapons... if (!IsOpen()) return; // See if we should close ourselves... // See if we should switch to the next ammo type... if (m_AutoCloseTimer.On() && m_AutoCloseTimer.Stopped()) { g_pClientSoundMgr->PlayInterfaceSound((char*)g_pInterfaceResMgr->GetSoundSelect()); Close(); } else if (m_NextAmmoKeyDownTimer.On() && m_NextAmmoKeyDownTimer.Stopped()) { if (m_AutoSwitchTimer.On()) { if (m_AutoSwitchTimer.Stopped()) { NextAmmo(); m_AutoSwitchTimer.Start(g_vtChooserAutoSwitchFreq.GetFloat()); } } else { m_AutoSwitchTimer.Start(g_vtChooserAutoSwitchFreq.GetFloat()); } } }
[ [ [ 1, 321 ] ] ]
e35728907b1e762771966bf6f5325f99a1c446b4
06b2d2df5f39e37b74b68a56381c7eabb8c44e3c
/[NEXE]TransformImage.cpp
630d877797abdcf91e91c862caf5f0b6f571c3eb
[]
no_license
wonjb/wprobot
e6ccf1badcd1801d9a1be4b8aba7a05b5c8f296b
5f1a133c1681925f028514dd2d86d03947471bee
refs/heads/master
2021-01-01T05:40:23.339929
2008-09-05T09:12:48
2008-09-05T09:12:48
34,102,331
0
0
null
null
null
null
UHC
C++
false
false
10,438
cpp
#include "StdAfx.h" #include "TransformImage.h" #include "Stack.h" #include <vector> #ifdef _DEBUG #define new DEBUG_NEW #endif #define WINNAME "Binary Test" CTransformImage::CTransformImage(void) : m_image(NULL), m_transImage(NULL) { cvNamedWindow(WINNAME); } CTransformImage::~CTransformImage(void) { if(!m_image) cvReleaseImage(&m_image); if(!m_transImage) cvReleaseImage(&m_transImage); } void CTransformImage::setDC(CDC* dc) { m_pDC = dc; } void CTransformImage::setOriginImage(IplImage* image) { m_image = image; // setOriginImage 호출 후, 반드시 ThresholdYCbCr를 호출해야 함 } void CTransformImage::drawTransImage(int x, int y, int width, int height) { // CvvImage image; // image.CopyOf(m_transImage, m_transImage->nChannels*8); // image.Show(m_pDC->GetSafeHdc(), x, y, width, height); cvShowImage(WINNAME, m_transImage); } void CTransformImage::ThresholdYCbCr(int cbmin /*= 77*/, int cbmax /*= 127*/, int crmin /*= 133*/, int crmax /*= 173*/) { if(m_transImage) cvReleaseImage(&m_transImage); m_transImage = cvCreateImage(cvSize(240,180), IPL_DEPTH_8U, 1); int height = 180; // 180 : 새로운 height int width = 240; // 240 : 새로운 width int step = m_image->widthStep; // 이 줄이 없으면 이미지가 거꾸로 출력됨 // m_transImage 의 origin 과 m_image 의 origin 을 일치시켜줌 m_transImage->origin = m_image->origin; unsigned char r, g, b; double y, cb, cr; for(int i = 0, pastI = 60; i < height; ++i, ++pastI) { for(int j = 0; j < width; ++j) { // 컬러영상은 안에 b,g,r order 저장 r = m_image->imageData[pastI*step+j*3+2]; g = m_image->imageData[pastI*step+j*3+1]; b = m_image->imageData[pastI*step+j*3+0]; // R, G, B 값을 읽어들여 Y, Cb, Cr 로 변환하는 식 y = 0.299*r+0.587*g+0.114*b; cb = (b-y)*0.564+128; cr = (r-y)*0.713+128; // 살색의 임계값으로 Skin region 찾음 if( (cb >= cbmin && cb <= cbmax) && (cr >= crmin && cr <= crmax) ) m_transImage->imageData[i*width+j] = (unsigned char)255; else m_transImage->imageData[i*width+j] = 0; } } } void CTransformImage::Labeling() { int height = m_transImage->height; int width = m_transImage->width; // 반복문을 이용한 라벨링 // 지나간 곳을 저장하기 위해 메모리 할당 int* visited = new int[height*width]; memset( visited, 0, height*width*sizeof(int) ); // 삭제할 것을 담을 벡터 std::vector<int> deleted; cSTACK stack; stack.setSize(height*width); short r, c, curColor = 0; int iByWidth, mByWidth, area; unsigned char ch; for(int i = 0; i < height; ++i) { iByWidth = i*width; for(int j = 0; j < width; ++j) { ch = m_transImage->imageData[iByWidth+j]; if(visited[iByWidth+j] != 0 || ch != 255) // 지나갔던 점이거나 까만점이면 continue; stack.setEmpty(); area = 1; r = i, c = j; curColor++; while(1) { GRASSFIRE: for(int m = r-1; m <= r+1; ++m) // y축 { mByWidth = m*width; for(int n = c-1; n <= c+1; ++n) // x축 { if(m < 0 || m >= height || n < 0 || n >= width) continue; ch = m_transImage->imageData[mByWidth+n]; if(ch == 255 && visited[mByWidth+n] == 0) { visited[mByWidth+n] = curColor; if(!stack.push(n,m)) continue; r = m, c = n; area++; goto GRASSFIRE; } } } if(!stack.pop(&c, &r)) break; } deleted.push_back(area); } } for(int i = 0; i < height; ++i) { iByWidth = i*width; for(int j = 0; j < width; ++j) { ch = m_transImage->imageData[iByWidth+j]; if(ch != 255) // 까만점이면 continue; if(deleted[visited[iByWidth+j]-1] < 1000) m_transImage->imageData[iByWidth+j] = 0; } } delete[] visited; } void CTransformImage::Morphology() { if(!m_transImage) return; IplConvKernel* element = cvCreateStructuringElementEx(3, 3, 1, 1, CV_SHAPE_RECT, NULL); cvDilate(m_transImage, m_transImage, element, 1); cvDilate(m_transImage, m_transImage, element, 1); cvErode (m_transImage, m_transImage, element, 1); cvErode (m_transImage, m_transImage, element, 1); cvReleaseStructuringElement(&element); } void CTransformImage::drawHandLine() { if(!m_transImage) return; CvMemStorage* storage = cvCreateMemStorage(0); CvSeq* contours = 0; cvFindContours(m_transImage, storage, &contours, sizeof(CvContour), CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE); // Drawing image, point, external color, internal color, ?, thickness, linetype, offset cvDrawContours(m_image, contours, CV_RGB(255,242,0), CV_RGB(255,242,0), 1, 2, CV_AA); cvReleaseMemStorage(&storage); } CvPoint CTransformImage::findCenter() { IplImage* dist8u = cvCloneImage(m_transImage); IplImage* dist32f = cvCreateImage(cvGetSize(m_transImage), IPL_DEPTH_32F, 1); IplImage* dist32s = cvCreateImage(cvGetSize(m_transImage), IPL_DEPTH_32S, 1); // 거리 변환 행렬 float mask[3] = {1.f, 1.5f, 0}; // 거리 변환 함수 사용 cvDistTransform(m_transImage, dist32f, CV_DIST_USER, 3, mask, NULL); // 눈에 보이게 변환 cvConvertScale(dist32f, dist32f, 1000, 0); cvPow(dist32f, dist32f, 0.5); cvConvertScale(dist32f, dist32s, 1.0, 0.5); cvAndS(dist32s, cvScalarAll(255), dist32s, 0); cvConvertScale(dist32s, dist8u, 1, 0); // 가장 큰 좌표를 찾는다 int max; for(int i = max = 0; i < dist8u->height; ++i) { int index = i * dist8u->widthStep; for(int j = 0; j < dist8u->width; ++j) { if((unsigned char)dist8u->imageData[index+j] > max) { max = (unsigned char)dist8u->imageData[index+j]; m_center.x = j, m_center.y = i; } } } cvReleaseImage(&dist8u); cvReleaseImage(&dist32f); cvReleaseImage(&dist32s); if(m_center.x < 0 || m_center.y < 0) m_center.x = 0, m_center.y = 0; CvBox2D box; box.center = cvPoint2D32f(m_center.x, m_center.y); box.size = cvSize2D32f(3, 3); box.angle = 90; cvEllipseBox(m_image, box, CV_RGB(255,242,0), 3); return m_center; } CHandPoint CTransformImage::findFinger() { findCenter(); if(!m_transImage) return CHandPoint(); int width = m_transImage->width; int height = 180; int moveX = 0, moveY = height; BOOL bClick = FALSE, bWheel = FALSE; unsigned char ch; for(int y = m_center.y; y < height; ++y) { for(int x = m_center.x-100; x < m_center.x+50; ++x) { if(x < 0 || x >= width || y < 0 || y >= height) continue; ch = m_transImage->imageData[y*width+x]; if(ch == 255) { moveX = x, moveY = y; if(x < m_center.x-50) bClick = TRUE; break; } // CvBox2D box; // box.center = cvPoint2D32f(x, y); // box.size = cvSize2D32f(2, 2); // box.angle = 90; // cvEllipseBox(m_image, box, CV_RGB(0,255,255), 1); } if(moveY != y) break; } // 좌표가 조금씩 흔들리는 것을 방지하기 위한 부분 if(abs(m_pastPt.x-moveX) < 2 || abs(m_pastPt.y-moveY) < 2) moveX = m_pastPt.x, moveY = m_pastPt.y; m_pastPt.x = moveX, m_pastPt.y = moveY; CvBox2D box; box.center = cvPoint2D32f(moveX, moveY); box.size = cvSize2D32f(2, 2); box.angle = 90; cvEllipseBox(m_image, box, CV_RGB(0,255,0), 1); return CHandPoint(moveX, height-moveY, bClick, bWheel); } void CTransformImage::deleteHole() { CvPoint st, ed; int height = m_transImage->height; int width = m_transImage->width; unsigned char ch, pastCh = 255; for(int y = 0; y < height; ++y) { st = ed = cvPoint(0,0); for(int x = 0; x < width; ++x) { ch = m_transImage->imageData[y*width+x]; if(pastCh == 0 && ch == 255) st.x = x, st.y = y; else if(st.x != 0 && pastCh == 255 && ch == 0) ed.x = x, ed.y = y; pastCh = ch; } if(ed.x - st.x > 150) continue; for(int x = st.x; x < ed.x; ++x) m_transImage->imageData[y*width+x] = 255; } } CHandPoint CTransformImage::findFingerInfo() { if(!m_transImage) return CHandPoint(); findCenter(); CHandPoint handPt; std::vector<CvPoint> ptList; double pi = 3.1415; int width = m_transImage->width; int fingerCnt = 0; int x, y, radius = 80; unsigned char ch, pastCh = 0; for(double theta = 180; theta <= 360; ++theta) { x = (int)(m_center.x + radius*cos(theta*pi/180)); y = (int)(m_center.y - radius*sin(theta*pi/180)); ch = m_transImage->imageData[y*width+x]; if(ch == 255 && pastCh == 0) // Counting Finger ptList.push_back(cvPoint(x,y)), ++fingerCnt; pastCh = ch; // Draw OutLine CvBox2D box; box.center = cvPoint2D32f(x, y); box.size = cvSize2D32f(1, 1); box.angle = 90; cvEllipseBox(m_image, box, CV_RGB(255,242,0), 1); } // handPt Setting float dist = 0, dist2 = 0; switch(fingerCnt) { case 0: handPt.m_mode = CHandPoint::CLEAR; break; case 1: handPt.m_mode = CHandPoint::MOVE; findEndPoint(&handPt.m_nX, &handPt.m_nY); break; case 2: { CvPoint a = ptList[0], b = ptList[1]; float dist = sqrt((float)(abs(a.x-b.x)*abs(a.x-b.x) + abs(a.y-b.y)*abs(a.y-b.y))); if(dist < 70) // DRAW mode { handPt.m_mode = CHandPoint::CIRCLE; handPt.m_nX = m_center.x, handPt.m_nY = m_center.y; } else { handPt.m_mode = CHandPoint::DRAW; findEndPoint(&handPt.m_nX, &handPt.m_nY); } } break; case 3: { CvPoint a = ptList[0], b = ptList[1], c = ptList[2]; dist = sqrt((float)(abs(a.x-b.x)*abs(a.x-b.x) + abs(a.y-b.y)*abs(a.y-b.y))); dist2 = sqrt((float)(abs(c.x-b.x)*abs(c.x-b.x) + abs(c.y-b.y)*abs(c.y-b.y))); if(abs(dist-dist2) < 10) { handPt.m_mode = CHandPoint::TRIANGE; handPt.m_nX = m_center.x, handPt.m_nY = m_center.y; } else { handPt.m_mode = CHandPoint::SETTING; } } break; case 4: handPt.m_mode = CHandPoint::RECT; handPt.m_nX = m_center.x, handPt.m_nY = m_center.y; break; case 5: handPt.m_mode = CHandPoint::STAR; handPt.m_nX = m_center.x, handPt.m_nY = m_center.y; break; default: handPt.m_mode = CHandPoint::NOTHING; break; } TCHAR buf[256] = {0,}; swprintf(buf, sizeof(buf), _T("%d\t%f\n"), fingerCnt, dist); ::OutputDebugString(buf); return handPt; }
[ "[email protected]@d3b47800-9755-0410-939a-5b8eb3d84ce7" ]
[ [ [ 1, 412 ] ] ]
8bd320b361824bf51899f0dc745dfcc00bf43c4c
073dfce42b384c9438734daa8ee2b575ff100cc9
/RCF/include/RCF/util/Platform/Threads/RcfBoostThreads.hpp
2815fe6cfc0b05b7716d447bbdeb4c0f14ab0066
[]
no_license
r0ssar00/iTunesSpeechBridge
a489426bbe30ac9bf9c7ca09a0b1acd624c1d9bf
71a27a52e66f90ade339b2b8a7572b53577e2aaf
refs/heads/master
2020-12-24T17:45:17.838301
2009-08-24T22:04:48
2009-08-24T22:04:48
285,393
1
0
null
null
null
null
UTF-8
C++
false
false
7,487
hpp
//****************************************************************************** // RCF - Remote Call Framework // Copyright (c) 2005 - 2009, Jarl Lindrud. All rights reserved. // Consult your license for conditions of use. // Version: 1.1 // Contact: jarl.lindrud <at> gmail.com //****************************************************************************** #ifndef INCLUDE_UTIL_PLATFORM_THREADS_RCFBOOSTTHREADS_HPP #define INCLUDE_UTIL_PLATFORM_THREADS_RCFBOOSTTHREADS_HPP #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable : 4275 ) // warning C4275: non dll-interface class 'std::runtime_error' used as base for dll-interface class 'boost::thread_resource_error' #pragma warning( disable : 4251 ) // warning C4251: 'boost::thread_group::m_threads' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'boost::thread_group' #endif #include <boost/noncopyable.hpp> #include <RCF/RcfBoostThreads/RcfBoostThreads.hpp> #ifdef _MSC_VER #pragma warning( pop ) #endif #include <RCF/util/DefaultInit.hpp> #include <RCF/util/UnusedVariable.hpp> namespace Platform { namespace Threads { typedef RCF::RcfBoostThreads::boost::thread thread; typedef RCF::RcfBoostThreads::boost::thread_group thread_group; template<typename T> struct thread_specific_ptr { typedef RCF::RcfBoostThreads::boost::thread_specific_ptr<T> Val; }; typedef RCF::RcfBoostThreads::boost::mutex mutex; typedef RCF::RcfBoostThreads::boost::try_mutex try_mutex; class condition : boost::noncopyable { public: template<typename T> void wait(const T &t) { mCondition.wait(t); } template<typename T> bool timed_wait(const T &t, int timeoutMs) { RCF::RcfBoostThreads::boost::xtime xt; RCF::RcfBoostThreads::boost::xtime_get(&xt, RCF::RcfBoostThreads::boost::TIME_UTC); xt.sec += timeoutMs / 1000; xt.nsec += 1000*(timeoutMs - 1000*(timeoutMs / 1000)); return mCondition.timed_wait(t, xt); } void notify_one() { mCondition.notify_one(); } void notify_all() { mCondition.notify_all(); } private: RCF::RcfBoostThreads::boost::condition mCondition; }; // simple drop in replacement for boost::read_write_mutex, until there's a final version in boost.threads enum read_write_scheduling_policy { writer_priority , reader_priority , alternating_many_reads , alternating_single_read }; class read_write_mutex; namespace detail { class scoped_read_lock : boost::noncopyable { public: scoped_read_lock(read_write_mutex &rwm); ~scoped_read_lock(); void lock(); void unlock(); private: typedef mutex::scoped_lock scoped_lock; read_write_mutex & rwm; bool locked; }; class scoped_write_lock : boost::noncopyable { public: scoped_write_lock(read_write_mutex &rwm); ~scoped_write_lock(); void lock(); void unlock(); private: typedef mutex::scoped_lock scoped_lock; read_write_mutex & rwm; scoped_lock readLock; scoped_lock writeLock; bool locked; }; } // namespace detail class read_write_mutex : boost::noncopyable { public: read_write_mutex(read_write_scheduling_policy rwsp) : readerCount(RCF_DEFAULT_INIT) { RCF_UNUSED_VARIABLE(rwsp); } private: typedef mutex::scoped_lock scoped_lock; void waitOnReadUnlock(scoped_lock &lock) { readUnlockEvent.wait(lock); } void notifyReadUnlock() { readUnlockEvent.notify_all(); } mutex readMutex; mutex writeMutex; condition readUnlockEvent; int readerCount; public: typedef detail::scoped_read_lock scoped_read_lock; typedef detail::scoped_write_lock scoped_write_lock; friend class detail::scoped_read_lock; friend class detail::scoped_write_lock; }; namespace detail { inline scoped_read_lock::scoped_read_lock(read_write_mutex &rwm) : rwm(rwm), locked(RCF_DEFAULT_INIT) { lock(); } inline scoped_read_lock::~scoped_read_lock() { unlock(); } inline void scoped_read_lock::lock() { if (!locked) { { scoped_lock lock( rwm.readMutex ); ++rwm.readerCount; } locked = true; } } inline void scoped_read_lock::unlock() { if (locked) { { scoped_lock lock( rwm.readMutex ); --rwm.readerCount; rwm.notifyReadUnlock(); } locked = false; } } inline scoped_write_lock::scoped_write_lock(read_write_mutex &rwm) : rwm(rwm), readLock(rwm.readMutex, false), writeLock(rwm.writeMutex, false), locked(RCF_DEFAULT_INIT) { lock(); } inline scoped_write_lock::~scoped_write_lock() { unlock(); } inline void scoped_write_lock::lock() { if (!locked) { readLock.lock(); while (rwm.readerCount > 0) { rwm.waitOnReadUnlock(readLock); } writeLock.lock(); locked = true; } } inline void scoped_write_lock::unlock() { if (locked) { writeLock.unlock(); readLock.unlock(); locked = false; } } } // namespace detail } // namespace Threads } // namespace Platform #endif // ! INCLUDE_UTIL_PLATFORM_THREADS_RCFBOOSTTHREADS_HPP
[ [ [ 1, 232 ] ] ]
dcfec9845e7ac5b1bf4393c3453770ab7723b3b5
6e4f9952ef7a3a47330a707aa993247afde65597
/PROJECTS_ROOT/WireKeys/WP_WTraits/DLGOptions.cpp
9f952c9caae254630c3f98757a55ae7f29b9c1d7
[]
no_license
meiercn/wiredplane-wintools
b35422570e2c4b486c3aa6e73200ea7035e9b232
134db644e4271079d631776cffcedc51b5456442
refs/heads/master
2021-01-19T07:50:42.622687
2009-07-07T03:34:11
2009-07-07T03:34:11
34,017,037
2
1
null
null
null
null
WINDOWS-1251
C++
false
false
6,555
cpp
// DLGOptions.cpp : implementation file // #include "stdafx.h" #include "HookCode.h" #include "WP_WTraits.h" #include "DLGOptions.h" extern CWKHekperInfo hookData; #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif HWND hOpenedOptions=0; const char* aWays[]={"Tray", "Minimize", "Hide", "Rollup", "Floater", "Close"}; static BOOL bAutoHideTextEmptyOnDialogOpen=0; char g_szStartUpWindowName[256]={0}; WKCallbackInterface*& WKGetPluginContainer(); int CALLBACK OptionsDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { if(uMsg==WM_INITDIALOG){ ::SetWindowLong(hwndDlg,GWL_EXSTYLE,WS_EX_APPWINDOW|::GetWindowLong(hwndDlg,GWL_EXSTYLE)); PostMessage(::GetDesktopWindow(), WM_SYSCOMMAND, (WPARAM) SC_HOTKEY, (LPARAM)hwndDlg); hOpenedOptions=hwndDlg; // Локализация ::SetWindowText(GetDlgItem(hwndDlg,IDC_STATIC99),_pl("WiredPlane.com @2008")); ::SetWindowText(GetDlgItem(hwndDlg,IDC_MIN2),_pl("Hide to tray inactive windows")); ::SetWindowText(GetDlgItem(hwndDlg,IDC_STATIC4),_pl("Description: Place one title per line (Use '*' as a wildcard for partial matches). Prefix title with action type to modify plugin behaviour. Valid prefixes are: 'Minimize', 'Hide', 'Rollup', 'Tray', 'Floater' and 'Close'. Default is 'Tray' - application will be hidden to tray. Example: Minimize: *Bat!")); ::SetWindowText(GetDlgItem(hwndDlg,IDC_STATIC5),_pl("sec")); ::SetWindowText(GetDlgItem(hwndDlg,IDOPTIONS),_pl("Options")); ::SetWindowText(GetDlgItem(hwndDlg,IDC_STATICP),_pl("Inactivity period")); ::SetWindowText(GetDlgItem(hwndDlg,IDC_STATIC_ADDT),_pl("Window title")); ::SetWindowText(GetDlgItem(hwndDlg,IDC_BUTTON_ADD),_pl("Add")); ::SetWindowText(GetDlgItem(hwndDlg,IDC_STATIC_RDSC),_pl("To remove application entry, simply remove its title from text boxes above")); ::SetWindowText(GetDlgItem(hwndDlg,IDC_STATIC_RDSC2),_pl("Tips: You can use '*' for partial match. Delimit titles with ';'")); ::SetWindowText(GetDlgItem(hwndDlg,IDC_STATIC_ADDF),_pl("Add new window title")); ::SetWindowText(GetDlgItem(hwndDlg,IDC_STATIC_AH_TRAY),_pl("Enter titles of applications that should minimize to the tray (not taskbar)")); ::SetWindowText(GetDlgItem(hwndDlg,IDC_STATIC_AH_FL),_pl("Enter titles of applications that should minimize to the floater (not taskbar)")); ::SetWindowText(GetDlgItem(hwndDlg,IDC_STATIC_SBLOCK),_pl("Manual minimization")); ::SetWindowText(hwndDlg,_pl("Window`s traits plugin")); // Инициализация if(strlen(g_szStartUpWindowName)==0){ strcpy(g_szStartUpWindowName,"*"); } ::SetWindowText(GetDlgItem(hwndDlg,IDC_EDIT_NEWT),g_szStartUpWindowName); g_szStartUpWindowName[0]=0; ::SendMessage(GetDlgItem(hwndDlg,IDC_MIN2), BM_SETCHECK, hookData.bCatchAutoMinimize, 0); ::SetWindowText(GetDlgItem(hwndDlg,IDC_EDIT2),hookData.szAutoMinimizeTitle); ::SetWindowText(GetDlgItem(hwndDlg,IDC_EDIT3),hookData.szAutoMinToTray); ::SetWindowText(GetDlgItem(hwndDlg,IDC_EDIT4),hookData.szAutoMinToFloat); char szNumber[128]={0}; sprintf(szNumber,"%lu",hookData.iINACTSEC); ::SetWindowText(GetDlgItem(hwndDlg,IDC_INACTSEC),szNumber); if(strlen(hookData.szAutoMinimizeTitle)==0){ bAutoHideTextEmptyOnDialogOpen=TRUE; }else{ bAutoHideTextEmptyOnDialogOpen=FALSE; } for(int i2=5;i2>=0;i2--){ ::SendMessage(GetDlgItem(hwndDlg,IDC_COMBO_WAYS),CB_ADDSTRING,0,(LPARAM)(const char*)_pl(aWays[i2])); } ::SendMessage(GetDlgItem(hwndDlg,IDC_COMBO_WAYS), CB_SETCURSEL, 5, 0); } if(uMsg==WM_KEYDOWN){ if(GetKeyState(VK_CONTROL)<0){ if(wParam==VK_RETURN){ uMsg=WM_COMMAND; wParam=IDOK; } } } /* if(uMsg==WM_NOTIFY && wParam==IDC_TABS && lParam){ NMHDR* hNm=(NMHDR*)lParam; if(hNm->code==TCN_SELCHANGE){ ShowPage(TabCtrl_GetCurSel(GetDlgItem(hwndDlg,IDC_TABS)),hwndDlg); } } */ if(uMsg==WM_COMMAND && wParam==IDOPTIONS){ WKGetPluginContainer()->ShowPluginPrefernces(); return TRUE; } if(uMsg==WM_COMMAND && wParam==IDC_BUTTON_ADD){ char szNumber[128]={0}; GetWindowText(GetDlgItem(hwndDlg,IDC_EDIT_NEWT),szNumber,sizeof(szNumber)); if(strcmp(szNumber,"*")==0){ MessageBox(0,_pl("Enter window title first"),"Windows helper",0); }else{ int iType=(int)::SendMessage(GetDlgItem(hwndDlg,IDC_COMBO_WAYS), CB_GETCURSEL, 0, 0); if(strlen(szNumber)>0 && iType!=CB_ERR){ char szAddText[sizeof(hookData.szAutoMinimizeTitle)]={0}; strcpy(szAddText,aWays[5-iType]); strcat(szAddText,": "); strcat(szAddText,szNumber); strcat(szAddText,"\r\n"); memset(hookData.szAutoMinimizeTitle,0,sizeof(hookData.szAutoMinimizeTitle)); GetWindowText(GetDlgItem(hwndDlg,IDC_EDIT2),hookData.szAutoMinimizeTitle,sizeof(hookData.szAutoMinimizeTitle)-1); if(strlen(hookData.szAutoMinimizeTitle)+strlen(szAddText)<sizeof(hookData.szAutoMinimizeTitle)){ strcat(szAddText,hookData.szAutoMinimizeTitle); SetWindowText(GetDlgItem(hwndDlg,IDC_EDIT2),szAddText); } if(!hookData.bCatchAutoMinimize){ hookData.bCatchAutoMinimize=1; ::SendMessage(GetDlgItem(hwndDlg,IDC_MIN2), BM_SETCHECK, hookData.bCatchAutoMinimize, 0); hookData.iINACTSEC=2; ::SetWindowText(GetDlgItem(hwndDlg,IDC_INACTSEC),"2"); } }else{ MessageBox(0,_pl("Enter window title first"),"Windows helper",0); } } } if(uMsg==WM_SYSCOMMAND && wParam==SC_CLOSE){ EndDialog(hwndDlg,1); return TRUE; } if(uMsg==WM_COMMAND && wParam==IDOK){ char szNumber[128]={0}; hookData.bCatchAutoMinimize=(int)::SendMessage(GetDlgItem(hwndDlg,IDC_MIN2), BM_GETCHECK, 0, 0); GetWindowText(GetDlgItem(hwndDlg,IDC_INACTSEC),szNumber,sizeof(szNumber)); hookData.iINACTSEC=atol(szNumber); memset(hookData.szAutoMinimizeTitle,0,sizeof(hookData.szAutoMinimizeTitle)); GetWindowText(GetDlgItem(hwndDlg,IDC_EDIT2),hookData.szAutoMinimizeTitle,sizeof(hookData.szAutoMinimizeTitle)-1); GetWindowText(GetDlgItem(hwndDlg,IDC_EDIT3),hookData.szAutoMinToTray,sizeof(hookData.szAutoMinToTray)-1); GetWindowText(GetDlgItem(hwndDlg,IDC_EDIT4),hookData.szAutoMinToFloat,sizeof(hookData.szAutoMinToFloat)-1); if(hookData.iStickness<3){ hookData.bSnapMovements=0; hookData.iStickness=0; } if(strlen(hookData.szAutoMinimizeTitle)>0 && bAutoHideTextEmptyOnDialogOpen){ hookData.bCatchAutoMinimize=TRUE; bAutoHideTextEmptyOnDialogOpen=0; } EndDialog(hwndDlg,0); return TRUE; } return FALSE; }
[ "wplabs@3fb49600-69e0-11de-a8c1-9da277d31688" ]
[ [ [ 1, 141 ] ] ]
3ae186125debf2d45fb74441de3b48749dc12e57
21737c1ff12ead3baf7bcf8bedbadb69b5f7ff1a
/generator.cpp
dcaf307265a02bd422fe1e1fa51ee6b9ec8db09c
[]
no_license
abdo5520/RTGen
941272322e4d92b5b014a3154e53dbe6b1d7e8cf
8d0bf859a5e601b4df775f0a21eadc07820f4414
refs/heads/master
2020-12-25T08:50:56.058621
2011-04-07T19:22:15
2011-04-07T19:22:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
13,468
cpp
//included code to generate packets of varying size. Default size is 24 bytes. - Vivek (2/28/08) #include "streamInfo.h" #include "packet.h" #include <sys/types.h> #include <sys/time.h> #include <sys/socket.h> #include <string> #include <iostream> #include <fstream> #include <netdb.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #include <ostream> #include <pthread.h> using namespace std; bool IsNumber ( char * str ); int main ( int argc, char *argv[] ) { //Declaration of Variables string addr = "" ; string filename = "" ; struct addrinfo * destInfo ; string port = "9876" ; int result = 0 ; int packetLength; struct timeval time1; u_long randStream; gettimeofday(&time1,NULL); randStream=(time1.tv_usec)*1000000; string logfile = "" ; // /**Added by Pete on 6/14/10**/ //edits end Packet packet ; packet.version = 0 ; //generate a random number from 0 to 10000 and add to time srand(time(NULL)); randStream=randStream+(rand() % 1000 +1); packet.streamId = time(NULL) + randStream; packet.sequenceNumber = 0 ; packet.payloadLength = 0; packet.finalSequenceNumber = 100 ; packet.interDepartureTime = 10 ; packet.initBufferCount = 10 ; //edited by Jared to flag type of packet //default packet is RT packet.isRT = '1'; //edits end //edited by vivek to include a payload of 1200 bytes //edited by Jared to include a payload of 1500 bytes int headerLength = sizeof(packet) - 1500; //edits end bool error = false; char state = ' ' ; //Check for config file for (int f = 1; f < argc && !error ; f ++ ) { switch ( state ) { case 'f' : //Config Filename filename.assign ( argv[f] ); state = ' ' ; break ; case ' ' : // Removes '-' characters and catches incorrect characters if ( argv[f][0] == '-' ) { state = argv[f][1] ; } else { error = true ; } break ; default : state = ' '; break ; } } //Edit by Jared on 6/19/08. Fixed 6/23/08 //Added ability to read config file denoted by -f option. if( filename != "" ){ ifstream cfg(filename.c_str()); if(cfg.good()){ char firstChar = ' '; char buff[1024]; char tag[24]; char value[24]; while( !cfg.eof() ){ do{ cfg.getline(buff,1024); firstChar = buff[0]; }while((firstChar == ' ') || (firstChar == '\n') || (firstChar == '#')); if((firstChar != ' ') && (firstChar != '\n') && (firstChar != '#') ){\ sscanf(buff, "%s %*s %s", tag, value); //Big Ol Switch string compStr = tag; if(compStr.compare("dest_addr") == 0){ addr.assign ( value ) ; }else if(compStr.compare("dest_port") == 0){ if ( IsNumber ( value ) ) { port.assign ( value ) ; }else error = true ; }else if(compStr.compare("init_buff") == 0){ if ( IsNumber ( value ) ) { packet.initBufferCount = short(atoi(value)) ; } else error = true ; }else if(compStr.compare("Payload") == 0){ if ( IsNumber ( value )) { packet.payloadLength = short(atoi(value)) -headerLength; //edited by Jared on 7/2/08. Max size of packet is 1524 B with 24B header. //Thus payload should not exceed 1500 B (1524 -24) if ( packet.payloadLength > (sizeof(Packet) - headerLength) ) { cout << "packet length must be between 24 and 1524 " << endl ; error = true ; } } else error = true ; }else if(compStr.compare("depart_time") == 0) { if ( IsNumber ( value ) ) { packet.interDepartureTime = short ( atoi (value) ) ; } else error = true ; }else if(compStr.compare("num") == 0) { if ( IsNumber ( value ) ) { packet.finalSequenceNumber = short ( atoi(value) ) ; } else error = true ; /**Added by Jared on 18th June 2008 to differentiate whether stream is RT or NRT **/ }else if(compStr.compare("is_RT") == 0){ string temp = value; if ( temp.compare("false") == 0 ){ packet.isRT = '0'; }else if ( temp.compare("true") == 0 ){ packet.isRT = '1'; }else{ error = true; } //edits end // /**Added by Pete on 11th June 2010 to add a log file // **/ }else if(compStr.compare("log") == 0) { logfile.assign(value); } } } cfg.close(); }else{ //Filename is not a valid one error = true; } } //Config File Read Done state = ' '; for (int c = 1; c < argc && !error ; c ++ ) { switch ( state ) { case 'a' : // Destination Address addr.assign ( argv[c] ) ; state = ' ' ; break ; case 'f' : //Config Filename filename.assign ( argv[c] ); state = ' ' ; break ; case 'p' : // Destination Port if ( IsNumber ( argv[c] ) ) { port.assign ( argv[c] ) ; } else error = true ; state = ' ' ; break ; case 'b' : // Buffer Size Allocation if ( IsNumber ( argv[c] ) ) { packet.initBufferCount = short(atoi(argv[c])) ; } else error = true ; state = ' ' ; break ; case 's' : // Payload Size (24 -1524 bytes) if ( IsNumber ( argv[c] ) ) { packet.payloadLength = int(atoi(argv[c])) -headerLength; /**edited by Jared on 7/2/08. Max size of packet is 1524 B with 24B header. * Thus payload should not exceed 1500 B (1524 -24) **/ if ( packet.payloadLength > (sizeof(Packet) - headerLength) ) { cout << "packet length must be between 24 and 1524 " << endl ; error = true ; } } else error = true ; state = ' ' ; break ; case 't' : // Interdepature Time (ms) if ( IsNumber ( argv[c] ) ) { packet.interDepartureTime = short ( atoi (argv[c]) ) ; } else error = true ; state = ' ' ; break ; case 'n' : // Number of Packets to Send if ( IsNumber ( argv[c] ) ) { packet.finalSequenceNumber = short ( atoi(argv[c]) ) ; } else error = true ; state = ' ' ; break ; /**Added by Jared on 18th June 2008 to differentiate whether stream is RT or NRT **/ case 'r' : // Whether packets are RT (0) or NRT (1) if ( argv[c][0] == '0' ){ packet.isRT = '0'; }else if (argv[c][0] == '1' ){ packet.isRT = '1'; }else{ error = true; } state = ' '; break; //edits end // /**Added by Peter on 11th June 2010 to add a log file // **/ case 'l' : // Log file name logfile.assign(argv[c]) ; state = ' ' ; break; //edits end case ' ' : // Removes '-' characters and catches incorrect parameters if ( argv[c][0] == '-' ) { state = argv[c][1] ; } else { error = true ; } break ; default : error = true ; break ; } } //Command Line Read Done // /**Added by Pete on 6/14/10**/ //edits end //edits by Vivek start. Assigning 'a' to the packet payload. if (packet.payloadLength > 0) { // packet.payLoad=(u_char*)calloc(packet.payloadLength,sizeof(u_char)); for (int i=0;i<packet.payloadLength;i++) { packet.payLoad[i]='a'; } } packetLength = headerLength + packet.payloadLength ; //edits by Vivek end //No IP address was specified if (addr =="" ) error = true; //Error Handling if ( error ) { cout << " Stu\'s Real-Time Traffic Generator " << endl << "Usage: generator -a <receiver_address> -f <config filename> -p <port#> " << "-b <initial_buffer_size_in_bytes> -s <payload_size_in_bytes> " << "-t <delay_in_ms> -n <number_of_packets> -r <RT = 1/NRT = 0> -l <log_file_name>" << endl << "Explanation: " << endl << "-a = receiver\'s address or name (no default)" << endl << "-f = config filename (no default)" <<endl << "-p = port number (default: 9876) " << endl << "-b = number of packets to buffer before starting (default = 10) " << endl << "-s = Payload size (24-1524) (default = 160 B)" << endl << "-t = delay between packets, in ms (default=20ms)" << endl << "-n = number of packets to send (default=100)" << endl << "-r = '1' for RT packets '0' for NRT packets (default= 1)" << endl << "-l = name of the log file (default=generator.log)" << endl << "(option order not important)" << endl ; exit(0) ; } //Print Stream Info to console cout << "Stream to "<< addr << ":" << port << " n=" << packet.finalSequenceNumber << "packets" << " s=" << packet.payloadLength + headerLength << "Bytes" << " d=" << packet.interDepartureTime << "ms" << " buffer=" << packet.initBufferCount << " " << " RT=" << packet.isRT << "(1=RT/0=NRT)" << " log file=" << logfile << endl; // name lookup struct addrinfo hints ; memset(&hints, 0, sizeof(addrinfo) ) ; hints.ai_family = PF_INET ; hints.ai_socktype = SOCK_DGRAM ; if ( (result = (getaddrinfo(addr.c_str(), port.c_str(), &hints, &destInfo ))) ){ cout << "Error: getaddrinfo: " << result << endl ; exit (-1 ) ; } // create socket int sock = socket ( destInfo->ai_family, destInfo->ai_socktype, 0 ) ; if ( sock < 0 ) { cout << "Error: socket() " << sock << endl ; exit (-1) ; // error creating socket... bail. } // create packet data array u_char bytePacket[packetLength]; // clear it memset(&bytePacket, 0, packetLength); /**Added by Jared on 6/26/08. Switched values from Little endian to Big Endian. * To make things more standard. **/ //Hold onto finalSequenceNumber to use it for upcoming for loop. u_long finalNum = packet.finalSequenceNumber; //Hold onto delay to use for sleep function in for loop. short delay = packet.interDepartureTime; packet.version = htons(packet.version); packet.payloadLength = htons(packet.payloadLength); packet.streamId = htonl(packet.streamId); packet.finalSequenceNumber = htonl(packet.finalSequenceNumber); packet.interDepartureTime = htons(packet.interDepartureTime); packet.initBufferCount = htons(packet.initBufferCount); //edits end // copy the packet struct into it memcpy ( &bytePacket, &packet, packetLength ) ; // /**Added by Pete on 6/17/10**/ stringstream ss; ofstream gLog; gLog.clear(); gLog.open(logfile.data()) ; //edits end /**Added by Pete on 6/21/10**/ //microsecond timing char buffer[30]; struct timeval tv; time_t curtime; gettimeofday(&tv, NULL); curtime=tv.tv_sec; strftime(buffer,30,"%m-%d-%Y %T.",localtime(&curtime)); //edits end // /**Added by Pete on 6/14/10**/ char hostname[20] ; gethostname(hostname, 20) ; //edits end //Send packets from 0 to N to destination for ( packet.sequenceNumber = 0 ; packet.sequenceNumber < finalNum ; packet.sequenceNumber++ ) { /**Added by Pete on 6/21/10**/ //microsecond timing char buffer[30]; struct timeval tv; time_t curtime; gettimeofday(&tv, NULL); curtime=tv.tv_sec; /**Added time= by Pete on 7/13/2010**/ strftime(buffer,30,"%m-%d-%Y\" time=\"%T.",localtime(&curtime)); /** Old Date and Time Date and time char strTime[20]; time_t time1 = time(NULL) ; tm * time2 = localtime ( &time1 ) ; strftime( &strTime[0], 20, "%Y-%m-%dT%H:%M:%S", time2 ) ; **/ //Streamstart if(packet.sequenceNumber == 0) { ss << "<?xml version=\"1.0\" encoding=\"ascii\"?> " << endl ; ss << "<log node=\"" << hostname << "\" date=\"" << buffer << tv.tv_usec << "\">" << endl ; gLog << ss.rdbuf(); ss << "<streamstart " << "streamid=\"" << htonl(packet.streamId) << "\""; gLog << ss.rdbuf(); if(packet.isRT == '0') { ss << " type=\"NRT\""; gLog << ss.rdbuf(); }else{ ss << " type=\"RT\"";//edits end gLog << ss.rdbuf(); } /**Changed to receiver on 8/9/2010, now correct**/ ss << " receiver=\"" << addr << "\"" << " iseqnum=\"" << packet.sequenceNumber << "\"" << " fseqnum=\"" << finalNum - 1 << "\"" << " proctime=\"" << delay << "\"" << " initbuffs=\"" << htons(packet.initBufferCount) << "\"" /**Added time= by Pete on 7/13/2010**/ << " packetsize=\"" << htons(packet.payloadLength) + 24 << "\"" << " hostname=\"" << hostname << "\"" << " date=\"" << buffer << tv.tv_usec << "\"/>\n"; gLog << ss.rdbuf(); } //edits end //Flip sequence number for network semantics packet.sequenceNumber = htonl(packet.sequenceNumber); memcpy ( &bytePacket, &packet, packetLength ) ; sendto(sock, &bytePacket, packetLength, 0, destInfo->ai_addr, destInfo->ai_addrlen ) ; //Flip sequence number back to host semantics packet.sequenceNumber = ntohl(packet.sequenceNumber); //This adds the delay between the packets. Default delay is 20 ms (20 us * 1000) usleep ( (delay) * 1000); // /**Added by Pete on 6/14/10**/ //Streamstop if(packet.sequenceNumber == (finalNum - 1)) { ss << "<streamstop " << "streamid=\"" << htonl(packet.streamId) << "\"" << " date=\"" << buffer << tv.tv_usec << "\"/>\n"; gLog << ss.rdbuf(); } } return 0 ; gLog.close(); //edits end } /**Checks if input string is a composed of all digits (0-9) * and thus can be translated to a number. **/ bool IsNumber ( char * str ) { for ( int c = 0 ; str[c] != '\0' ; c ++ ) { if (str[c] > '9' || str[c] < '0' ) return false ; } return true ; }
[ [ [ 1, 421 ] ] ]
74cb20f939656532bc1ca121b27507e977c60335
faacd0003e0c749daea18398b064e16363ea8340
/lyxlib/skinner.h
48b66762e776ffa1e2e6d6a1efa38a939f055950
[]
no_license
yjfcool/lyxcar
355f7a4df7e4f19fea733d2cd4fee968ffdf65af
750be6c984de694d7c60b5a515c4eb02c3e8c723
refs/heads/master
2016-09-10T10:18:56.638922
2009-09-29T06:03:19
2009-09-29T06:03:19
42,575,701
0
0
null
null
null
null
UTF-8
C++
false
false
3,660
h
/* * Copyright (C) 2008 Pavlov Denis * * This is a skin engine implementation. * Engine is used by EVERY module to make it look like a main window * of an application. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or any later version. * */ #ifndef __SKINNER_H__ #define __SKINNER_H__ #include <QtXml> #include <QtGui> #include <QString> //! Skinner is a skin microengine class for this application. /*! Skinner uses XML file for skin description, then reads it and provides methods for reading interface objects skin properties. */ class ASkinner : public QObject { public: //! \brief Constructor /*! \param parent specifies parent object \param skinName specifies skin directory name */ ASkinner(QObject *parent = 0, QString skinName = ""); ~ASkinner() {} //! \brief Loads skin specified by the name /*! \param name specifies skin directory name */ int loadSkin(QString name); //! \brief Gets value from skin configuration file /*! The value is determined my three parameters. \param part is a part of configuration \param root is an object, e.g. "panel" or "" for main window. \param attribute determines the name of an attribute to read */ QString skinValue(QString part = "", QString root = "", QString attribute = ""); //! \brief Gets value from module-specific skin configuration file /*! The value is determined my three parameters. \param module is a name of module. \param object is an object, e.g. "volume_up_button" or "background". \param attribute determines the name of an attribute to read */ QString skinModuleValue(QString module = "", QString object = "", QString attribute = ""); //! \brief Gets value from skin configuration file. The same as skinValue but thinks that parameter is an image link. QString skinImage(QString part = "", QString root = "", QString attribute = ""); //! \brief Gets value from module-specific skin configuration file. The same as skinModuleValue but thinks that parameter is an image link. QString skinModuleImage(QString module = "", QString object = "", QString attribute = ""); //! \brief Gets skin images storage by module name. /* \param module is a module name. */ QString skinModuleImagePath(QString module = ""); //! \brief Gets DOM container from module-specific skin configuration file. Gets a Dom element of module object's configuration. /*! \param module is a name of module. \param elementName is a name of element to get. */ QDomElement skinModuleElement(QString module, QString elementName); //! \brief Gets DOM container from module-specific skin configuration file by object type (tag name) and object name (the "name" attribute). /*! \param module is a name of module \param element is a type of object (tag name) \param elementName is a name of an element (the "name" attribute) */ QDomElement skinModuleElementByName(QString module, QString element, QString elementName); private: QString skinsPath; QString skinName; QDomDocument * skin; QDomElement skinRoot; QDomElement panel; QDomElement modules; }; #endif
[ "futurelink.vl@9e60f810-e830-11dd-9b7c-bbba4c9295f9", "inndie@9e60f810-e830-11dd-9b7c-bbba4c9295f9" ]
[ [ [ 1, 12 ], [ 14, 23 ], [ 27, 27 ], [ 34, 34 ], [ 36, 36 ], [ 42, 42 ], [ 74, 74 ], [ 82, 82 ], [ 85, 86 ], [ 92, 94 ] ], [ [ 13, 13 ], [ 24, 26 ], [ 28, 33 ], [ 35, 35 ], [ 37, 41 ], [ 43, 73 ], [ 75, 81 ], [ 83, 84 ], [ 87, 91 ] ] ]
8ea4a528c1937d9d47b3a9bd3ad1cdc48d8b80e1
df666afdfc06d2239b2fd10f419b8177a3a6284f
/IMShield/IMShield.cpp
fa52694cc0c770b5b8fcd779069c164871b62037
[]
no_license
instcode/imshield
12824ed353ef0b1a4e47783d6d92589fb052ca4b
9c6cc643ca6e7c2068fa9b2b0c39dde1f6272d5c
refs/heads/master
2016-09-05T09:40:15.708457
2008-10-22T09:03:07
2008-10-22T09:03:07
32,088,299
0
0
null
null
null
null
UTF-8
C++
false
false
7,421
cpp
#define INCL_WINSOCK_API_TYPEDEFS 1 #include <winsock2.h> #include "HookingAPI.h" #include "System.h" #include "IMShield.h" #include "IPC.h" LPFN_WSARECV fpWSARecv = NULL; LPFN_WSASEND fpWSASend = NULL; LPFN_SEND fpSend = NULL; LPFN_CONNECT fpConnect = NULL; LPFN_CLOSESOCKET fpCloseSocket = NULL; SOCKET g_socket = INVALID_SOCKET; LPCRITICAL_SECTION g_lpCriticalSection = NULL; BOOL g_isBeingMonitored = FALSE; BOOL g_isRunning = TRUE; DWORD ipc_descriptor = 0; int WSAAPI CloseSocketHookProc(SOCKET s) { SysTrace("CloseSocketHookProc - Global socket: %d - Closing socket: %d\n", g_socket, s); if (g_socket == s) g_socket = INVALID_SOCKET; return (fpCloseSocket)(s); } int WSAAPI ConnectHookProc(SOCKET s, const struct sockaddr* name, int namelen) { SOCKADDR_IN* pSock = (SOCKADDR_IN*)name; char sIP[15]; int nRemoteIP = pSock->sin_addr.s_addr; SysTrace("ConnectHookProc - Connected socket: %d - Remote Host: %d.%d.%d.%d\n", s, nRemoteIP & 0xFF, (nRemoteIP >> 8) & 0xFF, (nRemoteIP >> 16) & 0xFF, (nRemoteIP >> 24) & 0xFF); g_socket = s; return (fpConnect)(s, name, namelen); } int WSAAPI SendHookProc(SOCKET s, const char FAR* buf, int len, int flags) { if (g_isBeingMonitored && len > 0) { EnterCriticalSection(g_lpCriticalSection); SysTrace("SendHookProc - Using socket: %d\n", s); IPC_MESSAGE ipc_message; ipc_message.lpBuffer = (LPBYTE)buf; ipc_message.dwSize = len; WriteIPC(ipc_descriptor, &ipc_message); SignalEvent(INCOMMING_BUFFER_AVAILABLE_EVENT); // Wait for buffer available const LPCTSTR szEvents[] = {OUTGOING_BUFFER_AVAILABLE_EVENT, STOP_MONITORING_EVENT}; DWORD dwReturn = WaitForEvents( 2, (LPCTSTR *)szEvents, FALSE, REQUEST_TIME_WAIT); if (dwReturn == WAIT_OBJECT_0) { ResetEvent(OUTGOING_BUFFER_AVAILABLE_EVENT); ReadIPC(ipc_descriptor, &ipc_message); buf = (const char*)ipc_message.lpBuffer; len = ipc_message.dwSize; } // We must complete send data within critical section, // otherwise, it may be intercepted by another thread // and therefore, data will be corrupted. int nRet = (fpSend)(s, buf, len, flags); LeaveCriticalSection(g_lpCriticalSection); return nRet; } return (fpSend)(s, buf, len, flags); } int WSAAPI WSARecvHookProc(SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesRecvd, LPDWORD lpFlags, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) { int nRetCode = (fpWSARecv)(s, lpBuffers, dwBufferCount, lpNumberOfBytesRecvd, lpFlags, lpOverlapped, lpCompletionRoutine); if (nRetCode != 0) return nRetCode; if (g_isBeingMonitored && *lpNumberOfBytesRecvd > 0) { EnterCriticalSection(g_lpCriticalSection); SysTrace("WSARecvHookProc - Receive count: %d\n", *lpNumberOfBytesRecvd); IPC_MESSAGE ipc_message; ipc_message.lpBuffer = (LPBYTE)lpBuffers->buf; ipc_message.dwSize = *lpNumberOfBytesRecvd; WriteIPC(ipc_descriptor, &ipc_message); SignalEvent(INCOMMING_BUFFER_AVAILABLE_EVENT); const LPCTSTR szEvents[] = {OUTGOING_BUFFER_AVAILABLE_EVENT, STOP_MONITORING_EVENT}; DWORD dwReturn = WaitForEvents( 2, (LPCTSTR *)szEvents, FALSE, REQUEST_TIME_WAIT); if (dwReturn == WAIT_OBJECT_0) { ResetEvent(OUTGOING_BUFFER_AVAILABLE_EVENT); // Take the modified buffer effect ReadIPC(ipc_descriptor, &ipc_message); lpBuffers->buf = (char *)ipc_message.lpBuffer; *lpNumberOfBytesRecvd = ipc_message.dwSize; } LeaveCriticalSection(g_lpCriticalSection); } return nRetCode; } DWORD WINAPI IMServiceRoutine(LPVOID lpParam) { while (g_isRunning) { const LPCTSTR szEvents[] = {IM_SERVICE_EVENT, PROCESS_DETACH_EVENT}; DWORD dwReturn = WaitForEvents( 2, (LPCTSTR *)szEvents, FALSE, REQUEST_TIME_WAIT); if (dwReturn != WAIT_OBJECT_0) continue; ResetEvent(IM_SERVICE_EVENT); // Make sure no one can modify the IPC buffer concurrently EnterCriticalSection(g_lpCriticalSection); // Get the data & serve IPC_MESSAGE ipc_message; ReadIPC(ipc_descriptor, &ipc_message); // Check whether we have a valid socket, and send the buffer // Note: Use the buffer of the IPC directly for fast processing if (g_socket != INVALID_SOCKET) { SysTrace("Service: Send request...\n"); (fpSend)(g_socket, (const char*)ipc_message.lpBuffer, ipc_message.dwSize, 0); } // It's time to leave ;) LeaveCriticalSection(g_lpCriticalSection); } SysTrace("IMServiceRoutine is exiting!...\n"); return 0; } DWORD WINAPI PingServiceRoutine(LPVOID lpParam) { const LPCTSTR PING[] = {ALIVE_EVENT, STOP_MONITORING_EVENT, PROCESS_DETACH_EVENT}; const LPCTSTR SLEEP[] = {PROCESS_DETACH_EVENT, STOP_MONITORING_EVENT}; const LPCTSTR WAIT[] = {ALIVE_EVENT, PROCESS_DETACH_EVENT}; DWORD dwTimeWait = REQUEST_TIME_WAIT; BOOL isSignalPingEvent = TRUE; LPCTSTR* lpszEvents = (LPCTSTR *)PING; while (g_isRunning) { if (isSignalPingEvent) { //SysTrace("Send PING signal!...\n"); SignalEvent(PING_EVENT); } DWORD dwReturn = WaitForEvents(3, lpszEvents, FALSE, dwTimeWait); switch (dwReturn) { case WAIT_OBJECT_0: ResetEvent(ALIVE_EVENT); g_isBeingMonitored = TRUE; //SysTrace("Supervisor is monitoring!...\n"); dwTimeWait = PING_TIME_WAIT; lpszEvents = (LPCTSTR *)SLEEP; break; case WAIT_TIMEOUT: if (!isSignalPingEvent) { dwTimeWait = REQUEST_TIME_WAIT; lpszEvents = (LPCTSTR *)PING; break; } // Cross over!! case WAIT_OBJECT_0 + 1: g_isBeingMonitored = FALSE; SysTrace("Supervisor is no longer existed!...\n"); dwTimeWait = INFINITE; lpszEvents = (LPCTSTR *)WAIT; break; } isSignalPingEvent = (dwReturn == WAIT_TIMEOUT) || (dwReturn == WAIT_OBJECT_0 + 1); } SysTrace("PingServiceRoutine is exiting!...\n"); return TRUE; } BOOL BeginMonitorIM(HINSTANCE hInstance) { // Initialize IM Shield g_lpCriticalSection = new CRITICAL_SECTION; InitializeCriticalSection(g_lpCriticalSection); ipc_descriptor = OpenIPC(MAPPING_FILE_NAME, SHARE_MEM_SIZE); if (ipc_descriptor < 0) return FALSE; ResetEvent(PROCESS_DETACH_EVENT); ResetEvent(INCOMMING_BUFFER_AVAILABLE_EVENT); g_isRunning = TRUE; BeginThread(0, PingServiceRoutine); BeginThread(1, IMServiceRoutine); // Hook APIs HookAPI("ws2_32.dll", "WSARecv", (PROC)WSARecvHookProc, (PROC*)&fpWSARecv); HookAPI("ws2_32.dll", "connect", (PROC)ConnectHookProc, (PROC*)&fpConnect); HookAPI("ws2_32.dll", "closesocket", (PROC)CloseSocketHookProc, (PROC*)&fpCloseSocket); HookAPI("ws2_32.dll", "send", (PROC)SendHookProc, (PROC*)&fpSend); SysTrace("Begin monitoring IM...\n"); return TRUE; } BOOL EndMonitorIM() { g_isRunning = FALSE; SignalEvent(PROCESS_DETACH_EVENT); WaitForThreadsToExit(); CloseIPC(ipc_descriptor); DeleteCriticalSection(g_lpCriticalSection); delete g_lpCriticalSection; SysTrace("Stop monitoring IM...\n"); ResetEvent(PROCESS_DETACH_EVENT); ResetEvent(INCOMMING_BUFFER_AVAILABLE_EVENT); return TRUE; } BOOL APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { switch (dwReason) { case DLL_PROCESS_ATTACH: BeginMonitorIM(hInstance); break; case DLL_PROCESS_DETACH: EndMonitorIM(); break; } return TRUE; }
[ "instcode@910b4a73-bf2d-0410-a614-036a4d528d2e" ]
[ [ [ 1, 244 ] ] ]
e17cf4130f3f361bdf93b43a427dbf255e207f7c
f89e32cc183d64db5fc4eb17c47644a15c99e104
/pcsx2-rr/pcsx2/CDVD/IsoFS/IsoFS.cpp
ca844818bbbff5480f8409207503915a0e2d328d
[]
no_license
mauzus/progenitor
f99b882a48eb47a1cdbfacd2f38505e4c87480b4
7b4f30eb1f022b08e6da7eaafa5d2e77634d7bae
refs/heads/master
2021-01-10T07:24:00.383776
2011-04-28T11:03:43
2011-04-28T11:03:43
45,171,114
0
0
null
null
null
null
UTF-8
C++
false
false
6,693
cpp
/* PCSX2 - PS2 Emulator for PCs * Copyright (C) 2002-2010 PCSX2 Dev Team * * PCSX2 is free software: you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. * * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with PCSX2. * If not, see <http://www.gnu.org/licenses/>. */ #include "PrecompiledHeader.h" #include "IsoFS.h" #include "IsoFile.h" ////////////////////////////////////////////////////////////////////////// // IsoDirectory ////////////////////////////////////////////////////////////////////////// //u8 filesystemType; // 0x01 = ISO9660, 0x02 = Joliet, 0xFF = NULL //u8 volID[5]; // "CD001" wxString IsoDirectory::FStype_ToString() const { switch( m_fstype ) { case FStype_ISO9660: return L"ISO9660"; break; case FStype_Joliet: return L"Joliet"; break; } return wxsFormat( L"Unrecognized Code (0x%x)", m_fstype ); } // Used to load the Root directory from an image IsoDirectory::IsoDirectory(SectorSource& r) : internalReader(r) { IsoFileDescriptor rootDirEntry; bool isValid = false; bool done = false; uint i = 16; m_fstype = FStype_ISO9660; while( !done ) { u8 sector[2048]; internalReader.readSector(sector,i); if( memcmp( &sector[1], "CD001", 5 ) == 0 ) { switch (sector[0]) { case 0: Console.WriteLn( Color_Green, "(IsoFS) Block 0x%x: Boot partition info.", i ); break; case 1: Console.WriteLn( "(IsoFS) Block 0x%x: Primary partition info.", i ); rootDirEntry.Load( sector+156, 38 ); isValid = true; break; case 2: // Probably means Joliet (long filenames support), which PCSX2 doesn't care about. Console.WriteLn( Color_Green, "(IsoFS) Block 0x%x: Extended partition info.", i ); m_fstype = FStype_Joliet; break; case 0xff: // Null terminator. End of partition information. done = true; break; default: Console.Error( "(IsoFS) Unknown partition type ID=%d, encountered at block 0x%x", sector[0], i ); break; } } else { sector[9] = 0; Console.Error( "(IsoFS) Invalid partition descriptor encountered at block 0x%x: '%s'", i, &sector[1] ); break; // if no valid root partition was found, an exception will be thrown below. } ++i; } if( !isValid ) throw Exception::FileNotFound(L"IsoFS") // FIXME: Should report the name of the ISO here... .SetDiagMsg(L"IsoFS could not find the root directory on the ISO image."); DevCon.WriteLn( L"(IsoFS) Filesystem is " + FStype_ToString() ); Init( rootDirEntry ); } // Used to load a specific directory from a file descriptor IsoDirectory::IsoDirectory(SectorSource& r, IsoFileDescriptor directoryEntry) : internalReader(r) { Init(directoryEntry); } IsoDirectory::~IsoDirectory() throw() { } void IsoDirectory::Init(const IsoFileDescriptor& directoryEntry) { // parse directory sector IsoFile dataStream (internalReader, directoryEntry); files.clear(); uint remainingSize = directoryEntry.size; u8 b[257]; while(remainingSize>=4) // hm hack :P { b[0] = dataStream.read<u8>(); if(b[0]==0) { break; // or continue? } remainingSize -= b[0]; dataStream.read(b+1, b[0]-1); files.push_back(IsoFileDescriptor(b, b[0])); } b[0] = 0; } const IsoFileDescriptor& IsoDirectory::GetEntry(int index) const { return files[index]; } int IsoDirectory::GetIndexOf(const wxString& fileName) const { for(unsigned int i=0;i<files.size();i++) { if(files[i].name == fileName) return i; } throw Exception::FileNotFound(fileName); } const IsoFileDescriptor& IsoDirectory::GetEntry(const wxString& fileName) const { return GetEntry(GetIndexOf(fileName)); } IsoFileDescriptor IsoDirectory::FindFile(const wxString& filePath) const { pxAssert( !filePath.IsEmpty() ); // wxWidgets DOS-style parser should work fine for ISO 9660 path names. Only practical difference // is case sensitivity, and that won't matter for path splitting. wxFileName parts( filePath, wxPATH_DOS ); IsoFileDescriptor info; const IsoDirectory* dir = this; ScopedPtr<IsoDirectory> deleteme; // walk through path ("." and ".." entries are in the directories themselves, so even if the // path included . and/or .., it still works) for(uint i=0; i<parts.GetDirCount(); ++i) { info = dir->GetEntry(parts.GetDirs()[i]); if(info.IsFile()) throw Exception::FileNotFound( filePath ); dir = deleteme = new IsoDirectory(internalReader, info); } if( !parts.GetFullName().IsEmpty() ) info = dir->GetEntry(parts.GetFullName()); return info; } bool IsoDirectory::IsFile(const wxString& filePath) const { if( filePath.IsEmpty() ) return false; return (FindFile(filePath).flags&2) != 2; } bool IsoDirectory::IsDir(const wxString& filePath) const { if( filePath.IsEmpty() ) return false; return (FindFile(filePath).flags&2) == 2; } u32 IsoDirectory::GetFileSize( const wxString& filePath ) const { return FindFile( filePath ).size; } IsoFileDescriptor::IsoFileDescriptor() { lba = 0; size = 0; flags = 0; } IsoFileDescriptor::IsoFileDescriptor(const u8* data, int length) { Load( data, length ); } void IsoFileDescriptor::Load( const u8* data, int length ) { lba = (u32&)data[2]; size = (u32&)data[10]; date.year = data[18] + 1900; date.month = data[19]; date.day = data[20]; date.hour = data[21]; date.minute = data[22]; date.second = data[23]; date.gmtOffset = data[24]; flags = data[25]; int fileNameLength = data[32]; if(fileNameLength==1) { u8 c = data[33]; switch(c) { case 0: name = L"."; break; case 1: name = L".."; break; default: name = (wxChar)c; } } else { // copy string and up-convert from ascii to wxChar const u8* fnsrc = data+33; const u8* fnend = fnsrc+fileNameLength; while( fnsrc != fnend ) { name += (wxChar)*fnsrc; ++fnsrc; } } }
[ "koeiprogenitor@bfa1b011-20a7-a6e3-c617-88e5d26e11c5" ]
[ [ [ 1, 263 ] ] ]
c8088cf4280b8b29f3d98ccdfce37370236046fa
9ef88cf6a334c82c92164c3f8d9f232d07c37fc3
/Libraries/QuickGUI/include/QuickGUIWidgetFactory.h
f18ffcebc7ac9f30ce1fe8b41187af183a82b566
[]
no_license
Gussoh/bismuthengine
eba4f1d6c2647d4b73d22512405da9d7f4bde88a
4a35e7ae880cebde7c557bd8c8f853a9a96f5c53
refs/heads/master
2016-09-05T11:28:11.194130
2010-01-10T14:09:24
2010-01-10T14:09:24
33,263,368
0
0
null
null
null
null
UTF-8
C++
false
false
2,799
h
#ifndef QUICKGUIWIDGETFACTORY_H #define QUICKGUIWIDGETFACTORY_H #include "QuickGUIException.h" #include "QuickGUIExportDLL.h" #include "QuickGUIWidget.h" #include "OgrePrerequisites.h" #include <map> #include <string> namespace QuickGUIEditor { // forward declarations class MainForm; } namespace QuickGUI { class _QuickGUIExport WidgetFactory { public: // Only FactoryManager can create/destroy Factories friend class FactoryManager; // Make Widgets as Friends, as they will create/destroy Widgets friend class ComboBox; friend class ComponentWidget; friend class ContainerWidget; friend class ContextMenu; friend class List; friend class Menu; friend class Sheet; friend class TabControl; friend class TabPage; friend class Widget; friend class GUIManager; // Editor creates and manages its own Widgets friend class QuickGUIEditor::MainForm; protected: typedef Widget* (WidgetFactory::*createWidgetFunction)(const std::string&); public: bool classRegistered(const std::string& className) { return (mFunctorMap.find(className) != mFunctorMap.end()); } std::string& getNamePrefix() { return mNamingPrefix; } template<typename ClassType> bool registerClass(const std::string& className) { if (mFunctorMap.find(className) != mFunctorMap.end()) return false; mFunctorMap[className] = &WidgetFactory::createWidget<ClassType>; return true; } /** * Sets the string prepended to every instance created by this factory */ void setNamePrefix(const std::string& prefix) { mNamingPrefix = prefix; } bool unregisterClass(const std::string& className) { return (mFunctorMap.erase(className) == 1); } protected: template<typename ClassType> ClassType* createInstance(const std::string& className, const std::string& name) { typename std::map<std::string, createWidgetFunction>::iterator iter = mFunctorMap.find(className); if (iter == mFunctorMap.end()) throw Exception(Exception::ERR_FACTORY,"\"" + className + "\" is not a registered class!","WidgetFactory::createInstance"); Widget* newInstance = (this->*(*iter).second)(mNamingPrefix + name); return dynamic_cast<ClassType*>(newInstance); } void destroyInstance(Widget* instance) { OGRE_DELETE_T(instance,Widget,Ogre::MEMCATEGORY_GENERAL); } protected: WidgetFactory() : mNamingPrefix("") {} virtual ~WidgetFactory() {} std::map<std::string, createWidgetFunction> mFunctorMap; std::string mNamingPrefix; template<typename ClassType> Widget* createWidget(const std::string& param1) { return OGRE_NEW_T(ClassType,Ogre::MEMCATEGORY_GENERAL)(param1); } }; } #endif
[ "rickardni@aefdbfa2-c794-11de-8410-e5b1e99fc78e" ]
[ [ [ 1, 114 ] ] ]
2af2dfb2a8dfcb1220fc009abf5d6411f23a9632
a9cf0c2a8904e42a206c3575b244f8b0850dd7af
/FileModel.h
c1363e9918954b16aa8ce611770622ae8a3f00ae
[]
no_license
jayrulez/ourlib
3a38751ccb6a38785d4df6f508daeff35ccfd09f
e4727d638f2d69ea29114dc82b9687ea1fd17a2d
refs/heads/master
2020-04-22T15:42:00.891099
2010-01-06T20:00:17
2010-01-06T20:00:17
40,554,487
0
0
null
null
null
null
UTF-8
C++
false
false
496
h
/* @Group: BSC2D @Group Members: <ul> <li>Robert Campbell: 0701334</li> <li>Audley Gordon: 0802218</li> <li>Dale McFarlane: 0801042</li> <li>Dyonne Duberry: 0802189</li> <li>Xavier Lowe: 0802488</li> </ul> @ */ #ifndef _FILEMODEL_H #define _FILEMODEL_H #ifndef _REFERENCEMATERIAL_H #include "ReferenceMaterial.h" #endif class FileModel { public: FileModel(); ~FileModel(); ReferenceMaterial* getReferenceMaterialRecordFromFile(string); }; #endif
[ [ [ 1, 27 ] ] ]
80b5f7bf9a75c2f04d0c3d6b429a7b04c9f0d748
c440e6c62e060ee70b82fc07dfb9a93e4cc13370
/src/xmlconfigfile.h
919e2ec9d656f0f6bbcbd349137129da6c4fb35f
[]
no_license
BackupTheBerlios/pgrtsound-svn
2a3f2ae2afa4482f9eba906f932c30853c6fe771
d7cefe2129d20ec50a9e18943a850d0bb26852e1
refs/heads/master
2020-05-21T01:01:41.354611
2005-10-02T13:09:13
2005-10-02T13:09:13
40,748,578
0
0
null
null
null
null
UTF-8
C++
false
false
767
h
#ifndef XMLCONFIGFILE_H #define XMLCONFIGFILE_H #include "tinyxml.h" #include "algorithm.h" #include "audiodriver.h" #include <map> /** * Obiekt pliku konfiguracyjnego XML. * Umozliwa wczytywanie konfiguracji algorytmu zapisanej w pliku XML ustalonego * formatu. */ class XMLConfigFile { public: XMLConfigFile(); ~XMLConfigFile(); void OpenFile(const char * fileName); void LoadAlgorithm(Algorithm* algo); void LoadAudioDriveSettings(AudioDriver* audio); void LoadModules(Algorithm* algo); private: void LoadAlgorithmSettings(Algorithm* algo); void LoadParameters(Algorithm* algo); void LoadConnections(Algorithm* algo); string fileName; TiXmlDocument document; }; #endif // XMLCONFIGFILE_H
[ "ad4m@fa088095-53e8-0310-8a07-f9518708c3e6", "mariusz@fa088095-53e8-0310-8a07-f9518708c3e6" ]
[ [ [ 1, 15 ], [ 17, 35 ] ], [ [ 16, 16 ] ] ]
2fb75c274841d54cbe5c7b6afee4d073e70f92e2
2ca3ad74c1b5416b2748353d23710eed63539bb0
/Src/Lokapala/Operator/ConnectedHostDTO.h
2c858f59fe8a8b0cf5407db0a9a358e53cc23903
[]
no_license
sjp38/lokapala
5ced19e534bd7067aeace0b38ee80b87dfc7faed
dfa51d28845815cfccd39941c802faaec9233a6e
refs/heads/master
2021-01-15T16:10:23.884841
2009-06-03T14:56:50
2009-06-03T14:56:50
32,124,140
0
0
null
null
null
null
UTF-8
C++
false
false
510
h
/**@file ConnectedHostDTO.h * @brief CConnnectedHostDTO 클래스를 정의한다. * @author siva */ #ifndef CONNECTED_HOST_DTO_H #define CONNECTED_HOST_DTO_H /**@ingroup GroupDAM * @class CConnectedHostDTO * @brief 현재 연결된 사용자 개인의 정보를 갖는다. */ class CConnectedHostDTO { public : CString m_userId; CString m_hostAddress; CConnectedHostDTO(CString a_user, CString a_hostAddress); CConnectedHostDTO(){} ~CConnectedHostDTO(){} }; #endif
[ "nilakantha38@b9e76448-5c52-0410-ae0e-a5aea8c5d16c" ]
[ [ [ 1, 25 ] ] ]
ee3fb04c9e45e3a9684e30dba563d513c6e29ca8
842997c28ef03f8deb3422d0bb123c707732a252
/src/uslsext/USCanvas.cpp
f4552c72bd5af7396ee7329080b0508425af5d90
[]
no_license
bjorn/moai-beta
e31f600a3456c20fba683b8e39b11804ac88d202
2f06a454d4d94939dc3937367208222735dd164f
refs/heads/master
2021-01-17T11:46:46.018377
2011-06-10T07:33:55
2011-06-10T07:33:55
1,837,561
2
1
null
null
null
null
UTF-8
C++
false
false
24,067
cpp
// Copyright (c) 2010-2011 Zipline Games, Inc. All Rights Reserved. // http://getmoai.com #include "pch.h" #include <uslsext/USBlendMode.h> #include <uslsext/USColor.h> #include <uslsext/USGfxDevice.h> #include <uslsext/USGLLine.h> #include <uslsext/USGLQuad.h> #include <uslsext/USCanvas.h> #include <uslsext/USMathConsts.h> #include <uslsext/USTexture.h> //================================================================// // USCanvas //================================================================// //----------------------------------------------------------------// void USCanvas::BeginDrawing () { USGfxDevice& gfxDevice = USGfxDevice::Get (); float width = ( float )gfxDevice.GetWidth (); float height = ( float )gfxDevice.GetHeight (); USViewport viewport; viewport.Init ( 0.0f, 0.0f, width, height ); viewport.SetScale ( width, -height ); viewport.SetOffset ( -1.0f, 1.0f ); USAffine2D camera; camera.Ident (); USCanvas::BeginDrawing ( viewport, camera ); } //----------------------------------------------------------------// void USCanvas::BeginDrawing ( USViewport& viewport, USAffine2D& camera ) { // set us up the viewport USRect rect = viewport.GetRect (); GLint x = ( GLint )rect.mXMin; GLint y = ( GLint )rect.mYMin; GLsizei w = ( GLsizei )( rect.Width () + 0.5f ); GLsizei h = ( GLsizei )( rect.Height () + 0.5f ); glViewport ( x, y, w, h ); // load view/proj glMatrixMode ( GL_PROJECTION ); glLoadIdentity (); USAffine2D mtx; USCanvas::GetViewProjMtx ( viewport, camera, mtx ); USCanvas::LoadMatrix ( mtx ); // load ident glMatrixMode ( GL_MODELVIEW ); glLoadIdentity (); glDisable ( GL_CULL_FACE ); } //----------------------------------------------------------------// void USCanvas::ClearColorBuffer ( u32 color ) { USColorVec colorVec; colorVec.SetRGBA ( color ); glClearColor ( colorVec.mR, colorVec.mG, colorVec.mB, 1.0f ); glClear ( GL_COLOR_BUFFER_BIT ); } //----------------------------------------------------------------// void USCanvas::DrawAxisGrid ( USVec2D loc, USVec2D vec, float size ) { USAffine2D mtx; USCanvas::GetViewProjMtx ( mtx ); USAffine2D invMtx; invMtx.Inverse ( mtx ); // Set the axis to the grid length so we can get the length back post-transform vec.SetLength ( size ); mtx.Transform ( loc ); mtx.TransformVec ( vec ); // Get the axis unit vector USVec2D norm = vec; size = norm.NormSafe (); // Get the axis normal USVec2D perpNorm ( norm.mY, -norm.mX ); // Project the corners of the viewport onto the axis to get the mix/max bounds float dot; float min; float max; USVec2D corner; // left, top corner.Init ( -1.0f, 1.0f ); corner.Sub ( loc ); dot = norm.Dot ( corner ); min = dot; max = dot; // right, top corner.Init ( 1.0f, 1.0f ); corner.Sub ( loc ); dot = norm.Dot ( corner ); min = ( dot < min ) ? dot : min; max = ( dot > max ) ? dot : max; // right, bottom corner.Init ( 1.0f, -1.0f ); corner.Sub ( loc ); dot = norm.Dot ( corner ); min = ( dot < min ) ? dot : min; max = ( dot > max ) ? dot : max; // left, bottom corner.Init ( -1.0f, -1.0f ); corner.Sub ( loc ); dot = norm.Dot ( corner ); min = ( dot < min ) ? dot : min; max = ( dot > max ) ? dot : max; // Get the start andstop grids s32 start = ( s32 )( min / size ) - 1; s32 stop = ( s32 )( max / size ) + 1; // Set the pen to the first... USVec2D pen = norm; pen.Scale (( float )start * size ); pen.Add ( loc ); // Step along the axis to draw perpendicular grid lines USRect viewRect; viewRect.Init ( -1.0f, -1.0f, 1.0f, 1.0f ); USGLLine glLine; for ( ; start < stop; ++start ) { USVec2D p0; USVec2D p1; if ( viewRect.GetIntersection ( pen, perpNorm, p0, p1 )) { invMtx.Transform ( p0 ); invMtx.Transform ( p1 ); glLine.SetVerts ( p0, p1 ); glLine.Draw (); } pen.Add ( vec ); } } //----------------------------------------------------------------// void USCanvas::DrawEllipseFill ( USRect& rect, u32 steps ) { float xRad = ( rect.mXMax - rect.mXMin ) * 0.5f; float yRad = ( rect.mYMax - rect.mYMin ) * 0.5f; USVec2D loc; loc.mX = rect.mXMin + xRad; loc.mY = rect.mYMin + yRad; USCanvas::DrawEllipseFill ( loc, xRad, yRad, steps ); } //----------------------------------------------------------------// void USCanvas::DrawEllipseFill ( USVec2D& loc, float rad, u32 steps ) { USCanvas::DrawEllipseFill ( loc, rad, rad, steps ); } //----------------------------------------------------------------// void USCanvas::DrawEllipseFill ( USVec2D& loc, float xRad, float yRad, u32 steps ) { static const u32 MAX = 64; if ( steps > MAX ) steps = MAX; float vtx [ MAX * 2 ]; glVertexPointer ( 2, GL_FLOAT, 0, vtx ); glEnableClientState ( GL_VERTEX_ARRAY ); float angle = ( float )TWOPI / ( float )steps; float angleStep = ( float )PI; for ( u32 i = 0; i < steps; ++i, angleStep += angle ) { u32 vi = i << 1; vtx [ vi ] = loc.mX + ( Sin ( angleStep ) * xRad ); vtx [ vi + 1 ] = loc.mY + ( Cos ( angleStep ) * yRad ); } glDrawArrays ( GL_TRIANGLE_FAN, 0, steps ); } //----------------------------------------------------------------// void USCanvas::DrawEllipseFill ( float left, float top, float right, float bottom, u32 steps ) { USRect rect; rect.Init ( left, top, right, bottom ); USCanvas::DrawEllipseFill ( rect, steps ); } //----------------------------------------------------------------// void USCanvas::DrawEllipseOutline ( USRect& rect, u32 steps ) { float xRad = ( rect.mXMax - rect.mXMin ) * 0.5f; float yRad = ( rect.mYMax - rect.mYMin ) * 0.5f; USVec2D loc; loc.mX = rect.mXMin + xRad; loc.mY = rect.mYMin + yRad; USCanvas::DrawEllipseOutline ( loc, xRad, yRad, steps ); } //----------------------------------------------------------------// void USCanvas::DrawEllipseOutline ( USVec2D& loc, float rad, u32 steps ) { USCanvas::DrawEllipseOutline ( loc, rad, rad, steps ); } //----------------------------------------------------------------// void USCanvas::DrawEllipseOutline ( USVec2D& loc, float xRad, float yRad, u32 steps ) { static const u32 MAX = 64; if ( steps > MAX ) steps = MAX; float vtx [ MAX * 2 ]; glVertexPointer ( 2, GL_FLOAT, 0, vtx ); glEnableClientState ( GL_VERTEX_ARRAY ); float angle = ( float )TWOPI / ( float )steps; float angleStep = ( float )PI; for ( u32 i = 0; i < steps; ++i, angleStep += angle ) { u32 vi = i << 1; vtx [ vi ] = loc.mX + ( Sin ( angleStep ) * xRad ); vtx [ vi + 1 ] = loc.mY + ( Cos ( angleStep ) * yRad ); } glDrawArrays ( GL_LINE_LOOP, 0, steps ); } //----------------------------------------------------------------// void USCanvas::DrawEllipseOutline ( float left, float top, float right, float bottom, u32 steps ) { USRect rect; rect.Init ( left, top, right, bottom ); USCanvas::DrawEllipseOutline ( rect, steps ); } //----------------------------------------------------------------// void USCanvas::DrawGrid ( USRect& rect, u32 xCells, u32 yCells ) { USGLLine glLine; if ( xCells > 1 ) { float xStep = rect.Width () / ( float )xCells; for ( u32 i = 1; i < xCells; ++i ) { float x = rect.mXMin + (( float )i * xStep ); USVec2D v0 ( x, rect.mYMin ); USVec2D v1 ( x, rect.mYMax ); glLine.SetVerts ( v0, v1 ); glLine.Draw (); } } if ( yCells > 1 ) { float yStep = rect.Height () / ( float )yCells; for ( u32 i = 1; i < yCells; ++i ) { float y = rect.mYMin + (( float )i * yStep ); USVec2D v0 ( rect.mXMin, y ); USVec2D v1 ( rect.mXMax, y ); glLine.SetVerts ( v0, v1 ); glLine.Draw (); } } USCanvas::DrawRectOutline ( rect ); } //----------------------------------------------------------------// void USCanvas::DrawLine ( USVec2D& v0, USVec2D& v1 ) { USGLLine glLine; glLine.SetVerts ( v0, v1 ); glLine.Draw (); } //----------------------------------------------------------------// void USCanvas::DrawLine ( float x0, float y0, float x1, float y1 ) { USGLLine glLine; glLine.SetVerts ( x0, y0, x1, y1 ); glLine.Draw (); } //----------------------------------------------------------------// void USCanvas::DrawPoint ( USVec2D& loc ) { USCanvas::DrawPoint ( loc.mX, loc.mY ); } //----------------------------------------------------------------// void USCanvas::DrawPoint ( float x, float y ) { float vtx [ 2 ]; glVertexPointer ( 2, GL_FLOAT, 0, vtx ); glEnableClientState ( GL_VERTEX_ARRAY ); vtx [ 0 ] = x; vtx [ 1 ] = y; glDrawArrays ( GL_POINTS, 0, 1 ); } //----------------------------------------------------------------// ////void USCanvas::DrawQuadFill ( USVec2D& v0, USVec2D& v1, USVec2D& v2, USVec2D& v3 ) { //// //// USVec2D p0 = v0; //// USVec2D p1 = v1; //// USVec2D p2 = v2; //// USVec2D p3 = v3; //// //// USCanvas::BeginPrim (); //// FXQuad fxQuad = USCanvas::NextQuad (); //// //// USCanvas::Project ( p0 ); //// USCanvas::Project ( p1 ); //// USCanvas::Project ( p2 ); //// USCanvas::Project ( p3 ); //// //// // USVec2D 0 //// fxQuad.mVtx [ 0 ].mX = p0.x; //// fxQuad.mVtx [ 0 ].mY = p0.y; //// //// // USVec2D 1 //// fxQuad.mVtx [ 1 ].mX = p1.x; //// fxQuad.mVtx [ 1 ].mY = p1.y; //// //// // USVec2D 2 //// fxQuad.mVtx [ 2 ].mX = p2.x; //// fxQuad.mVtx [ 2 ].mY = p2.y; //// //// // USVec2D 3 //// fxQuad.mVtx [ 3 ].mX = p3.x; //// fxQuad.mVtx [ 3 ].mY = p3.y; //// //// USCanvas::EndPrim (); ////} //----------------------------------------------------------------// void USCanvas::DrawRay ( USVec2D loc, USVec2D vec ) { USAffine2D mtx; USCanvas::GetViewProjMtx ( mtx ); USAffine2D invMtx; invMtx.Inverse ( mtx ); mtx.Transform ( loc ); mtx.TransformVec ( vec ); USRect viewRect; viewRect.Init ( -1.0f, -1.0f, 1.0f, 1.0f ); USVec2D p0; USVec2D p1; USGLLine glLine; if ( viewRect.GetIntersection ( loc, vec, p0, p1 )) { invMtx.Transform ( p0 ); invMtx.Transform ( p1 ); glLine.SetVerts ( p0, p1 ); glLine.Draw (); } } //----------------------------------------------------------------// void USCanvas::DrawRectEdges ( USRect rect, u32 edges ) { rect.Bless (); USGLLine glLine; // right if ( edges & USRect::kRight ) { glLine.SetVerts ( rect.mXMax, rect.mYMin, rect.mXMax, rect.mYMax ); glLine.Draw (); } // top if ( edges & USRect::kTop ) { glLine.SetVerts ( rect.mXMin, rect.mYMin, rect.mXMax, rect.mYMin ); glLine.Draw (); } // left if ( edges & USRect::kLeft ) { glLine.SetVerts ( rect.mXMin, rect.mYMin, rect.mXMin, rect.mYMax ); glLine.Draw (); } // bottom if ( edges & USRect::kBottom ) { glLine.SetVerts ( rect.mXMin, rect.mYMax, rect.mXMax, rect.mYMax ); glLine.Draw (); } } //----------------------------------------------------------------// void USCanvas::DrawRectFill ( USRect rect ) { rect.Bless (); USCanvas::DrawRectFill ( rect.mXMin, rect.mYMin, rect.mXMax, rect.mYMax ); } //----------------------------------------------------------------// void USCanvas::DrawRectFill ( float left, float top, float right, float bottom ) { glDisableClientState ( GL_TEXTURE_COORD_ARRAY ); glDisableClientState ( GL_COLOR_ARRAY ); //glDisable ( GL_CULL_FACE ); glEnable ( GL_BLEND ); glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); float vtx [ 8 ]; glVertexPointer ( 2, GL_FLOAT, 0, vtx ); glEnableClientState ( GL_VERTEX_ARRAY ); vtx [ 0 ] = left; vtx [ 1 ] = top; vtx [ 2 ] = right; vtx [ 3 ] = top; vtx [ 4 ] = left; vtx [ 5 ] = bottom; vtx [ 6 ] = right; vtx [ 7 ] = bottom; glDrawArrays ( GL_TRIANGLE_STRIP, 0, 4 ); } //----------------------------------------------------------------// void USCanvas::DrawRectOutline ( USRect& rect ) { USCanvas::DrawRectOutline ( rect.mXMin, rect.mYMin, rect.mXMax, rect.mYMax ); } //----------------------------------------------------------------// void USCanvas::DrawRectOutline ( float left, float top, float right, float bottom ) { float vtx [ 8 ]; glVertexPointer ( 2, GL_FLOAT, 0, vtx ); glEnableClientState ( GL_VERTEX_ARRAY ); vtx [ 0 ] = left; vtx [ 1 ] = top; vtx [ 2 ] = right; vtx [ 3 ] = top; vtx [ 4 ] = right; vtx [ 5 ] = bottom; vtx [ 6 ] = left; vtx [ 7 ] = bottom; glDrawArrays ( GL_LINE_LOOP, 0, 4 ); } //----------------------------------------------------------------// void USCanvas::GetModelToWorldMtx ( USAffine2D& modelToWorld ) { USMatrix3D mtx; glGetFloatv ( GL_MODELVIEW_MATRIX, mtx.m ); modelToWorld.Init ( mtx ); } //----------------------------------------------------------------// void USCanvas::GetModelToWndMtx ( USAffine2D& modelToWnd ) { USCanvas::GetModelToWorldMtx ( modelToWnd ); USAffine2D mtx; USCanvas::GetWorldToWndMtx ( mtx ); modelToWnd.Append ( mtx ); } //----------------------------------------------------------------// void USCanvas::GetNormToWndMtx ( const USViewport& viewport, USAffine2D& normToWnd ) { USAffine2D mtx; USRect rect = viewport.GetRect (); float hWidth = rect.Width () * 0.5f; float hHeight = rect.Height () * 0.5f; // Wnd normToWnd.Scale ( hWidth, -hHeight ); mtx.Translate ( hWidth + rect.mXMin, hHeight + rect.mYMin ); normToWnd.Append ( mtx ); } //----------------------------------------------------------------// USColorVec USCanvas::GetPenColor () { float p [ 4 ]; glGetFloatv ( GL_CURRENT_COLOR, p ); USColorVec color; color.Set ( p [ 0 ], p [ 1 ], p [ 2 ], p [ 3 ]); return color; } //----------------------------------------------------------------// void USCanvas::GetProjMtx ( const USViewport& viewport, USAffine2D& proj ) { USAffine2D mtx; USRect rect = viewport.GetRect (); // project float xScale = 2.0f / rect.Width (); float yScale = 2.0f / rect.Height (); proj.Scale ( xScale, yScale ); mtx.Translate ( viewport.mOffset.mX, viewport.mOffset.mY ); proj.Append ( mtx ); } //----------------------------------------------------------------// void USCanvas::GetViewProjMtx ( USAffine2D& viewProj ) { USMatrix3D mtx; glGetFloatv ( GL_PROJECTION_MATRIX, mtx.m ); viewProj.Init ( mtx ); } //----------------------------------------------------------------// void USCanvas::GetViewProjMtx ( const USViewport& viewport, const USAffine2D& camera, USAffine2D& viewProj ) { USAffine2D mtx; USRect rect = viewport.GetRect (); // View viewProj.Inverse ( camera ); // Project // rotate mtx.Rotate ( -viewport.mRotation * ( float )D2R ); viewProj.Append ( mtx ); // project USVec2D viewScale = viewport.GetScale (); float xScale = ( 2.0f / rect.Width ()) * viewScale.mX; float yScale = ( 2.0f / rect.Height ()) * viewScale.mY; mtx.Scale ( xScale, yScale ); viewProj.Append ( mtx ); // offset mtx.Translate ( viewport.mOffset.mX, viewport.mOffset.mY ); viewProj.Append ( mtx ); } //----------------------------------------------------------------// void USCanvas::GetViewProjMtxInv ( const USViewport& viewport, const USAffine2D& camera, USAffine2D& viewProjInv ) { USAffine2D mtx; USRect rect = viewport.GetRect (); // Inv Project // offset viewProjInv.Translate ( -viewport.mOffset.mX, -viewport.mOffset.mY ); // project USVec2D viewScale = viewport.GetScale (); float invXScale = 1.0f / (( 2.0f / rect.Width () * viewScale.mX )); float invYScale = 1.0f / (( 2.0f / rect.Height () * viewScale.mY )); mtx.Scale ( invXScale, invYScale ); viewProjInv.Append ( mtx ); // rotate mtx.Rotate ( viewport.mRotation * ( float )D2R ); viewProjInv.Append ( mtx ); // Inv View viewProjInv.Append ( camera ); } //----------------------------------------------------------------// void USCanvas::GetViewRect ( USRect& rect ) { int params [ 4 ]; glGetIntegerv ( GL_VIEWPORT, params ); rect.mXMin = ( float )params [ 0 ]; rect.mYMin = ( float )params [ 1 ]; rect.mXMax = rect.mXMin + ( float )params [ 2 ]; rect.mYMax = rect.mYMin + ( float )params [ 3 ]; } //----------------------------------------------------------------// void USCanvas::GetWndToModelMtx ( USAffine2D& wndToModel ) { USCanvas::GetModelToWndMtx ( wndToModel ); wndToModel.Inverse (); } //----------------------------------------------------------------// void USCanvas::GetWndToNormMtx ( const USViewport& viewport, USAffine2D& wndToNorm ) { USAffine2D mtx; USRect rect = viewport.GetRect (); float hWidth = rect.Width () * 0.5f; float hHeight = rect.Height () * 0.5f; // Inv Wnd wndToNorm.Translate ( -hWidth - rect.mXMin, -hHeight - rect.mYMin ); mtx.Scale (( 1.0f / hWidth ), -( 1.0f / hHeight )); wndToNorm.Append ( mtx ); } //----------------------------------------------------------------// void USCanvas::GetWndToWorldMtx ( USAffine2D& wndToWorld ) { USAffine2D mtx; USRect rect; USCanvas::GetViewRect ( rect ); float hWidth = rect.Width () * 0.5f; float hHeight = rect.Height () * 0.5f; // Inv Wnd wndToWorld.Translate ( -hWidth - rect.mXMin, -hHeight - rect.mYMin ); mtx.Scale (( 1.0f / hWidth ), -( 1.0f / hHeight )); wndToWorld.Append ( mtx ); // inv viewproj USCanvas::GetViewProjMtx ( mtx ); mtx.Inverse (); wndToWorld.Append ( mtx ); } //----------------------------------------------------------------// void USCanvas::GetWndToWorldMtx ( const USViewport& viewport, const USAffine2D& camera, USAffine2D& wndToWorld ) { USAffine2D mtx; USRect rect = viewport.GetRect (); float hWidth = rect.Width () * 0.5f; float hHeight = rect.Height () * 0.5f; // Inv Wnd wndToWorld.Translate ( -hWidth - rect.mXMin, -hHeight - rect.mYMin ); mtx.Scale (( 1.0f / hWidth ), -( 1.0f / hHeight )); wndToWorld.Append ( mtx ); USCanvas::GetViewProjMtxInv ( viewport, camera, mtx ); wndToWorld.Append ( mtx ); } //----------------------------------------------------------------// void USCanvas::GetWorldToModelMtx ( USAffine2D& worldToModel ) { USMatrix3D mtx; glGetFloatv ( GL_MODELVIEW_MATRIX, mtx.m ); worldToModel.Init ( mtx ); worldToModel.Inverse (); } //----------------------------------------------------------------// void USCanvas::GetWorldToWndMtx ( USAffine2D& worldToWnd, float xScale, float yScale ) { USAffine2D mtx; USRect viewport; USCanvas::GetViewRect ( viewport ); float hWidth = viewport.Width () * 0.5f; float hHeight = viewport.Height () * 0.5f; // viewproj USMatrix3D viewProj; glGetFloatv ( GL_PROJECTION_MATRIX, viewProj.m ); worldToWnd.Init ( viewProj ); // wnd mtx.Scale ( hWidth * xScale, hHeight * yScale ); worldToWnd.Append ( mtx ); mtx.Translate ( hWidth + viewport.mXMin, hHeight + viewport.mYMin ); worldToWnd.Append ( mtx ); } //----------------------------------------------------------------// void USCanvas::GetWorldToWndMtx ( const USViewport& viewport, const USAffine2D& camera, USAffine2D& worldToWnd ) { USAffine2D mtx; USRect rect = viewport.GetRect (); float hWidth = viewport.Width () * 0.5f; float hHeight = viewport.Height () * 0.5f; USCanvas::GetViewProjMtx ( viewport, camera, worldToWnd ); // Wnd mtx.Scale ( hWidth, -hHeight ); worldToWnd.Append ( mtx ); mtx.Translate ( hWidth + rect.mXMin, hHeight + rect.mYMin ); worldToWnd.Append ( mtx ); } //----------------------------------------------------------------// void USCanvas::LoadMatrix ( const USMatrix3D& mtx ) { glLoadMatrixf ( mtx.m ); } //----------------------------------------------------------------// void USCanvas::LoadMatrix ( const USAffine2D& mtx ) { USMatrix3D mtx3D; mtx3D.Init ( mtx ); glLoadMatrixf ( mtx3D.m ); } //----------------------------------------------------------------// void USCanvas::MultMatrix ( const USMatrix3D& mtx ) { glMultMatrixf ( mtx.m ); } //----------------------------------------------------------------// void USCanvas::MultMatrix ( const USAffine2D& mtx ) { USMatrix3D mtx3D; mtx3D.Init ( mtx ); glMultMatrixf ( mtx3D.m ); } //----------------------------------------------------------------// void USCanvas::SetPen ( u32 penColor, u32 penSize ) { USCanvas::SetPenColor ( penColor ); USCanvas::SetPenSize ( penSize ); } //----------------------------------------------------------------// void USCanvas::SetPenColor ( u32 penColor ) { USColorVec color; color.SetRGBA ( penColor ); color.LoadGfxState (); } //----------------------------------------------------------------// void USCanvas::SetPenColor ( const USColorVec& color ) { color.LoadGfxState (); } //----------------------------------------------------------------// void USCanvas::SetPenSize ( u32 penSize ) { glLineWidth (( GLfloat )penSize ); } //----------------------------------------------------------------// void USCanvas::SetScissorRect () { USGfxDevice& device = USGfxDevice::Get (); glScissor ( 0, 0, ( int )device.GetWidth (), ( int )device.GetHeight ()); } //----------------------------------------------------------------// void USCanvas::SetScissorRect ( USRect& rect ) { glScissor (( int )rect.mXMin, ( int )rect.mYMin, ( int )rect.Width (), ( int )rect.Height ()); } //----------------------------------------------------------------// void USCanvas::SetScreenSpace () { USAffine2D wndToWorld; USCanvas::GetWndToWorldMtx ( wndToWorld ); glMatrixMode ( GL_MODELVIEW ); USCanvas::LoadMatrix ( wndToWorld ); } //----------------------------------------------------------------// void USCanvas::SetScreenSpace ( USViewport& viewport ) { glMatrixMode ( GL_MODELVIEW ); glLoadIdentity (); USAffine2D wndToNorm; USCanvas::GetWndToNormMtx ( viewport, wndToNorm ); glMatrixMode ( GL_PROJECTION ); USCanvas::LoadMatrix ( wndToNorm ); } //----------------------------------------------------------------// void USCanvas::SetTexture () { glBindTexture ( GL_TEXTURE_2D, 0 ); } //----------------------------------------------------------------// void USCanvas::SetTexture ( USTexture& texture ) { texture.Bind (); } //----------------------------------------------------------------// void USCanvas::SetUVMtx () { glMatrixMode ( GL_TEXTURE ); glLoadIdentity (); } //----------------------------------------------------------------// void USCanvas::SetUVMtx ( const USAffine2D& mtx ) { glMatrixMode ( GL_TEXTURE ); USCanvas::LoadMatrix ( mtx ); } //----------------------------------------------------------------// void USCanvas::SetViewProjMtx () { glMatrixMode ( GL_PROJECTION ); glLoadIdentity (); } //----------------------------------------------------------------// void USCanvas::SetViewProjMtx ( const USAffine2D& mtx ) { glMatrixMode ( GL_PROJECTION ); USCanvas::LoadMatrix ( mtx ); } //----------------------------------------------------------------// void USCanvas::SetViewProjMtx ( const USMatrix3D& mtx ) { glMatrixMode ( GL_PROJECTION ); USCanvas::LoadMatrix ( mtx ); } //----------------------------------------------------------------// void USCanvas::SetWorldMtx () { glMatrixMode ( GL_MODELVIEW ); glLoadIdentity (); } //----------------------------------------------------------------// void USCanvas::SetWorldMtx ( const USAffine2D& mtx ) { glMatrixMode ( GL_MODELVIEW ); USCanvas::LoadMatrix ( mtx ); } //----------------------------------------------------------------// void USCanvas::SetWorldMtx ( const USMatrix3D& mtx ) { glMatrixMode ( GL_MODELVIEW ); USCanvas::LoadMatrix ( mtx ); }
[ "[email protected]", "Patrick@agile.(none)" ]
[ [ [ 1, 513 ], [ 515, 540 ], [ 542, 564 ], [ 566, 592 ], [ 594, 639 ], [ 641, 680 ], [ 682, 732 ], [ 734, 909 ] ], [ [ 514, 514 ], [ 541, 541 ], [ 565, 565 ], [ 593, 593 ], [ 640, 640 ], [ 681, 681 ], [ 733, 733 ] ] ]
bba4a199ca648580b095f66748f13d8f1c3cd568
0c1f669f3dfdab47085bf537348b0354f836abea
/ qtremotedroid/QtRemoteDroidServer/src/oscservermethod.cpp
f4ea006f0ddecc5b2a16824a214667b61e0bcae5
[]
no_license
harlentan/qtremotedroid
fc5fc96d4374c39561aea73470a88d1f0a68b637
d07dd045213711538b38c7ced2fd6d5a8edcf241
refs/heads/master
2021-01-10T11:37:59.331004
2010-12-12T09:55:39
2010-12-12T09:55:39
54,114,402
0
0
null
null
null
null
UTF-8
C++
false
false
424
cpp
#include "oscservermethod.h" OscServerMethod::OscServerMethod(WOscContainer *parent, WOscReceiver *receiverContext, const char *methodName, const char *methodDescription): WOscReceiverMethod(parent, receiverContext, methodName, methodDescription) { }
[ [ [ 1, 14 ] ] ]
0385cfa11ed354df6fc5e4455da3b70b22f42bc7
c86a845a7873e3f543b307c8c03ac92a724c8beb
/finalapp/stdafx.cpp
6c49f2da784b81de6947dae22dde31e6a7cbb417
[]
no_license
smyang/remobj
58e4c3305a27b1a33e9f96f986911a39c22178d8
d9bce0847b98c598500e2d72ec02bc88c54d8e93
refs/heads/master
2016-09-10T13:58:42.452434
2010-05-01T21:36:26
2010-05-01T21:36:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
295
cpp
// stdafx.cpp : source file that includes just the standard includes // finalapp.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file
[ [ [ 1, 8 ] ] ]
ed8804d1ca78cdb86fe0f26ad86b1cee28319a75
138a353006eb1376668037fcdfbafc05450aa413
/source/Level.cpp
9e62192d5b459b16bb2211e860156238d2155c28
[]
no_license
sonicma7/choreopower
107ed0a5f2eb5fa9e47378702469b77554e44746
1480a8f9512531665695b46dcfdde3f689888053
refs/heads/master
2020-05-16T20:53:11.590126
2009-11-18T03:10:12
2009-11-18T03:10:12
32,246,184
0
0
null
null
null
null
UTF-8
C++
false
false
129
cpp
#include "Level.h" #include <cstring> //for NULL void Level::initPhysics(){ //mNewtonWorld = NewtonCreate (NULL, NULL); }
[ "Sonicma7@0822fb10-d3c0-11de-a505-35228575a32e" ]
[ [ [ 1, 6 ] ] ]
150850519b6465bfa9b39e78931db152b0c0a1cd
e59eeaca030f1fdf12cb79de0e646fafdaab2c64
/hepth.cpp
4e402e25e84843116239373b49cacbb5aef29eca
[]
no_license
jcccf/hepth
5215c5056845efb06601ad20ea975587bfa8463d
093ad00ec8e833be8b8a7501245be09489887371
refs/heads/master
2021-01-22T09:54:57.305488
2010-12-05T04:16:15
2010-12-05T04:16:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,043
cpp
#include "stdafx.h" #include "ClosureTime.h" #include "Shadow.h" int main(int argc, char* argv[]) { Env = TEnv(argc, argv, TNotify::StdNotify); Env.PrepArgs(TStr::Fmt("DCGraphInfo. build: %s, %s. Time: %s", __TIME__, __DATE__, TExeTm::GetCurTm())); TExeTm ExeTm; const TStr patentsFile = "cit-Patents.txt"; const TStr hepthFile = "Cit-HepTh.txt"; const TStr hepphFile = "Cit-HepPh.txt"; const TStr InFNm = Env.GetIfArgPrefixStr("-i:", hepthFile, "Input file"); const TInt InMinCit = Env.GetIfArgPrefixInt("-cmin:", 500, "Minimum Citations"); const TInt InMaxCit = Env.GetIfArgPrefixInt("-cmax:", 1000, "Maximum Citations"); PNGraph g = TNGraph::New(); Try g = TSnap::LoadEdgeList<PNGraph>(InFNm); printf("\nInput file has %d nodes, %d edges\n", g->GetNodes(), g->GetEdges()); //createClosureAgainstTime(g, false, 500, 9999); //Patents //createClosureKsAgainstTimeSingleSlidingPatents(g, 30, 100, 4723129); //createClosureKsAgainstTimeSingleSlidingPatents(g, 30, 100, 4463359); //createClosureKsAgainstTimeSingleSlidingPatents(g, 30, 100, 4740796); //createClosureKsAgainstTimeSingleSlidingPatents(g, 30, 100, 4345262); //createClosureKsAgainstTimeSingleSlidingPatents(g, 30, 100, 4558333); //createClosureKsAgainstTimeSingleSlidingPatents(g, 30, 100, 4313124); //createClosureKsAgainstTimeSingleSlidingPatents(g, 30, 100, 4683195); //createClosureKsAgainstTimeSingleSlidingPatents(g, 30, 100, 4459600); //createClosureKsAgainstTimeSingleSlidingPatents(g, 30, 100, 4683202); //createClosureKsAgainstTimeSlidingPatents(g, 30, 100, 500, 9999); //HepPH /*createClosureKsAgainstTimeSingleSliding(g, 30, 100, 9803315); createClosureKsAgainstTimeSingleSliding(g, 30, 100, 9804398); createClosureKsAgainstTimeSingleSliding(g, 30, 100, 9407339); createClosureKsAgainstTimeSingleSliding(g, 30, 100, 9512380); createClosureKsAgainstTimeSingleSliding(g, 30, 100, 9606399); createClosureKsAgainstTimeSingleSliding(g, 30, 100, 9807344);*/ //HepTH //createClosureKsAgainstTimeSingle(g, 30, 9711200); /*createClosureKsAgainstTimeSingleSliding(g, 30, 100, 9711200); createClosureKsAgainstTimeSingleSliding(g, 30, 100, 9802150); createClosureKsAgainstTimeSingleSliding(g, 30, 100, 9802109); createClosureKsAgainstTimeSingleSliding(g, 30, 100, 9407087); createClosureKsAgainstTimeSingleSliding(g, 30, 100, 9610043); createClosureKsAgainstTimeSingleSliding(g, 30, 100, 9510017); createClosureKsAgainstTimeSingleSliding(g, 30, 100, 9908142); createClosureKsAgainstTimeSingleSliding(g, 30, 100, 9503124); createClosureKsAgainstTimeSingleSliding(g, 30, 100, 9906064); createClosureKsAgainstTimeSingleSliding(g, 30, 100, 9408099);*/ //createCitationsAgainstTime(g, 500, 9999); //createCitationsAgainstTimeSliding(g, 100, 500, 9999); //createClosureKsAgainstTimeSliding(g, 30, 100, 1000, 9999); //createClosureKsAgainstTime(g, 10, 100, 9999); //createClosureKsAgainstTime(g, 15, 500, 9999); //createClosureAgainstTime(g, false, InMinCit, InMaxCit); //createClosureAgainstTime(g, false, 100, 120); //createClosureAgainstTime(g, false, 500, 9999); //createScatter(g, 100, 200); //createClosureAgainstPapers(g, 20, false, 0, 2500); //createClosureAgainstPapers(g, 50, false, 0, 2500); //createClosureAgainstPapers(g, 150, true, 0, 2500); //createClosureAgainstPapers(g, 200, true, 0, 2500); //createClosureAgainstPapers(g, 100, true, 0, 2500); //createClosureAgainstTimePatents(g, false, 500, 9999); //createClosureAgainstTimePatents(g, false, 50, 100); //createShadowOfPaper(g, 9802109); //createShadowOfPaper(g, 9802150); //createShadowOfPaper(g, 9711200); //createShadowOfPaper(g, 9704104); //createShadowOfPaper(g, 9703031); //createShadowOfPaper(g, 9908141); //createShadowOfPaper(g, 9602022); //createShadowOfPaper(g, 9601029); //createShadowOfPaper(g, 9611050); Catch printf("\nrun time: %s (%s)\n", ExeTm.GetTmStr(), TSecTm::GetCurTm().GetTmStr().CStr()); system("PAUSE"); return 0; }
[ [ [ 1, 90 ] ] ]
33dd93495f6b88ebcb2b571d4e93d22fbeb90999
b8c3d2d67e983bd996b76825f174bae1ba5741f2
/RTMP/utils/gil_2/libs/gil/io_new/unit_test/stdafx.h
b5e8a5227ae35366280638bb68e74c0b4fcb5ade
[]
no_license
wangscript007/rtmp-cpp
02172f7a209790afec4c00b8855d7a66b7834f23
3ec35590675560ac4fa9557ca7a5917c617d9999
refs/heads/master
2021-05-30T04:43:19.321113
2008-12-24T20:16:15
2008-12-24T20:16:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
520
h
// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #pragma once #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. #endif #include <stdio.h> #include <tchar.h> #include <fstream> #include <iostream> #include <boost/filesystem.hpp>
[ "fpelliccioni@71ea4c15-5055-0410-b3ce-cda77bae7b57" ]
[ [ [ 1, 18 ] ] ]
6a7096821389bb892961df688c652523869bb541
38664d844d9fad34e88160f6ebf86c043db9f1c5
/branches/initialize/infostudio/studio/verifyimgdlg.cpp
24a26bfde5ec0a7d87d2c77804e740c049afcaa8
[]
no_license
cnsuhao/jezzitest
84074b938b3e06ae820842dac62dae116d5fdaba
9b5f6cf40750511350e5456349ead8346cabb56e
refs/heads/master
2021-05-28T23:08:59.663581
2010-11-25T13:44:57
2010-11-25T13:44:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
938
cpp
#include "stdafx.h" #include "resource.h" #include "engine/infoengine.h" #include "verifyimgdlg.h" LRESULT VerifyImgDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { CenterWindow(GetParent()); picwnd_.SubclassWindow(GetDlgItem(IDC_IMAGE1)); CPicture pic; pic.Load(_T("C:\\w\\infostudio\\InfoStudio\\test\\msdn.bmp")); picwnd_.SetPicture(pic); return TRUE; } LRESULT VerifyImgDlg::OnInput(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { size_t i = wID - IDC_INPUT1; ASSERT(i < items_.size()); VerifyItem & vi = items_[i]; CWindow wnd(GetDlgItem(IDC_CODE1 + i)); CString str; wnd.GetWindowText(str); vi.code = (LPCWSTR)str; // vi.task->EnterVerifyCode(vi.code); return 0; } void VerifyImgDlg::CloseDialog(int nVal) { DestroyWindow(); ::PostQuitMessage(nVal); }
[ "ken.shao@ba8f1dc9-3c1c-0410-9eed-0f8a660c14bd" ]
[ [ [ 1, 38 ] ] ]
d6f22fab12a0c01dae14ac9faedc471dd3f9b133
3bc3ce568f1938af569a7f84d1c6e261a6fd4de5
/VideoMan/VideoMan/VideoMan/CTreeNode.cpp
639a91362eafb5cd2a6e6e4e734f6ceb0024a1f3
[]
no_license
dekz/uni
524cc16e706221ad518577e5f00712d5030c035f
84c2466df43f9dc62425d2b7c0162ac6b0a1244f
refs/heads/master
2016-09-05T21:07:29.739745
2009-05-24T13:12:24
2009-05-24T13:12:24
195,698
2
0
null
null
null
null
UTF-8
C++
false
false
542
cpp
#include "CTreeNode.h" CTreeNode::CTreeNode(Customer* item) { lchild = 0; rchild = 0; m_item = item; } void CTreeNode::setItem(Customer* data) { m_item = data; } Customer* CTreeNode::getItem() const { return m_item; } CTreeNode* CTreeNode::getLChild() const { return lchild; } CTreeNode* CTreeNode::getRChild() const { return rchild; } void CTreeNode::setRChild(CTreeNode* p) { rchild = p; } void CTreeNode::setLChild(CTreeNode* p) { lchild = p; } CTreeNode::~CTreeNode(void) { }
[ [ [ 1, 2 ], [ 4, 9 ], [ 11, 14 ], [ 16, 43 ] ], [ [ 3, 3 ], [ 10, 10 ], [ 15, 15 ] ] ]
98307b56c39567a20e1394c3e1192ac40de2fa31
382b459563be90227848e5125f0d37f83c1e2a4f
/Schedule/include/type.h
9ef9c53b93a3eab2a9953f000928135a116d6266
[]
no_license
Maciej-Poleski/SchoolTools
516c9758dfa153440a816a96e3f05c7f290daf6c
e55099f77eb0f65b75a871d577cc4054221b9802
refs/heads/master
2023-07-02T09:07:31.185410
2010-07-11T20:56:59
2010-07-11T20:56:59
392,391,718
0
0
null
null
null
null
UTF-8
C++
false
false
1,423
h
#ifndef TYPE_H #define TYPE_H #include <QtCore/QString> #include "initializable.h" #include "deletable.h" /** Reprezentuje dany typ wydarzenia. Wydarzenie musi zostać ustawione zanim pojawi się. * * Jest to klasa w stylu Utility. Składa się w szczególności z: * - Wagi tego typu wydarzeń (ala mnożnik do ocen powstałych poprzez wydarzenie tego typu). * - Skali ocen i zasad oceniania. * - Metod do prostej i szybkiej transformacji oceny (Mark) w ocene cząstkową (uwzględniając format ocen tego typu). */ class Type : private Initializable, private Deletable { public: private: QString name; ///< Nazwa typu public: /** Konstruktor. Inicjalizuje dany Typ wydarzenia. * @param name Nazwa danego Typu wydarzenia */ Type(QString name) : name(name), Initializable(true), Deletable(false) {} /** Konstruktor. Pozwala na tworzenie niezainicjalizowanych obiektów. */ Type() : Initializable(false), Deletable(false) {} /** Porównuje ze sobą obiekty pod kątem identyczności. * Wykorzystywane do kontroli spójności zapisu. * @param o Obiekt z którym zostanie porównany dany obiekt **/ bool operator==(const Type &o) const { return Initializable(*this)==Initializable(o) && Deletable(*this)==Deletable(o) && name==o.name; } private: }; #endif // TYPE_H
[ [ [ 1, 42 ] ] ]
b38c88670fca8cad9e95790f5a3f6543a62ee1d9
b2ff7f6bdf1d09f1adc4d95e8bfdb64746a3d6a4
/src/mldrv.cpp
d8f0ea46eed7abe4f5cd25952a9b4d68d2aad52b
[]
no_license
thebruno/dabster
39a315025b9344b8cca344d2904c084516915353
f85d7ec99a95542461862b8890b2542ec7a6b28d
refs/heads/master
2020-05-20T08:48:42.053900
2007-08-29T14:29:46
2007-08-29T14:29:46
32,205,762
0
0
null
null
null
null
UTF-8
C++
false
false
1,081
cpp
/********************************************************************* Sigma Dabster 5 Copyright (C) The Dabster Team 2007. All rights reserved. http://www.dabster.prv.pl/ http://code.google.com/p/dabster/ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 dated June, 1991. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Mail Drive mldrv.cpp *********************************************************************/ #include "mldrv.h" /********************************************************************/
[ "latusekpiotr@019b6672-ce2e-0410-a4f6-31e0795bab1a" ]
[ [ [ 1, 31 ] ] ]
26123e79204bf7ccbdcaf3a1211f7b5daea07ac8
b957e10ed5376dbe85c07bdef1f510f641984a1a
/Trigger.cpp
c0b6bf9cb56279995d237ac65dbe1e305a4fd561
[]
no_license
alexjshank/motors
063245c206df936a886f72a22f0f15c78e1129cb
7193b729466d8caece267f0b8ddbf16d99c13f8a
refs/heads/master
2016-09-10T15:47:20.906269
2009-11-04T18:41:21
2009-11-04T18:41:21
33,394,870
0
0
null
null
null
null
UTF-8
C++
false
false
1,643
cpp
#include ".\trigger.h" #include "entity.h" #include <string.h> #include "timer.h" #include "console.h" #include "variables.h" extern Timer *timer; extern Console *console; extern EntityContainer *ents; Trigger::Trigger(void) { type = E_TRIGGER; family = EF_ENVIRONMENT; size = Vector(0,0,0); lastTriggerTime = 0; } void Trigger::Create(Vector p, float radius, float resetTime, const char *script) { creationTime = timer->time; triggerType = HOTSPOT; triggerScript = script; triggerResetTime = resetTime; hotspotRadius = radius; position = p; } void Trigger::Create(float time, bool triggerTime, const char *script) { creationTime = timer->time; triggerScript = script; lifespan = time; triggerType = (triggerTime) ? TRIGGERTIME : GAMETIME; } void Trigger::Pull() { lastTriggerTime = timer->time; console->RunLine(triggerScript.c_str()); } void Trigger::process() { switch (triggerType) { case HOTSPOT: { if (timer->time - lastTriggerTime < triggerResetTime) break; Entity *closestEntity = ents->qtree.tree->getClosestEntity(position,hotspotTypeFilter,hotspotFamilyFilter,true,hotspotTeamFilter); if (closestEntity && dist(closestEntity->position, position) < hotspotRadius) { Pull(); } break; } case GAMETIME: { if (timer->time > lifespan) { Pull(); Remove(); // gametime and triggertime triggers can only be triggered once, so remove them after they're triggered } break; } case TRIGGERTIME: { if (timer->time - creationTime > lifespan) { Pull(); Remove(); } break; } } }
[ "alexjshank@0c9e2a0d-1447-0410-93de-f5a27bb8667b" ]
[ [ [ 1, 70 ] ] ]
034e222e07b924b5ad380b3e780ebbbe805b6511
b7c505dcef43c0675fd89d428e45f3c2850b124f
/Util/alcommon/include/albrokertools.h
9df758058bee2668a9265dd8736944f3dd4e9664
[ "BSD-2-Clause" ]
permissive
pranet/bhuman2009fork
14e473bd6e5d30af9f1745311d689723bfc5cfdb
82c1bd4485ae24043aa720a3aa7cb3e605b1a329
refs/heads/master
2021-01-15T17:55:37.058289
2010-02-28T13:52:56
2010-02-28T13:52:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
781
h
/** * @author Aldebaran Robotics * Aldebaran Robotics (c) 2007 All Rights Reserved - This file is confidential.\n * * Version : $Id$ */ /** * Some tools used by Proxies object */ #ifndef AL_BROKER_TOOLS_H #define AL_BROKER_TOOLS_H #include "altypes.h" #include "alptr.h" //#include "alstub.h" #include "almoduleinfo.h" typedef AL::al__ALModuleInfoNaoqi ALModuleInfo; typedef std::vector < ALModuleInfo > TALModuleInfoVector; typedef TALModuleInfoVector::iterator ITALModuleInfoVector; typedef TALModuleInfoVector::const_iterator CITALModuleInfoVector; // return a string describing the structure ALModuleInfo (mainly for debug purpose) std::string ToString( const ALModuleInfo& pInfo ); #endif // AL_BROKER_TOOLS_H
[ [ [ 1, 36 ] ] ]
d5a547f9fef249fa4ef855bd4687ad2a05d881ba
59066f5944bffb953431bdae0482a2abfb75f49a
/trunk/ogreopcode/example/include/ogreOpcodeExample.h
614ec2c7c848a4875e899951a7cc714dcd105920
[]
no_license
BackupTheBerlios/conglomerate-svn
5b1afdea5fbcdd8b3cdcc189770b1ad0f8027c58
bbecac90353dca2ae2114d40f5a6697b18c435e5
refs/heads/master
2021-01-01T18:37:56.730293
2006-05-21T03:12:39
2006-05-21T03:12:39
40,668,508
0
0
null
null
null
null
UTF-8
C++
false
false
2,798
h
/* ----------------------------------------------------------------------------- This source file is part of OGRE (Object-oriented Graphics Rendering Engine) For the latest info, see http://www.ogre3d.org/ Copyright (c) 2000-2005 The OGRE Team Also see acknowledgements in Readme.html You may use this sample code for anything you like, it is not covered by the LGPL like the rest of the engine. ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- Filename: ogreOpcodeExample.h Description: A place for me to try out stuff with OGRE. ----------------------------------------------------------------------------- */ #ifndef __ogreOpcodeExample_h_ #define __ogreOpcodeExample_h_ #include <ogre.h> #include "OgreKeyEvent.h" #include "OgreEventListeners.h" #include "OgreStringConverter.h" #include "OgreException.h" using namespace Ogre; class LoadingBar; class OgreOpcodeExample : public Ogre::Singleton<OgreOpcodeExample>, public FrameListener, public KeyListener { public: OgreOpcodeExample(void); virtual ~OgreOpcodeExample(void); virtual void go(void); protected: virtual bool setup(); virtual bool configure(void); virtual void chooseSceneManager(void); virtual void createCamera(void); virtual void createFrameListener(void); // Override me! virtual void createScene(void) = 0; virtual void destroyScene(void); virtual void createViewports(void); virtual void setupResources(void); virtual void createResourceListener(void); virtual void loadResources(void); virtual void updateStats(void); virtual bool processUnbufferedKeyInput(const FrameEvent& evt); virtual bool processUnbufferedMouseInput(const FrameEvent& evt); virtual void moveCamera(); virtual bool frameStarted(const FrameEvent& evt); virtual bool frameEnded(const FrameEvent& evt); void showDebugOverlay(bool show); void switchMouseMode(); void switchKeyMode(); void keyClicked(KeyEvent* e); void keyPressed(KeyEvent* e); void keyReleased(KeyEvent* e); Root *mRoot; Camera* mCamera; SceneManager* mSceneMgr; RenderWindow* mWindow; LoadingBar* mLoadingBar; int mSceneDetailIndex ; Real mMoveSpeed; Degree mRotateSpeed; Overlay* mDebugOverlay; EventProcessor* mEventProcessor; InputReader* mInputDevice; Vector3 mTranslateVector; bool mStatsOn; bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn; unsigned int mNumScreenShots; float mMoveScale; Degree mRotScale; // just to stop toggles flipping too fast Real mTimeUntilNextToggle ; Radian mRotX, mRotY; TextureFilterOptions mFiltering; int mAniso; }; #endif // #ifndef __ogreOpcodeExample_h_
[ "jacmoe@4fa2dde5-35f3-0310-a95e-e112236e8438" ]
[ [ [ 1, 93 ] ] ]
61e204f41090578827b4c11183f739ea1d0c07a4
27d5670a7739a866c3ad97a71c0fc9334f6875f2
/CPP/include/symbian-r6/CleanupSupport.h
d28ebb6c3c989347d30e5d6e8fea8ba4b897c8b4
[ "BSD-3-Clause" ]
permissive
ravustaja/Wayfinder-S60-Navigator
ef506c418b8c2e6498ece6dcae67e583fb8a4a95
14d1b729b2cea52f726874687e78f17492949585
refs/heads/master
2021-01-16T20:53:37.630909
2010-06-28T09:51:10
2010-06-28T09:51:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,732
h
/* Copyright (c) 1999 - 2010, Vodafone Group Services Ltd All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Vodafone Group Services Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef CLEANUPSUPPORT_H #define CLEANUPSUPPORT_H #include <coemain.h> #include <badesca.h> #include "GuiProt/GuiProtMess.h" ///Function that can be pushed onto the cleanupstack to clean up fonts. ///@param ptr Should be a CFont pointer. inline void CleanupFont(TAny* ptr) { CCoeEnv::Static()->ScreenDevice()->ReleaseFont(static_cast<CFont*>(ptr)); } ///Constructs and pushes a TCleanupItem object onto the cleanup stask. ///The TCleanupItem encapsulates a CFont object and a function pointer ///to CleanupFont. CleanupFont is invoked by a subsequent call to ///CleanupStack::PopAndDestroy(). ///@param aFont a pointer to a CFont object that needs to be released /// later. inline void CleanupReleaseFontPushL(CFont* aFont){ CleanupStack::PushL(TCleanupItem(CleanupFont, aFont)); } ///This template class if a helper object for deleting non-CBase ///derived classes and arrays where the class's destructor needs to be ///called. It has only static functions and should never be instantiated. template<class T> class CleanupClass{ ///private to avoid instantiation. CleanupClass(); ///private to avoid instantiation. CleanupClass(const CleanupClass&); ///private to avoid instantiation. const CleanupClass& operator=(const CleanupClass&); ///The type to use on the pointer when deleting it. typedef T* ptr_t; public: ///Casts the argument to ptr_t and deletes it. ///@param any the poionter to delete. static void Cleanup(void* any){ delete static_cast<ptr_t>(any); } ///Casts the argument to ptr_t and delete[]s it. ///@param any the pointer to delete. static void CleanupArray(void* any){ delete[] static_cast<ptr_t>(any); } }; inline void CleanupCharArrayPushL(char* array) { CleanupStack::PushL(TCleanupItem(CleanupClass<char>::CleanupArray, array)); } ///Thes template function matches the CleanupClass::Cleanup function, ///but is unusable in VC6. //@{ template<typename type> static void Cleanup(void* any){ delete static_cast<type*>(any); } template<typename type> static void CleanupArray(void* any){ delete[] static_cast<type*>(any); } //@} template<class T> void CleanupClassPushL(T* aItem) { CleanupStack::PushL(TCleanupItem(CleanupClass<T>::Cleanup, aItem)); } ///This function matches the TCleanupOperation function pointer ///typedef, and can be used as a TCleanupItemArgument in combination ///with a CDesCArray derived object. ///On a Leave or PopAndDestroy it will remove the last descriptor in the array. ///If the function is called with a empty array as argument, it's a no-op. ///@param aCDesCArray a TAny pointer taht will be static_cast to a /// CDesCArray pointer. static void PopBack(TAny* aCDesCArray) { CDesCArray& array = *static_cast<CDesCArray*>(aCDesCArray); if(array.Count() > 0){ array.Delete(array.Count() - 1); } } ///This function matches the TCleanupOperation function pointer ///typedef, and can be used as a TCleanupItemArgument in combination ///with a CDesCArray derived object. ///On a Leave or PopAndDestroy it will remove the first descriptor ///in the array. ///If the function is called with a empty array as argument, it's a no-op. ///@param aCDesCArray a TAny pointer that will be static_cast to a /// CDesCArray pointer. static void PopFront(TAny* aCDesCArray) { CDesCArray& array = *static_cast<CDesCArray*>(aCDesCArray); if(array.Count() > 0){ array.Delete(0); } } ///This function appends a descriptor to an array, and pushes a ///PopBack cleanupitem to the cleanupstack. Do this if you want the ///array to roll back to its initial state in a leave. ///@param aArray the array to append to. ///@param aDes the descriptor to append. inline void CleanupPushAppendL(CDesCArray* aArray, const TDesC& aDes) { aArray->AppendL(aDes); CleanupStack::PushL(TCleanupItem(PopBack, aArray)); } ///This function inserts a descriptor at the beginning of an array, ///and pushes a PopBack cleanupitem to the cleanupstack. Do this if ///you want the array to roll back to its initial state in a leave. ///@param aArray the array to insert into. ///@param aDes the descriptor to insert. inline void CleanupPushInsertL(CDesCArray* aArray, const TDesC& aDes) { aArray->InsertL(0, aDes); CleanupStack::PushL(TCleanupItem(PopFront, aArray)); } template<class T> class SignalItem { public: static void Signal(TAny* aAny){ static_cast<T*>(aAny)->Signal(); } }; template<class T> void CleanupSignalPushL(T& aRef) { CleanupStack::PushL(TCleanupItem(SignalItem<T>::Signal, &aRef)); } inline void DeleteMembers(TAny* aAny) { class isab::GuiProtMess* mess = static_cast<isab::GuiProtMess*>(aAny); mess->deleteMembers(); } inline void CleanupDeleteMembersPushL(class isab::GuiProtMess* aMess) { CleanupStack::PushL(TCleanupItem(DeleteMembers, aMess)); } inline void CleanupDeleteMembersPushL(class isab::GuiProtMess& aMess) { CleanupStack::PushL(TCleanupItem(DeleteMembers, &aMess)); } #endif
[ [ [ 1, 169 ] ] ]
293f883cb3d2cb9e560a6f1dc32cc98902c4fe99
d397b0d420dffcf45713596f5e3db269b0652dee
/src/Lib/PropertySystem/TypeNumeric.hpp
f82d0b91a0eead431fdb35981dec9bc78f4c7bcf
[]
no_license
irov/Axe
62cf29def34ee529b79e6dbcf9b2f9bf3709ac4f
d3de329512a4251470cbc11264ed3868d9261d22
refs/heads/master
2021-01-22T20:35:54.710866
2010-09-15T14:36:43
2010-09-15T14:36:43
85,337,070
0
0
null
null
null
null
UTF-8
C++
false
false
742
hpp
# pragma once # include <typeinfo> # include "Type.hpp" # include "Numeric.hpp" namespace AxeProperty { template<class T> class TypeNumeric : public Type { public: TypeNumeric() : Type( typeid(T).name() ) { } public: BasePtr gen() override { return new Numeric<T>( this ); } void visit( TypeVisitor * _visitor ) override; }; //typedef TypeNumeric<bool> TypeBool; //typedef TypeNumeric<int> TypeInt; //typedef TypeNumeric<float> TypeFloat; //typedef TypeNumeric<double> TypeDouble; //typedef AxeHandle<TypeBool> TypeBoolPtr; //typedef AxeHandle<TypeInt> TypeIntPtr; //typedef AxeHandle<TypeFloat> TypeFloatPtr; //typedef AxeHandle<TypeDouble> TypeDoublePtr; }
[ "yuriy_levchenko@b35ac3e7-fb55-4080-a4c2-184bb04a16e0" ]
[ [ [ 1, 39 ] ] ]
b09d9242f42ea8649ce2ccded602f76fef0f99bb
24bc1634133f5899f7db33e5d9692ba70940b122
/extlibs/RakNet/include/DS_BytePool.h
92fb03726ebb3cb33b0243c3515a155f95bff649
[]
no_license
deft-code/ammo
9a9cd9bd5fb75ac1b077ad748617613959dbb7c9
fe4139187dd1d371515a2d171996f81097652e99
refs/heads/master
2016-09-05T08:48:51.786465
2009-10-09T05:49:00
2009-10-09T05:49:00
32,252,326
0
0
null
null
null
null
UTF-8
C++
false
false
960
h
#ifndef __BYTE_POOL_H #define __BYTE_POOL_H #include "RakMemoryOverride.h" #include "DS_MemoryPool.h" #include "Export.h" #include "SimpleMutex.h" #include <assert.h> // #define _DISABLE_BYTE_POOL // #define _THREADSAFE_BYTE_POOL namespace DataStructures { // Allocate some number of bytes from pools. Uses the heap if necessary. class RAK_DLL_EXPORT BytePool { public: BytePool(); ~BytePool(); // Should be at least 8 times bigger than 8192 void SetPageSize(int size); unsigned char* Allocate(int bytesWanted); void Release(unsigned char *data); void Clear(void); protected: MemoryPool<unsigned char[128]> pool128; MemoryPool<unsigned char[512]> pool512; MemoryPool<unsigned char[2048]> pool2048; MemoryPool<unsigned char[8192]> pool8192; #ifdef _THREADSAFE_BYTE_POOL SimpleMutex mutex128; SimpleMutex mutex512; SimpleMutex mutex2048; SimpleMutex mutex8192; #endif }; } #endif
[ "PhillipSpiess@d8b90d80-bb63-11dd-bed2-db724ec49875" ]
[ [ [ 1, 40 ] ] ]