All file read operations should be done through FileLoader.
[platform/core/uifw/dali-demo.git] / examples / builder / examples.cpp
index 2895d82..e022227 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 #include <dali-toolkit/devel-api/builder/builder.h>
 #include <dali-toolkit/devel-api/builder/tree-node.h>
 #include <dali-toolkit/devel-api/builder/json-parser.h>
+#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
 #include <dali-toolkit/devel-api/controls/popup/popup.h>
 #include <dali-toolkit/devel-api/controls/navigation-view/navigation-view.h>
 
@@ -42,6 +43,7 @@
 #include <cstring>
 
 #include <dali/integration-api/debug.h>
+#include <dali/devel-api/adaptor-framework/file-loader.h>
 #include "shared/view.h"
 
 #define TOKEN_STRING(x) #x
@@ -85,9 +87,14 @@ std::string ReplaceQuotes(const std::string &single_quoted)
 
 std::string GetFileContents(const std::string &fn)
 {
-  std::ifstream t(fn.c_str());
-  return std::string((std::istreambuf_iterator<char>(t)),
-                     std::istreambuf_iterator<char>());
+  std::streampos bufferSize = 0;
+  Dali::Vector<char> fileBuffer;
+  if( !Dali::FileLoader::ReadFile( fn, bufferSize, fileBuffer, FileLoader::FileType::BINARY ) )
+  {
+    return std::string();
+  }
+
+  return std::string( &fileBuffer[0], bufferSize );
 };
 
 typedef std::vector<std::string> FileList;
@@ -472,8 +479,8 @@ public:
 
     // Create an edit mode button. (left of toolbar)
     Toolkit::PushButton backButton = Toolkit::PushButton::New();
-    backButton.SetUnselectedImage( EDIT_IMAGE );
-    backButton.SetSelectedImage( EDIT_IMAGE_SELECTED );
+    backButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, EDIT_IMAGE );
+    backButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, EDIT_IMAGE_SELECTED );
     backButton.ClickedSignal().Connect( this, &ExampleApp::OnBackButtonPressed);
     backButton.SetLeaveRequired( true );
     mToolBar.AddControl( backButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalLeft, DemoHelper::DEFAULT_MODE_SWITCH_PADDING  );