EzDevInfo.com

cells

View components for Ruby and Rails. Trailblazer trailblazer : a new architecture for rails.

How can I disable editing cells in a WPF Datagrid?

I'm constructing a datagrid in Windows Presentation Foundation, and I have a problem. When a user double-clicks on a cell in my datagrid, the cell goes into edit mode. I want to prevent that. Instead I want users to be able to select the full row - not edit values in it.

How can I make it so that double-clicks select the full row instead of putting the clicked-on cell in edit mode?


Source: (StackOverflow)

gridView with different cells sizes, pinterest style

Background

GridView is a class that extends AdapterView , which means it shows cells in a grid-style efficiently, recycling old views to be shown as new ones when the user scrolls it.

The problem

Sometimes, you would want to get a special UI, which resembles the Windows Phone Tiles UI, having cells of different sizes on top of each other.

Something like this:

AABB
AACC
AADD
AADD

each letter represents a part of its cell, so cell A is 2x4 , cell B and cell C take 2x1 each , and cell D is 2x2 .

It could be even more than that, where cell D finished a bit above what i've shown, and right beneath it there is another cell so the end of D and the end of A aren't necessary aligned.

an example of an app that has this style is pinterest .

GridView doesn't allow such a thing.

In fact , every solution I've tried has issues. Would like to ask if there are any other alternatives or better solutions.

What I've found

There are multiple ways to handle this problem:

  1. As a class that extends AdapterView GridView has the ability to have a type for each item (using the BaseAdapter), which would allow you to set how to layout the cell .

    However, it still limits you since you will get rows of items, one beneath the other. you have to have them aligned.

  2. GridLayout is a relatively new layout, and it's quite flexible. Google has published a nice compatibility library for it, supporing API7 and above.

    However, it doesn't use any recycling of views, so it's a bad choice in case you wish to show a lot of items.

    If you have a lot of items, you would need to create all of the views for them .

  3. QuiltView Library - extends from GridLayout, so basically has the same problem like it.

  4. StaggeredGridView - looks the most promising, but has a lot of bugs, especially when changing orientation. such bugs include empty cells, bad scrolling and NPEs (rare but still happens). I'm also not sure if it supports having customized cells instead of imageViews alone .

  5. other solutions, as mentions here .

The question

Does anyone know of another alternative to this problem? Maybe some workarounds for any of the solutions I've shown?


EDIT: I think that about StaggeredGridView , the scrolling and exceptions can be solved by using a normal ImageView that you set its size inside the getView. i think that the reason for it to work in a weird way is that the sample updates the size of the imageview after it was loaded from the internet.

However, empty cells issue still remains in this library. not only that, but their sizes change a lot , even without changing the orientation.


EDIT: for now, i think the best solution is to use , PinterestLikeAdapterView library.

it doesn't have any issues that i can find.

however, it can't make items to take more than 1 cell width. it's very good nevertheless.

EDIT: sadly it has issues with notifyDataSetChanged . i've reported about it here.


Source: (StackOverflow)

Advertisements

how to compare matlab cells or structs [duplicate]

Possible Duplicate:
Octave/MATLAB: How to compare structs for equality?

is there a simple comparison function for matlab cell or struct objects? using '==' doesn't seem to work :(


Source: (StackOverflow)

Disable Excel's Automatic Cell Reference Change After Copy/Paste

I've got a massive Excel 2003 spreadsheet I'm working on. There are a lot of very large formulas with a lot of cell references. Here's a simple example.

='Sheet'!AC69+'Sheet'!AC52+'Sheet'!AC53)*$D$3+'Sheet'!AC49

Most of them are more complicated than that, but this gives a good idea of what I'm working with. Few of these cell references are absolute ($s). I'd like to be able to copy these cells to a different location without the cell references changing. I know I can simply use f4 to make the references absolute, but there is a lot of data and I may need to use Fill later. Is there any way to temporarily disable the cell reference changing on copy-paste/fill without making the references absolute?

EDIT: I just found out that you can do this with VBA by copying the cell contents as text instead of a formula. I'd like to not have to do this though because I want to copy whole rows/columns at once. Is there a simple solution I am missing?


Source: (StackOverflow)

Merging cells in a JXTreeTable

I want to merge two cells in a JXTreeTable. Is this possible? I have read the solution for Merging cells in JTable, but this does not work for JXTreeTables.

What I mean with merging cells: I want to create a structure like this:

node 1    | title for 3 cells | title for 3 cells |
  subnode |  c1  | c2  |  c3  |  c1  | c2  |  c3  |
  subnode |  c1  | c2  |  c3  |  c1  | c2  |  c3  |

so the 'title for 3 cells' is created by merging 3 different cells on the same row/node.


Source: (StackOverflow)

A way to group table cells together in html?

So it is pretty straight forward. I need a way to group cells together. Like a <div> or a <span> but none of them worked. <tbody> seemed like a good solution but it only works for table rows. Help!


Source: (StackOverflow)

how to rotate text left 90 degree and cell size is adjusted according to text in html

Suppose i have table with some rows and column,so i want to rotate text in cells something like this
: enter image description here

problem is when i rotate text using style :

#rotate {
     -moz-transform: rotate(-90.0deg);  /* FF3.5+ */
       -o-transform: rotate(-90.0deg);  /* Opera 10.5 */
  -webkit-transform: rotate(-90.0deg);  /* Saf3.1+, Chrome */
             filter:  progid:DXImageTransform.Microsoft.BasicImage(rotation=0.083);  /* IE6,IE7 */
         -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=0.083)"; /* IE8 */

it all get messed up like this

html code:

<table cellpadding="0" cellspacing="0" align="center">
    <tr>
        <td id='rotate'>10kg</td>
        <td >B</td>
        <td >C</td>
        <td>D</td>
        <td>E</td>
    </tr>
    <tr>
        <td id='rotate'>20kg</td>
        <td>G</td>
        <td>H</td>
        <td>I</td>
        <td>J</td>
    </tr>
    <tr>
        <td id='rotate'>30kg</td>
        <td>L</td>
        <td>M</td>
        <td>N</td>
        <td>O</td>
    </tr>


</table>

css:

<style type="text/css">
td {
    border-collapse:collapse;
    border: 1px black solid;
}
tr:nth-of-type(5) td:nth-of-type(1) {
    visibility: hidden;
}
#rotate {
     -moz-transform: rotate(-90.0deg);  /* FF3.5+ */
       -o-transform: rotate(-90.0deg);  /* Opera 10.5 */
  -webkit-transform: rotate(-90.0deg);  /* Saf3.1+, Chrome */
             filter:  progid:DXImageTransform.Microsoft.BasicImage(rotation=0.083);  /* IE6,IE7 */
         -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=0.083)"; /* IE8 */
}
</style>

Source: (StackOverflow)

MATLAB: Is it possible to overload operators on native constructs (cells, structs, etc)?

I'm using cells to manage data in some stuff I'm working on. I'd like to be able to do things like:

A = cellfun( @(X)( randn( 5,5 ) ), cell( 5,1 ), 'UniformOutput', 0 );
B = cellfun( @(X)( randn( 5,5 ) ), cell( 5,1 ), 'UniformOutput', 0 );
%#
%# Each of the following would fail if cell member dimensions
%# don't match up
%#
%# matrix sums for each cell entry
%# C = A + B;
C = cellfun( @(X,Y)( X + Y ), A, B, 'UniformOutput', 0 );
%#
%# direct/hadamard product
%# D = A .* B;
D = cellfun( @(X,Y)( X .* Y ), A, B, 'UniformOutput', 0 );
%#
%# matrix-matrix products (not across all entries)
%# E = A * B;
E = cellfun( @(X,Y)( X * Y ), A, B, 'UniformOutput', 0 );

However, I don't want the extremely verbose syntax to do it. It seems a bit overboard to create a new class for this when all I want to do is provide a definition for math operators on cells.

The question: Is a class the only way to go about it?

If I write a class to do this, it certainly makes it easier to write the code. The biggest negatives I see are related to optimizations, though there's a few other things that bug me about it..

Any optimizations going on behind the scenes (eg, when Jacket compiles something to run on a GPU) would potentially have a harder time determining what optimizations to make. As an example, suppose I have two cells (A,B) containing a number of matrices of appropriate dimension. If I write code to produce a new cell:

Z = c1*A + c2*B

... with scalars {c1,c2}, I can write it in such a way that Jacket (or whatever) will easily determine that it should do the calculations as:

Z{kk} = c1*A{kk} + c2*B{kk}

or perhaps an even better optimization than that. Otherwise. it may end up with something slower and/or less memory efficient, eg:

temp1 = cellfun( @(X)( c1*X ), A );
temp2 = cellfun( @(X)( c2*X ), B );
Z     = cellfun( @plus, temp1, temp2 );

Assuming MATLAB or Jacket are unable to optimize it, this would end up using too much memory.


Source: (StackOverflow)

How to create a cell array of k similar objects in Matlab?

I want to create an 1,k cell of m,m matrices. I have some trouble trying to initialize it. My first idea was to do this

myCell = cell{1,K};
for k = 1:K
  myCell{1,k} = eye(m);
end 

But it seems like such ugly way to initialize it. There have to be a better way?


Source: (StackOverflow)

find NaN values is cell array

lets assume I have the following array:

a = {1; 'abc'; NaN}

Now I want to find out in which indices this contains NaN, so that I can replace these with '' (empty string).

If I use cellfun with isnan I get a useless output

cellfun(@isnan, a, 'UniformOutput', false)

ans = 
[          0]
[1x3 logical]
[          1]

So how would I do this correct?


Source: (StackOverflow)

dequeueReusableCellWithIdentifier behavior changed for prototype cells?

In iOS5, using ARC and prototype cells for tableView on storyboard, can I replace the code below:

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView 
  dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc] 
      initWithStyle:UITableViewCellStyleDefault 
      reuseIdentifier:CellIdentifier];
}

// Configure the cell...
return cell;

With this simple code??:

UITableViewCell *cell = [tableView 
  dequeueReusableCellWithIdentifier:@"Cell"];
return cell;

I saw this on this link:

http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1

Thank's in advance!

Arildo


Source: (StackOverflow)

Paste Mathematica code so that's it's broken into separate input cells

I often copy Mathematica code from websites (such as SO) to a notebook. The code usually gets pasted as a single input cell. I'm looking for a simple way to paste it as several input cells for convenient step-by-step evaluation.

For example,

a = 2;
f[x_] := x^a

Plot[f[x], {x,0,2}]

would ideally paste as two input cells. Manual formatting (i.e. the original newlines) should preferably also be preserved (this is not the case with default pasting).

Generally, if one selects all input cells (ALT-click), copies them into a text editor, then copies the resulting text back into a notebook, one should get a close equivalent of the original cells that were copied.


Source: (StackOverflow)

MonoTouch How to implement RowSelected for a UITableViewController with Static Cells

I'm porting a native objective-C app to a Monotouch solution.

I have a in my storyboard a tableview, with some static table cells.

Using following objective-c code a received a selection from the table

- (void) tableView:(UITableView *) aTableView didSelectRowAtIndexPath:(NSIndexPath *) indexPath
{        // remove the row highlight
    [aTableView deselectRowAtIndexPath:indexPath animated:YES];

    switch(indexPath.row) {
        case 0: [self callWebsite]; break;
        case 1: [self sendEmail]; break;
        case 2: [self makePhoneCall]; break;
    }

    return;
}

Now I want to do the same in MonoTouch, but can't find out how and all the examples I find on the net, are using the DataSource and UITableViewDelegate.

But when using that approach, My "Static" cells are removed, replaced.

This is what I'm trying

public partial class ContactViewController : UITableViewController
{
    public ContactViewController (IntPtr handle) : base (handle)
    {
        this.TableView.Delegate = new CustomTableViewDelegate();
    }
}

public class CustomTableViewDelegate : UITableViewDelegate
{
    public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
    {
        // Remove the row highlight
        RowDeselected(tableView, indexPath);

        /*
             // Is this section our "button" section?
            switch(indexPath.row) {
                case 0: [self callWebsite]; break;
                case 1: [self sendEmail]; break;
                case 2: [self makePhoneCall]; break;
            }
        */

        Console.WriteLine("Do something meaningfull.");
    }
}

Somebody any suggestion?


Source: (StackOverflow)

Individual and not continuous JTable's cell selection

Is there any clean way to allow a user to select multiple non continuos cells of a JTable? Or I'm forced to implement my own ListSelectionModel?

I played around with setCellSelectionEnabled() and setSelectionModel() methods on JTable but I can only select groups of continuous cells.

EDIT:

I tried @mKorbel nice SSCCE. It works fine for list but it seems not fully working on tables. Here's an SSCCE:

import java.awt.Component;

import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;


public class TableSelection extends JFrame{
    String[] columnNames = {"First Name",
            "Last Name",
            "Sport",
            "# of Years",
            "Vegetarian"};
    Object[][] data = {
            {"Kathy", "Smith",
             "Snowboarding", new Integer(5), new Boolean(false)},
            {"John", "Doe",
             "Rowing", new Integer(3), new Boolean(true)},
            {"Sue", "Black",
             "Knitting", new Integer(2), new Boolean(false)},
            {"Jane", "White",
             "Speed reading", new Integer(20), new Boolean(true)},
            {"Joe", "Brown",
             "Pool", new Integer(10), new Boolean(false)}
        };

    public TableSelection(){
        JPanel main= new JPanel();
        JTable table = new JTable(data, columnNames){
             @Override
                protected void processMouseEvent(MouseEvent e) {
                    int modifiers = e.getModifiers() | InputEvent.CTRL_MASK;
                    // change the modifiers to believe that control key is down
                    int modifiersEx = e.getModifiersEx() | InputEvent.CTRL_MASK;
                    // can I use this anywhere?  I don't see how to change the modifiersEx of the MouseEvent
                    MouseEvent myME = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), modifiers, e.getX(),
                            e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), e.getButton());
                    super.processMouseEvent(myME);
                }

        };
        JScrollPane pane = new JScrollPane(table);
        main.add(pane);
        this.add(main);

        this.setSize(800, 600);
        this.setVisible(true);
    }
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        new TableSelection();
    }

}

I can select non-contiguous row but not single cells. I mean, I would like to be able to select cell 0,0 and 3,3 for example.


Source: (StackOverflow)

Count strings occurences and plot histogram

Is there any straightforward way to create a histogram from a cell array like the one below? The spacing between the consecutive bars should be exactly the same and the labels of the x-axis should be the corresponding names of the variables below in a vertical orientation.

'w464'
'w462'
'w461'
'w464'
'w461'
'w463'
'w466'
'w461'

Source: (StackOverflow)