Skip to content

Commit 187ce81

Browse files
coremail-cyt徐扬斌
authored andcommitted
wxMSW: add setDarkModeDragBorderColor to set the wxHeader drag area border color; wxSystemSettings add support custom define color under windows
1 parent cbfa414 commit 187ce81

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

include/wx/generic/headerctrlg.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ class WXDLLIMPEXP_CORE wxHeaderCtrl : public wxHeaderCtrlBase
4747

4848
virtual ~wxHeaderCtrl();
4949

50+
static void setDarkModeDragBorderColor(wxColor c) { g_clDarkModeDragBorder = c; }
51+
5052
protected:
5153
virtual wxSize DoGetBestSize() const wxOVERRIDE;
5254

@@ -187,6 +189,8 @@ class WXDLLIMPEXP_CORE wxHeaderCtrl : public wxHeaderCtrlBase
187189

188190
bool m_wasSeparatorDClick;
189191

192+
static wxColor g_clDarkModeDragBorder;
193+
190194
wxDECLARE_EVENT_TABLE();
191195
wxDECLARE_NO_COPY_CLASS(wxHeaderCtrl);
192196
};

include/wx/settings.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ class WXDLLIMPEXP_CORE wxSystemSettingsNative
231231

232232
// return true if the port has certain feature
233233
static bool HasFeature(wxSystemFeature index);
234+
235+
#ifdef __WXMSW__
236+
static void SetCustomSystemColor(wxColor* aryColor);
237+
#endif
234238
};
235239

236240
// ----------------------------------------------------------------------------

src/generic/headerctrlg.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ unsigned int wxHeaderCtrl::FindColumnAfter(const unsigned int column_idx) const{
232232
//auto target_column_found = false;
233233
for ( unsigned n = 0; n < count; n++ )
234234
{
235-
if (m_colIndices[n] == column_idx && n + 1 < count ){
235+
if (static_cast<unsigned>(m_colIndices[n]) == column_idx && n + 1 < count ){
236236
after_idx = m_colIndices[n + 1];
237237
break;
238238
}
@@ -246,13 +246,13 @@ unsigned int wxHeaderCtrl::FindColumnBefore(const unsigned int column_idx) const
246246
auto target_column_found = false;
247247
for ( unsigned n = 0; n < count; n++ )
248248
{
249-
if (m_colIndices[n] == column_idx){
249+
if (static_cast<unsigned>(m_colIndices[n]) == column_idx){
250250
target_column_found = true;
251251
break;
252252
}
253253
before_idx = m_colIndices[n];
254254
}
255-
if (not target_column_found)
255+
if (!target_column_found)
256256
before_idx = COL_NONE;
257257
return before_idx;
258258
}
@@ -404,17 +404,17 @@ void wxHeaderCtrl::EndResizing(int xPhysical)
404404
m_colBeingResized = COL_NONE;
405405
}
406406

407+
wxColor wxHeaderCtrl::g_clDarkModeDragBorder;
408+
407409
void wxHeaderCtrl::UpdateReorderingMarker(int xPhysical)
408410
{
409411
wxClientDC dc(this);
410412

411413
wxDCOverlay dcover(m_overlay, &dc);
412414
dcover.Clear();
413415

414-
static const auto g_light_cyan_pen = wxPen{ wxColour{208, 226, 249} };
415-
static const auto g_light_cyan_brush = wxBrush{ wxColour{208, 226, 249} };
416-
if (wxSystemSettings::GetAppearance().IsDark()) {
417-
dc.SetPen(g_light_cyan_pen);
416+
if (wxSystemSettings::GetAppearance().IsDark() && g_clDarkModeDragBorder.IsOk()) {
417+
dc.SetPen(g_clDarkModeDragBorder);
418418
dc.SetBrush(*wxTRANSPARENT_BRUSH);
419419
}
420420
else {
@@ -435,8 +435,8 @@ void wxHeaderCtrl::UpdateReorderingMarker(int xPhysical)
435435
{
436436
static const int DROP_MARKER_WIDTH = 4;
437437

438-
if (wxSystemSettings::GetAppearance().IsDark())
439-
dc.SetBrush(g_light_cyan_brush);
438+
if (wxSystemSettings::GetAppearance().IsDark() && g_clDarkModeDragBorder.IsOk())
439+
dc.SetBrush(g_clDarkModeDragBorder);
440440
else
441441
dc.SetBrush(*wxBLUE);
442442
if (hover_region == Region::LeftHalf){
@@ -553,7 +553,7 @@ bool wxHeaderCtrl::EndReordering(int xPhysical)
553553
MoveColumnInOrderArray(new_colIndices, colOld, new_pos);
554554
auto old_after_pos = new_colIndices.Index(colNew);
555555
auto new_after_pos = new_colIndices.Index(colOld);
556-
if (old_after_pos != old_pos || new_after_pos != new_pos || move_left || old_pos > new_pos){
556+
if (static_cast<unsigned>(old_after_pos) != old_pos || static_cast<unsigned>(new_after_pos) != new_pos || move_left || old_pos > new_pos){
557557
event.SetNewOrder(new_pos);
558558

559559
//printf("Move col %d to %d, pos to %d\n", colOld, colNew, new_pos);

src/msw/settings.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,18 @@ void wxSystemSettingsModule::OnExit()
9696
// colours
9797
// ----------------------------------------------------------------------------
9898

99+
static wxColour* g_aryColorSysSetting = NULL;
100+
101+
void wxSystemSettingsNative::SetCustomSystemColor(wxColor* aryColor)
102+
{
103+
g_aryColorSysSetting = aryColor;
104+
}
105+
99106
wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
100107
{
108+
if (g_aryColorSysSetting && index < wxSYS_COLOUR_MAX && g_aryColorSysSetting[index].IsOk())
109+
return g_aryColorSysSetting[index];
110+
101111
if ( index == wxSYS_COLOUR_LISTBOXTEXT)
102112
{
103113
// there is no standard colour with this index, map to another one

0 commit comments

Comments
 (0)