本文整理汇总了C++中NewEventHandlerUPP函数的典型用法代码示例。如果您正苦于以下问题:C++ NewEventHandlerUPP函数的具体用法?C++ NewEventHandlerUPP怎么用?C++ NewEventHandlerUPP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewEventHandlerUPP函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dialog_create_grid_mesh_run
bool dialog_create_grid_mesh_run(int *xdiv,int *ydiv,int *zdiv)
{
EventHandlerUPP event_upp;
EventTypeSpec event_list[]={{kEventClassCommand,kEventProcessCommand}};
// open the dialog
dialog_open(&dialog_create_grid_mesh_wind,"GridMesh");
// install event handler
event_upp=NewEventHandlerUPP(create_grid_mesh_event_proc);
InstallWindowEventHandler(dialog_create_grid_mesh_wind,event_upp,GetEventTypeCount(event_list),event_list,NULL,NULL);
// setup controls
dialog_set_int(dialog_create_grid_mesh_wind,kGridMeshXDivision,0,10);
dialog_set_int(dialog_create_grid_mesh_wind,kGridMeshYDivision,0,10);
dialog_set_int(dialog_create_grid_mesh_wind,kGridMeshZDivision,0,10);
// show window
ShowWindow(dialog_create_grid_mesh_wind);
// modal window
dialog_create_grid_mesh_cancel=FALSE;
RunAppModalLoopForWindow(dialog_create_grid_mesh_wind);
// get object name
if (!dialog_create_grid_mesh_cancel) {
*xdiv=dialog_get_int(dialog_create_grid_mesh_wind,kGridMeshXDivision,0);
*ydiv=dialog_get_int(dialog_create_grid_mesh_wind,kGridMeshYDivision,0);
*zdiv=dialog_get_int(dialog_create_grid_mesh_wind,kGridMeshZDivision,0);
}
// close window
DisposeWindow(dialog_create_grid_mesh_wind);
return(!dialog_create_grid_mesh_cancel);
}
示例2: main
int main(int argc, char* argv[])
{
IBNibRef nibRef;
OSStatus err;
// check the correct BASS was loaded
if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
Error("An incorrect version of BASS was loaded");
return 0;
}
// initialize default output device
if (!BASS_Init(-1,44100,0,NULL,NULL)) {
Error("Can't initialize device");
return 0;
}
BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST,1); // enable playlist processing
BASS_SetConfig(BASS_CONFIG_NET_PREBUF,0); // minimize automatic pre-buffering, so we can do it (and display it) instead
BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY,proxy); // setup proxy server location
// Create Window and stuff
err = CreateNibReference(CFSTR("netradio"), &nibRef);
if (err) return err;
err = CreateWindowFromNib(nibRef, CFSTR("Window"), &win);
if (err) return err;
DisposeNibReference(nibRef);
int a;
for (a=10;a<20;a++)
SetupControlHandler(a,kEventControlHit,RadioEventHandler);
SetupControlHandler(41,kEventControlHit,DirectEventHandler);
{
EventTypeSpec etype={'blah','blah'};
InstallApplicationEventHandler(NewEventHandlerUPP(CustomEventHandler),1,&etype,NULL,NULL);
}
ShowWindow(win);
RunApplicationEventLoop();
BASS_Free();
return 0;
}
示例3: m_owner
KGlobalAccelImpl::KGlobalAccelImpl(GlobalShortcutsRegistry* owner)
: m_owner(owner)
, m_eventTarget(GetApplicationEventTarget())
, m_eventHandler(NewEventHandlerUPP(hotKeyEventHandler))
{
m_eventType[0].eventClass = kEventClassKeyboard;
m_eventType[0].eventKind = kEventHotKeyPressed;
m_eventType[1].eventClass = kEventClassKeyboard; // only useful for testing, is not used because count passed in call to InstallEventHandler is 1
m_eventType[1].eventKind = kEventRawKeyDown;
refs = new QMap<int, QList<EventHotKeyRef> >();
CFStringRef str = CFStringCreateWithCString(NULL, "AppleKeyboardPreferencesChangedNotification", kCFStringEncodingASCII);
if (str) {
CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), this, layoutChanged, str, NULL, CFNotificationSuspensionBehaviorHold);
CFRelease(str);
} else {
kWarning(125) << "Couldn't create CFString to register for keyboard notifications";
}
}
示例4: install_app_launch_cb
int
install_app_launch_cb(void *user_data)
{
static int already_installed = 0;
if(!already_installed){
EventHandlerUPP cb_upp;
EventTypeSpec event_types[2] = {
{kEventClassApplication, kEventAppTerminated},
{kEventClassApplication, kEventAppLaunchNotification}};
if((cb_upp = NewEventHandlerUPP(osx_launch_app_callback)) == NULL)
return 1;
InstallApplicationEventHandler(cb_upp, 2, event_types,
user_data, NULL);
already_installed = 1;
}
return 0;
}
示例5: palette_polygon_open
void palette_polygon_open(int x,int y)
{
EventHandlerUPP event_upp;
EventTypeSpec event_list[]={{kEventClassControl,kEventControlHit},
{kEventClassKeyboard,kEventRawKeyUp}};
// open the window
dialog_open(&palette_poly_wind,"PolyPalette");
MoveWindow(palette_poly_wind,x,y,FALSE);
// show palette
ShowWindow(palette_poly_wind);
// install event handler
event_upp=NewEventHandlerUPP(palette_poly_event_proc);
InstallWindowEventHandler(palette_poly_wind,event_upp,GetEventTypeCount(event_list),event_list,NULL,NULL);
}
示例6: setupJoyConfig
static OSStatus setupJoyConfig (OSType type) {
OSStatus err = noErr;
char elementName[256] = "----";
err = CreateWindowFromNib(nibRef, CFSTR("InputWindow"), &joyWin);
if (err == noErr) {
EventTypeSpec list[]={ { kEventClassCommand, kEventCommandProcess } };
EventHandlerRef ref;
InstallWindowEventHandler (joyWin, NewEventHandlerUPP(joyWinproc), 1, list, (void *)joyWin, &ref);
ShowSheetWindow(joyWin, soundWin);
if (setJoypad(type, elementName)) {
setTitle(type, elementName);
}
HideSheetWindow(joyWin);
DisposeWindow(joyWin);
}
return(err);
}
示例7: WindowImpl
// ---------------------------------------------------------------------------
OSXWindowImpl::OSXWindowImpl(Window* window)
: WindowImpl(window)
{
OSStatus s;
WindowClass wc = kDocumentWindowClass;
WindowAttributes wa = 0
// |kWindowCompositingAttribute
|kWindowStandardDocumentAttributes
|kWindowStandardHandlerAttribute
|kWindowLiveResizeAttribute
;
mRect.left = 100;
mRect.right = mRect.left + 256;
mRect.top = 100;
mRect.bottom = mRect.top + 256;
s = CreateNewWindow(wc,wa,&mRect,&mWindowRef);
check_noerr(s);
EventTypeSpec typeList[] = {
{ kEventClassWindow, kEventWindowClosed },
{ kEventClassWindow, kEventWindowDrawContent },
{ kEventClassWindow, kEventWindowBoundsChanged },
{ kEventClassKeyboard, kEventRawKeyDown },
{ kEventClassKeyboard, kEventRawKeyUp },
{ kEventClassMouse, kEventMouseDown },
{ kEventClassMouse, kEventMouseUp },
{ kEventClassMouse, kEventMouseMoved },
{ kEventClassMouse, kEventMouseDragged },
{ kEventClassMouse, kEventMouseWheelMoved }
};
int numTypes = sizeof(typeList)/sizeof(EventTypeSpec);
EventHandlerUPP handlerUPP = NewEventHandlerUPP(OSXWindowImpl::memberDelegate);
EventTargetRef theTarget;
theTarget = GetWindowEventTarget(mWindowRef);
InstallEventHandler(
theTarget, handlerUPP,
numTypes, typeList,
this,
NULL
);
on_init();
}
示例8: wxTaskBarIconImpl
//-----------------------------------------------------------------------------
// wxDockTaskBarIcon ctor
//
// Initializes the dock implementation of wxTaskBarIcon.
//
// Here we create some Mac-specific event handlers and UPPs.
//-----------------------------------------------------------------------------
wxDockTaskBarIcon::wxDockTaskBarIcon(wxTaskBarIcon* parent)
: wxTaskBarIconImpl(parent),
m_eventHandlerRef(NULL), m_pMenu(NULL),
m_theLastMenu(GetApplicationDockTileMenu()), m_iconAdded(false)
{
// register the events that will return the dock menu
EventTypeSpec tbEventList[] =
{
{ kEventClassCommand, kEventProcessCommand },
{ kEventClassApplication, kEventAppGetDockTileMenu }
};
m_eventupp = NewEventHandlerUPP(wxDockEventHandler);
wxASSERT(m_eventupp != NULL);
OSStatus err = InstallApplicationEventHandler(
m_eventupp,
GetEventTypeCount(tbEventList), tbEventList,
this, &m_eventHandlerRef);
verify_noerr( err );
}
示例9: loadAboutWin
bool loadAboutWin()
{
IBNibRef nibFile;
OSStatus iResult;
EventTypeSpec pEvent;
g_lpfnAboutProc = NewEventHandlerUPP(aboutEvtHandler);
if (noErr != (iResult = CreateNibReference(CFSTR("AboutWin"), &nibFile)))
{
DisposeEventHandlerUPP(g_lpfnAboutProc);
fprintf(stderr, "loadAboutWin() - CreateNibReference(AboutWin) failed, returning %lu!\n", (unsigned long) iResult);
return false;
}
if (noErr != (iResult = CreateWindowFromNib(nibFile, CFSTR("FroggAboutWindow"), &g_refAboutWin)))
{
DisposeNibReference(nibFile);
DisposeEventHandlerUPP(g_lpfnAboutProc);
fprintf(stderr, "loadAboutWin() - CreateWindowFromNib(FroggAboutWindow) failed, returning %lu!\n", (unsigned long) iResult);
return false;
}
DisposeNibReference(nibFile);
pEvent.eventClass = kEventClassWindow;
pEvent.eventKind = kEventWindowClose;
if (noErr != (iResult = InstallWindowEventHandler(g_refAboutWin, g_lpfnAboutProc, 1, &pEvent, NULL, &g_refAboutHdlr)))
{
DisposeWindow(g_refAboutWin);
DisposeEventHandlerUPP(g_lpfnAboutProc);
fprintf(stderr, "loadAboutWin() - InstallWindowEventHandler() failed, returning %lu!\n", (unsigned long) iResult);
return false;
}
g_bLoaded = true;
return true;
}
示例10: CreateDialogWindow
// Create, show and run modally our dialog window
OSStatus CreateDialogWindow()
{
IBNibRef nibRef;
EventTypeSpec dialogSpec = {kEventClassCommand, kEventCommandProcess };
WindowRef dialogWindow;
EventHandlerUPP dialogUPP;
OSStatus err = noErr;
// Find the dialog nib
err = CreateNibReference(CFSTR("dialog"), &nibRef);
require_noerr( err, CantFindDialogNib );
// Load the window inside it
err = CreateWindowFromNib(nibRef, CFSTR("dialog"), &dialogWindow);
require_noerr( err, CantCreateDialogWindow );
// We don't need the nib reference anymore.
DisposeNibReference(nibRef);
// Install our event handler
dialogUPP = NewEventHandlerUPP (DialogWindowEventHandler);
err = InstallWindowEventHandler (dialogWindow, dialogUPP, 1, &dialogSpec, (void *) dialogWindow, NULL);
require_noerr( err, CantInstallDialogHandler );
// Show the window
ShowWindow( dialogWindow );
// Run modally
RunAppModalLoopForWindow(dialogWindow);
HideWindow(dialogWindow);
DisposeWindow(dialogWindow);
DisposeEventHandlerUPP(dialogUPP);
CantFindDialogNib:
CantCreateDialogWindow:
CantInstallDialogHandler:
return err;
}
示例11: dialog_group_settings_run
bool dialog_group_settings_run(group_type *group)
{
EventHandlerUPP event_upp;
EventTypeSpec event_list[]={{kEventClassCommand,kEventProcessCommand}};
// open the dialog
dialog_open(&dialog_group_settings_wind,"GroupSettings");
// set controls
dialog_set_text(dialog_group_settings_wind,kGroupName,0,group->name);
// show window
ShowWindow(dialog_group_settings_wind);
// install event handler
event_upp=NewEventHandlerUPP(group_setting_event_proc);
InstallWindowEventHandler(dialog_group_settings_wind,event_upp,GetEventTypeCount(event_list),event_list,NULL,NULL);
// modal window
dialog_group_settings_cancel=FALSE;
RunAppModalLoopForWindow(dialog_group_settings_wind);
// dialog to data
if (!dialog_group_settings_cancel) {
dialog_get_text(dialog_group_settings_wind,kGroupName,0,group->name,name_str_len);
}
// close window
DisposeWindow(dialog_group_settings_wind);
return(!dialog_group_settings_cancel);
}
示例12: ui_main
void ui_main() {
if( data.init_done )
return;
data.init_done = 1;
# if defined(NEKO_WINDOWS)
{
WNDCLASSEX wcl;
HINSTANCE hinst = GetModuleHandle(NULL);
memset(&wcl,0,sizeof(wcl));
wcl.cbSize = sizeof(WNDCLASSEX);
wcl.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wcl.lpfnWndProc = WindowProc;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
wcl.hInstance = hinst;
wcl.hIcon = NULL;
wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
wcl.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
wcl.lpszMenuName = "";
wcl.lpszClassName = CLASS_NAME;
wcl.hIconSm = 0;
RegisterClassEx(&wcl);
}
data.tid = GetCurrentThreadId();
data.wnd = CreateWindow(CLASS_NAME,"",0,0,0,0,0,NULL,NULL,NULL,NULL);
# elif defined(NEKO_MAC)
MPCreateTask(nothing,NULL,0,0,0,0,0,NULL); // creates a MPTask that will enable Carbon MT
data.tid = pthread_self();
EventTypeSpec ets = { UIEvent, eCall };
InstallEventHandler(GetApplicationEventTarget(),NewEventHandlerUPP(handleEvents),1,&ets,0,0);
# elif defined(NEKO_LINUX)
g_thread_init(NULL);
gdk_threads_init();
gtk_init(NULL,NULL);
setlocale(LC_NUMERIC,"POSIX"); // prevent broking atof()
data.tid = pthread_self();
pthread_mutex_init(&data.lock,NULL);
# endif
}
示例13: main
//---------------------------------------------------------------------------------------------
int main()
{
static const EventTypeSpec sApplicationEvents[] = {{ kEventClassCommand, kEventCommandProcess }};
OSErr err;
if (!SystemVersionRequired(0x1020))
{
DialogRef theAlert;
CreateStandardAlert(kAlertStopAlert, CFSTR("Need 10.2 or later!"), NULL, NULL, &theAlert);
RunStandardAlert(theAlert, NULL, NULL);
return 0;
}
ProcessSerialNumber psn = {0, kCurrentProcess};
err = GetProcessBundleLocation(&psn, &gApplicationBundleFSRef);
err = CreateNibReference(CFSTR("CarbonSketch"), &gOurNibRef );
require_noerr( err, CantGetNibRef );
err = SetMenuBarFromNib( gOurNibRef, CFSTR("MenuBar") );
require_noerr( err, SetMenuBarFromNib_FAILED );
AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, DoOpenApp, 0, false);
AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, DoOpenDocuments, 0, false);
// AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, DoPrintDocuments, 0, false);
InstallApplicationEventHandler( NewEventHandlerUPP(AppEventHandlerProc),
GetEventTypeCount(sApplicationEvents),
sApplicationEvents, 0, NULL );
RunApplicationEventLoop();
SetMenuBarFromNib_FAILED:
DisposeNibReference(gOurNibRef);
CantGetNibRef:
return err;
}
示例14: main
int main(int argc, char* argv[])
{
IBNibRef nibRef;
OSStatus err;
// Create a Nib reference passing the name of the nib file (without the .nib extension)
// CreateNibReference only searches into the application bundle.
err = CreateNibReference(CFSTR("main"), &nibRef);
require_noerr( err, CantGetNibRef );
// Once the nib reference is created, set the menu bar. "MainMenu" is the name of the menu bar
// object. This name is set in InterfaceBuilder when the nib is created.
err = SetMenuBarFromNib(nibRef, CFSTR("MenuBar"));
require_noerr( err, CantSetMenuBar );
MakeWindow(nibRef);
// don't need the nib reference anymore.
DisposeNibReference(nibRef);
const EventTypeSpec commandProcessEvents[] = { { kEventClassCommand, kEventCommandProcess } };
InstallAppleEventHandlers();
InstallApplicationEventHandler( NewEventHandlerUPP(CommandProcessEventHandler),
GetEventTypeCount(commandProcessEvents),
commandProcessEvents, NULL, NULL );
// Must initialize QuickTime first
InitializeQuickTime ();
// Call the event loop
RunApplicationEventLoop();
CantCreateWindow:
CantSetMenuBar:
CantGetNibRef:
return err;
}
示例15: main
int main(int argc, char* argv[])
{
IBNibRef nibRef;
WindowRef window;
OSStatus err;
EventTypeSpec cmdEvent = {kEventClassCommand, kEventCommandProcess};
// Create a Nib reference passing the name of the nib file (without the .nib extension)
// CreateNibReference only searches into the application bundle.
err = CreateNibReference(CFSTR("main"), &nibRef);
require_noerr( err, CantGetNibRef );
// Once the nib reference is created, set the menu bar. "MainMenu" is the name of the menu bar
// object. This name is set in InterfaceBuilder when the nib is created.
err = SetMenuBarFromNib(nibRef, CFSTR("MenuBar"));
require_noerr( err, CantSetMenuBar );
// Then create a window. "MainWindow" is the name of the window object. This name is set in
// InterfaceBuilder when the nib is created.
err = CreateWindowFromNib(nibRef, CFSTR("MainWindow"), &window);
require_noerr( err, CantCreateWindow );
// We don't need the nib reference anymore.
DisposeNibReference(nibRef);
// The window was created hidden so show it.
ShowWindow( window );
InstallApplicationEventHandler(NewEventHandlerUPP(appCommandHandler), GetEventTypeCount(cmdEvent), &cmdEvent, 0, NULL);
// Call the event loop
RunApplicationEventLoop();
CantCreateWindow:
CantSetMenuBar:
CantGetNibRef:
return err;
}