The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

817 lines
30KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. } // (juce namespace)
  19. extern juce::JUCEApplicationBase* juce_CreateApplication(); // (from START_JUCE_APPLICATION)
  20. namespace juce
  21. {
  22. //==============================================================================
  23. JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, launchApp, void, (JNIEnv* env, jobject activity,
  24. jstring appFile, jstring appDataDir))
  25. {
  26. android.initialise (env, activity, appFile, appDataDir);
  27. DBG (SystemStats::getJUCEVersion());
  28. JUCEApplicationBase::createInstance = &juce_CreateApplication;
  29. initialiseJuce_GUI();
  30. JUCEApplication* app = dynamic_cast <JUCEApplication*> (JUCEApplicationBase::createInstance());
  31. if (! app->initialiseApp (String::empty))
  32. exit (0);
  33. }
  34. JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, quitApp, void, (JNIEnv* env, jobject activity))
  35. {
  36. JUCEApplicationBase::appWillTerminateByForce();
  37. android.shutdown (env);
  38. }
  39. //==============================================================================
  40. #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \
  41. METHOD (drawBitmap, "drawBitmap", "([IIIFFIIZLandroid/graphics/Paint;)V") \
  42. METHOD (getClipBounds, "getClipBounds", "()Landroid/graphics/Rect;")
  43. DECLARE_JNI_CLASS (CanvasMinimal, "android/graphics/Canvas");
  44. #undef JNI_CLASS_MEMBERS
  45. //==============================================================================
  46. #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \
  47. METHOD (setViewName, "setViewName", "(Ljava/lang/String;)V") \
  48. METHOD (layout, "layout", "(IIII)V") \
  49. METHOD (getLeft, "getLeft", "()I") \
  50. METHOD (getTop, "getTop", "()I") \
  51. METHOD (getWidth, "getWidth", "()I") \
  52. METHOD (getHeight, "getHeight", "()I") \
  53. METHOD (getLocationOnScreen, "getLocationOnScreen", "([I)V") \
  54. METHOD (bringToFront, "bringToFront", "()V") \
  55. METHOD (requestFocus, "requestFocus", "()Z") \
  56. METHOD (setVisible, "setVisible", "(Z)V") \
  57. METHOD (isVisible, "isVisible", "()Z") \
  58. METHOD (hasFocus, "hasFocus", "()Z") \
  59. METHOD (invalidate, "invalidate", "(IIII)V") \
  60. METHOD (containsPoint, "containsPoint", "(II)Z") \
  61. DECLARE_JNI_CLASS (ComponentPeerView, JUCE_ANDROID_ACTIVITY_CLASSPATH "$ComponentPeerView");
  62. #undef JNI_CLASS_MEMBERS
  63. //==============================================================================
  64. class AndroidComponentPeer : public ComponentPeer
  65. {
  66. public:
  67. AndroidComponentPeer (Component* const component, const int windowStyleFlags)
  68. : ComponentPeer (component, windowStyleFlags),
  69. usingAndroidGraphics (false),
  70. fullScreen (false),
  71. sizeAllocated (0)
  72. {
  73. // NB: must not put this in the initialiser list, as it invokes a callback,
  74. // which will fail if the peer is only half-constructed.
  75. view = GlobalRef (android.activity.callObjectMethod (JuceAppActivity.createNewView,
  76. component->isOpaque()));
  77. if (isFocused())
  78. handleFocusGain();
  79. }
  80. ~AndroidComponentPeer()
  81. {
  82. if (MessageManager::getInstance()->isThisTheMessageThread())
  83. {
  84. android.activity.callVoidMethod (JuceAppActivity.deleteView, view.get());
  85. }
  86. else
  87. {
  88. class ViewDeleter : public CallbackMessage
  89. {
  90. public:
  91. ViewDeleter (const GlobalRef& view_)
  92. : view (view_)
  93. {
  94. post();
  95. }
  96. void messageCallback()
  97. {
  98. android.activity.callVoidMethod (JuceAppActivity.deleteView, view.get());
  99. }
  100. private:
  101. GlobalRef view;
  102. };
  103. new ViewDeleter (view);
  104. }
  105. view.clear();
  106. }
  107. void* getNativeHandle() const
  108. {
  109. return (void*) view.get();
  110. }
  111. void setVisible (bool shouldBeVisible)
  112. {
  113. if (MessageManager::getInstance()->isThisTheMessageThread())
  114. {
  115. view.callVoidMethod (ComponentPeerView.setVisible, shouldBeVisible);
  116. }
  117. else
  118. {
  119. class VisibilityChanger : public CallbackMessage
  120. {
  121. public:
  122. VisibilityChanger (const GlobalRef& view_, bool shouldBeVisible_)
  123. : view (view_), shouldBeVisible (shouldBeVisible_)
  124. {
  125. post();
  126. }
  127. void messageCallback()
  128. {
  129. view.callVoidMethod (ComponentPeerView.setVisible, shouldBeVisible);
  130. }
  131. private:
  132. GlobalRef view;
  133. bool shouldBeVisible;
  134. };
  135. new VisibilityChanger (view, shouldBeVisible);
  136. }
  137. }
  138. void setTitle (const String& title)
  139. {
  140. view.callVoidMethod (ComponentPeerView.setViewName, javaString (title).get());
  141. }
  142. void setPosition (int x, int y)
  143. {
  144. const Rectangle<int> pos (getBounds());
  145. setBounds (x, y, pos.getWidth(), pos.getHeight(), false);
  146. }
  147. void setSize (int w, int h)
  148. {
  149. const Rectangle<int> pos (getBounds());
  150. setBounds (pos.getX(), pos.getY(), w, h, false);
  151. }
  152. void setBounds (int x, int y, int w, int h, bool isNowFullScreen)
  153. {
  154. if (MessageManager::getInstance()->isThisTheMessageThread())
  155. {
  156. fullScreen = isNowFullScreen;
  157. w = jmax (0, w);
  158. h = jmax (0, h);
  159. view.callVoidMethod (ComponentPeerView.layout, x, y, x + w, y + h);
  160. }
  161. else
  162. {
  163. class ViewMover : public CallbackMessage
  164. {
  165. public:
  166. ViewMover (const GlobalRef& view_, int x_, int y_, int w_, int h_)
  167. : view (view_), x (x_), y (y_), w (w_), h (h_)
  168. {
  169. post();
  170. }
  171. void messageCallback()
  172. {
  173. view.callVoidMethod (ComponentPeerView.layout, x, y, x + w, y + h);
  174. }
  175. private:
  176. GlobalRef view;
  177. int x, y, w, h;
  178. };
  179. new ViewMover (view, x, y, w, h);
  180. }
  181. }
  182. Rectangle<int> getBounds() const
  183. {
  184. return Rectangle<int> (view.callIntMethod (ComponentPeerView.getLeft),
  185. view.callIntMethod (ComponentPeerView.getTop),
  186. view.callIntMethod (ComponentPeerView.getWidth),
  187. view.callIntMethod (ComponentPeerView.getHeight));
  188. }
  189. Point<int> getScreenPosition() const
  190. {
  191. return Point<int> (view.callIntMethod (ComponentPeerView.getLeft),
  192. view.callIntMethod (ComponentPeerView.getTop));
  193. }
  194. Point<int> localToGlobal (const Point<int>& relativePosition)
  195. {
  196. return relativePosition + getScreenPosition();
  197. }
  198. Point<int> globalToLocal (const Point<int>& screenPosition)
  199. {
  200. return screenPosition - getScreenPosition();
  201. }
  202. void setMinimised (bool shouldBeMinimised)
  203. {
  204. // n/a
  205. }
  206. bool isMinimised() const
  207. {
  208. return false;
  209. }
  210. void setFullScreen (bool shouldBeFullScreen)
  211. {
  212. Rectangle<int> r (shouldBeFullScreen ? Desktop::getInstance().getMainMonitorArea()
  213. : lastNonFullscreenBounds);
  214. if ((! shouldBeFullScreen) && r.isEmpty())
  215. r = getBounds();
  216. // (can't call the component's setBounds method because that'll reset our fullscreen flag)
  217. if (! r.isEmpty())
  218. setBounds (r.getX(), r.getY(), r.getWidth(), r.getHeight(), shouldBeFullScreen);
  219. component->repaint();
  220. }
  221. bool isFullScreen() const
  222. {
  223. return fullScreen;
  224. }
  225. void setIcon (const Image& newIcon)
  226. {
  227. // n/a
  228. }
  229. bool contains (const Point<int>& position, bool trueIfInAChildWindow) const
  230. {
  231. return isPositiveAndBelow (position.x, component->getWidth())
  232. && isPositiveAndBelow (position.y, component->getHeight())
  233. && ((! trueIfInAChildWindow) || view.callBooleanMethod (ComponentPeerView.containsPoint,
  234. position.x, position.y));
  235. }
  236. BorderSize<int> getFrameSize() const
  237. {
  238. // TODO
  239. return BorderSize<int>();
  240. }
  241. bool setAlwaysOnTop (bool alwaysOnTop)
  242. {
  243. // TODO
  244. return false;
  245. }
  246. void toFront (bool makeActive)
  247. {
  248. view.callVoidMethod (ComponentPeerView.bringToFront);
  249. if (makeActive)
  250. grabFocus();
  251. handleBroughtToFront();
  252. }
  253. void toBehind (ComponentPeer* other)
  254. {
  255. // TODO
  256. }
  257. //==============================================================================
  258. void handleMouseDownCallback (float x, float y, int64 time)
  259. {
  260. lastMousePos.setXY ((int) x, (int) y);
  261. currentModifiers = currentModifiers.withoutMouseButtons();
  262. handleMouseEvent (0, lastMousePos, currentModifiers, time);
  263. currentModifiers = currentModifiers.withoutMouseButtons().withFlags (ModifierKeys::leftButtonModifier);
  264. handleMouseEvent (0, lastMousePos, currentModifiers, time);
  265. }
  266. void handleMouseDragCallback (float x, float y, int64 time)
  267. {
  268. lastMousePos.setXY ((int) x, (int) y);
  269. handleMouseEvent (0, lastMousePos, currentModifiers, time);
  270. }
  271. void handleMouseUpCallback (float x, float y, int64 time)
  272. {
  273. lastMousePos.setXY ((int) x, (int) y);
  274. currentModifiers = currentModifiers.withoutMouseButtons();
  275. handleMouseEvent (0, lastMousePos, currentModifiers, time);
  276. }
  277. //==============================================================================
  278. bool isFocused() const
  279. {
  280. return view.callBooleanMethod (ComponentPeerView.hasFocus);
  281. }
  282. void grabFocus()
  283. {
  284. view.callBooleanMethod (ComponentPeerView.requestFocus);
  285. }
  286. void handleFocusChangeCallback (bool hasFocus)
  287. {
  288. if (hasFocus)
  289. handleFocusGain();
  290. else
  291. handleFocusLoss();
  292. }
  293. void textInputRequired (const Point<int>& position)
  294. {
  295. // TODO
  296. }
  297. //==============================================================================
  298. void handlePaintCallback (JNIEnv* env, jobject canvas)
  299. {
  300. #if USE_ANDROID_CANVAS
  301. if (usingAndroidGraphics)
  302. {
  303. AndroidLowLevelGraphicsContext g (canvas);
  304. handlePaint (g);
  305. }
  306. else
  307. #endif
  308. {
  309. jobject rect = env->CallObjectMethod (canvas, CanvasMinimal.getClipBounds);
  310. const int left = env->GetIntField (rect, RectClass.left);
  311. const int top = env->GetIntField (rect, RectClass.top);
  312. const int right = env->GetIntField (rect, RectClass.right);
  313. const int bottom = env->GetIntField (rect, RectClass.bottom);
  314. env->DeleteLocalRef (rect);
  315. const Rectangle<int> clip (left, top, right - left, bottom - top);
  316. const int sizeNeeded = clip.getWidth() * clip.getHeight();
  317. if (sizeAllocated < sizeNeeded)
  318. {
  319. buffer.clear();
  320. sizeAllocated = sizeNeeded;
  321. buffer = GlobalRef (env->NewIntArray (sizeNeeded));
  322. }
  323. jint* dest = env->GetIntArrayElements ((jintArray) buffer.get(), 0);
  324. if (dest != 0)
  325. {
  326. {
  327. Image temp (new PreallocatedImage (clip.getWidth(), clip.getHeight(),
  328. dest, ! component->isOpaque()));
  329. {
  330. LowLevelGraphicsSoftwareRenderer g (temp);
  331. g.setOrigin (-clip.getX(), -clip.getY());
  332. handlePaint (g);
  333. }
  334. }
  335. env->ReleaseIntArrayElements ((jintArray) buffer.get(), dest, 0);
  336. env->CallVoidMethod (canvas, CanvasMinimal.drawBitmap, (jintArray) buffer.get(), 0, clip.getWidth(),
  337. (jfloat) clip.getX(), (jfloat) clip.getY(),
  338. clip.getWidth(), clip.getHeight(), true, (jobject) 0);
  339. }
  340. }
  341. }
  342. void repaint (const Rectangle<int>& area)
  343. {
  344. if (MessageManager::getInstance()->isThisTheMessageThread())
  345. {
  346. view.callVoidMethod (ComponentPeerView.invalidate, area.getX(), area.getY(), area.getRight(), area.getBottom());
  347. }
  348. else
  349. {
  350. class ViewRepainter : public CallbackMessage
  351. {
  352. public:
  353. ViewRepainter (const GlobalRef& view_, const Rectangle<int>& area_)
  354. : view (view_), area (area_)
  355. {
  356. post();
  357. }
  358. void messageCallback()
  359. {
  360. view.callVoidMethod (ComponentPeerView.invalidate, area.getX(), area.getY(), area.getRight(), area.getBottom());
  361. }
  362. private:
  363. GlobalRef view;
  364. const Rectangle<int>& area;
  365. };
  366. new ViewRepainter (view, area);
  367. }
  368. }
  369. void performAnyPendingRepaintsNow()
  370. {
  371. // TODO
  372. }
  373. void setAlpha (float newAlpha)
  374. {
  375. // TODO
  376. }
  377. #if USE_ANDROID_CANVAS
  378. StringArray getAvailableRenderingEngines()
  379. {
  380. StringArray s (ComponentPeer::getAvailableRenderingEngines());
  381. s.add ("Android Canvas Renderer");
  382. return s;
  383. }
  384. int getCurrentRenderingEngine() const
  385. {
  386. return usingAndroidGraphics ? 1 : 0;
  387. }
  388. void setCurrentRenderingEngine (int index)
  389. {
  390. if (usingAndroidGraphics != (index > 0))
  391. {
  392. usingAndroidGraphics = index > 0;
  393. component->repaint();
  394. }
  395. }
  396. #endif
  397. //==============================================================================
  398. static AndroidComponentPeer* findPeerForJavaView (JNIEnv* env, jobject viewToFind)
  399. {
  400. for (int i = getNumPeers(); --i >= 0;)
  401. {
  402. AndroidComponentPeer* const ap = static_cast <AndroidComponentPeer*> (getPeer(i));
  403. jassert (dynamic_cast <AndroidComponentPeer*> (getPeer(i)) != nullptr);
  404. if (env->IsSameObject (ap->view.get(), viewToFind))
  405. return ap;
  406. }
  407. return nullptr;
  408. }
  409. static ModifierKeys currentModifiers;
  410. static Point<int> lastMousePos;
  411. private:
  412. //==============================================================================
  413. GlobalRef view;
  414. GlobalRef buffer;
  415. bool usingAndroidGraphics, fullScreen;
  416. int sizeAllocated;
  417. class PreallocatedImage : public ImagePixelData
  418. {
  419. public:
  420. PreallocatedImage (const int width_, const int height_, jint* data_, bool hasAlpha_)
  421. : ImagePixelData (Image::ARGB, width_, height_), data (data_), hasAlpha (hasAlpha_)
  422. {
  423. if (hasAlpha_)
  424. zeromem (data_, width * height * sizeof (jint));
  425. }
  426. ~PreallocatedImage()
  427. {
  428. if (hasAlpha)
  429. {
  430. PixelARGB* pix = (PixelARGB*) data;
  431. for (int i = width * height; --i >= 0;)
  432. {
  433. pix->unpremultiply();
  434. ++pix;
  435. }
  436. }
  437. }
  438. ImageType* createType() const { return new SoftwareImageType(); }
  439. LowLevelGraphicsContext* createLowLevelContext() { return new LowLevelGraphicsSoftwareRenderer (Image (this)); }
  440. void initialiseBitmapData (Image::BitmapData& bm, int x, int y, Image::BitmapData::ReadWriteMode mode)
  441. {
  442. bm.lineStride = width * sizeof (jint);
  443. bm.pixelStride = sizeof (jint);
  444. bm.pixelFormat = Image::ARGB;
  445. bm.data = (uint8*) (data + x + y * width);
  446. }
  447. ImagePixelData* clone()
  448. {
  449. PreallocatedImage* s = new PreallocatedImage (width, height, 0, hasAlpha);
  450. s->allocatedData.malloc (sizeof (jint) * width * height);
  451. s->data = s->allocatedData;
  452. memcpy (s->data, data, sizeof (jint) * width * height);
  453. return s;
  454. }
  455. private:
  456. jint* data;
  457. HeapBlock<jint> allocatedData;
  458. bool hasAlpha;
  459. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PreallocatedImage);
  460. };
  461. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AndroidComponentPeer);
  462. };
  463. ModifierKeys AndroidComponentPeer::currentModifiers = 0;
  464. Point<int> AndroidComponentPeer::lastMousePos;
  465. //==============================================================================
  466. #define JUCE_VIEW_CALLBACK(returnType, javaMethodName, params, juceMethodInvocation) \
  467. JUCE_JNI_CALLBACK (JUCE_JOIN_MACRO (JUCE_ANDROID_ACTIVITY_CLASSNAME, _00024ComponentPeerView), javaMethodName, returnType, params) \
  468. { \
  469. AndroidComponentPeer* const peer = AndroidComponentPeer::findPeerForJavaView (env, view); \
  470. if (peer != nullptr) \
  471. peer->juceMethodInvocation; \
  472. }
  473. JUCE_VIEW_CALLBACK (void, handlePaint, (JNIEnv* env, jobject view, jobject canvas), handlePaintCallback (env, canvas))
  474. JUCE_VIEW_CALLBACK (void, handleMouseDown, (JNIEnv* env, jobject view, jfloat x, jfloat y, jlong time), handleMouseDownCallback ((float) x, (float) y, (int64) time))
  475. JUCE_VIEW_CALLBACK (void, handleMouseDrag, (JNIEnv* env, jobject view, jfloat x, jfloat y, jlong time), handleMouseDragCallback ((float) x, (float) y, (int64) time))
  476. JUCE_VIEW_CALLBACK (void, handleMouseUp, (JNIEnv* env, jobject view, jfloat x, jfloat y, jlong time), handleMouseUpCallback ((float) x, (float) y, (int64) time))
  477. JUCE_VIEW_CALLBACK (void, viewSizeChanged, (JNIEnv* env, jobject view), handleMovedOrResized())
  478. JUCE_VIEW_CALLBACK (void, focusChanged, (JNIEnv* env, jobject view, jboolean hasFocus), handleFocusChangeCallback (hasFocus))
  479. //==============================================================================
  480. ComponentPeer* Component::createNewPeer (int styleFlags, void*)
  481. {
  482. return new AndroidComponentPeer (this, styleFlags);
  483. }
  484. //==============================================================================
  485. bool Desktop::canUseSemiTransparentWindows() noexcept
  486. {
  487. return true;
  488. }
  489. Desktop::DisplayOrientation Desktop::getCurrentOrientation() const
  490. {
  491. // TODO
  492. return upright;
  493. }
  494. void Desktop::createMouseInputSources()
  495. {
  496. // This creates a mouse input source for each possible finger
  497. for (int i = 0; i < 10; ++i)
  498. mouseSources.add (new MouseInputSource (i, false));
  499. }
  500. Point<int> MouseInputSource::getCurrentMousePosition()
  501. {
  502. return AndroidComponentPeer::lastMousePos;
  503. }
  504. void Desktop::setMousePosition (const Point<int>& newPosition)
  505. {
  506. // not needed
  507. }
  508. //==============================================================================
  509. bool KeyPress::isKeyCurrentlyDown (const int keyCode)
  510. {
  511. // TODO
  512. return false;
  513. }
  514. void ModifierKeys::updateCurrentModifiers() noexcept
  515. {
  516. currentModifiers = AndroidComponentPeer::currentModifiers;
  517. }
  518. ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept
  519. {
  520. return AndroidComponentPeer::currentModifiers;
  521. }
  522. //==============================================================================
  523. bool Process::isForegroundProcess()
  524. {
  525. return true; // TODO
  526. }
  527. //==============================================================================
  528. void JUCE_CALLTYPE NativeMessageBox::showMessageBoxAsync (AlertWindow::AlertIconType iconType,
  529. const String& title, const String& message,
  530. Component* associatedComponent)
  531. {
  532. android.activity.callVoidMethod (JuceAppActivity.showMessageBox, javaString (title).get(), javaString (message).get(), (jlong) 0);
  533. }
  534. bool JUCE_CALLTYPE NativeMessageBox::showOkCancelBox (AlertWindow::AlertIconType iconType,
  535. const String& title, const String& message,
  536. Component* associatedComponent,
  537. ModalComponentManager::Callback* callback)
  538. {
  539. jassert (callback != 0); // on android, all alerts must be non-modal!!
  540. android.activity.callVoidMethod (JuceAppActivity.showOkCancelBox, javaString (title).get(), javaString (message).get(),
  541. (jlong) (pointer_sized_int) callback);
  542. return false;
  543. }
  544. int JUCE_CALLTYPE NativeMessageBox::showYesNoCancelBox (AlertWindow::AlertIconType iconType,
  545. const String& title, const String& message,
  546. Component* associatedComponent,
  547. ModalComponentManager::Callback* callback)
  548. {
  549. jassert (callback != 0); // on android, all alerts must be non-modal!!
  550. android.activity.callVoidMethod (JuceAppActivity.showYesNoCancelBox, javaString (title).get(), javaString (message).get(),
  551. (jlong) (pointer_sized_int) callback);
  552. return 0;
  553. }
  554. JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, alertDismissed, void, (JNIEnv* env, jobject activity,
  555. jlong callbackAsLong, jint result))
  556. {
  557. ModalComponentManager::Callback* callback = (ModalComponentManager::Callback*) callbackAsLong;
  558. if (callback != 0)
  559. callback->modalStateFinished (result);
  560. }
  561. //==============================================================================
  562. void Desktop::setScreenSaverEnabled (const bool isEnabled)
  563. {
  564. // TODO
  565. }
  566. bool Desktop::isScreenSaverEnabled()
  567. {
  568. return true;
  569. }
  570. //==============================================================================
  571. void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDisable, bool allowMenusAndBars)
  572. {
  573. // TODO
  574. }
  575. //==============================================================================
  576. void Desktop::getCurrentMonitorPositions (Array <Rectangle<int> >& monitorCoords, const bool clipToWorkArea)
  577. {
  578. monitorCoords.add (Rectangle<int> (0, 0, android.screenWidth, android.screenHeight));
  579. }
  580. JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, setScreenSize, void, (JNIEnv* env, jobject activity,
  581. jint screenWidth, jint screenHeight))
  582. {
  583. const bool isSystemInitialised = android.screenWidth != 0;
  584. android.screenWidth = screenWidth;
  585. android.screenHeight = screenHeight;
  586. if (isSystemInitialised)
  587. Desktop::getInstance().refreshMonitorSizes();
  588. }
  589. //==============================================================================
  590. Image juce_createIconForFile (const File& file)
  591. {
  592. return Image::null;
  593. }
  594. //==============================================================================
  595. void* MouseCursor::createMouseCursorFromImage (const Image&, int, int) { return nullptr; }
  596. void* MouseCursor::createStandardMouseCursor (const MouseCursor::StandardCursorType) { return nullptr; }
  597. void MouseCursor::deleteMouseCursor (void* const /*cursorHandle*/, const bool /*isStandard*/) {}
  598. //==============================================================================
  599. void MouseCursor::showInWindow (ComponentPeer*) const {}
  600. void MouseCursor::showInAllWindows() const {}
  601. //==============================================================================
  602. bool DragAndDropContainer::performExternalDragDropOfFiles (const StringArray& files, const bool canMove)
  603. {
  604. return false;
  605. }
  606. bool DragAndDropContainer::performExternalDragDropOfText (const String& text)
  607. {
  608. return false;
  609. }
  610. //==============================================================================
  611. void LookAndFeel::playAlertSound()
  612. {
  613. }
  614. //==============================================================================
  615. void SystemClipboard::copyTextToClipboard (const String& text)
  616. {
  617. const LocalRef<jstring> t (javaString (text));
  618. android.activity.callVoidMethod (JuceAppActivity.setClipboardContent, t.get());
  619. }
  620. String SystemClipboard::getTextFromClipboard()
  621. {
  622. const LocalRef<jstring> text ((jstring) android.activity.callObjectMethod (JuceAppActivity.getClipboardContent));
  623. return juceString (text);
  624. }
  625. //==============================================================================
  626. const int extendedKeyModifier = 0x10000;
  627. const int KeyPress::spaceKey = ' ';
  628. const int KeyPress::returnKey = 0x0d;
  629. const int KeyPress::escapeKey = 0x1b;
  630. const int KeyPress::backspaceKey = 0x7f;
  631. const int KeyPress::leftKey = extendedKeyModifier + 1;
  632. const int KeyPress::rightKey = extendedKeyModifier + 2;
  633. const int KeyPress::upKey = extendedKeyModifier + 3;
  634. const int KeyPress::downKey = extendedKeyModifier + 4;
  635. const int KeyPress::pageUpKey = extendedKeyModifier + 5;
  636. const int KeyPress::pageDownKey = extendedKeyModifier + 6;
  637. const int KeyPress::endKey = extendedKeyModifier + 7;
  638. const int KeyPress::homeKey = extendedKeyModifier + 8;
  639. const int KeyPress::deleteKey = extendedKeyModifier + 9;
  640. const int KeyPress::insertKey = -1;
  641. const int KeyPress::tabKey = 9;
  642. const int KeyPress::F1Key = extendedKeyModifier + 10;
  643. const int KeyPress::F2Key = extendedKeyModifier + 11;
  644. const int KeyPress::F3Key = extendedKeyModifier + 12;
  645. const int KeyPress::F4Key = extendedKeyModifier + 13;
  646. const int KeyPress::F5Key = extendedKeyModifier + 14;
  647. const int KeyPress::F6Key = extendedKeyModifier + 16;
  648. const int KeyPress::F7Key = extendedKeyModifier + 17;
  649. const int KeyPress::F8Key = extendedKeyModifier + 18;
  650. const int KeyPress::F9Key = extendedKeyModifier + 19;
  651. const int KeyPress::F10Key = extendedKeyModifier + 20;
  652. const int KeyPress::F11Key = extendedKeyModifier + 21;
  653. const int KeyPress::F12Key = extendedKeyModifier + 22;
  654. const int KeyPress::F13Key = extendedKeyModifier + 23;
  655. const int KeyPress::F14Key = extendedKeyModifier + 24;
  656. const int KeyPress::F15Key = extendedKeyModifier + 25;
  657. const int KeyPress::F16Key = extendedKeyModifier + 26;
  658. const int KeyPress::numberPad0 = extendedKeyModifier + 27;
  659. const int KeyPress::numberPad1 = extendedKeyModifier + 28;
  660. const int KeyPress::numberPad2 = extendedKeyModifier + 29;
  661. const int KeyPress::numberPad3 = extendedKeyModifier + 30;
  662. const int KeyPress::numberPad4 = extendedKeyModifier + 31;
  663. const int KeyPress::numberPad5 = extendedKeyModifier + 32;
  664. const int KeyPress::numberPad6 = extendedKeyModifier + 33;
  665. const int KeyPress::numberPad7 = extendedKeyModifier + 34;
  666. const int KeyPress::numberPad8 = extendedKeyModifier + 35;
  667. const int KeyPress::numberPad9 = extendedKeyModifier + 36;
  668. const int KeyPress::numberPadAdd = extendedKeyModifier + 37;
  669. const int KeyPress::numberPadSubtract = extendedKeyModifier + 38;
  670. const int KeyPress::numberPadMultiply = extendedKeyModifier + 39;
  671. const int KeyPress::numberPadDivide = extendedKeyModifier + 40;
  672. const int KeyPress::numberPadSeparator = extendedKeyModifier + 41;
  673. const int KeyPress::numberPadDecimalPoint = extendedKeyModifier + 42;
  674. const int KeyPress::numberPadEquals = extendedKeyModifier + 43;
  675. const int KeyPress::numberPadDelete = extendedKeyModifier + 44;
  676. const int KeyPress::playKey = extendedKeyModifier + 45;
  677. const int KeyPress::stopKey = extendedKeyModifier + 46;
  678. const int KeyPress::fastForwardKey = extendedKeyModifier + 47;
  679. const int KeyPress::rewindKey = extendedKeyModifier + 48;