Skip to content

Commit

Permalink
1.6.6a
Browse files Browse the repository at this point in the history
- #4 fix: line numbers -> allow turning off
  • Loading branch information
jtorjo committed Jan 6, 2016
1 parent b495e9f commit 970b318
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 25 deletions.
4 changes: 3 additions & 1 deletion src/docs/history.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@



1.6.6
1.6.6a
- #4 fix: line numbers -> allow turning off


1.6.5b
- moved bugs/features issues into github
Expand Down
2 changes: 1 addition & 1 deletion src/docs/todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@



#4 bug: line numbers -> allow turning off


#5 - add a horizonal scrollbar (make Msg not "occupy remaining space") -> allow a checkbox

Expand Down
1 change: 1 addition & 0 deletions src/lw_common/lw_common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
<SubType>Component</SubType>
</Compile>
<Compile Include="ui\log_view\log_view_right_click.cs" />
<Compile Include="ui\log_view\log_view_column_tag.cs" />
<Compile Include="ui\log_view\match\log_view_data_source.cs" />
<Compile Include="ui\log_view\match\match_full_item.cs" />
<Compile Include="ui\log_view\match\match_item.cs" />
Expand Down
16 changes: 7 additions & 9 deletions src/lw_common/ui/log_view/log_view.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ public log_view(Form parent, string name)
lv_parent.handle_subcontrol_keys(this);

render_ = new log_view_render(this);
foreach (var col in list.AllColumns)
(col as OLVColumn).Renderer = render_;
foreach (var col in list.AllColumns) {
col.Renderer = render_;
col.Tag = new log_view_column_tag(this);
}
right_click_ = new log_view_right_click(this);

// just an example:
//render_.set_override("settings", new log_view_render.print_info { fg = Color.Blue, bold = true });
cur_col_ = msgCol.fixed_index();
edit.on_sel_changed = on_edit_sel_changed;
edit.on_search_ahead = search_ahead;
Expand Down Expand Up @@ -188,9 +188,7 @@ public log_view(Form parent, string name)
if (!is_visible)
continue;
ToolStripMenuItem sub = new ToolStripMenuItem(col.Text);
sub.Checked = col.IsVisible;
if (col.Index == 0)
sub.Enabled = false;
sub.Checked = log_view_show_columns.is_column_visible(col);
var c = col;
sub.Click += (a, ee) => toggle_column_visible(c, sub);
menu.Items.Add(sub);
Expand Down Expand Up @@ -265,8 +263,7 @@ public log_view(Form parent, string name)
}

private void toggle_column_visible(OLVColumn col, ToolStripMenuItem sub) {
col.IsVisible = !col.IsVisible;
sub.Checked = col.IsVisible;
sub.Checked = log_view_show_columns.toggle_column_visible(col);
list.RebuildColumns();
}

Expand Down Expand Up @@ -1441,6 +1438,7 @@ public enum select_type {
private static extern int ShowWindow(IntPtr hwnd, int nCmdShow);

private void list_CellToolTipShowing(object sender, ToolTipShowingEventArgs e) {
// 1.6.6+ - I think this is wrong!
if (e.ColumnIndex == msgCol.fixed_index())
ShowWindow(e.ToolTipControl.Handle, 0);
}
Expand Down
3 changes: 0 additions & 3 deletions src/lw_common/ui/log_view/log_view.resx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,4 @@
<metadata name="tip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="tip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
19 changes: 19 additions & 0 deletions src/lw_common/ui/log_view/log_view_column_tag.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace lw_common.ui {
// placed in the .Tag of each lv column
internal class log_view_column_tag {

public readonly log_view parent;

public int line_width = -1;

public log_view_column_tag(log_view parent) {
this.parent = parent;
}

}
}
66 changes: 57 additions & 9 deletions src/lw_common/ui/log_view/log_view_show_columns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static class log_view_show_columns {
if (type == info_type.max)
continue;
bool is_visible = has_value_at_column(full_log, type, row_count);
show_column(full_log, log_view_cell.column(full_log,type), DEFAULT_COL_WIDTH, is_visible);
show_column(log_view_cell.column(full_log,type), DEFAULT_COL_WIDTH, is_visible);
if ( is_visible)
visible_columns.Add(type);
}
Expand All @@ -128,25 +128,73 @@ public static class log_view_show_columns {
for (int idx = 0; idx < lv.list.AllColumns.Count; ++idx) {
var col = lv.list.AllColumns[idx];
if (col != lv.viewCol)
show_column(lv, col, full_log.list.AllColumns[idx].Width, full_log.list.AllColumns[idx].IsVisible);
show_column(col, full_log.list.AllColumns[idx].Width, full_log.list.AllColumns[idx].IsVisible);
else
show_column(lv, col, DEFAULT_COL_WIDTH, false);
show_column(col, DEFAULT_COL_WIDTH, false);
}
lv.list.RebuildColumns();
}

static private void show_column(log_view lv, OLVColumn col, int width, bool show) {
//if( lv.is_full_log)
// logger.Debug("showing column " + col.Text + " w=" + width +" visible=" + show);
static private void show_column(OLVColumn col, int width, bool show) {
Debug.Assert(col.Tag != null);

bool is_line_col = col.fixed_index() == 0;
bool visible = is_line_col ? col.Width > 1 : col.IsVisible;

if (col.Width == 0)
col.Width = width;
if (col.IsVisible == show)
if (visible == show)
return;

col.Width = width;
col.IsVisible = show;
// 1.6.6 for Line column - we can't hide it (due to some weird b_ug in ListView); so we just set its width to 1
if (is_line_col) {
if (show) {
col.MaximumWidth = -1;
col.Width = width;
} else {
col.lv_tag().line_width = width;
// ... don't allow resizing
col.MaximumWidth = col.Width = 1;
}
col.IsVisible = true;
} else {
col.Width = width;
col.IsVisible = show;
}
}

internal static bool is_column_visible(OLVColumn col) {
Debug.Assert(col.Tag != null);

bool is_line_col = col.fixed_index() == 0;
bool visible = is_line_col ? col.Width > 1 : col.IsVisible;
return visible;
}

// toggles whether column is visible or not, and returns the new state
static internal bool toggle_column_visible(OLVColumn col) {
Debug.Assert(col.Tag != null);

bool is_line_col = col.fixed_index() == 0;
bool visible = is_line_col ? col.Width > 1 : col.IsVisible;
visible = !visible;

// 1.6.6 for Line column - we can't hide it (due to some weird b_ug in ListView); so we just set its width to 1
if (is_line_col) {
// for line column - simple trick - save the old width in "Tag" property
if (visible) {
col.MaximumWidth = -1;
col.Width = col.lv_tag().line_width > 0 ? col.lv_tag().line_width : DEFAULT_COL_WIDTH;
} else {
col.lv_tag().line_width = col.Width;
col.MaximumWidth = col.Width = 1;
}
col.IsVisible = true;
} else
col.IsVisible = visible;

return visible;
}


static private void load_column_positions(log_view lv, string str) {
Expand Down
18 changes: 16 additions & 2 deletions src/lw_common/util/olv_extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,32 @@
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using BrightIdeasSoftware;
using lw_common.ui;

namespace lw_common {
public static class olv_extensions {
internal static class olv_extensions {

public static log_view_column_tag lv_tag(this OLVColumn c) {
var tag = c.Tag as log_view_column_tag;
Debug.Assert(tag != null);
return tag;
}

public static int fixed_index(this OLVColumn c) {
if (c.ListView == null)
if (c.ListView == null) {
// 1.6.6
var tag = c.Tag as log_view_column_tag;
if (tag != null)
return tag.parent.list.AllColumns.IndexOf(c);

// why would listview EVER become null? beats the hell out of me; first, I was extremely nervous at looking at this, but then, I realized:
// this can happpen if the column is not visible at all (like, for msg column, when it's completely invisible - I'm assuming OLV will completely remove it in this case)
return c.LastDisplayIndex;
}

// theoretically, we should reference LastDisplayIndex
// but by looking at the implementation, it looks really fishy...
Expand Down

0 comments on commit 970b318

Please sign in to comment.