Sin descripción

TestApp1.cpp 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // TestApp1.cpp : Defines the entry point for the application.
  2. //
  3. #ifdef _WIN32
  4. #include "Win32/stdafx.h"
  5. #endif
  6. #include <DK.h>
  7. class TestApp1 : public DKApplication
  8. {
  9. DKObject<DKWindow> window;
  10. public:
  11. void OnInitialize(void) override
  12. {
  13. DKLog("%s", DKGL_FUNCTION_NAME);
  14. DKWindow::WindowCallback cb = {};
  15. cb.draggingFeedback = DKFunction([](DKWindow*, DKWindow::DraggingState state, const DKPoint& pos, const DKStringArray& files) {
  16. DKLog("cb.draggingFeedback: pos:(%.0f, %.0f), state:%d", pos.x, pos.y, state);
  17. if (files.Count() > 2)
  18. return DKWindow::DragOperationCopy;
  19. if (files.Count() > 1)
  20. return DKWindow::DragOperationMove;
  21. return DKWindow::DragOperationLink;
  22. });
  23. cb.closeRequest = DKFunction([](DKWindow* window)
  24. {
  25. DKLog("Close request?");
  26. return true;
  27. });
  28. window = DKWindow::Create("DefaultWindow",
  29. DKWindow::StyleGenericWindow|DKWindow::StyleAcceptFileDrop,
  30. this->EventLoop(),
  31. cb);
  32. window->Activate();
  33. window->AddEventHandler(this,
  34. DKFunction([this](const DKWindow::WindowEvent& e)
  35. {
  36. if (e.type == DKWindow::WindowEvent::WindowClosed)
  37. DKApplication::Instance()->Terminate(0);
  38. }),
  39. DKFunction([this](const DKWindow::KeyboardEvent& e)
  40. {
  41. }),
  42. DKFunction([this](const DKWindow::MouseEvent& e)
  43. {
  44. })
  45. );
  46. }
  47. void OnTerminate(void) override
  48. {
  49. DKLog("%s", DKGL_FUNCTION_NAME);
  50. }
  51. };
  52. #ifdef _WIN32
  53. int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
  54. _In_opt_ HINSTANCE hPrevInstance,
  55. _In_ LPWSTR lpCmdLine,
  56. _In_ int nCmdShow)
  57. #else
  58. int main(int argc, const char * argv[])
  59. #endif
  60. {
  61. DKPropertySet::SystemConfig().SetValue("DisableWindowKey", 1LL);
  62. TestApp1 app;
  63. DKPropertySet::SystemConfig().SetValue("AppDelegate", "AppDelegate");
  64. return app.Run();
  65. }