Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: chrome/browser/first_run_win.cc

Issue 545144: Position the the inactive toast to the left in RTL machines.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/first_run.h" 5 #include "chrome/browser/first_run.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <shellapi.h> 8 #include <shellapi.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 10
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 // Fifth row views. 828 // Fifth row views.
829 layout->StartRowWithPadding(0, 4, 0, 10); 829 layout->StartRowWithPadding(0, 4, 0, 10);
830 views::Link* link = new views::Link(why_this); 830 views::Link* link = new views::Link(why_this);
831 link->SetController(this); 831 link->SetController(this);
832 layout->AddView(link); 832 layout->AddView(link);
833 833
834 // We resize the window according to the layout manager. This takes into 834 // We resize the window according to the layout manager. This takes into
835 // account the differences between XP and Vista fonts and buttons. 835 // account the differences between XP and Vista fonts and buttons.
836 layout->Layout(root_view); 836 layout->Layout(root_view);
837 gfx::Size preferred = layout->GetPreferredSize(root_view); 837 gfx::Size preferred = layout->GetPreferredSize(root_view);
838 pos = ComputeWindowPosition(preferred.width(), preferred.height()); 838 pos = ComputeWindowPosition(preferred.width(),
839 preferred.height(),
840 root_view->UILayoutIsRightToLeft());
839 popup->SetBounds(pos); 841 popup->SetBounds(pos);
840 842
841 // Carve the toast shape into the window. 843 // Carve the toast shape into the window.
842 SetToastRegion(popup->GetNativeView(), 844 SetToastRegion(popup->GetNativeView(),
843 preferred.width(), preferred.height()); 845 preferred.width(), preferred.height());
844 // Time to show the window in a modal loop. 846 // Time to show the window in a modal loop.
845 popup_ = popup; 847 popup_ = popup;
846 popup_->Show(); 848 popup_->Show();
847 MessageLoop::current()->Run(); 849 MessageLoop::current()->Run();
848 return result_; 850 return result_;
(...skipping 28 matching lines...) Expand all
877 879
878 private: 880 private:
879 enum ButtonTags { 881 enum ButtonTags {
880 BT_NONE, 882 BT_NONE,
881 BT_CLOSE_BUTTON, 883 BT_CLOSE_BUTTON,
882 BT_OK_BUTTON, 884 BT_OK_BUTTON,
883 }; 885 };
884 886
885 // Returns a screen rectangle that is fit to show the window. In particular 887 // Returns a screen rectangle that is fit to show the window. In particular
886 // it has the following properties: a) is visible and b) is attached to 888 // it has the following properties: a) is visible and b) is attached to
887 // the bottom of the working area. 889 // the bottom of the working area. For LTR machines it returns a left side
888 gfx::Rect ComputeWindowPosition(int width, int height) { 890 // rectangle and for RTL it returns a right side rectangle so that the
891 // dialog does not compete with the standar place of the start menu.
892 gfx::Rect ComputeWindowPosition(int width, int height, bool is_RTL) {
889 // The 'Shell_TrayWnd' is the taskbar. We like to show our window in that 893 // The 'Shell_TrayWnd' is the taskbar. We like to show our window in that
890 // monitor if we can. This code works even if such window is not found. 894 // monitor if we can. This code works even if such window is not found.
891 HWND taskbar = ::FindWindowW(L"Shell_TrayWnd", NULL); 895 HWND taskbar = ::FindWindowW(L"Shell_TrayWnd", NULL);
892 HMONITOR monitor = 896 HMONITOR monitor =
893 ::MonitorFromWindow(taskbar, MONITOR_DEFAULTTOPRIMARY); 897 ::MonitorFromWindow(taskbar, MONITOR_DEFAULTTOPRIMARY);
894 MONITORINFO info = {sizeof(info)}; 898 MONITORINFO info = {sizeof(info)};
895 if (!GetMonitorInfoW(monitor, &info)) { 899 if (!GetMonitorInfoW(monitor, &info)) {
896 // Quite unexpected. Do a best guess at a visible rectangle. 900 // Quite unexpected. Do a best guess at a visible rectangle.
897 return gfx::Rect(20, 20, width + 20, height + 20); 901 return gfx::Rect(20, 20, width + 20, height + 20);
898 } 902 }
899 // The |rcWork| is the work area. It should account for the taskbars that 903 // The |rcWork| is the work area. It should account for the taskbars that
900 // are in the screen when we called the function. 904 // are in the screen when we called the function.
901 int left = info.rcWork.right - width; 905 int left = is_RTL ? info.rcWork.left : info.rcWork.right - width;
902 int top = info.rcWork.bottom - height; 906 int top = info.rcWork.bottom - height;
903 return gfx::Rect(left, top, width, height); 907 return gfx::Rect(left, top, width, height);
904 } 908 }
905 909
906 // Create a windows region that looks like a toast of width |w| and 910 // Create a windows region that looks like a toast of width |w| and
907 // height |h|. This is best effort, so we don't care much if the operation 911 // height |h|. This is best effort, so we don't care much if the operation
908 // fails. 912 // fails.
909 void SetToastRegion(HWND window, int w, int h) { 913 void SetToastRegion(HWND window, int w, int h) {
910 static const POINT polygon[] = { 914 static const POINT polygon[] = {
911 {0, 4}, {1, 2}, {2, 1}, {4, 0}, // Left side. 915 {0, 4}, {1, 2}, {2, 1}, {4, 0}, // Left side.
(...skipping 16 matching lines...) Expand all
928 932
929 DISALLOW_COPY_AND_ASSIGN(TryChromeDialog); 933 DISALLOW_COPY_AND_ASSIGN(TryChromeDialog);
930 }; 934 };
931 935
932 } // namespace 936 } // namespace
933 937
934 Upgrade::TryResult Upgrade::ShowTryChromeDialog(size_t version) { 938 Upgrade::TryResult Upgrade::ShowTryChromeDialog(size_t version) {
935 TryChromeDialog td; 939 TryChromeDialog td;
936 return td.ShowModal(); 940 return td.ShowModal();
937 } 941 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698