2
* Copyright 2010 Inalogic Inc.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License version 3, as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the applicable version of the GNU Lesser General Public
12
* License for more details.
14
* You should have received a copy of both the GNU Lesser General Public
15
* License version 3 along with this program. If not, see
16
* <http://www.gnu.org/licenses/>
18
* Authored by: Jay Taoko <jay.taoko_AT_gmail_DOT_com>
27
#include "ToolButton.h"
28
#include "ActionItem.h"
29
#include "AbstractSeparator.h"
30
#include "VSeparator.h"
31
#include "EditTextBox.h"
32
#include "StaticTextBox.h"
46
void HToolBar::InitializeWidgets()
48
m_hlayout->SetHorizontalInternalMargin(2);
49
m_hlayout->SetHorizontalExternalMargin(0);
50
m_hlayout->SetVerticalExternalMargin(0);
51
m_hlayout->SetContentStacking(eStackLeft);
52
SetMinimumSize(200, 32);
54
setGeometry(Geometry(0, 0, 200, 20));
55
SetCompositionLayout(m_hlayout);
58
void HToolBar::InitializeLayout()
60
m_hlayout = smptr(HLayout)(new HLayout());
63
void HToolBar::DestroyLayout()
67
long HToolBar::ProcessEvent(IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
69
long ret = TraverseInfo;
71
ret = m_hlayout->ProcessEvent(ievent, TraverseInfo, ProcessEventInfo);
73
// PostProcessEvent2 must always have its last parameter set to 0
74
// because the m_BackgroundArea is the real physical limit of the window.
75
// So the previous test about IsPointInside do not prevail over m_BackgroundArea
76
// testing the event by itself.
77
ret = PostProcessEvent2(ievent, ret, 0);
81
void HToolBar::Draw(GraphicsContext& GfxContext, bool force_draw)
83
Geometry base = GetGeometry();
84
GfxContext.PushClippingRectangle(base);
85
GfxContext.SetEnvModeSelectColor(GL_TEXTURE0);
86
GfxContext.QRP_GLSL_Color(base.x, base.y, base.GetWidth(), base.GetHeight(), COLOR_BACKGROUND_PRIMARY);
88
GfxContext.PopClippingRectangle();
91
void HToolBar::DrawContent(GraphicsContext& GfxContext, bool force_draw)
93
Geometry base = GetGeometry();
94
GfxContext.PushClippingRectangle(base);
95
gPainter.PushColorLayer(GfxContext, base, COLOR_BACKGROUND_PRIMARY);
96
m_hlayout->ProcessDraw(GfxContext, force_draw);
97
gPainter.PopBackground();
98
GfxContext.PopClippingRectangle();
101
void HToolBar::PostDraw(GraphicsContext& GfxContext, bool force_draw)
106
void HToolBar::AddToolButton(smptr(ToolButton) toolbutton)
108
nuxAssert(toolbutton.IsValid());
112
m_hlayout->AddActiveInterfaceObject(toolbutton, 0, eCenter, eFix);
113
// 0: the WidgetLayout geometry will be set to setGeometry(0,0,1,1);
114
// and the children will take their natural size by expending WidgetLayout.
115
// If the parent of WidgetLayout offers more space, it won't be used by WidgetLayout.
116
ComputeChildLayout();
119
void HToolBar::AddAction(smptr(ActionItem) action)
121
// nuxAssert(action);
125
smptr(ToolButton) tool_button(new ToolButton);
126
tool_button->SetAction(*action);
128
m_hlayout->AddActiveInterfaceObject(tool_button, 0, eCenter, eFix);
129
// 0: the WidgetLayout geometry will be set to setGeometry(0,0,1,1);
130
// and the children will take their natural size by expending WidgetLayout.
131
// If the parent of WidgetLayout offers more space, it won't be used by WidgetLayout.
132
ComputeChildLayout();
135
void HToolBar::AddSpace(int size)
137
smptr(SpaceLayout) layout(new SpaceLayout());
138
layout->SetMaximumWidth(size);
139
layout->SetMinimumWidth(size);
140
m_hlayout->AddLayout(layout);
141
ComputeChildLayout();
144
void HToolBar::AddSeparator()
146
smptr(VSeparator) separator(new VSeparator());
147
m_hlayout->AddActiveInterfaceObject(separator, 0);
148
ComputeChildLayout();
151
void HToolBar::AddEditTextLine(smptr(EditTextBox) edittextline)
153
nuxAssert(edittextline.IsValid());
154
if(edittextline == 0)
157
m_hlayout->AddActiveInterfaceObject(edittextline, 0, eCenter, eFix);
158
// 0: the WidgetLayout geometry will be set to setGeometry(0,0,1,1);
159
// and the children will take their natural size by expending WidgetLayout.
160
// If the parent of WidgetLayout offers more space, it won't be used by WidgetLayout.
161
ComputeChildLayout();
164
void HToolBar::AddStaticTextLine(smptr(StaticTextBox) statictextline)
166
nuxAssert(statictextline.IsValid());
167
if(statictextline == 0)
170
m_hlayout->AddActiveInterfaceObject(statictextline, 0, eCenter, eFix);
171
// 0: the WidgetLayout geometry will be set to setGeometry(0,0,1,1);
172
// and the children will take their natural size by expending WidgetLayout.
173
// If the parent of WidgetLayout offers more space, it won't be used by WidgetLayout.
174
ComputeChildLayout();
177
void HToolBar::ClearWidget()
179
m_CompositionLayout->Clear();
182
void HToolBar::RecvMouseDownOnIcon(int x, int y, unsigned long button_flags, unsigned long key_flags)
187
void HToolBar::RecvMouseUpOnIcon(int x, int y, unsigned long button_flags, unsigned long key_flags)
192
void HToolBar::RecvMouseMoveOnIcon(int x, int y, unsigned long button_flags, unsigned long key_flags)
197
void HToolBar::RecvMouseDragOnIcon(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
202
void HToolBar::RecvMouseEnterIcon(int x, int y, unsigned long button_flags, unsigned long key_flags)
207
void HToolBar::RecvMouseLeaveIcon(int x, int y, unsigned long button_flags, unsigned long key_flags)