~ubuntu-branches/ubuntu/wily/ginkgocadx/wily-proposed

« back to all changes in this revision

Viewing changes to src/cadxcore/main/controllers/windowattributescontroller.cpp

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2013-10-24 21:28:17 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20131024212817-ej1skb9og09d3ht6
Tags: 3.5.0.1137.31+dfsg-1
New upstream release [October 2013]

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *  $Id: thumbnailcontroller.cpp $
4
4
 *  Ginkgo CADx Project
5
5
 *
6
 
 *  Copyright 2008-12 MetaEmotion S.L. All rights reserved.
 
6
 *  Copyright 2008-14 MetaEmotion S.L. All rights reserved.
7
7
 *  http://ginkgo-cadx.com
8
8
 *
9
9
 *  This file is licensed under LGPL v3 license.
11
11
 *
12
12
 *
13
13
 */
 
14
#include <limits> 
14
15
#include <wx/toplevel.h>
15
16
#include <wx/display.h>
16
17
#include "configurationcontroller.h"
17
18
#include "windowattributescontroller.h"
 
19
#include "controladorlog.h"
18
20
 
19
21
#define ATTRIBUTES_SCOPE "/GinkgoCore/WindowAttributes"
20
22
#define WINDOW_ID_KEY "windowId"
38
40
                        GNC::GCS::IConfigurationController::TListGroups groups;
39
41
                        GNC::GCS::ConfigurationController::Instance()->readGroupUser(ATTRIBUTES_SCOPE, groups);
40
42
 
41
 
                        int maxX = 0, maxY = 0;
42
 
                        int deviceCount = wxDisplay::GetCount();
43
 
                        for (int i = 0; i < deviceCount; ++i) {
44
 
                                wxDisplay dsply(i);
45
 
                                maxX = std::max<int>(maxX, dsply.GetClientArea().x + dsply.GetCurrentMode().GetWidth());
46
 
                                maxY = std::max<int>(maxY, dsply.GetClientArea().y + dsply.GetCurrentMode().GetHeight());
 
43
                        int maxX = 0, maxY = 0, minX=std::numeric_limits<int>::max(), minY=std::numeric_limits<int>::max();
 
44
                        int deviceCount = wxDisplay::GetCount();
 
45
                        for (int i = 0; i < deviceCount; ++i) {
 
46
                                wxDisplay dsply(i);
 
47
                                maxX = std::max<int>(maxX, dsply.GetClientArea().x + dsply.GetCurrentMode().GetWidth());
 
48
                                maxY = std::max<int>(maxY, dsply.GetClientArea().y + dsply.GetCurrentMode().GetHeight());
 
49
                                minX = std::min<int>(minX, dsply.GetClientArea().x);
 
50
                                minY = std::min<int>(minY, dsply.GetClientArea().y);
47
51
                        }
48
 
                        
 
52
                        LOG_DEBUG ("WindowAttributes",  "Client area X: " << minX << ", " << maxX << "  Y: " << minY << ", " << maxY << std::endl);
49
53
                        std::string windowIdTmp;
50
54
                        for (GNC::GCS::IConfigurationController::TListGroups::iterator it = groups.begin(); it != groups.end(); ++it)
51
55
                        {
52
56
                                (*it).readStringValue(WINDOW_ID_KEY, windowIdTmp);
53
57
                                if (windowId.compare(windowIdTmp) == 0) {
54
58
                                        wxPoint position;
 
59
                                        wxSize size;
55
60
                                        (*it).readIntValue(X_KEY_POSITION, position.x, -1);
56
61
                                        (*it).readIntValue(Y_KEY_POSITION, position.y, -1);
57
 
                                        if (position.x > -50 && position.x  < maxX 
58
 
                                                && position.y > -50 && position.y < maxY) {
 
62
                                        if (position.x >= (minX - pWindow->GetMinSize().x) && position.x  < maxX 
 
63
                                                && position.y >= (minY  - pWindow->GetMinSize().y) && position.y < maxY) {
59
64
                                                pWindow->SetPosition(position);
60
65
                                        }
61
 
                                        wxSize size;
62
66
                                        wxTopLevelWindow* pTopLevel = dynamic_cast<wxTopLevelWindow*>(pWindow);
63
67
                                        if (pTopLevel != NULL) {
64
68
                                                bool isMaximized = defaultMaximized;
65
69
                                                (*it).readBoolValue(IS_MAXIMIZED_KEY, isMaximized);
66
70
                                                pTopLevel->Maximize(isMaximized);
67
71
                                                if (!isMaximized) {
68
 
                                                        (*it).readIntValue(WIDTH_KEY_POSITION, size.x, -1);
69
 
                                                        (*it).readIntValue(HEIGH_KEY_POSITION, size.y, -1);
 
72
                                                        (*it).readIntValue(WIDTH_KEY_POSITION, size.x, 0);
 
73
                                                        (*it).readIntValue(HEIGH_KEY_POSITION, size.y, 0);
70
74
                                                }
71
75
                                        } else {
72
 
                                                (*it).readIntValue(WIDTH_KEY_POSITION, size.x, -1);
73
 
                                                (*it).readIntValue(HEIGH_KEY_POSITION, size.y, -1);
 
76
                                                (*it).readIntValue(WIDTH_KEY_POSITION, size.x, 0);
 
77
                                                (*it).readIntValue(HEIGH_KEY_POSITION, size.y, 0);
74
78
                                        }
75
79
                                        pWindow->SetSize(size);
76
80
                                }