static jboolean isFloat_native(JNIEnv* env, jobject object, jint row, jint column)
{
    int32_t err;
    CursorWindow * window = GET_WINDOW(env, object);
LOG_WINDOW("Checking if column is a float for %d,%d from %p", row, column, window);

    field_slot_t field;
    err = window->read_field_slot(row, column, &field);
    if (err != 0) {
        throwExceptionWithRowCol(env, row, column);
        return false;
    }

    return field.type == FIELD_TYPE_FLOAT;
}
static jint getType_native(JNIEnv* env, jobject object, jint row, jint column)
{
    int32_t err;
    CursorWindow * window = GET_WINDOW(env, object);
LOG_WINDOW("Getting type for %d,%d from %p", row, column, window);

    field_slot_t field;
    err = window->read_field_slot(row, column, &field);
    if (err != 0) {
        throwExceptionWithRowCol(env, row, column);
        return false;
    }

    return field.type;
}
Example #3
0
void sdl_event_manager::process_window_event(running_machine &machine, SDL_Event &sdlevent)
{
	sdl_window_info *window = GET_WINDOW(&sdlevent.window);

	if (window == NULL)
		return;

	switch (sdlevent.window.event)
	{
	case SDL_WINDOWEVENT_CLOSE:
		machine.schedule_exit();
		break;

	case SDL_WINDOWEVENT_LEAVE:
		machine.ui_input().push_mouse_leave_event(window->target());
		m_app_has_mouse_focus = 0;
		break;

	case SDL_WINDOWEVENT_MOVED:
		window->notify_changed();
		m_focus_window = window;
		break;

	case SDL_WINDOWEVENT_RESIZED:
#ifndef SDLMAME_WIN32
		/* FIXME: SDL2 sends some spurious resize events on Ubuntu
		* while in fullscreen mode. Ignore them for now.
		*/
		if (!window->fullscreen())
#endif
		{
			//printf("event data1,data2 %d x %d %ld\n", event.window.data1, event.window.data2, sizeof(SDL_Event));
			window->resize(sdlevent.window.data1, sdlevent.window.data2);
		}
		m_focus_window = window;
		break;

	case SDL_WINDOWEVENT_ENTER:
		m_app_has_mouse_focus = 1;
		/* fall through */
	case SDL_WINDOWEVENT_FOCUS_GAINED:
	case SDL_WINDOWEVENT_EXPOSED:
	case SDL_WINDOWEVENT_MAXIMIZED:
	case SDL_WINDOWEVENT_RESTORED:
		m_focus_window = window;
		break;
	}
}
static jstring getString_native(JNIEnv* env, jobject object, jint row, jint column)
{
  int i;
    int32_t err;
    CursorWindow * window = GET_WINDOW(env, object);
    LOG_WINDOW("Getting string for %d,%d from %p", row, column, window);
    field_slot_t field;
    err = window->read_field_slot(row, column, &field);
    if (err != 0) {
        throwExceptionWithRowCol(env, row, column);
        return NULL;
    }
    uint8_t type = field.type;
    jint size = (jint)field.data.buffer.size;
    if (type == FIELD_TYPE_NULL) {
         return NULL;
    } else if (type == FIELD_TYPE_BLOB) {
        throw_sqlite3_exception(env, "Unable to convert BLOB to string");
        return NULL;
    } else if (type == FIELD_TYPE_STRING) {
      jchar * buf = (jchar *)window->offsetToPtr(field.data.buffer.offset);
      jclass strClass = env->FindClass("java/lang/String"); 
      jmethodID ctorID = env->GetMethodID(strClass, "<init>", "([BLjava/lang/String;)V"); 
      jstring encoding = env->NewStringUTF("UTF-16LE");
      jbyteArray bytes = env->NewByteArray(size); 
      env->SetByteArrayRegion(bytes, 0, size, (jbyte*)buf);
      return (jstring)env->NewObject(strClass, ctorID, bytes, encoding);
    } else if (type == FIELD_TYPE_INTEGER) {
        int64_t value;
        if (window->getLong(row, column, &value)) {
          char buf[32];
          snprintf(buf, sizeof(buf), "%lld", value);
          return env->NewStringUTF((const char*)buf);
        }
        return NULL;
    } else if (type == FIELD_TYPE_FLOAT) {
        double value;
        if (window->getDouble(row, column, &value)) {
            char buf[32];
            snprintf(buf, sizeof(buf), "%g", value);
            return env->NewStringUTF(buf);
        }
        return NULL;
    }
}
Example #5
0
INT_PTR CALLBACK PropSheetPageDlg::DialogProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam)
{
	PropSheetPageDlg* pThis = GET_WINDOW(PropSheetPageDlg, hwnd);

	if (pThis) {
		switch(nmsg) {
		  case WM_COMMAND:
			SetWindowLong(hwnd, DWL_MSGRESULT, (LPARAM)pThis->Command(LOWORD(wparam), HIWORD(wparam)));
			return TRUE;	// message has been processed

		  case WM_NOTIFY:
			pThis->Notify(wparam, (NMHDR*)lparam);
			return TRUE;	// message has been processed

		  case WM_NOTIFYFORMAT:
			SetWindowLong(hwnd, DWLP_MSGRESULT, NFR_CURRENT);	// set return value NFR_CURRENT
			return TRUE;	// message has been processed

		  case WM_NCDESTROY:
			delete pThis;
			return TRUE;	// message has been processed

		  default:
			return pThis->WndProc(nmsg, wparam, lparam);
		}
	} else if (nmsg == WM_INITDIALOG) {
		PROPSHEETPAGE* psp = (PROPSHEETPAGE*) lparam;
		PropSheetPage* ppsp = (PropSheetPage*) psp->lParam;

		if (ppsp->_dlg_creator) {
			pThis = static_cast<PropSheetPageDlg*>(ppsp->_dlg_creator(hwnd));

			if (pThis)
				return pThis->Init(NULL);
		}

		return TRUE;
	}

	return FALSE;	// message has not been processed
}
Example #6
0
HWND DesktopWindow::Create()
{
	static IconWindowClass wcDesktop(TEXT("Progman"), IDI_REACTOS, CS_DBLCLKS);
	/* (disabled because of small ugly temporary artefacts when hiding start menu)
	wcDesktop.hbrBackground = (HBRUSH)(COLOR_BACKGROUND+1); */

	int width = GetSystemMetrics(SM_CXSCREEN);
	int height = GetSystemMetrics(SM_CYSCREEN);

	HWND hwndDesktop = Window::Create(WINDOW_CREATOR(DesktopWindow),
					WS_EX_TOOLWINDOW, wcDesktop, TEXT("Program Manager"), WS_POPUP|WS_VISIBLE,	//|WS_CLIPCHILDREN for SDI frames
					0, 0, width, height, 0);

	 // work around to display desktop bar in Wine
	ShowWindow(GET_WINDOW(DesktopWindow, hwndDesktop)->_desktopBar, SW_SHOW);

	 // work around for Windows NT, Win 98, ...
	 // Without this the desktop has mysteriously only a size of 800x600 pixels.
	MoveWindow(hwndDesktop, 0, 0, width, height, TRUE);

	return hwndDesktop;
}
// free the last row
static void freeLastRow(JNIEnv * env, jobject object) {
    CursorWindow * window = GET_WINDOW(env, object);
    window->freeLastRow();
}
static jboolean allocRow(JNIEnv * env, jobject object)
{
    CursorWindow * window = GET_WINDOW(env, object);
    return window->allocRow() != NULL;
}
static jboolean setNumColumns(JNIEnv * env, jobject object, jint columnNum)
{
    CursorWindow * window = GET_WINDOW(env, object);
    return window->setNumColumns(columnNum);
}
static jint getNumRows(JNIEnv * env, jobject object)
{
    CursorWindow * window = GET_WINDOW(env, object);
    return window->getNumRows();
}
CursorWindow * get_window_from_object(JNIEnv * env, jobject javaWindow)
{
    return GET_WINDOW(env, javaWindow);
}
static jcharArray copyStringToBuffer_native(JNIEnv* env, jobject object, jint row,
                                      jint column, jint bufferSize, jobject buf)
{
    int32_t err;
    CursorWindow * window = GET_WINDOW(env, object);
LOG_WINDOW("Copying string for %d,%d from %p", row, column, window);

    field_slot_t field;
    err = window->read_field_slot(row, column, &field);
    if (err != 0) {
        jniThrowException(env, "java/lang/IllegalStateException", "Unable to get field slot");
        return NULL;
    }

    jcharArray buffer = (jcharArray)env->GetObjectField(buf, gBufferField);
    if (buffer == NULL) {
        jniThrowException(env, "java/lang/IllegalStateException", "buf should not be null");
        return NULL;
    }
    jchar* dst = env->GetCharArrayElements(buffer, NULL);
    uint8_t type = field.type;
    uint32_t sizeCopied = 0;
    jcharArray newArray = NULL;
    if (type == FIELD_TYPE_STRING) {
        uint32_t size = field.data.buffer.size;
        if (size > 0) {
#if WINDOW_STORAGE_UTF8
            // Pass size - 1 since the UTF8 is null terminated and we don't want a null terminator on the UTF16 string
            String16 utf16((char const *)window->offsetToPtr(field.data.buffer.offset), size - 1);
            int32_t strSize = utf16.size();
            if (strSize > bufferSize || dst == NULL) {
                newArray = env->NewCharArray(strSize);
                env->SetCharArrayRegion(newArray, 0, strSize, (jchar const *)utf16.string());
            } else {
                memcpy(dst, (jchar const *)utf16.string(), strSize * 2);
            }
            sizeCopied = strSize;
#else
            sizeCopied = size/2 + size % 2;
            if (size > bufferSize * 2 || dst == NULL) {
                newArray = env->NewCharArray(sizeCopied);
                memcpy(newArray, (jchar const *)window->offsetToPtr(field.data.buffer.offset), size);
            } else {
                memcpy(dst, (jchar const *)window->offsetToPtr(field.data.buffer.offset), size);
            }
#endif
        }
    } else if (type == FIELD_TYPE_INTEGER) {
        int64_t value;
        if (window->getLong(row, column, &value)) {
            char buf[32];
            int len;
            snprintf(buf, sizeof(buf), "%lld", value);
            jchar* dst = env->GetCharArrayElements(buffer, NULL);
            sizeCopied = charToJchar(buf, dst, bufferSize);
         }
    } else if (type == FIELD_TYPE_FLOAT) {
        double value;
        if (window->getDouble(row, column, &value)) {
            char tempbuf[32];
            snprintf(tempbuf, sizeof(tempbuf), "%g", value);
            jchar* dst = env->GetCharArrayElements(buffer, NULL);
            sizeCopied = charToJchar(tempbuf, dst, bufferSize);
        }
    } else if (type == FIELD_TYPE_NULL) {
    } else if (type == FIELD_TYPE_BLOB) {
        throw_sqlite3_exception(env, "Unable to convert BLOB to string");
    } else {
        LOGE("Unknown field type %d", type);
        throw_sqlite3_exception(env, "UNKNOWN type in copyStringToBuffer_native()");
    }
    SET_SIZE_COPIED(env, buf, sizeCopied);
    env->ReleaseCharArrayElements(buffer, dst, JNI_OK);
    return newArray;
}
Example #13
0
LRESULT NotifyArea::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
{
	switch(nmsg) {
	  case WM_PAINT:
		Paint();
		break;

	  case WM_TIMER: {
		Refresh();

		ClockWindow* clock_window = GET_WINDOW(ClockWindow, _hwndClock);

		if (clock_window)
			clock_window->TimerTick();
		break;}

	  case PM_REFRESH:
		Refresh(true);
		break;

	  case WM_SIZE: {
		int cx = LOWORD(lparam);
		SetWindowPos(_hwndClock, 0, cx-_clock_width, 0, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
		break;}

	  case PM_GET_WIDTH: {
		int w = _sorted_icons.size()*NOTIFYICON_DIST + NOTIFYAREA_SPACE + _clock_width;
		if (_show_button)
			w += NOTIFYICON_DIST;
		return w;}

	  case PM_REFRESH_CONFIG:
		read_config();
		break;

	  case WM_CONTEXTMENU: {
		Point pt(lparam);
		POINTS p;
		p.x = (SHORT) pt.x;
		p.y = (SHORT) pt.y;
		ScreenToClient(_hwnd, &pt);

		if (IconHitTest(pt) == _sorted_icons.end()) { // display menu only when no icon clicked
			PopupMenu menu(IDM_NOTIFYAREA);
			SetMenuDefaultItem(menu, 0, MF_BYPOSITION);
			CheckMenuItem(menu, ID_SHOW_HIDDEN_ICONS, MF_BYCOMMAND|(_show_hidden?MF_CHECKED:MF_UNCHECKED));
			CheckMenuItem(menu, ID_SHOW_ICON_BUTTON, MF_BYCOMMAND|(_show_button?MF_CHECKED:MF_UNCHECKED));
			menu.TrackPopupMenu(_hwnd, p);
		}
		break;}

	  case WM_COPYDATA: {	// receive NotifyHook answers
		String path;
		HWND hwnd;

		if (_hook.ModulePathCopyData(lparam, &hwnd, path))
			_window_modules[hwnd] = path;
		break;}

	  default:
		if (nmsg>=WM_MOUSEFIRST && nmsg<=WM_MOUSELAST) {
			 // close startup menu and other popup menus
			 // This functionality is missing in MS Windows.
			if (nmsg==WM_LBUTTONDOWN || nmsg==WM_MBUTTONDOWN || nmsg==WM_RBUTTONDOWN
#ifdef WM_XBUTTONDOWN
				|| nmsg==WM_XBUTTONDOWN
#endif
				)

				CancelModes();

			Point pt(lparam);
			NotifyIconSet::const_iterator found = IconHitTest(pt);

			if (found != _sorted_icons.end()) {
				const NotifyInfo& entry = const_cast<NotifyInfo&>(*found);	// Why does GCC 3.3 need this additional const_cast ?!

				 // set activation time stamp
				if (nmsg == WM_LBUTTONDOWN ||	// Some programs need PostMessage() instead of SendMessage().
					nmsg == WM_MBUTTONDOWN ||	// So call SendMessage() only for BUTTONUP and BLCLK messages
#ifdef WM_XBUTTONDOWN
					nmsg == WM_XBUTTONDOWN ||
#endif
					nmsg == WM_RBUTTONDOWN) {
					_icon_map[entry]._lastChange = GetTickCount();
				}

				 // Notify the message if the owner is still alive
				if (IsWindow(entry._hWnd)) {
					if (nmsg == WM_MOUSEMOVE ||		// avoid to call blocking SendMessage() for merely moving the mouse over icons
						nmsg == WM_LBUTTONDOWN ||	// Some programs need PostMessage() instead of SendMessage().
						nmsg == WM_MBUTTONDOWN ||	// So call SendMessage() only for BUTTONUP and BLCLK messages
#ifdef WM_XBUTTONDOWN
						nmsg == WM_XBUTTONDOWN ||
#endif
						nmsg == WM_RBUTTONDOWN)
						PostMessage(entry._hWnd, entry._uCallbackMessage, entry._uID, nmsg);
					else {
						 // allow SetForegroundWindow() in client process
						DWORD pid;

						if (GetWindowThreadProcessId(entry._hWnd, &pid)) {
							 // bind dynamically to AllowSetForegroundWindow() to be compatible to WIN98
							static DynamicFct<BOOL(WINAPI*)(DWORD)> AllowSetForegroundWindow(TEXT("USER32"), "AllowSetForegroundWindow");

							if (AllowSetForegroundWindow)
								(*AllowSetForegroundWindow)(pid);
						}

						 // use PostMessage() for notifcation icons of Shell Service Objects in the own process
						if (pid == GetCurrentProcessId())
							PostMessage(entry._hWnd, entry._uCallbackMessage, entry._uID, nmsg);
						else
							SendMessage(entry._hWnd, entry._uCallbackMessage, entry._uID, nmsg);
					}
				}
				else if (_icon_map.erase(entry))	// delete icons without valid owner window
					UpdateIcons();
			} else
				 // handle clicks on notification area button "show hidden icons"
				if (_show_button)
					if (nmsg == WM_LBUTTONDOWN)
						if (pt.x>=NOTIFYICON_X && pt.x<NOTIFYICON_X+NOTIFYICON_SIZE &&
							pt.y>=NOTIFYICON_Y && pt.y<NOTIFYICON_Y+NOTIFYICON_SIZE)
							PostMessage(_hwnd, WM_COMMAND, MAKEWPARAM(ID_SHOW_HIDDEN_ICONS,0), 0);
		}

		return super::WndProc(nmsg, wparam, lparam);
	}

	return 0;
}
Example #14
0
//=============================================================================
// constructor
//=============================================================================
Title::Title()
{
	//ウィンドウ
	auto window = GET_WINDOW();

	//とりあえず背景
	auto sprite = std::make_shared<mesh::Sprite>(float2(window->GetWidth(), window->GetHeight()));

	background_ = std::make_shared<MeshObject>(sprite);
	sprite->SetAnchorPoint(float2(0.0f, 0.0f));
	sprite->Apply();
	background_->SetPosition(0.0f, 0.0f, 0.0f);
	background_->SetTexture(0, GET_GRAPHIC_DEVICE()->LoadTexture("resources/texture/title_background.png"));
	
	//ロゴ
	auto sprite_logo = std::make_shared<mesh::Sprite>(float2(800, 400));
	logo_ = std::make_shared<MeshObject>(sprite_logo);
	sprite_logo->SetAnchorPoint(float2(0.0f, 0.0f));
	sprite_logo->Apply();
	logo_->SetPosition(window->GetWidth()/2-400.0f, window->GetHeight()/2-250.0f, 0.0f);
	logo_->SetTexture(0, GET_GRAPHIC_DEVICE()->LoadTexture("resources/texture/title_logo.png"));

	//ボタン
	auto sprite_button = std::make_shared<mesh::Sprite>(float2(400, 200));
	button_ = std::make_shared<MeshObject>(sprite_button);
	sprite_button->SetAnchorPoint(float2(0.0f, 0.0f));
	sprite_logo->Apply();
	button_->SetPosition(window->GetWidth() / 2 - 210.0f, window->GetHeight() - 250.0f, 0.0f);
	button_->SetTexture(0, GET_GRAPHIC_DEVICE()->LoadTexture("resources/texture/Start.png"));

	//ボタン背景
	auto sprite_button_interface_ = std::make_shared<mesh::Sprite>(float2(300, 100));
	button_interface_ = std::make_shared<MeshObject>(sprite_button_interface_);
	sprite_button_interface_->SetAnchorPoint(float2(0.0f, 0.0f));
	sprite_button_interface_->Apply();
	button_interface_->SetPosition(window->GetWidth() / 2 - 150.0f, window->GetHeight() - 200.0f, 0.0f);
	button_interface_->SetTexture(0, GET_GRAPHIC_DEVICE()->LoadTexture("resources/texture/window_256x512.png"));

	//パーティクル
	for (u32 i = 0; i < PARTICUL_MAX; ++i)
	{
		auto sprite_particul = std::make_shared<mesh::Sprite>(float2(30,30));
		particul_[i].particul_ = std::make_shared<MeshObject>(sprite_particul);
		sprite->SetAnchorPoint(float2(0.0f, 0.0f));
		particul_[i].particul_->SetPosition(f32((rand() % window->GetWidth())), -30.0f, 0.0f);
		particul_[i].particul_->SetTexture(0, GET_GRAPHIC_DEVICE()->LoadTexture("resources/texture/petal.png"));
		particul_[i].particul_angle_ = 0.0f;
		particul_[i].start_cnt_ = i * 10;
		particul_[i].start_flag_ = false;
	}

	//2D用カメラ設定
	observer_2d_ = std::make_shared<Observer2D>(window->GetWidth(), window->GetHeight());

	//BGM
	Sound::Instance().PlaySound(SOUND_LABEL_BGM000);

	draw_cnt_ = 0;
	use_flag_ = false;
	particul_cnt_ = 0;
}
Example #15
0
//=============================================================================
// update
//=============================================================================
void Title::Update()
{
	auto p_input_manager = GET_INPUT_MANAGER();
	auto window = GET_WINDOW();

	//効果音デバッグ
	if (GET_INPUT_KEYBOARD()->GetTrigger(DIK_O))
	{
		{
			Sound::Instance().PlaySeSound(SOUND_LABEL_SE_PMOVE, 0);
		}
	}

	//if (p_input_manager->GetTrigger(InputManager::Command::A, 0))
	if(GET_INPUT_MOUSE()->GetPress(InputMouse::MOUSE_KEY::LEFT))
	{
		//効果音再生
		Sound::Instance().PlaySeSound(SOUND_LABEL_SE_YES, 0);

		SceneManager::Instance().set_p_next_scene(SceneManager::Instance().get_game());
		SceneManager::Instance().set_scene_change_flag(true);
	}

	//パーティクル
	for (u32 i = 0; i < PARTICUL_MAX; ++i)
	{
		
		if (particul_cnt_ == particul_[i].start_cnt_)
		{
			particul_[i].start_flag_ = true;

		}	
		if (particul_[i].start_flag_)
		{
			auto position = particul_[i].particul_->GetPosition();
			particul_[i].particul_angle_ -= D3DX_PI*0.01f;
			position._x -= sinf(particul_[i].particul_angle_);
			position._y += 0.5f;

			auto rotate = particul_[i].particul_->GetRotation();
			rotate._z = 1.2f;

			
			if (particul_[i].particul_angle_ < -D3DX_PI)
			{
				particul_[i].particul_angle_ += 2 * D3DX_PI;
			}
			else if (particul_[i].particul_angle_ > D3DX_PI)
			{
				particul_[i].particul_angle_ -= 2 * D3DX_PI;
			}
			
			if (position._y > window->GetHeight())
			{
				position._x = (rand() % window->GetWidth());
				position._y = -10.0f;
			}
			
			particul_[i].particul_->SetPosition(position._x, position._y, position._z);
			particul_[i].particul_->SetRotation(rotate);
		}
	}
	particul_cnt_++;

	for (int i = 0; i < PLAYER_SUM; i++)
	{
		if (GET_INPUT_XPAD(i)->GetPress(XIPad::KEY::A) || GET_INPUT_XPAD(i)->GetPress(XIPad::KEY::B))
		{
			//効果音再生
			Sound::Instance().PlaySeSound(SOUND_LABEL_SE_YES, 0);

			SceneManager::Instance().set_p_next_scene(SceneManager::Instance().get_game());
			SceneManager::Instance().set_scene_change_flag(true);
		}
	}
}