예제 #1
0
 /**
  * Sets the receiver's text. The string may include the mnemonic character.
  *
  * <p>Mnemonics are indicated by an '&amp;' that causes the next character to be the mnemonic.
  * When the user presses a key sequence that matches the mnemonic, a selection event occurs. On
  * most platforms, the mnemonic appears underlined but may be emphasised in a platform specific
  * manner. The mnemonic indicator character '&amp;' can be escaped by doubling it in the string,
  * causing a single '&amp;' to be displayed.
  *
  * @param string the new text
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_NULL_ARGUMENT - if the text is null
  *     </ul>
  *
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void setText(String string) {
   checkWidget();
   if (string == null) error(SWT.ERROR_NULL_ARGUMENT);
   if ((style & SWT.SEPARATOR) != 0) return;
   if (string.equals(this.text)) return;
   super.setText(string);
   if (labelHandle == 0) return;
   char[] chars = fixMnemonic(string);
   byte[] buffer = Converter.wcsToMbcs(null, chars, true);
   OS.gtk_label_set_text_with_mnemonic(labelHandle, buffer);
   if ((style & SWT.DROP_DOWN) != 0 && OS.GTK_VERSION < OS.VERSION(2, 6, 0)) {
     if (string.length() != 0) {
       OS.gtk_widget_show(labelHandle);
     } else {
       OS.gtk_widget_hide(labelHandle);
     }
   }
   /*
    * If Text/Image of a tool-item changes, then it is
    * required to reset the proxy menu. Otherwise, the
    * old menuItem appears in the overflow menu.
    */
   if ((style & SWT.DROP_DOWN) != 0) {
     proxyMenuItem = 0;
     proxyMenuItem = OS.gtk_tool_item_retrieve_proxy_menu_item(handle);
     OS.g_signal_connect(
         proxyMenuItem, OS.activate, ToolBar.menuItemSelectedFunc.getAddress(), handle);
   }
   parent.relayout();
 }
예제 #2
0
 /**
  * Sets the receiver's text. The string may include the mnemonic character.
  *
  * <p>Mnemonics are indicated by an '&amp;' that causes the next character to be the mnemonic.
  * When the user presses a key sequence that matches the mnemonic, a selection event occurs. On
  * most platforms, the mnemonic appears underlined but may be emphasised in a platform specific
  * manner. The mnemonic indicator character '&amp;' can be escaped by doubling it in the string,
  * causing a single '&amp;' to be displayed.
  *
  * @param string the new text
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_NULL_ARGUMENT - if the text is null
  *     </ul>
  *
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void setText(String string) {
   checkWidget();
   if (string == null) error(SWT.ERROR_NULL_ARGUMENT);
   if ((style & SWT.SEPARATOR) != 0) return;
   super.setText(string);
   parent.relayout();
   redraw();
 }
예제 #3
0
파일: TreeColumn.java 프로젝트: oaperez/rap
 @Override
 public void setText(String value) {
   checkWidget();
   if (value == null) {
     error(SWT.ERROR_NULL_ARGUMENT);
   }
   if (!value.equals(text)) {
     super.setText(value);
     parent.layoutCache.invalidateHeaderHeight();
   }
 }
예제 #4
0
 public void setText(String string) {
   checkWidget();
   if (string == null) error(SWT.ERROR_NULL_ARGUMENT);
   super.setText(string);
   char[] buffer = new char[text.length()];
   text.getChars(0, buffer.length, buffer, 0);
   int length = fixMnemonic(buffer);
   displayText = new String(buffer, 0, length);
   NSString title = NSString.stringWith(displayText);
   nsColumn.headerCell().setTitle(title);
   NSTableHeaderView headerView = ((NSOutlineView) parent.view).headerView();
   if (headerView == null) return;
   int index = parent.indexOf(nsColumn);
   NSRect rect = headerView.headerRectOfColumn(index);
   headerView.setNeedsDisplayInRect(rect);
 }
예제 #5
0
  @Override
  public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
    final Add_item item = items.get(position);

    ((Item) holder).title.setText(item.getTitle());
    ((Item) holder).checkBox.setChecked(item.isChecked());
    ((Item) holder)
        .checkBox.setOnCheckedChangeListener(
            new CompoundButton.OnCheckedChangeListener() {
              @Override
              public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                ((Item) holder).checkBox.setChecked(isChecked);
                if (isChecked) club_names.add(item.getTitle());
                else club_names.remove(item.getTitle());
              }
            });
  }
예제 #6
0
 /**
  * Sets the receiver's text. The string may include the mnemonic character.
  *
  * <p>Mnemonics are indicated by an '&amp;' that causes the next character to be the mnemonic.
  * When the user presses a key sequence that matches the mnemonic, a selection event occurs. On
  * most platforms, the mnemonic appears underlined but may be emphasised in a platform specific
  * manner. The mnemonic indicator character '&amp;' can be escaped by doubling it in the string,
  * causing a single '&amp;' to be displayed.
  *
  * @param string the new text
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_NULL_ARGUMENT - if the text is null
  *     </ul>
  *
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void setText(String string) {
   checkWidget();
   if (string == null) error(SWT.ERROR_NULL_ARGUMENT);
   if ((style & SWT.SEPARATOR) != 0) return;
   if (string.equals(text)) return;
   super.setText(string);
   int strPtr = createDotNetString(string, true);
   if (strPtr == 0) error(SWT.ERROR_NO_HANDLES);
   OS.AccessText_Text(textHandle, strPtr);
   OS.GCHandle_Free(strPtr);
   OS.UIElement_Visibility(
       textHandle,
       string.length() == 0 && image != null ? OS.Visibility_Collapsed : OS.Visibility_Visible);
   int spacing = image != null && text.length() != 0 ? 3 : 0;
   int margin =
       (parent.style & SWT.RIGHT) != 0
           ? OS.gcnew_Thickness(0, 0, spacing, 0)
           : OS.gcnew_Thickness(0, 0, 0, spacing);
   OS.FrameworkElement_Margin(imageHandle, margin);
   OS.GCHandle_Free(margin);
 }
예제 #7
0
  /**
   * Sets the receiver's text. The string may include the mnemonic character.
   *
   * <p>Mnemonics are indicated by an '&amp;' that causes the next character to be the mnemonic.
   * When the user presses a key sequence that matches the mnemonic, a selection event occurs. On
   * most platforms, the mnemonic appears underlined but may be emphasised in a platform specific
   * manner. The mnemonic indicator character '&amp;' can be escaped by doubling it in the string,
   * causing a single '&amp;' to be displayed.
   *
   * @param string the new text
   * @exception IllegalArgumentException
   *     <ul>
   *       <li>ERROR_NULL_ARGUMENT - if the text is null
   *     </ul>
   *
   * @exception SWTException
   *     <ul>
   *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
   *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
   *     </ul>
   */
  public void setText(String string) {
    checkWidget();
    if (string == null) error(SWT.ERROR_NULL_ARGUMENT);
    if ((style & SWT.SEPARATOR) != 0) return;
    if (string.equals(text)) return;
    super.setText(string);
    long /*int*/ hwnd = parent.handle;
    TBBUTTONINFO info = new TBBUTTONINFO();
    info.cbSize = TBBUTTONINFO.sizeof;
    info.dwMask = OS.TBIF_TEXT | OS.TBIF_STYLE;
    info.fsStyle = (byte) (widgetStyle() | OS.BTNS_AUTOSIZE);
    long /*int*/ hHeap = OS.GetProcessHeap(), pszText = 0;
    if (string.length() != 0) {
      info.fsStyle |= OS.BTNS_SHOWTEXT;
      TCHAR buffer = new TCHAR(parent.getCodePage(), string, true);
      int byteCount = buffer.length() * TCHAR.sizeof;
      pszText = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
      OS.MoveMemory(pszText, buffer, byteCount);
      info.pszText = pszText;
    }
    OS.SendMessage(hwnd, OS.TB_SETBUTTONINFO, id, info);
    if (pszText != 0) OS.HeapFree(hHeap, 0, pszText);

    /*
     * Bug in Windows.  For some reason, when the font is set
     * before any tool item has text, the tool items resize to
     * a very small size.  Also, a tool item will only show text
     * when text has already been set on one item and then a new
     * item is created.  The fix is to use WM_SETFONT to force
     * the tool bar to redraw and layout.
     */
    parent.setDropDownItems(false);
    long /*int*/ hFont = OS.SendMessage(hwnd, OS.WM_GETFONT, 0, 0);
    OS.SendMessage(hwnd, OS.WM_SETFONT, hFont, 0);
    parent.setDropDownItems(true);
    parent.layoutItems();
  }
예제 #8
0
 public void loadJson(String folderPath) {
   String content = "";
   File file = new File(folderPath + "content.json");
   BufferedReader bufferedReader = null;
   try {
     bufferedReader = new BufferedReader(new FileReader(file));
     String read;
     while ((read = bufferedReader.readLine()) != null) {
       content += read;
     }
   } catch (FileNotFoundException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   } finally {
     if (bufferedReader != null)
       try {
         bufferedReader.close();
       } catch (IOException e) {
         e.printStackTrace();
       }
   }
   this.removeAllViews();
   ArrayList<LinkedTreeMap> beans = new Gson().fromJson(content, ArrayList.class);
   if (beans == null) {
     return;
   }
   for (LinkedTreeMap<String, Object> bean : beans) {
     // F**k me.
     int type = (int) Math.round((Double) bean.get("type"));
     switch (type) {
       case Constants.TYPE_TEXT:
         Text text = addTextOn((int) Math.round((Double) bean.get("index")));
         SpannableString ssText = new SpannableString(Html.fromHtml((String) bean.get("text")));
         populateAdditionalStyles(bean, ssText);
         text.setText(ssText);
         break;
       case Constants.TYPE_IMAGE:
         Image img = addImageOn((int) Math.round((Double) bean.get("index")));
         img.setImage((String) bean.get("imgPath"), (int) Math.round((Double) bean.get("width")));
         break;
       case Constants.TYPE_TODO:
         Todo todo = addTodoOn((int) Math.round((Double) bean.get("index")));
         SpannableString ssTodo = new SpannableString(Html.fromHtml((String) bean.get("text")));
         populateAdditionalStyles(bean, ssTodo);
         // Why the hell there are to extra '\n' appended???
         ssTodo = (SpannableString) ssTodo.subSequence(0, ssTodo.length() - 2);
         todo.setText(ssTodo);
         todo.setChecked((Boolean) bean.get("checked"));
         break;
       case Constants.TYPE_ITEM:
         Item item = addItemOn((int) Math.round((Double) bean.get("index")));
         SpannableString ssItem = new SpannableString(Html.fromHtml((String) bean.get("text")));
         populateAdditionalStyles(bean, ssItem);
         ssItem = (SpannableString) ssItem.subSequence(0, ssItem.length() - 2);
         item.setText(ssItem);
         break;
       case Constants.TYPE_ATT:
         sun.bob.pooredit.views.File fileView =
             addFileOn((int) Math.round((Double) bean.get("index")));
         fileView.setFilePath((String) bean.get("filePath"));
         break;
       default:
         break;
     }
   }
 }
예제 #9
0
  /**
   * Sets the receiver's text. The string may include the mnemonic character and accelerator text.
   *
   * <p>Mnemonics are indicated by an '&amp;' that causes the next character to be the mnemonic.
   * When the user presses a key sequence that matches the mnemonic, a selection event occurs. On
   * most platforms, the mnemonic appears underlined but may be emphasised in a platform specific
   * manner. The mnemonic indicator character '&amp;' can be escaped by doubling it in the string,
   * causing a single '&amp;' to be displayed.
   *
   * <p>Accelerator text is indicated by the '\t' character. On platforms that support accelerator
   * text, the text that follows the '\t' character is displayed to the user, typically indicating
   * the key stroke that will cause the item to become selected. On most platforms, the accelerator
   * text appears right aligned in the menu. Setting the accelerator text does not install the
   * accelerator key sequence. The accelerator key sequence is installed using #setAccelerator.
   *
   * @param string the new text
   * @exception IllegalArgumentException
   *     <ul>
   *       <li>ERROR_NULL_ARGUMENT - if the text is null
   *     </ul>
   *
   * @exception SWTException
   *     <ul>
   *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
   *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
   *     </ul>
   *
   * @see #setAccelerator
   */
  public void setText(String string) {
    checkWidget();
    if (string == null) error(SWT.ERROR_NULL_ARGUMENT);
    if ((style & SWT.SEPARATOR) != 0) return;
    if (text.equals(string)) return;
    super.setText(string);
    long /*int*/ hHeap = OS.GetProcessHeap();
    long /*int*/ pszText = 0;
    boolean success = false;
    if ((OS.IsPPC || OS.IsSP) && parent.hwndCB != 0) {
      /*
       * Bug in WinCE PPC.  Tool items on the menubar don't resize
       * correctly when the character '&' is used (even when it
       * is a sequence '&&').  The fix is to remove all '&' from
       * the string.
       */
      if (string.indexOf('&') != -1) {
        int length = string.length();
        char[] text = new char[length];
        string.getChars(0, length, text, 0);
        int i = 0, j = 0;
        for (i = 0; i < length; i++) {
          if (text[i] != '&') text[j++] = text[i];
        }
        if (j < i) string = new String(text, 0, j);
      }
      /* Use the character encoding for the default locale */
      TCHAR buffer = new TCHAR(0, string, true);
      int byteCount = buffer.length() * TCHAR.sizeof;
      pszText = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
      OS.MoveMemory(pszText, buffer, byteCount);
      long /*int*/ hwndCB = parent.hwndCB;
      TBBUTTONINFO info2 = new TBBUTTONINFO();
      info2.cbSize = TBBUTTONINFO.sizeof;
      info2.dwMask = OS.TBIF_TEXT;
      info2.pszText = pszText;
      success = OS.SendMessage(hwndCB, OS.TB_SETBUTTONINFO, id, info2) != 0;
    } else {
      MENUITEMINFO info = new MENUITEMINFO();
      info.cbSize = MENUITEMINFO.sizeof;
      long /*int*/ hMenu = parent.handle;

      /* Use the character encoding for the default locale */
      TCHAR buffer = new TCHAR(0, string, true);
      int byteCount = buffer.length() * TCHAR.sizeof;
      pszText = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
      OS.MoveMemory(pszText, buffer, byteCount);
      /*
       * Bug in Windows 2000.  For some reason, when MIIM_TYPE is set
       * on a menu item that also has MIIM_BITMAP, the MIIM_TYPE clears
       * the MIIM_BITMAP style.  The fix is to use MIIM_STRING.
       */
      if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION(4, 10)) {
        info.fMask = OS.MIIM_STRING;
      } else {
        info.fMask = OS.MIIM_TYPE;
        info.fType = widgetStyle();
      }
      info.dwTypeData = pszText;
      success = OS.SetMenuItemInfo(hMenu, id, false, info);
    }
    if (pszText != 0) OS.HeapFree(hHeap, 0, pszText);
    if (!success) {
      int error = OS.GetLastError();
      SWT.error(
          SWT.ERROR_CANNOT_SET_TEXT,
          null,
          " [GetLastError=0x" + Integer.toHexString(error) + "]"); // $NON-NLS-1$ $NON-NLS-2$
    }
    parent.redraw();
  }
예제 #10
0
 public void setText(String string) {
   super.setText(string);
   byte[] buffer = Converter.wcsToMbcs(null, string, true);
   OS.gtk_label_set_text(labelHandle, buffer);
 }